/*** wwwcommon.js *********/
function page_index_move(url)
{
populate_httpdiv(url,'gamesection',2);
} 
/********  common.js ****/
function finderror( name )
{
name = unescape(window.location.href);
if(name.lastIndexOf("error") != -1)
return name.substr(name.lastIndexOf("error")+6).replace(/\<br\/\>/,' ');
else
return '';

} 

function loginclick()
{    
var loginerror = finderror('error');  
document.getElementById("loginerror").innerHTML = loginerror;
}
function create_httpobject(objName){try{window[objName]=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){window[objName]=false;}
return window[objName];}

var time1 = 0;
var time2 = 0;
function populate_httpdiv(urlval,divval,retry){
try{
var objname=divval+'_obj';window[objname]=create_httpobject(divval+'_obj');
if(window[divval+'_obj']){
window[objname].onreadystatechange=function(){
if(window[objname].readyState==4){
if(window[objname].status==200){
time1 = (new Date()).getTime();
while(true){
if(document.getElementById(divval))	{
document.getElementById(divval).innerHTML=window[objname].responseText;
break;
}
time2 = (new Date()).getTime();
if((time2-time1)>120000)//timeout in miliseconds for the infinite loop
break;
}
}else {
if(retry>1){
retry=retry-1;
populate_httpdiv(urlval,divval,retry);
}	else	{
document.getElementById(divval).innerHTML="<font color='white'>.</font>";
}
}
}
}
window[objname].open('get',urlval,true);
window[objname].send(null);
}
}
catch(e){document.getElementById(divval).innerHTML="";
}}

function set_cookie( name, value, expires) 
{

var domain = ".zapak.com";
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() : "")+
((domain) ? ";domain=" + domain : "") 
}

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 delete_cookie(name) {
if(get_cookie(name)) 
document.cookie = name + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function bookmarkurl(url,title)
{
if (window.sidebar) 
{ // Mozilla Firefox Bookmark
window.sidebar.addPanel(title, url,"");
} 
else if( window.external )
{ // IE Favorite
window.external.AddFavorite( url, title); 
}
else if(window.opera && window.print)
{ // Opera Hotlist
return true;
}
}

function gotourl(link)
{
location.href=link;
}
/*************** makehome.js **************/
/*************************************************/
//CHANGE THE LINK HREF VALUE AS CURRENT PAGE CODE
/*************************************************/
var IE = document.all?true:false;
function checkie(){
if (!IE){  
var curPage=window.location;
//alert(document.getElementById("lnkLogo").innerHTML);
document.getElementById("lnkLogo").innerHTML='<a title="Zapak!"  style="width:66px;height:59px;font-size:0px;line-height:0px;top:10px;left:10px;display:block;position:absolute;background:url('+RESOURCE_SERVER_URL+'/www/images/zapak_logo_sm.gif);" href="'+ curPage +'"><strong>Zapak!</strong></a>';
}
}
/*************************************************/
//CHANGE THE LINK HREF VALUE AS CURRENT PAGE CODE
/*************************************************/

function adjustLink(){
checkie();	
document.getElementById("dvHomePage").style.visibility="visible";
document.getElementById("dvHomePage").style.display="inline";
var curleft=findMyDivPostion();
//document.getElementById("dvHomePage").style.left=curleft-120;
}

function homePageSet(obj){
obj.style.behavior='url(#default#homepage)';
//obj.setHomePage('http://www.zapak.com');
url=window.location.href;
obj.setHomePage(url);
}

function findMyDivPostion1() { 
var obj=document.getElementById("lnkHome"); 
var curleft = obj.offsetLeft; 
var curtop=obj.offsetTop; 

while(obj.offsetParent)   {
curleft=curleft + (obj.offsetParent.offsetLeft); 
curtop=curtop + (obj.offsetParent.offsetTop); 
obj=obj.offsetParent; 
} 
//alert("your span was found at " + curleft +":" + curtop);
return curleft;

}


if (!IE) document.captureEvents(Event.MOUSECLICK)
document.onclick = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS

tempX = e.pageX;
tempY = e.pageY;
lnkLeft=findMyDivPostion1();
//alert(tempX + ":" + lnkLeft);
//alert((lnkLeft+200));
if(tempX >= lnkLeft && tempX <=(lnkLeft+150))	 {

}
else	 {
if(document.getElementById("dvHomePage").style.visibility=="visible")		{
document.getElementById("dvHomePage").style.visibility="hidden"; 
document.getElementById("dvHomePage").style.display="none";
}
else	{
//alert("No");
} 
} 
}  
}

/*************************************************/
//DVHOME HIDE CODE ... WHEN CLICK ON CLOSE X
/*************************************************/
function hideme(){
if(document.getElementById("dvHomePage").style.visibility=="visible")    {
document.getElementById("dvHomePage").style.visibility="hidden"; 
document.getElementById("dvHomePage").style.display="none";
}
}
function findMyDivPostion(){ 
var obj=document.getElementById("lnkHome"); 
var curleft = obj.offsetLeft; 
var curtop=obj.offsetTop; 

while(obj.offsetParent)   {
curleft=curleft + (obj.offsetParent.offsetLeft); 
curtop=curtop + (obj.offsetParent.offsetTop); 
obj=obj.offsetParent; 
} 
return curleft;
} 
/*****************  menuslide_new.js  *****/
var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "") //get current page path and name, used to uniquely identify this page for persistence feature

