<!--//<![CDATA[

function afaqsSearch()
{
	var obj = document.getElementById("sbox");
	var obj1 = document.getElementById("slist");
	if(obj1.className == "hideslist")
	{
		obj.childNodes[0].src = "/site_images/sboxup.gif";
		obj1.className = "showslist";
	}
	else
	{
		obj.childNodes[0].src = "/site_images/sboxdown.gif";
		obj1.className = "hideslist";
	}
}

function addBannerCode(zid)
{
	if(zid == "500") zid = "76";
	document.MAX_ct0 ='{clickurl}';
       var m3_u = (location.protocol=='https:'?'https://ads.afaqs.com/ads/www/delivery/ajs.php':'http://ads.afaqs.com/ads/www/delivery/ajs.php');
       if (!document.MAX_used) document.MAX_used = ',';
       document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
       document.write ("?zoneid="+zid);
       if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
       document.write ("&amp;loc=" + escape(window.location));
       if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
       if (document.context) document.write ("&context=" + escape(document.context));
       if ((typeof(document.MAX_ct0) != 'undefined') && (document.MAX_ct0.substring(0,4) == 'http')) {
           document.write ("&amp;ct0=" + escape(document.MAX_ct0));
       }
       if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
       document.write ("'><\/scr"+"ipt>");
}

function createXMLHTTPObject() {
  var XMLHttpFactories = [
    function () {return new XMLHttpRequest()},
    function () {return new ActiveXObject("Msxml2.XMLHTTP")},
    function () {return new ActiveXObject("Msxml3.XMLHTTP")},
    function () {return new ActiveXObject("Microsoft.XMLHTTP")}
	];
	var xmlhttp = false;
   for (var i=0;i<XMLHttpFactories.length;i++) {
           try{
                  xmlhttp = XMLHttpFactories[i]();
          }
          catch (e) {
                  continue;
          }
          break;
    }
    return xmlhttp;
}

function submitForm()
{
	var xhr = createXMLHTTPObject();
	if(xhr)
	{
		var poststr = "headline=" + encodeURI(document.getElementById('subject').value) + "&toemail=" + encodeURI(document.getElementById("toemail").value) + "&fromname=" + encodeURI(document.getElementById("fromname").value) + "&fromemail=" + encodeURI(document.getElementById("fromemail").value) + "&message=" + encodeURI(document.getElementById("message").value) + "&mlink=" + encodeURI(document.getElementById('mlink').value)+ "&murl="+encodeURI(document.getElementById('murl').value);
		xhr.open("POST", "/perl/news/maillink_other.html", true);
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr.setRequestHeader('Content-length', poststr.length);
		xhr.setRequestHeader('Connection', 'close');
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState == 4) {
        		if (xhr.status == 200)
				{
           			result = xhr.responseText;
            		document.getElementById('mailform').innerHTML = result; 
					document.getElementById("rta").onclick = removeMtp;
         		}
			}
		}
		xhr.send(poststr);
	}
	return false;
}

function remove_text()
{
	if(this.value!="" && (this.value == '[Enter your name]' || this.value == '[Enter your email address]' || this.value == '[Recipient Email(s)]'))
		this.value="";
}

function addText(eid, txt)
{
	e = document.getElementById(eid);
	if(e.value =="")
		e.value=txt;
}

function removeMtp()
{
	var m = document.getElementById("mailwrapper");
	document.body.removeChild(m);
	return false;
}

