var isFF = navigator.userAgent.indexOf("Gecko");
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}
function expiry_date(){
var current_date = new Date ( );
var month_names = new Array ( );
month_names[month_names.length] = "January";
month_names[month_names.length] = "February";
month_names[month_names.length] = "March";
month_names[month_names.length] = "April";
month_names[month_names.length] = "May";
month_names[month_names.length] = "June";
month_names[month_names.length] = "July";
month_names[month_names.length] = "August";
month_names[month_names.length] = "September";
month_names[month_names.length] = "October";
month_names[month_names.length] = "November";
month_names[month_names.length] = "December";
var current_year=current_date.getFullYear();
var current_month=month_names[current_date.getMonth()];
var current_day=current_date.getDate();
var new_date=current_month+" "+current_day+","+current_year;
var milli_secs=Date.parse(new_date);
current_date.setTime(milli_secs+86401000);
var tomorrow=current_date.toUTCString();
return tomorrow;
}
/*function getcookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}*/
function getcookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function setcookie(name,value,duration){
if(duration!=0){
	cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
}else{
	cookiestring=name+"="+escape(value)+";EXPIRES="+expiry_date();
}
document.cookie=cookiestring;
if(!getcookie(name)){
return false;
}
else{
return true;
}
}
function date1(){
now = new Date();
then = new Date(" Jan 01 1970 00:00:00");
seconds=now-then/1000;
month=1+now.getMonth();
day=now.getDate();
year=now.getFullYear();
document.write( day+"-"+month+"-"+year+"");
}
var shownleave = 0;
function exitbox(){
	if (shownleave == 1) return;
	shownleave = 1;
	nowatch = 1;
	if(getcookie('safeexit') == 'yes' || getcookie('safeexit')==""){
		return;
	}
	else
	{
		try {var adeel = window.showModalDialog("","Exit PopOVER",""); }
		catch (e) {adeel = 1};
		if (adeel != 1) return;
		var confMsg = "Claim your FREE copy of the 'Global Mobiel Market Fact Book 2008' - completely free and without obligation. The 'Global Mobile Market Factbook 2008' will give you:\n> Introduction \n> GSM & CDMA: \n> 3G: \n> Handsets \n> ARPU: \n> Emerging Markets \n> MVNOs: \n> Pre-Paid: \n> Spectrum: \n> Termination Rates \n> Bluetooth & UWB \n> Mobile Data: \n> Regional Markets: \n> Europe: \n- Balkans and South East Europe \n- Baltic countries \n-\nCentral Europe \n- France and Switzerland \n- Germany and Austria \n- Italy and Malta \n- Russia, Belarus,\nMoldova and Ukraine \n- Scandinavia \n- Spain and Portugal \n- United Kingdom and Ireland \n> Africa: \n-\nCentral and Eastern Regions \n- Lesotho, South Africa and Swaziland \n- Northern Regions \n- Southern Region and\nIndian Ocean Islands \n- Western Region \n> Asia-Pacific \n- Hong Kong and Macau \n- Indonesia and Timor Leste \n- Japan \n- Malaysia and Philippines \n- Myanmar and Thailand \n- North and South Korea \n- South Pacific Islands \n- Taiwan \n- China \n- Australia \n- New Zealand: \n> North America \n> Latin America \n- Andean Bloc \n- Central\nAmerica \n- Eastern Nations \n- Mexico and the Caribbean \n- Southern Cone \n> Middle East - Gulf \n> Middle East - Mediterranean and Levant Countries  ";
		try {window.event.returnValue = confMsg;}
		catch(e) { }
		return confMsg;
	}
}
var exitlayer;
function prepareExitTrack() {
	mkoverlayexit();
	sl =0;
	exitlayer = document.getElementById("itexit").cloneNode(true);
	document.body.appendChild(exitlayer);
}