function animatedcollapse(divId, animatetime, persistexpand,initstate){
this.divId=divId;
this.divObj=document.getElementById(divId);
this.divObj.style.overflow="hidden";
this.timelength=animatetime;
this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract"
this.isExpanded="no";
this.contentheight=parseInt(this.divObj.style.height)
var thisobj=this
if (isNaN(this.contentheight)){ //if no CSS "height" attribute explicitly defined, get DIV's height on window.load
animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load")
if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
{
this.divObj.style.visibility="hidden" //hide content (versus collapse) until we can get its height
this.divObj.style.display="none"

}

}
else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
this.divObj.style.height=0 //just collapse content if CSS "height" attribute available

}

animatedcollapse.prototype._getheight=function(persistexpand){
this.contentheight=this.divObj.offsetHeight
if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"){ //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
this.divObj.style.height=0 //collapse content
this.divObj.style.visibility="visible"
this.divObj.style.display="block"
}
else //else if persistence is enabled AND this content should be expanded, define its CSS height value so slideup() has something to work with
this.divObj.style.height=this.contentheight+"px"
}


animatedcollapse.prototype._slideengine=function(direction){
var elapsed=new Date().getTime()-this.startTime //get time animation has run
var thisobj=this
if (elapsed<this.timelength){ //if time run is less than specified length
var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength)
this.divObj.style.height=distancepercent * this.contentheight +"px"
this.runtimer=setTimeout(function(){thisobj._slideengine(direction)}, 10)
}
else{ //if animation finished
this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0
this.isExpanded=(direction=="down")? "yes" : "no" //remember whether content is expanded or not
this.runtimer=null
}



}


animatedcollapse.prototype.slidedown=function(){
if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
alert("Please wait until document has fully loaded then click again")
else if (parseInt(this.divObj.style.height)==0){ //if content is collapsed
this.startTime=new Date().getTime() //Set animation start time
this._slideengine("down")


}  
}  
}  

animatedcollapse.prototype.slideup=function(){ 
if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
alert("Please wait until document has fully loaded then click again")
else if (parseInt(this.divObj.style.height)==this.contentheight){ //if content is expanded
this.startTime=new Date().getTime()
this._slideengine("up")

}
}
}

animatedcollapse.prototype.slideit=function(){
if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
alert("Please wait until document has fully loaded then click again")
else if (parseInt(this.divObj.style.height)==0)
this.slidedown()
else if (parseInt(this.divObj.style.height)==this.contentheight)
this.slideup()

}


animatedcollapse.curveincrement=function(percent){
return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
}


animatedcollapse.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}


/**************sliding function start *************************/


function slide(divid)
{

if(divid == 'div1')
{
var divobj = collapse1;
} 
if(divid == 'div2')
{
var divobj = collapse2;
}
if(divid == 'div3')
{
var divobj = collapse3;
}
if(divid == 'div4')
{
var divobj = collapse4;
}

if(divid == 'div5')
{
var divobj = collapse5;
}
if(divid == 'div6')
{
var divobj = collapse6;
}
if(divid == 'div7')
{
var divobj = collapse7;
}

if(divobj.isExpanded == 'no')
{
if(divid == 'div1')
setTimeout("document.getElementById('slideItDown1').style.display = 'block';",200);
if(divid == 'div2')
setTimeout("document.getElementById('slideItDown2').style.display = 'block';",200);
if(divid == 'div3')
setTimeout("document.getElementById('slideItDown3').style.display = 'block';",100);
if(divid == 'div4')
setTimeout("document.getElementById('slideItDown4').style.display = 'block';",200);
if(divid == 'div5')
setTimeout("document.getElementById('slideItDown5').style.display = 'block';",200);
if(divid == 'div6')
setTimeout("document.getElementById('slideItDown6').style.display = 'block';",200);
if(divid == 'div7')
setTimeout("document.getElementById('slideItDown7').style.display = 'block';",200);

divobj.slidedown();
document.getElementById(divid).innerHTML = '<img src="'+RESOURCE_SERVER_URL+'/www/images/minus.gif" border="0"/>';
}

if(divobj.isExpanded == 'yes')
{
divobj.slideup();
document.getElementById(divid).innerHTML = '<img src="'+RESOURCE_SERVER_URL+'/www/images/plus.gif" border="0"/>';

if(divid == 'div1')
setTimeout("document.getElementById('slideItDown1').style.display = 'none';",900);
if(divid == 'div2')
setTimeout("document.getElementById('slideItDown2').style.display = 'none';",900);
if(divid == 'div3')
setTimeout("document.getElementById('slideItDown3').style.display = 'none';",400);
if(divid == 'div4')
setTimeout("document.getElementById('slideItDown4').style.display = 'none';",900);
if(divid == 'div5')
setTimeout("document.getElementById('slideItDown5').style.display = 'none';",900);
if(divid == 'div6')
setTimeout("document.getElementById('slideItDown6').style.display = 'none';",900);
if(divid == 'div7')
setTimeout("document.getElementById('slideItDown7').style.display = 'none';",900);


}

}

/************** sliding function end ******************************/
/*************  showhidegamelist.js  ************/

function load_show_hide()
{
username=get_cookie('AllGameList');
//alert(username);
if (get_cookie("AllGameList=") == '')
{
document.getElementById("showgamelist").style.display="block";
document.getElementById("writediv1").style.display="none";
document.getElementById("writediv2").style.display="block";
}

if(get_cookie('AllGameList')=='hide')
{
document.getElementById("showgamelist").style.display="none";
document.getElementById("writediv1").style.display="block";
document.getElementById("writediv2").style.display="none";
}
else
{
document.getElementById("showgamelist").style.display="block";
document.getElementById("writediv1").style.display="none";
document.getElementById("writediv2").style.display="block";
}
}

