// JavaScript Document
function collapseExpand(element,jmlhElement){
for(i=1;i<=jmlhElement;i++){	
document.getElementById(element + i).style.display =(document.getElementById(element+i).style.display=="none")?"":"none";
}	
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function trim(item){
var tmp = "";
var item_length = item.value.length;
var item_length_minus_1 = item.value.length - 1;
for (index = 0; index < item_length; index++)
{
if (item.value.charAt(index) != ' ')
{
tmp += item.value.charAt(index);
}
else
{
if (tmp.length > 0)
{
if ((item.value.charAt(index+1) != ' ') && (index != item_length_minus_1))
{
tmp += item.value.charAt(index);
}
}
}
}
return (tmp) ;
}

function trim_image(item){
var tmp = "";
var item_length = item.length;
var item_length_minus_1 = item.length - 1;
for (index = 0; index < item_length; index++)
{
if (item.charAt(index) != ' ')
{
tmp += item.charAt(index);
}
else
{
if (tmp.length > 0)
{
if ((item.charAt(index+1) != ' ') && (index != item_length_minus_1))
{
tmp += item.charAt(index);
}
}
}
}
return (tmp) ;
}

function getExtension(obj){
var panjangString = obj.length;
obj = trim_image(obj);
for(i = 0 ; i < panjangString ; i++){
if(obj.charAt(i) == "."){
break;
}
}

extensi = obj.substring(i,panjangString).toLowerCase();
return extensi;
}

function toggle_display(o){
o.style.display=(o.style.display=='none')?'':'none';
}

function check_email(str){
var filter=/^.+@.+\..{2,3}$/;
if(filter.test(str)) return true;
else return false;
}
function cek_int(e){
var key=(document.all)?event.keyCode:e.which;
if(key==8 || key==9 || key==13 || key==37 || key==38 || key==39 || key==40) return true;
if((key<48 || key>57) && (key<96 || key>105)) return false;
}
function is_image_complete(img) {
// During the onload event, IE correctly identifies any images that
// weren’t downloaded as not complete. Others should too. Gecko-based
// browsers act like NS4 in that they report this incorrectly.
if (!img.complete) {
return false;
}

// However, they do have two very useful properties: naturalWidth and
// naturalHeight. These give the true size of the image. If it failed
// to load, either of these should be zero.
if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
return false;
}

// No other way of checking: assume it’s ok.
return true;
}