function mailThisPage()
{
	if(!document.createElement && !document.getElementById) return;
	if(document.getElementById("mailwrapper")) return;
	var mtp = document.createElement("DIV");
	mtp.setAttribute("id", "mailwrapper");
	mtp.innerHTML = '<div id="bluestrip"><a id="mtpclose" href="#">Close [X]</a></div><div id="mailtop"><img src="http://www.afaqs.com/grfx/logosmall.gif" alt="afaqs" width="131" height="51" /></div><div align="center" style="padding-top:2px;"><object id="roll" type="application/x-shockwave-flash" data="/banners/swf/2009/economist_500x80_20090513.swf" width="500" height="80"><param name="movie" value="/banners/swf/2009/economist_500x80_20090513.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowscriptAccess" value="always" /></object></div><div id="mailform"><span id="headline" class="topheadline"></span><form><label for="toemail">To:</label><input type="text" id="toemail" name="toemail" value="[Recipient Email(s)]"/><br /><small>Separate multiple addresses with commas.</small><br /><br><label for="fromname">From:</label><input type="text" id="fromname" name="fromname" value="[Enter your name]"/><br /><br /><label for="fromemail">&nbsp;</label><input type="text" id="fromemail" name="fromemail" value="[Enter your email address]"/><br /><br /><small><strong>If you would like to include a message, type it here:</strong></small><label for="message">&nbsp;</label><textarea id="message" name="message" class="msgbox"></textarea><br /><input type="hidden" id="mlink" name="mlink" value="" /><input type="hidden" id="murl" name="murl" value="" /><input type="hidden" id="subject" name="subject" value="" /><button type="submit" id="send" name="send">Send</button></form></div>';
	document.body.appendChild(mtp);
	var u = document.title;
	u=u.replace("&",'_amp_');
	document.getElementById('mlink').value = u;
	myurl=document.URL;
	myurl=myurl.replace("&",'_amp_');
	document.getElementById('murl').value = myurl;
	var xhr = createXMLHTTPObject();
	if(xhr)
	{
		xhr.open("GET", "/perl/news/maillink_other.html?value="+1+"&url="+u, true);
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr.setRequestHeader('Content-length', u.length);
		xhr.setRequestHeader('Connection', 'close');
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState == 4) {
        		if (xhr.status == 200)
				{
					document.getElementById('headline').innerHTML = document.getElementById('subject').value = xhr.responseText;
         		}
			}
		}
	xhr.send(null);
	}

	document.getElementById("send").onclick = submitForm;	
	document.getElementById("mtpclose").onclick = removeMtp;
	document.getElementById("fromname").onfocus = remove_text;
	document.getElementById("fromemail").onfocus = remove_text;
	document.getElementById("toemail").onfocus = remove_text;
	document.getElementById("fromname").onblur = add_name;
	document.getElementById("fromemail").onblur = add_email;
	document.getElementById("toemail").onblur = add_remail;
	return false;
}
function changeClass(e, cls)
{
	for(var i=0; i<e.childNodes.length; i++)
	{
		var node = e.childNodes[i];
		node.className = cls;
	}
}

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 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 handleNsTab(e)
{
	changeClass(document.getElementById("bc"), "taboff");
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3)
		targ = targ.parentNode;
	while(targ.nodeName != "LI")
		targ = targ.parentNode;
	targ.className = "tabon";
	return false;
}

function showrightads()
{
		var ww = f_clientWidth();
		if (document.getElementById && ww > 0)
		{
			if(document.getElementById('skyscraper'))
			{
				var mysky = document.getElementById('skyscraper');
				var ff = document.getElementById('np');
				(ww > 1000)?(mysky.style.display = "block"):(mysky.style.display = "none");
				(ww > 1220)?(ff.style.display = "block"):(ff.style.display = "none");
			}
		}
}

//menu bar js
var mmArray = new Array();
	var smArray = new Array();
	var whichMenu;
	var timeout;
	
	function $(id)
	{
		if(document.getElementById(id))
			return document.getElementById(id);
		else
			return false;
	}
	
	function extractNodes(pnode, nodeName)
	{
		var elArr = new Array();
		for(var i=0, j=0; i<pnode.childNodes.length; i++)
		{
			if(pnode.childNodes[i].nodeName == nodeName)
				elArr[j++] = pnode.childNodes[i];
		}
		return(elArr);
	}
	
	function getXYOffset(what) {
		var totalOffset = new Object();
		totalOffset.left = what.offsetLeft;
		totalOffset.top = what.offsetTop;
		var parentEl = what.offsetParent;
		while (parentEl!=null){
			totalOffset.left = totalOffset.left+parentEl.offsetLeft;
			totalOffset.top = totalOffset.top+parentEl.offsetTop;
			parentEl = parentEl.offsetParent;
		}
		return totalOffset;
	}
	
	function showSubMenu()
	{
		if(whichMenu)
		{
			clearTimeout(timeout);
			hidesubMenu();
		}
		var count = parseInt(this.id.substr(2, this.id.length));
		whichMenu = smArray[count];
		whichMenu.style.visibility = "visible";
		if($("iframeshim"))
		{
			offSetX = whichMenu.style.left;
			offSetY = whichMenu.style.top;
			shimobject = $("iframeshim");
			shimobject.style.left = offSetX;
			shimobject.style.top = offSetY;
			shimobject.style.width = whichMenu.offsetWidth+"px";
			shimobject.style.height = whichMenu.offsetHeight+"px";
			shimobject.style.display = "block";
		}
	}
	
	function clearSubMenu() 
	{
		timeout = setTimeout("hidesubMenu()", 500);
	}
	
	function cancelClearMenu()
	{
		clearTimeout(timeout);
	}
	
	function hidesubMenu()
	{
		if(whichMenu)
			whichMenu.style.visibility = "hidden";
		if($("iframeshim"))
		{
			shimobject = $("iframeshim");
			shimobject.style.display = "none";
		}
	}
	
