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());
}




function showCPMAds(show_ads_id,height,width,url)
{
	
	if ( !top.location.href.equals(window.location.href ))
		{
				return;
		}
	else
		{
	
			//var url="http://192.168.1.114/workspace/custom/cpm-5.2/show-cpm-ads.php";
		
			var arr1=show_ads_id.split("_");
								
		//alert(show_ads_id);
			url=url+"?id="+arr1[2];	
		url=url+"&hostname="+utf8_encode(window.location.hostname);
	
			//		url=url+"&hostname="+utf8_encode('robin.com');
		//alert(window.location.hostname);
		
		/*if(Get_Cookie('_io_vcm')!=null)
		url=url+"&cookie="+Get_Cookie('_io_vcm');
		else
			{
				url=url+"&cookie=";
				//alert(url);
				Set_Cookie( '_io_vcm', window.location.hostname, 24 , "/") ;
				//alert(url);
			}
			*/
			//alert(Get_Cookie('io_cp'));
					if(Get_Cookie('io_cp')!=null)
		url=url+"&cookie1="+Get_Cookie('io_cp');
		else
			{
				url=url+"&cookie1=";
			
			}
		
		//alert("<"+"script type=\"text/javascript\" src=\""+url+"\" language=\"javascript\"><"+"/script>");
		
		document.open();
		document.write("<"+"span id=\"121\"  style=\"display:none\">1111<"+"/span>");
		document.write("<"+"span id=\""+show_ads_id+"\"  ><"+"/span>");
		document.write("<"+"script type=\"text/javascript\" src=\""+url+"\" language=\"javascript\"><"+"/script>");
		//document.write("<"+"iframe src=\""+url+"\" frameborder=0 height=\""+height+"\" width=\""+width+"\" ><"+"/iframe>");
		//document.write("<"+"iframe src=\""+url+"\" frameborder=0 height=\""+height+"\" width=\""+width+"\" ><"+"/iframe>");
		
		document.close();
		
		
		//alert(url);
		}

}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{	
	if ( expires )
	{
		expires = expires *  60 * 60 ;
	}
	var expires_date = new Date( today.getTime() + (expires) );
//alert(expires_date);
	document.cookie = name + "=" +escape( value ) +

		 ";expires=" + expires_date.toGMTString()  + //expires.toGMTString()

		( ( 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 ) );

}
