<!--
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 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_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_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 StrReplace(str1, str2, str3)
{
  str1 = str1.split(str2).join(str3);
  return str1;
}

function ltrim ( s )
{
	return s.replace( /^\s*/, "" )
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}


function trim ( s )
{
	return rtrim(ltrim(s));
}

function trimspace(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}


function isNumeric(str)
{
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9')
      p++;
    else
      ok= false;
  }
  return ok;
}

function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("Format Email yang Anda Input Belum Benar")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
	    // user is not valid
	    alert("Format Email yang Anda Input Belum Benar")
	    return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	    // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("Format Email yang Anda Input Belum Benar")
			return false
		    }
	    }
	    return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("Format Email yang Anda Input Belum Benar")
	    return false
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   alert("Format Email yang Anda Input Belum Benar")
	   return false
	}
	if (len<2) {
	   var errStr="Format Email yang Anda Input Belum Benar"
	   alert(errStr)
	   return false
	}
	return true;
}

function emailCheck2 (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("Your email format is incorrect")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
	    // user is not valid
	    alert("Your email format is incorrect")
	    return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	    // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("Your email format is incorrect")
			return false
		    }
	    }
	    return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("FYour email format is incorrect")
	    return false
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   alert("Your email format is incorrect")
	   return false
	}
	if (len<2) {
	   var errStr="Your email format is incorrect"
	   alert(errStr)
	   return false
	}
	return true;
}

function isEmpty(str)
{
	temp=trim(str)
	if (temp.length==0)
	{
		return true
	}else
	{
		return false
	}
}

//CHECK WHETHER THE TEXT LENGTH IN 'FIELD' EXCEEDED THE 'MAXLIMIT', N DISPLAY CHARACTER LEFT AT 'COUNTFIELD' 
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function confirmdelete()
{
var agree=confirm("Apakah Anda yakin ingin menghapusnya?");
if (agree)
	return true ;
else
	return false ;
}

//CHECK WHETHER THE 'STR' IS EMPTY OR NOT,IF IT IS EMPTY THEN THE 'STRNAME' WILL BE ADDED TO THE  ERROR 'MESSAGE'
function validateString(message, str, strname){
	if (isEmpty(str))
	{
 		message=message+strname+", ";
	}
	return message
}

//DISPLAY ERROR 'MESSAGE' IF ERROR EXIST ('MESSAGE'<>' ') N CANCEL SUBMIT IF ERROR EXIST ('MESSAGE'<>' ' OR 'VALID'=FALSE)
function validationMessage(message,valid)
{
if ((message==" ") && (valid))
{
 return true; 
}
else
{
	if (message!=" ")
	{
		message=message.substring(0,message.length-2)
 		message="Anda Belum Mengisi" + message;
 		alert(message);
 	}
 	return false;
 }
}

function validationMessage2(message,valid)
{
if ((message==" ") && (valid))
{
 return true; 
}
else
{
	if (message!=" ")
	{
		message=message.substring(0,message.length-2)
 		message="Please input your" + message ;
 		alert(message);
 	}
 	return false;
 }
}

//POP UP WINDOW FOR 'CONTACT.ASP'
function popUpCenteredWindow(link) 
{ 
	var realHeight=540; 
	var realWidth=420; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(link,"Title","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");  win2.focus(); 
} 

//POP UP WINDOW FOR 'CREATIVE'
function popUpCreativeWindow(link) 
{ 
	var realHeight=360; 
	var realWidth=390; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(link,"Title","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");  win2.focus(); 
} 

//USED IN FORUM TO ADD EMOTICON TO TEXTAREA 
function emoticonToTextArea(text) 
{
	text = ' ' + text + ' ';
	document.myForm.message.value  += text;
	document.myForm.message.focus();
}

function isDate(dateStr) {

    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?

    if (matchArray == null) {
    		alert("Masukkan format tanggal yg benar");
        //alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
        return false;
    }

    month = matchArray[1]; // parse date into variables
    day = matchArray[3];
    year = matchArray[5];

    if (month < 1 || month > 12) { // check month range
        alert("Bulan harus antara 1 sampai dengan 12");
        //alert("Month must be between 1 and 12.");
        return false;
    }

    if (day < 1 || day > 31) {
    	 	alert("Tgl harus antara 1 sampai dengan 31");
        //alert("Day must be between 1 and 31.");
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Bulan bersangkutan hanya memiliki 30 hari")
        //alert("Month "+month+" doesn't have 31 days!")
        return false;
    }

    if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            alert("Februari " + year + " tidak memiliki tanggal " + day)
            //alert("February " + year + " doesn't have " + day + " days!");
            return false;
        }
    }

		if (!((year>=1753) && (year<=9999)))
		{
			alert("Tahun harus antara 1753 sampai 9999");
			return false;
		}
    return true; // date is valid
}

