function getE(elemene){
if ( typeof(elemene)=='string' ) {
  return document.getElementById(elemene);
  }
}
function eValue(elemene) {
var d=getE(elemene);
if ( d!=null && d!=undefined ) {
  return document.getElementById(elemene).value;
  }
}
function eValueX(elemene) {
var d=getE(elemene);
if ( d!=null && d!=undefined ) {
  var objVal=(document.getElementById(elemene).value) * 1;
  return objVal;
  }
return 0;  
}
function setEValue(elemene, val) {
document.getElementById(elemene).value=val;
}
function eStyle(elemene) {
return document.getElementById(elemene).style;
}
function setEStyle(elemene, stile, val) {
var s=document.getElementById(elemene).style;
s.stile=val;
}
function eInner(elemene) {
return document.getElementById(elemene).innerHTML;
}
function setEInner(elemene, val) {
document.getElementById(elemene).innerHTML=val;
}
function eDisabled(elemene) {
return document.getElementById(elemene).disabled;
}
function setEDisabled(elemene, val) {
document.getElementById(elemene).disabled=val;
}
function eChecked(elemene) {
return document.getElementById(elemene).checked;
}
function setEChecked(elemene, val) {
document.getElementById(elemene).checked=val;
}
function eVisible(elemene){
if ( eStyle(elemene).visibility=='visible' ) return true;
else return false;
}
function showE(elemene, vis, absolut) {
var v='visible';
var p='relative';
if ( vis==false ) {
  v='hidden';
  p='absolute';
  }
if ( absolut ) {
  p='absolute';
  }
var s=eStyle(elemene);
s.visibility=v;
s.position=p;
}
function getCursorPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}
function removeNonAlphaNumeric(st,subtitutes){
var nst='';
if ( subtitutes=='' || subtitutes==undefined ) {
  subtitutes='-';
  }
var jelek=true;
var tambahPengganti=false;
var chare='';
if ( st.length> 0 ) {
  for(i=0;i<st.length;i++){
	chare=st.charAt(i);
    if ( isValidAlphaNumeric(chare)==true ) {
	  if ( tambahPengganti ) {
	    nst=nst+subtitutes+chare;
		}
	  else {
	    nst=nst+chare;
		}
	  tambahPengganti=false;
	  }
	else {
	  chare='';
	  tambahPengganti=true;
	  }
	}
  
  }
return nst;  
}
function isNumericChar(c){
var valids='0123456789';
if ( c.length!=1 ) return false;
if ( valids.indexOf(c)==-1 ) return false;
return true;
}
function isNumeric(s){
var valids='0123456789';
var cc;
var hasil=true;
if ( s.length==0 ) return false;
for(i=0;i<c.length && hasil == true ;i++) {
  cc=s.charAt(i);
  if ( valids.indexOf(cc)==-1 ) hasil=false;
  }
return hasil;
}
function isHex(tx) {
var valids='0123456789ABCDEFabcdef';
var cc;
var hasil=true;
if ( tx.length==0 ) return false;
for(i=0;i<tx.length && hasil == true ;i++) {
  cc=tx.charAt(i);
  if ( valids.indexOf(cc)==-1 ) hasil=false;
  }
return hasil;
}
function getNumerice(s) {
var ss='';
if ( s.length>0 ) {
  for(i=0;i<s.length;i++){
    if ( isNumericChar(s.charAt(i)) ) {
	  ss=ss+s.charAt(i);
	  }
	}
  }
if ( ss!='' ) {
  ss=ss*1;
  }
return ss;
}
function isAlpha(st){
var xx;
var valid=false;
if ( st!='' ) {
  var valid=true;
  for(x=0;x<st.length;x++){
    xx=st.charCodeAt(x);
	if ( xx<65 || (xx>90 && xx<97) || xx>122 ) {
	  valid=false;
	  }
	}
  }
return valid;  
}
function isValidAlphaNumeric(st){
	/*
0=48
9=57
a=97
z=122
A=65
Z=90
	*/
var xx;
var valid=false;
if ( st!='' ) {
  var valid=true;
  for(x=0;x<st.length;x++){
    xx=st.charCodeAt(x);
	//if ( (xx>=48 && xx<=57) || (xx>=48 && xx<=57) || (xx>=48 && xx<=57) ) {
	if ( xx<48 || (xx>57 && xx<65) || (xx>90 && xx<97) || xx>122 ) {
	  valid=false;
	  }
	}
  }
return valid;  
}
function isAlphaNumeric(s){
var valids='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var cc;
var hasil=true;
if ( s.length==0 ) return false;
for(i=0;i<s.length && hasil == true ;i++) {
  cc=s.charAt(i);
  if ( valids.indexOf(cc)==-1 ) hasil=false;
  }
return hasil;
}
function ucFirst(t) {
var temuspace=true;
var s='';
var c;
for(i=0;i<t.length;i++) {
  c=t.charAt(i);
  if ( temuspace==true ) {
    s=s+c.toUpperCase();
	}
  else {
    s=s+c.toLowerCase();
    }
  if ( t.charCodeAt(i)==32 || t.charCodeAt(i)==10 ) {
    temuspace=true;
    }
  else {
    temuspace=false;
	}
  }
return s;
}
function listToArray(st){
var arra=new Array();
if ( st!='' ) {
  var jume=0;
  var stre='';
  for(i=0;i<st.length;i++) {
    if (st.charCodeAt(i)==10) {
      if ( stre!='' ) {
	    arra[jume]=stre;
	    jume=jume+1;
	    stre='';
	    }
	  }
    else {
     if (st.charCodeAt(i)>31) {
	    stre=stre+st.charAt(i);
	    }
	  }
    }
  if ( stre!='' ) {
    arra[jume]=stre;
    }
  }
return arra;
}
function formatNumeric(n, l){
	alert(n);
s=String(n);
while (s.length<l){
  s='0'+s;
  }
return s;
}
function trims(tt){
if ( tt!='' ) {
  var nt=tt;
  tt='';
  var adaChar=false;
  var sebelumnyaSpace=false;
  for(x=0;x<nt.length;x++){
    if ( nt.charCodeAt(x)==32 ) {
	  if ( adaChar==true ) {
	    sebelumnyaSpace=true;
		}
	  }
	else {
	  adaChar=true;
	  if ( sebelumnyaSpace==true ) {
	    tt=tt+' '+nt.charAt(x);
	    }
	  else {
	    tt=tt+nt.charAt(x);
		}
	  sebelumnyaSpace=false;
	  }
	}
  }
return tt;  
}
function bandingString(st1,st2){
// return -1 if st1<st2
// return  0 if st1=st2
// return  1 if  st1>st2
var hasil=0;
var batas =st1.length;
if ( st2.length<st1.length) batas=st2.length;
var lebihKecil=false;
var ulang=true;
var nomers=0;

while(ulang){
  if ( st2.charCodeAt(nomers)!=st1.charCodeAt(nomers) ) {
    hasil=1;
	if ( st1.charCodeAt(nomers)<st2.charCodeAt(nomers) ) {
	  hasil=-1;
	  }
	ulang=false;
	}
  nomers=nomers+1;
  if ( nomers==batas ) ulang=false;
  }
if ( hasil==0 ) {
  if ( st2.length!=st1.length) {
    if ( st1.length<st2.length ) {
	  hasil=-1;
	  }
	else {
	  hasil=1;
	  }
	}
  }
return hasil;
}
function arrayShort(arr, ordere, ignoreCase){
if ( ordere==undefined ) {
  ordere='asc';
  }
if ( ignoreCase==undefined ) {
  ignoreCase=true;
  }

ordere=ordere.toLowerCase();
var tampung='';
var hasilBanding;
var str1, str2;
if ( arr.length>0 ){
  for(q=0;q<arr.length-1;q++){
    for(w=q+1;w<arr.length;w++){
	  str1=arr[q];str2=arr[w];
	  if ( ignoreCase ) {
	    str1=arr[q].toLowerCase();
		str2=arr[w].toLowerCase();
		}
	  if ( ordere=='desc' ) {
	    if ( bandingString(str1,str2)==-1 ) {
		  tampung=arr[q];
		  arr[q]=arr[w];
		  arr[w]=tampung;
		  }
		}
	  else {
	    if ( bandingString(str1,str2)==1 ) {
		  tampung=arr[q];
		  arr[q]=arr[w];
		  arr[w]=tampung;
		  }
		}
	  }
	}
  }
return arr;
}
function in_Array(isi,isiList,ignoreCase){
ada=false;
for(z=0;z<isiList.length;z++){
  if ( ignoreCase==true ) {
    if ( isi.toLowerCase()==isiList[z].toLowerCase()){
      ada=true;
	  }
    }
  else {
    if ( isi==isiList[z]){
      ada=true;
	  }
    }
  }
return ada;  
}
function explodetrim(spacer,teks){
var ret=new Array();
if ( teks!='' && teks!=undefined && spacer!=undefined ) {
  var list=teks.split(spacer);
  var jum=0;
  for(i=0;i<list.length;i++){
    list[i]=trims(list[i]);
	if ( list[i]!='' ) {
	  ret[jum]=list[i];
	  jum=jum+1;
	  }
	}
  }
return ret;
}
function kirimHtmlPostData(urle, vare,  modene, idne) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', urle, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');//multipart/form-data
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			updatePageHTML(modene, idne, self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(vare);
}
function validityEmail(email){
var valids='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.-@';
var cc;
var hasil=true;
if ( email.length==0 ) return false;
for(i=0;i<email.length && hasil == true ;i++) {
  cc=email.charAt(i);
  if ( valids.indexOf(cc)==-1 ) hasil=false;
  }
hasil=isValidAlphaNumeric(email.substr(0,1)); 
if ( hasil==true ) {
  if ( email.indexOf('@')==-1 ) {
    return false;
	}
  if ( email.indexOf('.')==-1 ) {
    return false;
	}
  var ceks=email.split('@');
  if ( ceks.length!=2 ) {
    return false;
	}
  if ( ceks[1].indexOf('.')==-1 ) {
    return false;
	}
  var domain=ceks[1].split('.');
  if ( domain.length<2 ) {
    return false;
	}
  if ( isValidAlphaNumeric(domain[0].substr(0,1))==false ) {
    return false;
    }
  var jumDomain=domain.length  - 1;
  if ( isAlpha(domain[jumDomain])==false ) {
    return false;
    }
  if ( domain[jumDomain].length<2 || domain[jumDomain].length>4) {
    return false;
	}
  }
return hasil;
}

function jsUrlEncode(str){
var normalChar=new Array(' ', ',', ':', '/', '@', '&', '#', ';', '<', '>', '"', '\'', '+', '(', ')', '[', ']', '*', '`', '{', '}', '&#187;', '&#171;', '&#169;');//'%', , '-', '_', '.', '//'
var encodeChar=new Array('+', '%2C', '%3A', '%2F', '%40', '%26', '%23', '%3B', '%3C', '%3E', '%22', '%27', '%2B', '%28', '%29', '%5B', '%5D', '%2A', '%60', '%7B', '%7D', '%BB', '%AB', '%A9');//, '%25', '-', '_', '.', '%2F%2F'
if ( str!='' ) {
  for(i=0;i<normalChar.length;i++){
    while(str.indexOf(normalChar[i])!=-1) {
	  str=str.replace(normalChar[i],encodeChar[i]);
	  }
	}
  }
return str;
}
function jsSterilizeText(str){
str=str.replace("'",'\'');
return str;
}