function showhidediv(action)
{
if(action == "show")
{
document.getElementById("showgamelist").style.display="block";
document.getElementById("writediv1").style.display="none";
document.getElementById("writediv2").style.display="block";
}
else
{
document.getElementById("showgamelist").style.display="none";
document.getElementById("writediv1").style.display="block";
document.getElementById("writediv2").style.display="none";
}
}
/************************  flg_cookie.js  *************************/
function flg_set_cookie( name, value, expires) 
{
var domain='.zapak.com';
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() : "")+
((domain) ? ";domain=" + domain : "");
//alert('cookie:'+name+'is set');
}

function flg_get_cookie(name) 
{
if (document.cookie.length>0)
{
start=document.cookie.indexOf(name + "=");
if (start!=-1)
{ 
start=start + name.length+1; 
end=document.cookie.indexOf(";",start);
if (end==-1) end=document.cookie.length;
return unescape(document.cookie.substring(start,end));
} 
}
return "";
}


function get_param( name )
{
name = name.replace(/[[]/,"[").replace(/[]]/,"]");
var regexS = "[?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return ""; 
else
return results[1];
} 

function flg_cookie(name)
{
var flg_val = get_param(name);
//alert(flg_val);
if(flg_val != '')
{
flg_set_cookie(name, flg_val, 60);
}
}
/*********  egobox.js  ***************/
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 ='';
          
			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_content").style.display = '';
		document.getElementById("newsholder").style.width='59%';	
		document.getElementById("scroll3_top").style.width='450px';		
		printegobox(mailcount,scrapscount,challengescount,loyaltypoints,username_cookie,avatar,gender,facebook_avatar);
	
}

function hideEgoBox()
{
if(document.getElementById("userid"))
document.getElementById("userid").innerHTML = 'Stranger';
/*slider userid div start here*/
if(document.getElementById("slide_uid"))
document.getElementById("slide_uid").innerHTML = 'Stranger';
/*slider userid div ends here*/
document.getElementById("loginbox").style.display = '';
document.getElementById("egobox_content").style.display = 'none';
document.getElementById("scroll3_top").style.width='600px';
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>';
//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://blog.zapak.com" style="font-size: 11px;" target="_blank"><b><u>Just Launched: The Zapak Blog </u></b></a>';
//document.getElementById("zhousie").innerHTML ='<a class="head01" href="javascript:void(0);" onclick="switch_lite();" style="font-size: 11px;"><b><u>Site taking time to load?<br/>Try Zapak Lite</u></b></a>';
//document.getElementById("zhousie").innerHTML ='<a class="head01" href="http://www.zapak.com/zclindex.php" style="font-size: 11px;"><b><u>ZCL contest closed.<br/>Click here for winners!</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';
document.searchform.submit();
return true;
}
else{
submitform();
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 id="egobox"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
egoboxcontent +='<td width="22" align="center" valign="middle"><a href="javascript:void(0);" onclick="javascript:divhowhide(\'ego_links\');"><img src="'+RESOURCE_SERVER_URL+'/www/images/gruparrow.gif" width="9" height="9" border="0" /></a></td>';
egoboxcontent +='<td width="156" height="20" align="left" valign="middle" class="ar11bl"><span id="userid">Hi <a style="text-decoration:underline;" href="javascript:void(0);" onclick="javascript:divhowhide(\'ego_links\');"><strong>'+userid+'</strong></span></strong></a></td>';
egoboxcontent +='<td width="2" rowspan="2" align="left" valign="top" background="'+RESOURCE_SERVER_URL+'/www/images/lgdivider.gif"><img src="'+RESOURCE_SERVER_URL+'/www/images/spacer.gif" width="2" height="1" /></td>';
egoboxcontent +='<td width="22" rowspan="2" align="center" valign="middle" class="ar11bl"><a href="http://mail.zapak.com" target="_blank"><img src="'+RESOURCE_SERVER_URL+'/www/images/icon_envelop.gif" width="16" height="16" border="0" alt="Zapak Mail" title="Zapak Mail"/></a></td>';
egoboxcontent +='<td width="29" rowspan="2" class="ar11bl" style="padding-top:5px"><a href="http://mail.zapak.com" target="_blank">'+mailcount+'</a></td>';
egoboxcontent +='<td width="20" rowspan="2" align="left" valign="middle" style="padding-top:2px"><a href="'+myzapak+'/zloyaltymypoints.php" target="_top"><img src="'+RESOURCE_SERVER_URL+'/www/images/icon_gift.gif" width="16" height="16" border="0" alt="Loyalty Points" title="Loyalty Points"/></a></td>';
egoboxcontent +='<td width="41" rowspan="2" align="left" valign="middle" class="ar11bl" style="padding-top:5px"><a href="'+myzapak+'/zloyaltymypoints.php" target="_top">'+loyaltycount+'</a></td>';
egoboxcontent +='</tr><tr><td>&nbsp;</td><td align="left" valign="top" class="ar11bl" id="signout"><a href="'+SECURE_SERVER_URL+'/zlogout.php" target="_parent">Signout</a></td></tr></table></div>';
document.getElementById("egobox_content").innerHTML = egoboxcontent;

	if(document.getElementById("ego_link_uid"))
		{
		document.getElementById("ego_link_uid").innerHTML = '<a href="javascript:void(0);" onclick="javascript:divhowhide(\'ego_links\');"><strong>Hi '+userid+'</strong></span></strong></a>';
		}
		/*slider userid div start here*/
		if(document.getElementById("slide_uid"))
		document.getElementById("slide_uid").innerHTML = userid;

		/*slider userid div ends here*/
		if(document.getElementById("avatar_image"))
		{
		document.getElementById("avatar_image").innerHTML = '<a href="'+myzapakPath+'/public/home/show/'+'" target="_top"><img style="border:1px solid #cccccc" src="'+avatarimg+'" border="0" width="55" height="55"></a>';
		}
			if(document.getElementById("ego_link_signout"))
		{
		document.getElementById("ego_link_signout").innerHTML = '<a href="'+SECURE_SERVER_URL+'/zlogout.php" target="_parent">Signout</a>';
		}
   
   }
   
   function divhowhide(divobj)
   {
	   if(document.getElementById(divobj).style.display =='none')
	   {
		   document.getElementById(divobj).style.display='';
	   }
	   else
	   {
		   document.getElementById(divobj).style.display='none';
	   }
   }
   
   /***********function from cricketscoreticker.js  **************/

