var game_Hour = '';
var from_Hour = '';
var from_Hour_new = '';
var to_Hour_new = '';
var to_Hour = '';
var zhcontent = '';
/*********functions realted to egobox start *****************/
function showEgoBox(mailcount,scrapscount,challengescount,loyaltypoints,favgamecount,buddycount,username_cookie,avatar,gender,facebook_avatar)
{	
		//zhcontent = '<a class="head01" href="http://www.zapak.com/happyhours.php" style="font-size: 11px;"><b><u>It\'s Happy Hours on Zapak! Play between<br/> 4 to 8 PM and earn double loyalty points!</u></b></a>';
		if(document.getElementById("zhousie")){
		//zhcontent = '<a class="head01" href="http://shop.zapak.com" style="font-size: 11px;" target="_blank"><b><u>Now shop @ India\'s coolest gadget store</u></b></a>';	
		//zhcontent = '<a class="head01" href="http://idiotsacademy.zapak.com" style="font-size: 11px;" target="_blank"><b><u>Catch Aamir Khan and spend New Year with him!</u></b></a>';
		}
		
		zhcontent ='';
            if(document.getElementById("signout"))
			document.getElementById("signout").innerHTML = '| <a href="'+SECURE_SERVER_URL+'/zlogout.php" target="_parent">Signout</a>';			
			if(document.getElementById("userid"))
			document.getElementById("userid").innerHTML = username_cookie;
			if(document.getElementById("useridyes"))
			document.getElementById("useridyes").style.display = 'none';
			
			if(document.getElementById("myzapak"))
			document.getElementById("myzapak").style.display = 'block';
			
			if(document.getElementById("zhousie"))
		    document.getElementById("zhousie").innerHTML = zhcontent;
			
			if(document.getElementById("div5"))
			slide('div5');
			
		document.getElementById("loginbox").style.display = 'none';
		document.getElementById("egobox").style.display = '';
		
	printegobox(mailcount,scrapscount,challengescount,loyaltypoints,username_cookie,avatar,gender,facebook_avatar);
	
}


function hideEgoBox()
{
	
        if(document.getElementById("userid"))
		document.getElementById("userid").innerHTML = 'Stranger';
		
		document.getElementById("loginbox").style.display = '';
		document.getElementById("egobox").style.display = 'none';
		
		if(document.getElementById("signout"))
		document.getElementById("signout").innerHTML = '';
		
		/* if(document.getElementById("zhousie"))
		{
		
			document.getElementById("zhousie").innerHTML = '<a class="head01" href="http://www.zapak.com/happyhours.php" style="font-size: 11px;"><b><u>It\'s Happy Hours on Zapak! Login & Play between<br/> 4 to 8 PM and earn double loyalty points!</u></b></a>';
		
}*/
if(document.getElementById("zhousie")){

//document.getElementById("zhousie").innerHTML ='<a class="head01" href="http://shop.zapak.com" style="font-size: 11px;" target="_blank"><b><u>Now shop @ India\'s coolest gadget store</u></b></a> ';
//document.getElementById("zhousie").innerHTML ='<a class="head01" href="http://idiotsacademy.zapak.com" style="font-size: 11px;" target="_blank"><b><u>Catch Aamir Khan and spend New Year with him!</u></b></a>';

}
      
}
/***************** function common egobox ends **************************/



   
   //function for submitting search form egobox
function submitform()
{
 if(document.searchform.textfield.value=='' || document.searchform.textfield.value=='Jump to your favourite game')document.searchform.textfield.value='NULL';document.searchform.submit();

}

//functin for search form

   function searchcheck()
{
if(document.searchform.textfield.value=='')
{
document.searchform.textfield.style.color='white';
document.searchform.textfield.value='NULL';

return true;
}
else{
return true;

}
}



   //function for submitting search form egobox
function submitegoform()
{
 if(document.searchegoform.textfield.value=='' || document.searchegoform.textfield.value=='Jump to your favourite game')document.searchegoform.textfield.value='NULL';document.searchegoform.submit();

}