function popUpBigPicWindow(link) 
{ 
	var realHeight=540; 
	var realWidth=500; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(link,"Title","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");  win2.focus(); 
}

function ValidateSearch()
{
	valid=true
	pesan=" "
	temp=document.formSearch.searchstr.value.toUpperCase()
	temp=rtrim(ltrim(temp))
	pesan=validateString(pesan,temp,"Search String")
	var rep1=/\bAND\b/
	var rep2=/\bOR\b/
	temp2=temp
	while (temp2.match(rep1)!=null)
	{
		temp2=temp2.replace(rep1,"")	
	}
	while (temp2.match(rep2)!=null)
	{
		temp2=temp2.replace(rep2,"")	
	}
	if ((!(isEmpty(temp))) && (isEmpty(temp2)))
	{
 		alert("Please insert more words (other than 'AND' and 'OR')")
 		valid=false;
	}
	return validationMessage(pesan,valid)
}

function doShow(showID,preTxt,firstIDIndex,lastIDIndex){
	var showMode = '';
	var hideMode='none'
	//hiding all
	for (var i=firstIDIndex;i<=lastIDIndex;i++)
	{
		if (document.getElementById) {
		// this is the way the standards work
			document.getElementById(preTxt+i).style.display = hideMode;
		}
		else if (document.all) {
		// this is the way old msie versions work
			document.all(preTxt+i).style.display = hideMode;
		}
		else if (document.layers) {
		// this is the way nn4 works
			if (document.getElementsByName)
			{
				document.getElementsByName(preTxt+i).style.display = hideMode;
			}
		}
	}
	//showing the one 2 be shown
	if (document.getElementById) {
	// this is the way the standards work
		document.getElementById(preTxt+showID).style.display = showMode;
	}
	else if (document.all) {
	// this is the way old msie versions work
		document.all(preTxt+showID).style.display = showMode;
	}
	else if (document.layers) {
	// this is the way nn4 works
		if (document.getElementsByName)
		{
			document.getElementsByName(preTxt+showID).style.display = showMode;
		}
	}
}

function doShowDetail(catID) {
	var showMode = '';
	var hideMode='none'
	tempcatID=catID.split("-")
	if(tempcatID[1]=="1"){	
		//showing the one 2 be shown
		if (document.getElementById) {
		// this is the way the standards work
			document.getElementById("url").style.display = hideMode;
			document.getElementById("gambar").style.display = hideMode;
}
		else if (document.all) {
		// this is the way old msie versions work
			document.all("url").style.display = hideMode;
			document.all("gambar").style.display = hideMode;
		}
		else if (document.layers) {
		// this is the way nn4 works
			if (document.getElementsByName)
			{
				document.getElementsByName("url").style.display = hideMode;
				document.getElementsByName("gambar").style.display = hideMode;				
			}
		}
	}
	else if(tempcatID[1]=="2"){	
		//showing the one 2 be shown
		if (document.getElementById) {
		// this is the way the standards work
			document.getElementById("url").style.display = hideMode;
			document.getElementById("gambar").style.display = showMode;
		}
		else if (document.all) {
		// this is the way old msie versions work
			document.all("url").style.display = hideMode;
			document.all("gambar").style.display = showMode;
		}
		else if (document.layers) {
		// this is the way nn4 works
			if (document.getElementsByName)
			{
				document.getElementsByName("url").style.display = hideMode;
				document.getElementsByName("gambar").style.display = showMode;				
			}
		}
	}
	else{	
		//showing the one 2 be shown
		if (document.getElementById) {
		// this is the way the standards work
			document.getElementById("url").style.display = showMode;
			document.getElementById("gambar").style.display = showMode;
		}
		else if (document.all) {
		// this is the way old msie versions work
			document.all("url").style.display = showMode;
			document.all("gambar").style.display = showMode;
		}
		else if (document.layers) {
		// this is the way nn4 works
			if (document.getElementsByName)
			{
				document.getElementsByName("url").style.display = showMode;
				document.getElementsByName("gambar").style.display = showMode;				
			}
		}
	}
}
-->
