function EncodeURL(Str) {
	Str = encodeURI(Str);
	Str = Str.replace(/\&/g,"%26");
	return Str ;
}

function MM_ReloadImageMessenger() {
	var Data = new Array() ;
	var Rand = EncodeURL(Math.round(Math.random(0,1)*100000000000)) ;
	Data['YM_1'] = "http://opi.yahoo.com/online?m=g&t=1&u=sentrainfo&ref="+Rand ;
	Data['YM_2'] = "http://opi.yahoo.com/online?m=g&t=1&u=lung1&ref="+Rand ;
	var Port = 8000 + (Rand%2) + 2 ;
	Data['MSN_1'] = "http://www.the-server.net:"+Port+"/msn/sentrainfo@yahoo.com/onurl=www.sentrainfo.com/images/im_msn_online.gif/offurl=www.sentrainfo.com/images/im_msn_offline.gif/unknownurl=www.sentrainfo.com/images/im_msn_offline.gif?ref="+Rand ;
	Data['MSN_2'] = "http://www.the-server.net:"+Port+"/msn/s1au@hotmail.com/onurl=www.sentrainfo.com/images/im_msn_online.gif/offurl=www.sentrainfo.com/images/im_msn_offline.gif/unknownurl=www.sentrainfo.com/images/im_msn_offline.gif?ref="+Rand ;
	for (var i in Data)
	{
		if (document.getElementById(i))
		{
			var Img = document.getElementById(i) ;
			Img.src = Data[i] ;
		}
	}
	setTimeout("MM_ReloadImageMessenger();",300000);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function cNum(e) {
	var strCheck = '0123456789\b';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (whichCode == 0) return true ;
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
}

function cPhone(e) {
	var strCheck = '0123456789-+ ()[]/\b';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (whichCode == 0) return true ;
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
}

function cUserID(e) {
	var strCheck = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\b';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (whichCode == 0) return true ;
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
}

function isEmail(Email) {
	var result = true ;
	var Regex = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/ ;
	return Regex.test(Email) ;
}

function isUrl(Url) {
	var result = true ;
	var Regex = /^http\:\/\// ;
	return Regex.test(Url) ;
}

function Trim(Str) {
	Str = Str.replace(/^\s+/ig,"");
	Str = Str.replace(/\s+$/ig,"");
	return Str ;
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function Global_RequestReady(ID,http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			RequestDone(ID,http_request) ;
		} else {
			//alert('There was a problem with the data request.');
		}
	}
}