//forget password
function showFP()
{
		/*var Geometry = {};
		if (document.documentElement && document.documentElement.scrollWidth)
		{
			Geometry.getDocumentWidth =	function()
			{ 
				return document.documentElement.scrollWidth; 
			};
			Geometry.getDocumentHeight = function()
			{
				return document.documentElement.scrollHeight;
			};
		}
		else if (document.body.scrollWidth) 
		{
			Geometry.getDocumentWidth =	function() 
			{
				return document.body.scrollWidth; 
			};
			Geometry.getDocumentHeight = function() 
			{ 
				return document.body.scrollHeight;
			};
		}
		dw = Geometry.getDocumentWidth();
		dh = Geometry.getDocumentHeight();
		var e = document.createElement("DIV");
		e.setAttribute("id", "hideScreen");
		e.style.width = dw+"px";
		e.style.height = dh+"px";
		e.className = "dialogbox";
		document.body.appendChild(e);
		var ff = document.getElementById("forgetform");
		ff.totalWidth = ff.offsetWidth;
		ff.totalHeight = ff.offsetHeight;
		ff.inW = parseInt(ff.totalWidth/7);
		ff.inH = parseInt(ff.totalHeight/7);
		ff.screenWidth = dw;
		ff.screenHeight = f_clientHeight();
		ff.style.width = "0px";
		ff.style.height = "0px";
		ff.style.left = (ff.screenWidth-parseInt(ff.style.width))/2+"px";
		ff.style.top = (ff.screenHeight-parseInt(ff.style.height))/2+"px";
		ff.style.overflow = "hidden";
		ff.style.visibility = "visible";
		setTimeout("calFunc()", 50);*/
		var ff = document.getElementById("forgetform");
		if(ff.style.display != "block")
		{
			ff.totalHeight = ff.offsetHeight;
			ff.inH = parseInt(ff.totalHeight/5);
			ff.style.display = "none";
			ff.style.position = "static";
			ff.style.height = "0px";
			ff.style.display = "block";
			ff.style.overflow = "hidden";
			setTimeout("calFunc()", 50);
		}
}

function calFunc()
{
	var ff = document.getElementById("forgetform");
	ff.style.height = parseInt(ff.style.height)+ff.inH+"px";
	ff.style.overflow = "hidden";
	if(parseInt(ff.style.height) < ff.totalHeight)
		setTimeout("calFunc()", 50);
	else
	{
		ff.style.height = ff.totalHeight+"px";
		ff.style.overflow = "hidden";
	}
}

/*function calFunc()
{
	var ff = document.getElementById("forgetform");
	ff.style.width = parseInt(ff.style.width)+ff.inW+"px";
	ff.style.height = parseInt(ff.style.height)+ff.inH+"px";
	ff.style.left = (ff.screenWidth-parseInt(ff.style.width))/2+"px";
	ff.style.top = (ff.screenHeight-parseInt(ff.style.height))/2+"px";
	ff.style.overflow = "hidden";
	if(parseInt(ff.style.width) < ff.totalWidth && parseInt(ff.style.height) < ff.totalHeight)
		setTimeout("calFunc()", 50);
	else
	{
		ff.style.width = ff.totalWidth+"px";
		ff.style.height = ff.totalHeight+"px";
		ff.style.left = (ff.screenWidth-parseInt(ff.style.width))/2+"px";
		ff.style.top = (ff.screenHeight-parseInt(ff.style.height))/2+"px";
		ff.style.overflow = "hidden";
	}
}*/
	
function $init($p)
{
	var W3CDOM = document.createElement && document.getElementById;
	if(!W3CDOM) return;
	if($p=="ddmenu")
	{
		//init drop down menu
		var browser = navigator.appName;
		var el = $("mainmenu");
		for(var i=0; i<el.childNodes.length; i++)
		{
			if(el.childNodes[i].nodeName == "UL")
			{
				el = el.childNodes[i];
				break;
			}
		}
		mmArray = extractNodes(el, "LI");
		smArray = extractNodes($("submenu"), "DIV");
		for(var i=0; i<mmArray.length; i++)
		{
			mmArray[i].id = "mm"+i;
			var offset = getXYOffset(mmArray[i]);
			smArray[i].style.left = offset.left+"px";
			smArray[i].style.top = offset.top+mmArray[i].offsetHeight+"px";
			mmArray[i].onmouseover = showSubMenu;
			mmArray[i].onmouseout = clearSubMenu;
			smArray[i].onmouseover = cancelClearMenu;
			smArray[i].onmouseout = clearSubMenu;
		}
		document.onclick = function() {
			clearTimeout(timeout);
			hidesubMenu();
		}
		if(browser == "Microsoft Internet Explorer")
		{
			document.write('<IFRAME id="iframeshim" src="about:blank" frameBorder="0" scrolling="no" style="position:absolute; display:none;z-index:999; background: transparent;"></IFRAME>');
		}
	}
	if(document.getElementById("sbox"))
	{
		var e = document.getElementById("sbox");
		e.onclick = afaqsSearch;
	}
	if($p=="mtp")
	{
		document.getElementById("mtp").onclick = mailThisPage;
	}
	if($p=="activateTabs")
	{
		document.getElementById("tabouter").onclick = handleNsTab;
		//getData("nstab", nstid);
	}
	showrightads();
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

if(navigator.appName!='Netscape')
{
	var h = "0.6em";
}
else
{
	var h = "1.9em";
}

//]]>-->