var scorelength = 1;
var cricketscoreticker = ""; 

function getXmlHttp_RequestObject() 
{	
if (window.XMLHttpRequest) 
{		
return new XMLHttpRequest(); //Not IE	
} 
else if	(window.ActiveXObject) 
{		
return new ActiveXObject("Microsoft.XMLHTTP"); //IE	
} 
else 
{		
//Display your error message here. 		
//and inform the user they might want to upgrade		
//their browser.		
alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");	
}
} 

function scoreupdate(holdingdiv,tickerdiv,xmlpage)
{
var receive_Request = getXmlHttp_RequestObject();

if (receive_Request.readyState == 4 || receive_Request.readyState == 0) 
{

//True explicity sets the request to asyncronous (default).		

var urlval = xmlpage;
receive_Request.open("GET", urlval, true);		
receive_Request.onreadystatechange = handlescore; 		

//Make the actual request.		
receive_Request.send(null);	
}



function handlescore()
{    
if (receive_Request.readyState == 4) 
{
xmlDoc=receive_Request.responseXML;

if(xmlDoc.getElementsByTagName("match")[0])
{
scorelength = xmlDoc.getElementsByTagName("match").length;
var i=0;
cricketscoreticker = "";

for(i=0;i<scorelength;i++)
{

if(i == 0)
cricketscoreticker += "<font color='e84c00'> Live Score : </font>";
else
cricketscoreticker += " | ";

cricketscoreticker += "<a href="+CRICKET_SERVER_URL+"/scorecard/cricket-scores-"+xmlDoc.getElementsByTagName("id")[i].childNodes[0].nodeValue+".php target='_blank'>";

if(xmlDoc.getElementsByTagName("team1")[i].childNodes[0])
cricketscoreticker += xmlDoc.getElementsByTagName("team1")[i].childNodes[0].nodeValue;

cricketscoreticker += " Vs ";

if(xmlDoc.getElementsByTagName("team2")[i].childNodes[0])
cricketscoreticker += xmlDoc.getElementsByTagName("team2")[i].childNodes[0].nodeValue; 


if(xmlDoc.getElementsByTagName("batteam")[i].childNodes[0])
cricketscoreticker += " - "+xmlDoc.getElementsByTagName("batteam")[i].childNodes[0].nodeValue;



if(xmlDoc.getElementsByTagName("batteamover")[i].childNodes[0])
{
		cricketscoreticker += ": ";

		if(xmlDoc.getElementsByTagName("batteamrun")[i].childNodes[0])
		cricketscoreticker += xmlDoc.getElementsByTagName("batteamrun")[i].childNodes[0].nodeValue;

		cricketscoreticker += "/ ";


		if(xmlDoc.getElementsByTagName("batteamwicket")[i].childNodes[0])
		cricketscoreticker += xmlDoc.getElementsByTagName("batteamwicket")[i].childNodes[0].nodeValue;

		cricketscoreticker += " (";

		if(xmlDoc.getElementsByTagName("batteamover")[i].childNodes[0])
		cricketscoreticker += xmlDoc.getElementsByTagName("batteamover")[i].childNodes[0].nodeValue;

		cricketscoreticker += " Ovs.). ";
}
//if(xmlDoc.getElementsByTagName("status")[i].childNodes[0])
//cricketscoreticker += xmlDoc.getElementsByTagName("status")[i].childNodes[0].nodeValue;

cricketscoreticker += "</a>"; 

}

document.getElementById(tickerdiv).innerHTML =  cricketscoreticker;
document.getElementById(holdingdiv).style.display = '';



if(document.getElementById("ads_exp_Middle")){
document.getElementById("ads_exp_Middle").style.paddingTop = 167;
}
}

else 
document.getElementById(holdingdiv).style.display = 'none';

}      
}			
}	