var n=30;
var exitoverlay;
function mkoverlayexit() {
	exitoverlay = document.createElement('DIV');
	exitoverlay.id="itexit1";
	exitoverlay.style.position = 'absolute';
	exitoverlay.style.left = '0px';
	exitoverlay.style.top = '0px';
	var w = (document.body.scrollWidth>document.body.clientWidth)? document.body.scrollWidth : document.body.clientWidth;
	var h = (document.body.scrollHeight>document.body.clientHeight)? document.body.scrollHeight : document.body.clientHeight;
	w = w + 50+'px';
	h = h + 50+'px';
	exitoverlay.style.width = w;
	exitoverlay.style.height = h;
	exitoverlay.innerHTML = "<table width = " + w + " height = " + h + "> </table>";
	exitoverlay.style.backgroundColor = "#FF8000";
	exitoverlay.above = exitlayer;
	exitoverlay.style.visibility = "hidden";
	document.body.appendChild(exitoverlay);
	exitoverlay.style.opacity = 0;
	exitoverlay.style.filter = 'alpha(opacity=' + 0 + ')';
}
var sl = 0;
var tm = 14;
function shadeinexoverlay() {
	// sl=30;
	var temp1=document.getElementById("itexit1");
	if(temp1.filters){
	temp1.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+n / 10 * sl+')';}
	else {exitoverlay.style.filter = 'alpha(opacity=' + (n / 10) * sl + ')';
	exitoverlay.style.opacity = ((n/100) / 10) * sl;}
	sl+=1;
	if (sl<=10)  setTimeout('shadeinexoverlay()',tm); 
	// exitoverlay.style.backgroundColor = "#FF8000";
}
function shadeoutexoverlay() {
	var temp1=document.getElementById("itexit1");
	if(temp1.filters){
		temp1.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+n / 10 * sl+')';}
	else {exitoverlay.style.filter = 'alpha(opacity=' + (n / 10) * sl + ')';
		exitoverlay.style.opacity = ((n/100) / 10) * sl;}
	// temp1.filters.item("DXImageTransform.Microsoft.Alpha").Opacity=n / 10 *
	// sl;
	// exitoverlay.style='-ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity='
	// + n / 10 * sl + ')';
	exitoverlay.style.filter = 'alpha(Opacity=' + n / 10 * sl + ')';
	exitoverlay.style.opacity = (n/100) / 10 * sl;
	sl-=1;
	if (sl>=0)  {setTimeout('shadeoutexoverlay()',tm); }
	else {exitoverlay.style.visibility = "hidden";
	exitlayer.style.visibility = "hidden";
	} 
}
var x,y,nowatch = 0; var shownexit = 0;
function mouseProc(e) {
	if(getcookie('safeexit') == 'yes'){
		return;
	}
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		x = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		y = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	if ((y<20) && (nowatch == 0)){
		if (shownexit == 0) {
			setcookie('safeexit','yes',1);
			shownexit = 1;
			if(!document.getElementById("itexit1")){
				var idiv=document.getElementById('itexit');
				box_height=stripAlphaChars(idiv.style.height);
				box_width=stripAlphaChars(idiv.style.width);
				setcookie('safeexit','no',1);
				prepareExitTrack();
			}
			exitlayer.style.top=  parseInt((document.body.scrollTop + (f_clientHeight() - box_height)) / 2)+'px';
			exitlayer.style.left=  parseInt((document.body.scrollLeft + (f_clientWidth()- box_width)) / 2)+'px';
			exitlayer.style.visibility="visible";
			exitoverlay.style.visibility="visible";
			shadeinexoverlay();
		}
	}
}
function dismissexit(){
	try {if (document.getElementById('idiframe')) {frames['idiframe'].location.href = 'about:blank';}} catch (e) {}
	nowatch = 1;
	sl = 10; 
	shadeoutexoverlay();
}
document.onmouseout=mouseProc;
document.onmousemove=mouseProc;
var box_height,box_width=0;
function stripAlphaChars(pstrSource) 
{ 
	var m_strOut = new String(pstrSource); 
    m_strOut = pstrSource.replace(/[^0-9]/g, ''); 
    return m_strOut; 
}

function init() {
	if(getcookie('safeexit') == 'yes')return; 
	var idiv=document.getElementById('itexit');
	box_height=stripAlphaChars(idiv.style.height);
	box_width=stripAlphaChars(idiv.style.width);
	setcookie('safeexit','no',1);
	prepareExitTrack();
	if (window.attachEvent) {
		window.attachEvent("onbeforeunload", cookiecheck); 
		window.attachEvent("onunload", cookiecheck); }
	else {
		window.onbeforeunload = cookiecheck; 
		window.onunload = cookiecheck; }
}
function cookiecheck(){
	var currentvalue;
	var uservalue =1;
	if(getcookie('popover') > 0){
		currentvalue = getcookie('popover');
		if(currentvalue == (uservalue+1))
		{
		}
		else
		{
			currentvalue = parseInt(currentvalue) + 1;
			setcookie('popover', currentvalue ,364);
			exitbox();
		}
	}
	else
	{
		setcookie('popover',2,364);
		exitbox();
	}
}
window.onload=function(){
 	init();
}