// Fixed by AtmaLib Team

	function fullscreen()
	{
		var hdiff;
		window.moveTo(-4,-4);
		window.resizeTo(screen.width,screen.height);
		hdiff=window.screenTop;
		window.moveTo(-6,-hdiff-7);
		window.resizeTo(screen.width+13,screen.height+hdiff+35)
	}


	//-------------------------------------------------------------
	// Select all the checkboxes (Hotmail style)
	//-------------------------------------------------------------
	function SelectAllCheckboxes(spanChk){
	
	// Added as ASPX uses SPAN for checkbox 
	if (spanChk.type=="checkbox") {
		var oItem = spanChk;
		var theBox=oItem;
	} else {
		var oItem = spanChk.children;
		var theBox=oItem.item(0);
	}
	
	xState=theBox.checked;	

		elm=theBox.form.elements;
		for(i=0;i<elm.length;i++)
		if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
			{
			//elm[i].click();
			if(elm[i].checked!=xState)
			elm[i].click();
			//elm[i].checked=xState;
			}
	}

	function SelectAllCheckboxesGrid(spanChk,gridName){
	
	// Added as ASPX uses SPAN for checkbox 
	if (spanChk.type=="checkbox") {
		var oItem = spanChk;
		var theBox=oItem;
	} else {
		var oItem = spanChk.children;
		var theBox=oItem.item(0);
	}
	
	xState=theBox.checked;	

		elm=theBox.form.elements;
		for(i=0;i<elm.length;i++) {
			str = elm[i].name.split(":");
			if (str[4] == gridName.toString()) {
				if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
				{
					//elm[i].click();
					if(elm[i].checked!=xState)
					elm[i].click();
					//elm[i].checked=xState;
				}
			}
		}
	}
	
	var keys="";
	function myonkeypress(obj) 
	{
		var key = event.keyCode;
		event.returnValue=false;
		//a-z, A-Z, 0-9
		if ((key>=97 && key<=122) || (key>=65 && key<=90) || (key>=48 &&
		key<=57) || (key==27) || (key==32))
		{
			if (key==27)
			{
				keys = "";
				return;
			}
			else
			{
				key = String.fromCharCode(key);
				keys = keys + key;
			}
			var cnt;
			for (cnt=0;cnt<obj.children.length;cnt++)
			{
				var itm = obj.children[cnt].text;
				if (itm.substring(0,keys.length).toUpperCase()==keys.toUpperCase())
				{
					obj.selectedIndex = cnt;
					break;
				}
			}
		}
	}
	
	function clearText(ctrl) {
		document.getElementById(ctrl).value="";
	}
	
	function delText(ctrl) {
		var str=document.getElementById(ctrl).value;
		document.getElementById(ctrl).value=str.substring(0, str.length-1) ;
	}
	
	function addAnd(ctrl) {
		document.getElementById(ctrl).value+="*";
	}

	function addOr(ctrl) {
		document.getElementById(ctrl).value+="+";
	}
	
	function addBuka(ctrl) {
		document.getElementById(ctrl).value+="(";
	}

	function addTutup(ctrl) {
		document.getElementById(ctrl).value+=")";
	}
	
	function addIndeks(ctrl, Indeks) {
		document.getElementById(ctrl).value+=Indeks;
	}
	
	var scroll = (window.scrollTo) ? 1 : 0;
	function saveScroll(ASPPageName) 
	{
		try
		{
				if (!scroll) return;
				var x = document.body.scrollLeft;
				var y = document.body.scrollTop;
				var DocumentTitle = ASPPageName;
				var cookieDate = new Date();
				cookieDate.setTime(cookieDate.getTime() + 3*1000); //3 seconds
				var Expires = ";expires=" + cookieDate.toString(); 
				document.cookie="xy=" + x + "_" + y + "_" + DocumentTitle; //+ Expires;
			}
			catch(e)
			{
			}
		}

		function loadScroll(ASPPageName) 
		{
			try
			{
				if (!scroll) return;
				var xy = ReadACookie("xy");
				if (!xy) return;
				var ar = xy.split("_");
				if (ar.length == 3)
				{
					if (ar[2] == ASPPageName)
					{
						window.scrollTo(parseInt(ar[0]), parseInt(ar[1]));
					}
				}
			}
			catch(e)
			{
			}
		}

		function ReadACookie(TheName)
		{
			try
			{
				var cookieData = new String(document.cookie);
				var cookieHeader = TheName + "=";
				var cookieStart = cookieData.indexOf(cookieHeader) + cookieHeader.length;
				var cookieEnd = cookieData.indexOf(";",cookieStart);
				if(cookieEnd == -1)
				{
					cookieEnd = cookieData.length
				}
				if(cookieData.indexOf(cookieHeader) != -1)
				{
					return cookieData.substring(cookieStart,cookieEnd);
				}
				else
				{
					//no cookie
					return ""
				}
			}
			catch(e)
			{
				return ""
			}
		}
		
function makevisible(cur,which){
strength=(which==0)? 1 : 0.7

if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	//if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function countdown_clock(year, month, day, hour, minute, format)
{
         //I chose a div as the container for the timer, but
         //it can be an input tag inside a form, or anything
         //who's displayed content can be changed through
         //client-side scripting.
         html_code = '<div id="countdown"></div>';
         
         document.write(html_code);
         
         countdown(year, month, day, hour, minute, format);                
}

function countdown(year, month, day, hour, minute, format)
{
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth();                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
         Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();                  
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 0:
                    //The simplest way to display the time left.
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
                    break;
               case 1:
                    //More datailed.
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if(days == 1) dps ='';
                    if(hours == 1) hps ='';
                    if(minutes == 1) mps ='';
                    if(seconds == 1) sps ='';
                    
                    //document.all.countdown.innerHTML = days + ' day' + dps + ' ';
                    //document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
                    document.all.countdown.innerHTML = 'Waktu Anda ';
                    document.all.countdown.innerHTML += minutes + ' Menit ';
                    document.all.countdown.innerHTML += seconds + ' Detik';
                    break;
               default: 
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
               }
               
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}


function dyas_countdown_clock(second, format)
{
         //I chose a div as the container for the timer, but
         //it can be an input tag inside a form, or anything
         //who's displayed content can be changed through
         //client-side scripting.
         html_code = '<div id="countdown"></div>';
         
         document.write(html_code);
         
         dyas_countdown(second, format);                
}

var dyas_count = 0;
function dyas_countdown(second, format)
{
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round(second - dyas_count);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 0:
                    //The simplest way to display the time left.
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
                    break;
               case 1:
                    //More datailed.
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    document.all.countdown.innerHTML = 'Waktu Anda ';
                    document.all.countdown.innerHTML += minutes + ' Menit ';
                    document.all.countdown.innerHTML += seconds + ' Detik';
                    break;
               default: 
                    document.all.countdown.innerHTML = Time_Left + ' Detik';
               }
         
         dyas_count = dyas_count+1;
               
         //Recursive call, keeps the clock ticking.
         setTimeout('dyas_countdown(' + second + ',' + format + ');', 1000);
}