/*NEW SCROLL TICKER ADS XML*/
var sTop=30;
var xmlhttpScroller;
var defHeight = 30;
var noofScrolls =3;
var sctimerHandler ;
var scrollUp = 1;
var url='';
var moveFrom= 0;
var moveTo = 0;
var currPostition = 1;
var cricketscoreticker='';
var whichcontent=-1;
var i=0;
function scoreupdate_new(holdingdiv,tickerdiv,xmlpage)
{
var receive_Request = getXmlHttp_RequestObject();

if (receive_Request.readyState == 4 || receive_Request.readyState == 0) 
{

//True explicity sets the request to asyncronous (default).		

var urlval = xmlpage;
receive_Request.open("GET", urlval, true);		
receive_Request.onreadystatechange = handlescore; 		

//Make the actual request.		
//receive_Request.send(null);	
}



function handlescore()
{    
if (receive_Request.readyState == 4) 
{
xmlDoc=receive_Request.responseXML;

if(xmlDoc.getElementsByTagName("match")[0])
{
	whichcontent=1;
	scorelength = xmlDoc.getElementsByTagName("match").length;
	noofScrolls = xmlDoc.getElementsByTagName("match").length;
		for(i=0;i<scorelength;i++)
		{	
			//cricketscoreticker += " | ";
			cricketscoreticker += '<div onmouseover="javscript:pauseScroll();" onmouseout="javascript:clearpauseScroll();" style="padding:13px;float: none; position: absolute; top: ' + (i * 30) + 'px;" class="panel ar11bl"><a href='+CRICKET_SERVER_URL+'/scorecard/cricket-scores-'+xmlDoc.getElementsByTagName("id")[i].childNodes[0].nodeValue+'.php target="_blank">';

			if(xmlDoc.getElementsByTagName("team1")[i].childNodes[0])
			cricketscoreticker += xmlDoc.getElementsByTagName("team1")[i].childNodes[0].nodeValue;

			cricketscoreticker += " Vs ";

			if(xmlDoc.getElementsByTagName("team2")[i].childNodes[0])
			cricketscoreticker += xmlDoc.getElementsByTagName("team2")[i].childNodes[0].nodeValue; 


			if(xmlDoc.getElementsByTagName("batteam")[i].childNodes[0])
			cricketscoreticker += " - "+xmlDoc.getElementsByTagName("batteam")[i].childNodes[0].nodeValue;
			
			if(xmlDoc.getElementsByTagName("batteamover")[i].childNodes[0])
			{
					cricketscoreticker += ": ";

					if(xmlDoc.getElementsByTagName("batteamrun")[i].childNodes[0])
					cricketscoreticker += xmlDoc.getElementsByTagName("batteamrun")[i].childNodes[0].nodeValue;

					cricketscoreticker += "/ ";


					if(xmlDoc.getElementsByTagName("batteamwicket")[i].childNodes[0])
					cricketscoreticker += xmlDoc.getElementsByTagName("batteamwicket")[i].childNodes[0].nodeValue;

					cricketscoreticker += " (";

					if(xmlDoc.getElementsByTagName("batteamover")[i].childNodes[0])
					cricketscoreticker += xmlDoc.getElementsByTagName("batteamover")[i].childNodes[0].nodeValue;

					cricketscoreticker += " Ovs.). ";
			}
			else
			{
				try
				{
				
					if(xmlDoc.getElementsByTagName("toss")[i])
					{
						cricketscoreticker += ": " +xmlDoc.getElementsByTagName("winner")[i].childNodes[0].nodeValue + " won the toss and decided to ";
						if(xmlDoc.getElementsByTagName("decision")[i].childNodes[0].nodeValue == 'Fielding')
						{
							cricketscoreticker += "Field";
						}
						else
						{
							cricketscoreticker += "bat.";
						}
					}
					else
					{
						cricketscoreticker += ": Match yet to start.";
					}
				}
				catch (e)
				{
					
				}
			}
			//if(xmlDoc.getElementsByTagName("status")[i].childNodes[0])
			//cricketscoreticker += xmlDoc.getElementsByTagName("status")[i].childNodes[0].nodeValue;

			cricketscoreticker += "</a></div>"; 
			

		}
						
						/*document.getElementById("scroll3_top").innerHTML='<div class="belt_top" id="belt_top">	</div>';
		
		document.getElementById("belt_top").innerHTML = cricketscoreticker ;
		cricketscoreticker='';
						currPostition = 1;
						sTop = 30;
						moveFrom= 0;
						moveTo = 0;*/
						
						//startSlider();

}
else {
	//	Zpk_ScriptSrcTransport.bind(not_params);
	
}
}
}
}

/***********  activateswf.js  ****************/
var bo_ns_id = 0;function startIeFix(){  if(isIE()){    document.write('<div style="display: none;" id="bo_ns_id_' + bo_ns_id + '">');  }}function endIeFix(){  if(isIE()){    document.write('</div>');    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);    if(theObject.firstChild.data){      theObject.firstChild.removeAttribute('data');    }    var theParams = theObject.getElementsByTagName("param");    var theParamsLength = theParams.length;    for (var j = 0; j < theParamsLength; j++) {      if(theParams[j].name.toLowerCase() == 'flashvars'){        var theFlashVars = theParams[j].value;      }    }    var theInnnerHTML = theObject.innerHTML;    var re = /<param name="FlashVars" value="">/ig;    theInnnerHTML = theInnnerHTML.replace(re, "<param name='FlashVars' value='" + theFlashVars + "'>");    theObject.outerHTML = theInnnerHTML;  }}function isIE(){  var strBrwsr = navigator.userAgent.toLowerCase();  if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){    return true;  }else{    return false;  }}

function fixieswf(){
if(isIE()){
objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++){
objects[i].outerHTML = objects[i].outerHTML;
}
}
}

/************  scroll_ads.js  ************/
scrollcounter=0;
var timeoutid;
var pcount;
var movepos;
var moveposfrom;
function slideshow()
{
if(noofscrollads != 1)
{
timeoutid=setTimeout('slide_ads_new()', 1000);
}
}

function slide_ads_new()
{
if(scrollcounter ==-(scrolladwidth  * (noofscrollads -1)) - 5) 
{
reverse();
return false;
}

document.getElementById("belt").style.left= scrollcounter +'px' ;
if(scrollcounter % scrolladwidth  == 0) 
{
id="sponsorprev"
timeoutid=setTimeout('slide_ads_new()', 3000);
nextprevbuttons();


}
else timeoutid=setTimeout('slide_ads_new()', 1);
scrollcounter = scrollcounter-5 ;
}