function Global_Request(ID,url) {
	var url_post = url;
	var url_send = null;
	if (url.indexOf('?')>0)
	{
		url_post = url.substring(0,url.indexOf('?'));
		url_send = url.substring(url.indexOf('?')+1);
	} else {
		url_post = url ;
		url_send = null ;
	}

	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { Global_RequestReady(ID,http_request) }
	if (url_send != null)
	{
		http_request.open('POST', url_post, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", url_send.length);
		http_request.setRequestHeader("Connection", "close");	
		http_request.send(url_send);
	} else {
		http_request.open('GET', url_post, true);
		http_request.send(url_send);
	}
}

function CheckDatebyMonthYear(FormName,DForm,MForm,YForm) {
	var SD = eval("document."+FormName+"."+DForm);
	var SM = eval("document."+FormName+"."+MForm);
	var SY = eval("document."+FormName+"."+YForm);

	var TDD = SD.options[SD.options.selectedIndex].value ;
	var TDM = SM.options[SM.options.selectedIndex].value ;
	var TDY = SY.options[SY.options.selectedIndex].value ;

	var LongDate = (TDM==1 || TDM==3 || TDM==5 || TDM==7 || TDM==8 || TDM==10 || TDM==12)?31:30;
	if (TDM == 2)
	{
		LongDate = (TDY%4==0)?29:28;
	}
	while (SD.options.value)
	{
	   SD.options[0] = null ;
	}
	var j = 0 ;
	for (var i=1;i<=LongDate ;i++ )
	{
		var ValI = i ;
		ValI = (ValI<10)?"0"+i:i;
		SD.options[j] = new Option(SD,SD,true,true,true) ;
	    SD.options[j].text = i ;
	    SD.options[j].value = ValI ;
		j++;
	}
	if (TDD <= LongDate)
	{
		SD.options[TDD-1].selected = true ;
	} else {
		SD.options[j-1].selected = true ;
	}
}

function GoCustomDateNew(FormName,DForm,MForm,YForm,DD,MM,YY,Down,Up) {
	var SD = eval("document."+FormName+"."+DForm);
	var SM = eval("document."+FormName+"."+MForm);
	var SY = eval("document."+FormName+"."+YForm);
	if (DD == 0 || MM == 0 || YY == 0)
	{
		var a = new Date ;
		TDD = a.getDate() ;
		TMM = a.getMonth() + 1 ;
		TYY = a.getFullYear() ;
	} else {
		TDD = DD ;
		TMM = MM ;
		TYY = YY ;
	}
	var MonthName = new Array () ;
	MonthName[1] = "Jan" ;
	MonthName[2] = "Feb" ;
	MonthName[3] = "Mar" ;
	MonthName[4] = "Apr" ;
	MonthName[5] = "May" ;
	MonthName[6] = "Jun" ;
	MonthName[7] = "Jul" ;
	MonthName[8] = "Aug" ;
	MonthName[9] = "Sep" ;
	MonthName[10] = "Oct" ;
	MonthName[11] = "Nov" ;
	MonthName[12] = "Dec" ;
	var Sel = 0 ;
	var j = 0 ;
	for (var i=(TYY-Down); i<=(TYY+Up); i++ )
	{
		SY.options[j] = new Option(SY,SY,true,true,true) ;
	    SY.options[j].text = i ;
	    SY.options[j].value =  i ;
		if (i == TYY)
		{
			Sel = j ;
		}
		j++;
	}
	SY.options[Sel].selected = true ;

	j = 0 ;
	for (var i=1;i<=12 ;i++ )
	{
		var ValI = i ;
		ValI = (ValI<10)?"0"+i:i;
		SM.options[j] = new Option(SM,SM,true,true,true) ;
	    SM.options[j].text = MonthName[i] ;
	    SM.options[j].value = ValI ;
		if (i == TMM) 
		{
			Sel = j ;
		}
		j++;
	}
	SM.options[Sel].selected = true ;

	var LongDate = (TMM==1 || TMM==3 || TMM==5 || TMM==7 || TMM==8 || TMM==10 || TMM==12)?31:30;
	if (TMM == 2)
	{
		LongDate = (TYY%4==0)?29:28;
	}
	j = 0 ;
	for (var i=1;i<=LongDate ;i++ )
	{
		var ValI = i ;
		ValI = (ValI<10)?"0"+i:i;
		SD.options[j] = new Option(SD,SD,true,true,true) ;
	    SD.options[j].text = i ;
	    SD.options[j].value = ValI ;
		if (i == TDD) 
		{
			Sel = j ;
		}
		j++;
	}
	SD.options[Sel].selected = true ;
}

function checkCari(F) {
	var FN = eval('document.'+F);
	if (!Trim(FN.Cari.value)) {
		alert('masukkan kata/nama untuk mencari');
		return false;
	}
	return true ;
}

function SetMemberMenu(MainUrl) {
	var M = document.getElementById('DivMemberMenu');
	if (Get_Cookie('SentraInfoAnggotaLogin'))
	{
		var innerHTML = "" ;
		innerHTML += (Get_Cookie('SentraInfoAdminLogin'))?" | <a href=\""+MainUrl+"/admin_utama.php\" title=\"Web Administrator\">Administrator</a>":"" ;
		innerHTML += " | <a href=\""+MainUrl+"/komersial.php\" title=\"Membership Business\">Membership Business</a>" ;
		innerHTML += " | <a href=\""+MainUrl+"/profil.php\" title=\"Member Profile\">My Profile</a>" ;
		innerHTML += " | <a href=\""+MainUrl+"/logout.php\" onclick=\"ClearCookiesOnLogout();\" title=\"Logout\">Logout</a>" ;
		M.innerHTML = innerHTML ;
	}
}

function SetMemberMenu_Indonesia(MainUrl) {
	var M = document.getElementById('DivMemberMenu');
	if (Get_Cookie('SentraInfoAnggotaLogin'))
	{
		var innerHTML = "" ;
		innerHTML += (Get_Cookie('SentraInfoAdminLogin'))?" | <a href=\""+MainUrl+"/admin_utama.php\" title=\"Web Administrator\">Administrator</a>":"" ;
		innerHTML += " | <a href=\""+MainUrl+"/komersial.php\" title=\"Bisnis Data Milik Anggota\">Bisnis Anggota</a>" ;
		innerHTML += " | <a href=\""+MainUrl+"/profil.php\" title=\"Profil Lengkap Anggota\">Profil Anggota</a>" ;
		innerHTML += " | <a href=\""+MainUrl+"/logout.php\" onclick=\"ClearCookiesOnLogout();\" title=\"Logout Anggota Dari Sistem\">Logout</a>" ;
		M.innerHTML = innerHTML ;
	}
}

function ClearCookiesOnLogout() {
	Set_Cookie('SentraInfoAdminLogin', '', 0.1, '/', '', '' );
	Set_Cookie('SentraInfoAnggotaLogin', '', 0.1, '/', '', '' );
}

function RequestDone(ID,Data) {
	if (Data.responseText) {
		var CreateHTML = /^CreateHTML.+$/ ;
		if (ID == 'IDAnggota') {
			SetIDAnggota(Data.responseText);
		} else if (ID == 'IDAnggota2') {
			SetIDAnggota2(Data.responseText);
		} else if (ID == 'CheckIDAjax') {
			SetIDAjax(Data.responseText);
		} else if (ID == 'CheckNamaAjax') {
			SetNamaAjax(Data.responseText);
		} else if (ID == 'CheckMemberIDAjax') {
			SetMIDAjax(Data.responseText);
		} else if (CreateHTML.test(ID)) {
			GenerateHTMLSetAjax(ID,Data.responseText);
		}
	}
}

function KirimKeTeman() {
	var FN = eval("document.GotoKirimTemanForm");
	FN.URL.value = location.href ;
	FN.submit();
}