//functin for search form

   function searchegocheck()
{
if(document.searchegoform.textfield.value=='')
{
document.searchegoform.textfield.style.color='white';
document.searchegoform.textfield.value='NULL';

return true;
}
else{
return true;

}
}



   function printegobox(mailcount,scrapcount,challengecount,loyaltycount,userid,avatar,gender,facebook_avatar)
   { 

   var wwwzapakPath = WWW_SERVER_URL; //added by devendra to work in all pages	
   var myzapak = MY_SERVER_URL; //
   var mailzapakPath = EMAIL_SERVER_URL; //added by devendra to work in all pages
 var avatarimg='';

   var myzapakPath = SOCIAL_SERVER_URL; //added by cp for rajandra to work on social pages  

var egoboxcontent = '';

if(facebook_avatar !=''){
avatarimg= facebook_avatar;
}else
	   {
if(avatar=='0'){
	if(gender=='Male')
	{
	avatarimg= SOCIAL_SERVER_URL+'/public/images/boy.jpg';
	}else{
	avatarimg= SOCIAL_SERVER_URL+'/public/images/gal.jpg';
	}
	}else if(avatar=='1')
	{
 		avatarimg=SOCIAL_SERVER_URL+'/images/profiles/'+userid+'.jpeg';
	}
	else{
		avatarimg='http://images.api.weeworld.com/zapak/'+userid+'/weemee/scale/0.45.png?xPad=0&amp;yPad=-14&amp;showlogo=false';
	}
}



var zclpointsimg='<img src="'+RESOURCE_SERVER_URL+'/www/zcl/0.jpg"/>';
var scrapcount =parseInt(scrapcount);;

var scale = new Array();
var s1 = new Array("2","4","6","8","10");
var s2 = new Array("4","8","12","16","20");
var s3 = new Array("6","12","18","24","30");
var s4 = new Array("10","20","30","40","50");
var s5 = new Array("15","30","45","60","75");
var s6 = new Array("20","40","60","80","100");

scale[0] = s1;
scale[1] = s2;
scale[2] = s3;
scale[3] = s4;
scale[4] = s5;
scale[5] = s6;

var currscale = new Array();
if(scrapcount < 10){
currscale = scale[0];
}else if(scrapcount < 20 && scrapcount >= 10){
currscale = scale[1];
}else if(scrapcount <30 && scrapcount >= 20){
currscale = scale[2];
}else if(scrapcount <50 && scrapcount >= 30){
currscale = scale[3];
}else if(scrapcount <75 && scrapcount >= 50){
currscale = scale[4];
}else if(scrapcount >=100 && scrapcount >= 75){
currscale = scale[5];
}


var bar = 'bar',num = 'num';
var j=0;
for(i=0;i<currscale.length;i++){

if(scrapcount >= currscale[i]){
	j++;
}
}

zclpointsimg='<img src="'+RESOURCE_SERVER_URL+'/www/zcl/' + j + '.jpg"/>';



   egoboxcontent += '<div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="padding: 0px 5px 5px 0px;" valign="bottom" width="10%" align="left"><div id="avatar" style="background-color: rgb(255, 255, 255);" style="margin-right:5px"><a href="'+myzapakPath+'/public/home/show/'+'" target="_top"><img style1="margin: 0px 0px 0px -13px;" src="'+avatarimg+'" border="0" width="70" height="70"></a></div></td><td class="disT" valign="top" width="339" align="left" background="'+RESOURCE_SERVER_URL+'/www/images/sebg1.gif"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td colspan="5" class="loginbox disL" valign="middle" align="left" height="54"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr>';

//For ZCL promo
//egoboxcontent +='<td class="bltxt01" style="padding: 0pt 5px;" align="left" valign="top"><table bgcolor="#533400" border="0" cellpadding="0" cellspacing="0" width="100%" style="cursor:pointer" onclick="window.open(WWW_SERVER_URL+\'/zclpointstatus.php\',\'ZCL_Points\',\'location=1,status=1,scrollbars=0,toolbar=0,location=0,width=450,height=520\');"><tbody><tr><td style="font:normal 11px Tahoma; color:#FFFFFF;" align="center" width="35%">Your Cash*<br><span style="font:normal 20px Arial; color:#FFFFFF">'+scrapcount+'</span></td><td align="right" valign="top" width="65%">'+zclpointsimg+'</td></tr></tbody></table></td><td valign="top" width="1" align="left" bgcolor="#adadad"><img src="'+RESOURCE_SERVER_URL+'/www/images/spacer.gif" width="1" height="1"></td>';

   egoboxcontent += '<td class="bltxt01" valign="top" width="73" align="center"><a href="'+myzapakPath+'/public/friends/show/'+'" target="_top">Buddies</a><br><span class="bltxt02"><a href="'+myzapakPath+'/public/friends/show/'+'" target="_top">'+mailcount+'&nbsp;</a></span></td><td valign="top" width="1" align="left" bgcolor="#adadad"><img src="'+RESOURCE_SERVER_URL+'/www/images/spacer.gif" width="1" height="1"></td>';


  egoboxcontent += '<td class="bltxt01" valign="top" width="73" align="center"><a href="'+myzapakPath+'/public/scraps/show/'+'" target="_top">Scraps</a><br><span class="bltxt02"><a href="'+myzapakPath+'/public/scraps/show/'+'" target="_top">'+scrapcount+'&nbsp;</a></span></td><td valign="top" width="1" align="left" bgcolor="#adadad"><img src="'+RESOURCE_SERVER_URL+'/www/images/spacer.gif" width="1" height="1"></td>';

 
 egoboxcontent += '<td class="bltxt01" valign="top" width="85" align="center"><a href="'+myzapak+'/zprchallenge.php'+'" target="_top">Challenges </a><br><span class="bltxt02"><a href="'+myzapak+'/zprchallenge.php'+'" target="_top">'+challengecount+'&nbsp;</a></span></td><td valign="top" width="1" align="left" bgcolor="#adadad"><img src="'+RESOURCE_SERVER_URL+'/www/images/spacer.gif" width="1" height="1"></td>';
 
  egoboxcontent += '<td class="bltxt01" valign="top" width="77" align="center"><a href="'+myzapak+'/zloyaltymypoints.php" target="_top">Loyalty Points</a><br><span class="bltxt02"><a href="'+myzapak+'/zloyaltymypoints.php" target="_top">'+loyaltycount+'&nbsp;</a></span></td>'; 
   
 
   egoboxcontent += '</tr></tbody></table></td></tr><tr><td valign="top" width="1%" align="left"><img src="'+RESOURCE_SERVER_URL+'/www/images/secorL.gif" width="8" height="30"></td><td valign="top" width="4%" align="left"><img src="'+RESOURCE_SERVER_URL+'/www/images/magni.gif" width="30" height="30"></td><td style="padding-left: 18px; padding-right: 18px;" valign="middle" width="82%" align="left" background="'+RESOURCE_SERVER_URL+'/www/images/tseBg.gif"><form action="'+wwwzapakPath+'/zsearch.php" method="get" name="searchegoform" id="searchegoform" onsubmit="javascript:searchegocheck()" target="_top"><input name="select" value="ALL" type="hidden"><input name="type" value="GAME" type="hidden"><input name="startindex" value="0" type="hidden"><input name="rows" value="21" type="hidden"><input name="textfield" class="input" value="Jump to your favourite game" style="width: 200px; height: 18px;" onclick="document.searchegoform.textfield.value = \'\';" type="text" align="left"></form></td><td valign="middle" width="12%" align="left" background="'+RESOURCE_SERVER_URL+'/www/images/tseBg.gif"><a href="javascript:submitegoform();"><img src="'+RESOURCE_SERVER_URL+'/www/images/search.gif" width="56" border="0" height="11"></a></td><td valign="top" width="1%" align="left"><img src="'+RESOURCE_SERVER_URL+'/www/images/secorR.gif" width="7" height="30"></td></tr></tbody></table></td></tr></tbody></table>';
   egoboxcontent += '</div>';
 

document.getElementById("egobox").innerHTML = egoboxcontent;
   }
 
   