function reverse()
{
if(scrollcounter > 0)
{
slide_ads_new();
scrollcounter = 0;
return false;
}
scrollcounter = scrollcounter + 10;
document.getElementById("belt").style.left= scrollcounter +'px' ;
timeoutid=setTimeout('reverse()', 1);

}


function nextprevbuttons()
{

if(noofscrollads==1)
{
document.getElementById("sponsorprev").innerHTML = '<img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_l_d.gif" align="absmiddle" width="19" height="18" />' ;
document.getElementById("sponsornext").innerHTML = '<img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_r_d.gif" align="absmiddle" width="19" height="18" />' ;		
}
else if(scrollcounter ==0)
{
document.getElementById("sponsorprev").innerHTML = '<img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_l_d.gif" align="absmiddle" width="19" height="18" />' ;
document.getElementById("sponsornext").innerHTML = '<a onclick="clearTimeout(timeoutid);shownext('+scrollcounter+')" style="cursor:pointer;"><img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_r_a.gif" align="absmiddle" width="19" height="18" /></a>' ;		
}
else if(scrollcounter== - (scrolladwidth  * (noofscrollads-1)))
{
document.getElementById("sponsorprev").innerHTML = '<a onclick="clearTimeout(timeoutid);showprev('+scrollcounter+')"   style="cursor:pointer;"><img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_l_a.gif" align="absmiddle" width="19" height="18" /></a>' ;
document.getElementById("sponsornext").innerHTML = '<img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_r_d.gif" align="absmiddle" width="19" height="18" />' ;		
}
else if(scrollcounter % scrolladwidth == 0)
{
document.getElementById("sponsorprev").innerHTML = '<a onclick="clearTimeout(timeoutid);showprev('+scrollcounter+')"   style="cursor:pointer;"><img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_l_a.gif" align="absmiddle" width="19" height="18" /></a>' ;
document.getElementById("sponsornext").innerHTML = '<a onclick="clearTimeout(timeoutid);shownext('+scrollcounter+')" style="cursor:pointer;"><img src="'+RESOURCE_SERVER_URL+'/www/images/red_arr_r_a.gif" align="absmiddle" width="19" height="18" /></a>' ;		
}
}

function showprev(position)
{	

moveposto = scrollcounter;
moveposfrom = position  + scrolladwidth  ;
moveprev();

}

function moveprev()
{
if(moveposto < moveposfrom)
{
document.getElementById("belt").style.left= moveposto +'px' ;
moveposto = moveposto + 5;
timeoutid=setTimeout('moveprev()', 1);
}
else
{	
clearTimeout(timeoutid);
scrollcounter = moveposfrom;
document.getElementById("belt").style.left= scrollcounter +'px' ;
nextprevbuttons();
timeoutid=setTimeout('slideshow()', 2000);
}
}

function shownext(position)
{	

moveposto = scrollcounter;
moveposfrom = position  - scrolladwidth  ;
movenext();	 
}

function movenext()
{
if(moveposto > moveposfrom)
{
document.getElementById("belt").style.left= moveposto +'px' ;
moveposto = moveposto - 5;
timeoutid=setTimeout('movenext()', 1);
}
else
{	
clearTimeout(timeoutid);
scrollcounter = moveposfrom;
document.getElementById("belt").style.left= scrollcounter +'px' ;
nextprevbuttons();
timeoutid=setTimeout('slideshow()', 2000);
}
}


/*************  zapak_login.js  **************/

var ZPK_DOMAIN_PREFIX = '';
if(document.domain.indexOf('test64-') == 0)
ZPK_DOMAIN_PREFIX = 'test64-';
else if(document.domain.indexOf('stage-') == 0)
ZPK_DOMAIN_PREFIX = 'stage-';



var zpk_sitedomain = '';
// setcookie function for saving userdetails in cookie starts
function zpk_egobox_set_cookie( name, value, expires) 
{
var domain = ".zapak.com";
var today = new Date();
today.setTime( today.getTime() );

if (expires)
expires = expires * 1000 * 60 ;


var expires_date = new Date(today.getTime() + (expires));
document.cookie = name + "=" +escape( value ) +
((expires) ? ";expires=" + expires_date.toGMTString() : "")+
((domain) ? ";domain=" + domain : "") 
}
//setcookie function for saving userdetails in cookie ends 

//function to delete cookie
function zpk_egobox_delete_cookie(name) {
var domain = ".zapak.com";
if ( zpk_egobox_get_cookie( name ) ) document.cookie = name + "=" +
//( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//End

//function to get cookie
function zpk_egobox_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 ) );
}
//end

// code for json call starts 
function zpk_egobox_responsehandler(type, data, eventobj, params)
{

if(data.userdetails.loginstatus == '1')
{
showEgoBox(data.userdetails.mailcount,data.userdetails.scrapscount,data.userdetails.challengescount,data.userdetails.loyaltypoints,data.userdetails.favgamecount,data.userdetails.buddycount,data.userdetails.uid,data.userdetails.avatar,data.userdetails.gender,data.userdetails.facebook_avatar);
var userdetails_expired_in = 2;

var today = new Date();
var timestamp = new Date(today.getTime() + (userdetails_expired_in * 1000 * 60));

var userdetails = data.userdetails.mailcount+"|"+data.userdetails.scrapscount+"|"+data.userdetails.challengescount+"|"+data.userdetails.loyaltypoints+"|"+data.userdetails.favgamecount+"|"+data.userdetails.buddycount+"|"+data.userdetails.uid+"|"+data.userdetails.avatar+"|"+data.userdetails.gender+"|"+data.userdetails.facebook_avatar+"|"+zpk_sitedomain+"|"+timestamp;

zpk_egobox_set_cookie( ZPK_DOMAIN_PREFIX+'zpk_ud', userdetails, (0) );

}
else if(data.userdetails.loginstatus == '0')
{
hideEgoBox();
zpk_egobox_delete_cookie( ZPK_DOMAIN_PREFIX+'zpk_ud');
zpk_egobox_delete_cookie( ZPK_DOMAIN_PREFIX+'zpk_u');
}
}

