


var today = new Date();
today.setTime( today.getTime() );
today.setHours(today.getHours()+1);
today.setMinutes(0);
today.setSeconds(0);





function	utf8_encode  (string) 

{

	string = string.replace(/\r\n/g,"\n");

	var utftext = "";



	for (var n = 0; n < string.length; n++) 

	{



		var c = string.charCodeAt(n);



		if (c < 128) 

		{

			utftext += String.fromCharCode(c);

		}

		else if((c > 127) && (c < 2048)) 

		{

			utftext += String.fromCharCode((c >> 6) | 192);

			utftext += String.fromCharCode((c & 63) | 128);

		}

		else 

		{

			utftext += String.fromCharCode((c >> 12) | 224);

			utftext += String.fromCharCode(((c >> 6) & 63) | 128);

			utftext += String.fromCharCode((c & 63) | 128);

		}



	}



	return escape(utftext);

}

 




String.prototype.equalsIgnoreCase=myEqualsIgnoreCase;

String.prototype.equals=myEquals;



function myEquals(arg)

{

        return (this.toString()==arg.toString());

}



function myEqualsIgnoreCase(arg)

{               

        return (new String(this.toLowerCase())==(new String(arg)).toLowerCase());

}






 var pop_up_call=0; 

function showPopUpAds(show_ads_id,url_name)
{

	var url=url_name;
	var session;
	
	// session logic 
	
	var pop_client=Get_Cookie('pop_client');
	
//	alert(pop_client);
	if(pop_client==null) //session is not started
	{
	session=false;
	
	}
	else
	{
	session=true;
	}
var time=new Date( today.getTime());
Set_Cookie( 'pop_client',time, 0 , "/") ;
	//session logic ends
	
	url=url+"?aduid="+show_ads_id;
	url=url+"&session="+session;
	
//alert(url);	
	
	

pop_up_call=1;


document.open();

document.write("<"+"script type=\"text/javascript\" src=\""+url+"\" language=\"javascript\"><"+"/script>");



document.close();

}


 
 

  
  function confirmExit()
  {
  //return;
  var time=new Date().getTime();
  var pop_client=Get_Cookie('pop_client');
	
//	alert(pop_client);
	if(pop_client!=null) //session is not started
	{
  
	  Set_Cookie( 'pop_client',time,30, "/") ;
	  }
  }


function Set_Cookie( name, value, expires, path, domain, secure ) 
{	

	if ( expires>0 )
	{
		expires = expires * 1000  ;
		

	}


	var expires_date = new Date(new Date().getTime()+expires);

//alert(expires +' '+ expires_date.toGMTString());
 if(expires!=0)
 {

	document.cookie = name + "=" +escape( value ) +
		 ";expires=" + expires_date.toGMTString()  + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	}
	else
	{
	document.cookie = name + "=" +escape( value ) +		 
		( ( 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 ) );

}


window.onbeforeunload = confirmExit;