/*  ############## zapak landing js starts ################## */
/* by devendra on 10 dec 2009 */

/******************************************
* DHTML Ad Box (By Matt Gabbert at http://www.nolag.com)
* Visit http://www.dynamicdrive.com/ for full script
* This notice must stay intact for use
******************************************/
adTime=20;  // seconds ad reminder is shown
chanceAd=1; // ad will be shown 1 in X times (put 1 for everytime)

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
adCount=0;
function initAd(){
	document.getElementById('TB_overlay').style.display = 'block';
	if(!ns && !ie && !w3) return;
	if(ie)		adDiv=eval('document.all.sponsorAdDiv.style');
	else if(ns)	adDiv=eval('document.layers["sponsorAdDiv"]');
	else if(w3)	adDiv=eval('document.getElementById("sponsorAdDiv").style');
    if(ie)		overDiv=eval('document.all.TB_overlay.style');
	else if(ns)	overDiv=eval('document.layers["TB_overlay"]');
	else if(w3)	overDiv=eval('document.getElementById("TB_overlay").style');
	randAd=Math.ceil(Math.random()*chanceAd);
        if (ie||w3)
        adDiv.visibility="visible";
        else
        adDiv.visibility ="show";
	
	if(randAd==1) showAd();
}
function showAd() {

	if(adCount<adTime*50) {
		adCount+=1;
		if (ie) {
			documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
			documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
		}	
		else if (ns) {
			documentWidth=window.innerWidth/2+window.pageXOffset-20;
			documentHeight=window.innerHeight/2+window.pageYOffset-20;
		} 
		else if (w3) {
			documentWidth=self.innerWidth/2+window.pageXOffset-20;
			documentHeight=self.innerHeight/2+window.pageYOffset-20;
		} 
		adDiv.left=documentWidth-300+calunit;adDiv.top =documentHeight-200+calunit;
		setTimeout("showAd()",100);
	}
	else 
		closeAd();
}
function closeAd(){
if (ie||w3) {
    overDiv.display = "none";
    adDiv.display="none";
}
else {
    overDiv.visibility ="hide";
    adDiv.visibility ="hide";
}
}
function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function checkAdDivs(showhide) {
	if (!document.getElementsByTagName) return;
	arr_nodes = document.getElementsByTagName('div');
	for (i = 0; i < arr_nodes.length; i++) {
		obj_node = arr_nodes[i];
		if(/ZAPADS[_a-z]/.test(obj_node.id))
			hideDivAds(obj_node.id,showhide);
	}
	/* hiding right iframe ad slug */			
	arr_nodes = document.getElementsByTagName('iframe');
	for (i = 0; i < arr_nodes.length; i++) {
		obj_node = arr_nodes[i];
		if(/fr[_a-z]/.test(obj_node.id))
			hideDivAds(obj_node.id,showhide);
	}
				
}
function hideDivAds(divid,showhide) {
	if (!document.getElementById(divid)) return;
	if(showhide == 'hide')
		document.getElementById(divid).style.display='none';
	else
		document.getElementById(divid).style.display='';
}
//onload=initAd;
//End-->

function switch_lite()
{
	document.getElementById('TB_overlay').style.display = 'block';
if(get_cookie('zver')) 
delete_cookie('zver');

if(document.getElementById('TB_overlay'))
	{
	document.getElementById('TB_overlay').style.visibility='visible';
	document.getElementById('TB_overlay').style.display='';
	}

if(document.getElementById('sponsorAdDiv'))
	{
	document.getElementById('sponsorAdDiv').style.visibility='visible';
    document.getElementById('sponsorAdDiv').style.display='';
	}
  checkAdDivs("hide");
  initAd();
}



/* ######################### zapak landing js ends ############################### */