// function responsehandler ends 
function zpk_egobox_errorhandler(type, data, eventobj, params)
{
alert('error');
}


function zpk_egobox_timeouthandler(type, data, eventobj, params)
{
//alert('timeout');
}

function zpk_egobox_jsoncall(domain){
var params1 = {url:  SECURE_SERVER_URL+'/zuserdetails.php?domain='+domain, load: zpk_egobox_responsehandler, error: zpk_egobox_errorhandler, timeout: zpk_egobox_timeouthandler, timeoutSeconds: 5, jsonParamName: 'callback'};
Zpk_ScriptSrcTransport.bind(params1);
}
//code for json call ends 


function load_egobox(domain)
{
zpk_sitedomain = domain;
var username_cookie = get_cookie(ZPK_DOMAIN_PREFIX+'zpk_u');
var sso_cookie = get_cookie(ZPK_DOMAIN_PREFIX+'ssapresu');
var userdetails_cookie = get_cookie(ZPK_DOMAIN_PREFIX+'zpk_ud');

if(username_cookie || sso_cookie) //    check whether username_cookie exist or not 
{
if(userdetails_cookie)
{
var userdetails_arr = userdetails_cookie.split("|");
var mailcount  = userdetails_arr[0];
var scrapscount = userdetails_arr[1];
var challengescount = userdetails_arr[2];
var loyaltypoints = userdetails_arr[3];
var favgamecount = userdetails_arr[4];
var buddycount = userdetails_arr[5];
var uid = userdetails_arr[6];
var avatar = userdetails_arr[7];
		var gender = userdetails_arr[8];
		var facebook_avatar = userdetails_arr[9];

var sitedomain_cookie = userdetails_arr[10]
var timestamp = userdetails_arr[11];
}
if(mailcount != null && scrapscount != null && challengescount != null && loyaltypoints != null && uid != null && favgamecount != null && buddycount != null && uid == username_cookie && userdetails_cookie != null && sitedomain_cookie == zpk_sitedomain)
{
var today = new Date();
var currenttime = new Date(today.getTime()); //get current time
var timestamp = new Date(timestamp); // get timestamp from cookie


var time_diff = currenttime - timestamp;

if(time_diff < 0) //if timestamp is less than current time print egobox
{
showEgoBox(mailcount,scrapscount,challengescount,loyaltypoints,favgamecount,buddycount,username_cookie,avatar,gender,facebook_avatar);
}
else   // else print egobox and make jsoncall
{
showEgoBox(mailcount,scrapscount,challengescount,loyaltypoints,favgamecount,buddycount,username_cookie,avatar,gender,facebook_avatar);
zpk_egobox_jsoncall(domain);

}

}
else // if data is not present in cookie then make a json call
{						
zpk_egobox_jsoncall(domain);
}
}
else // if cookie not exist print stranger and remove signout link
{
hideEgoBox();
}
}
/*****************code for egobox end ********************************/


/****************  zapak-xd-ajax  *****************/
Zpk_ScriptSrcTransport=new function(){
this.preventCache=true;
this.maxUrlLength=1000;
this.inFlightTimer=null;
this.DsrStatusCodes={Continue:100,Ok:200,Error:500};
this.startWatchingInFlight=function(){
if(!this.inFlightTimer){
this.inFlightTimer=setInterval("Zpk_ScriptSrcTransport.watchInFlight();",100);
}
};
this.watchInFlight=function(){
var _1=0;
var _2=0;
for(var _3 in this._state){
_1++;
var _4=this._state[_3];
if(_4.isDone){
_2++;
delete this._state[_3];
}else{
if(!_4.isFinishing){
var _5=_4.kwArgs;
try{
if(_4.checkString&&eval("typeof("+_4.checkString+") != 'undefined'")){
_4.isFinishing=true;
this._finish(_4,"load");
_2++;
delete this._state[_3];
}else{
if(_5.timeoutSeconds&&_5.timeout){
if(_4.startTime+(_5.timeoutSeconds*1000)<(new Date()).getTime()){
_4.isFinishing=true;
this._finish(_4,"timeout");
_2++;
this.removeScript(_4.id);
delete this._state[_3];
}
}else{
if(!_5.timeoutSeconds){
_2++;
}
}
}
}
catch(e){
_4.isFinishing=true;
this._finish(_4,"error",{status:this.DsrStatusCodes.Error,response:e});
this.removeScript(_4.id);
}
}
}
}
if(_2>=_1){
clearInterval(this.inFlightTimer);
this.inFlightTimer=null;
}
};
this.removeScript=function(id){
var _7=document.getElementById(id);
var _8=_7.parentNode;
if(_7&&_7.className=="Zpk_ScriptSrcTransport"){
var _8=_7.parentNode;
_8.removeChild(_7);
}
};
this.bind=function(_9){
var _a=_9.url;
var _b="";
if(_a.indexOf("#")>-1){
_a=_a.split("#")[0];
}
var _c=_a.split("?");
if(_c&&_c.length==2){
_a=_c[0];
_b+=(_b?"&":"")+_c[1];
}
var id=_9["apiId"]?_9["apiId"]:"id"+this._counter++;
var _e=_9["content"];
var _f=_9.jsonParamName;
if(_9.sendTransport||_f){
if(!_e){
_e={};
}
if(_9.sendTransport){
_e["dojo.transport"]="scriptsrc";
}
if(_f){
_e[_f]="Zpk_ScriptSrcTransport._state."+id+".jsonpCall";
}
}
if(_e[_f]){
_b+=((_b)?"&":"")+_f+"="+encodeURIComponent(_e[_f]);
}
if(_9["apiId"]){
_9["useRequestId"]=true;
}
var _10={"id":id,"idParam":"_dsrid="+id,"url":_a,"query":_b,"kwArgs":_9,"startTime":(new Date()).getTime(),"isFinishing":false};
if(!_a){
this._finish(_10,"error",{status:this.DsrStatusCodes.Error,statusText:"url.none"});
return;
}
if(_e&&_e[_f]){
_10.jsonp=_e[_f];
_10.jsonpCall=function(_11){
if(_11["Error"]||_11["error"]){
if(dojo["json"]&&dojo["json"]["serialize"]){
}
Zpk_ScriptSrcTransport._finish(this,"error",_11);
}else{
Zpk_ScriptSrcTransport._finish(this,"load",_11);
}
};
}
if(_9["useRequestId"]||_9["checkString"]||_10["jsonp"]){
this._state[id]=_10;
}
if(_9["checkString"]){
_10.checkString=_9["checkString"];
}
_10.constantParams=(_9["constantParams"]==null?"":_9["constantParams"]);
if(_9["preventCache"]||(this.preventCache==true&&_9["preventCache"]!=false)){
_10.nocacheParam="dojo.preventCache="+new Date().valueOf();
}else{
_10.nocacheParam="";
}
var _12=_10.url.length+_10.query.length+_10.constantParams.length+_10.nocacheParam.length+this._extraPaddingLength;
if(_9["useRequestId"]){
_12+=_10.idParam.length;
}
if(!_9["checkString"]&&_9["useRequestId"]&&!_10["jsonp"]&&!_9["forceSingleRequest"]&&_12>this.maxUrlLength){
if(_a>this.maxUrlLength){
this._finish(_10,"error",{status:this.DsrStatusCodes.Error,statusText:"url.tooBig"});
return;
}else{
this._multiAttach(_10,1);
}
}else{
var _13=[_10.constantParams,_10.nocacheParam,_10.query];
if(_9["useRequestId"]&&!_10["jsonp"]){
_13.unshift(_10.idParam);
}
var _14=this._buildUrl(_10.url,_13);
_10.finalUrl=_14;
this._attach(_10.id,_14);
}
this.startWatchingInFlight();
};
this._counter=1;
this._state={};
this._extraPaddingLength=16;
this._buildUrl=function(url,_16){
var _17=url;
var _18="?";
for(var i=0;i<_16.length;i++){
if(_16[i]){
_17+=_18+_16[i];
_18="&";
}
}
return _17;
};
this._attach=function(id,url){
var _1c=document.createElement("script");
_1c.type="text/javascript";
_1c.src=url;
_1c.id=id;
_1c.className="Zpk_ScriptSrcTransport";
document.getElementsByTagName("head")[0].appendChild(_1c);
};
this._multiAttach=function(_1d,_1e){
if(_1d.query==null){
this._finish(_1d,"error",{status:this.DsrStatusCodes.Error,statusText:"query.null"});
return;
}
if(!_1d.constantParams){
_1d.constantParams="";
}
var _1f=this.maxUrlLength-_1d.idParam.length-_1d.constantParams.length-_1d.url.length-_1d.nocacheParam.length-this._extraPaddingLength;
var _20=_1d.query.length<_1f;
var _21;
if(_20){
_21=_1d.query;
_1d.query=null;
}else{
var _22=_1d.query.lastIndexOf("&",_1f-1);
var _23=_1d.query.lastIndexOf("=",_1f-1);
if(_22>_23||_23==_1f-1){
_21=_1d.query.substring(0,_22);
_1d.query=_1d.query.substring(_22+1,_1d.query.length);
}else{
_21=_1d.query.substring(0,_1f);
var _24=_21.substring((_22==-1?0:_22+1),_23);
_1d.query=_24+"="+_1d.query.substring(_1f,_1d.query.length);
}
}
var _25=[_21,_1d.idParam,_1d.constantParams,_1d.nocacheParam];
if(!_20){
_25.push("_part="+_1e);
}
var url=this._buildUrl(_1d.url,_25);
this._attach(_1d.id+"_"+_1e,url);
};
this._finish=function(_27,_28,_29){
if(_28!="partOk"&&!_27.kwArgs[_28]&&!_27.kwArgs["handle"]){
if(_28=="error"){
_27.isDone=true;
throw _29;
}
}else{
switch(_28){
case "load":
var _2a=_29?_29.response:null;
if(!_2a){
_2a=_29;
}
_27.kwArgs[(typeof _27.kwArgs.load=="function")?"load":"handle"]("load",_2a,_29,_27.kwArgs);
_27.isDone=true;
break;
case "partOk":
var _2b=parseInt(_29.response.part,10)+1;
if(_29.response.constantParams){
_27.constantParams=_29.response.constantParams;
}
this._multiAttach(_27,_2b);
_27.isDone=false;
break;
case "error":
_27.kwArgs[(typeof _27.kwArgs.error=="function")?"error":"handle"]("error",_29.response,_29,_27.kwArgs);
_27.isDone=true;
break;
default:
_27.kwArgs[(typeof _27.kwArgs[_28]=="function")?_28:"handle"](_28,_29,_29,_27.kwArgs);
_27.isDone=true;
}
}
};
};

/*  ############## 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 ############################### */

