<!--//<![CDATA[
function writeError(m)
{
var e=document.getElementById("error");
	if(!e)
	{
		var e = document.createElement("DIV");
		e.setAttribute("id", "error");
		e.style.position = "fixed";
		e.style.top = "400px";
		e.style.left = "300px";
		e.style.width = "200px";
		e.style.height = "300px";
		e.style.height = "auto";
		e.style.zIndex = 1000;
		e.style.backgroundColor = "#30e406";
		e.style.border = "1px solid #000";
		e.style.color = "#000";
		document.body.appendChild(e);
		e.innerHTML = m+" ";
	}
	else
	{
		var text = e.innerHTML;
		e.innerHTML = text+" "+m;
	}
}

function preLoadCheck(j)
{
	if(j == "2")
	{
		if (parent.location.href == self.location.href){
		window.location.href = 'main1.html'
		}
	}
	/*if(j == "2")
	{
		 var is = createXMLHTTPObject();
		 if(!is) location.replace("http://www.afaqslinux.com/cgi-bin/re.html?c=error&u=http://www.afaqs.com/demo/afaqs/new_home/index.html");
	}*/
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function showDiv(divId)
{
	var d = document.getElementById(divId);
	if(!d) return;
	if(d.style.display != "block")
		d.style.display = "block";
}

function hideDiv(divId)
{
	var d = document.getElementById(divId);
	if(!d) return;
	if(d.style.display != "none")
		d.style.display = "none";
}

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 addRollover(pdid, did, cssClassName, src, width, height)
{
	var myDiv = document.createElement("DIV");
	myDiv.setAttribute("id", did);
	myDiv.className = cssClassName;
	myDiv.innerHTML = "<object type='application/x-shockwave-flash' data='"+src+"' width='"+width+"' height='"+height+"'><param name='movie' value='"+src+"' /><param name='quality' value='high' /><param name='allowscriptAccess' value='always' /><param name='wmode' value='transparent' /></object>";
	var parentDiv = document.getElementById(pdid);
	var off = getXYOffset(parentDiv);
	myDiv.style.top = off.top+"px";
	parentDiv.appendChild(myDiv);
}

function showFloater()
{
	if(document.getElementById)
	{
		var x = readCookie('skHome')
		if(!x)
		{
			createCookie('skHome', 'floater', 0);
			var fl = document.getElementById("floater");
			fl.style.display = "block";
		}
	}
}


function showSubMenuItem()
{
	var e = this;
	for(var i=0; i<e.childNodes.length; i++)
	{
		var node = e.childNodes[i];
		if(node.nodeName == "UL")
		{
			node.style.display = "block";
		}
	}
}

function hideSubMenuItem()
{
	var e = this;
	for(var i=0; i<e.childNodes.length; i++)
	{
		var node = e.childNodes[i];
		if(node.nodeName == "UL")
		{
			node.style.display = "none";
		}
	}
}
	
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";
	}
}

var abtn, ct, pt, id, myId;
var process = false;
var tabheight = 162;
var speed = 20;

function scrolleffect() {
	var jcurr = parseInt(ct.style.height);
	var jprev = parseInt(pt.style.height);
	pt.style.overflow = 'hidden';
	ct.style.overflow = 'hidden';
	if(jcurr>=(tabheight-speed) || jprev<=0)
	{
			pt.style.height = tabheight+'px';
			pt.style.display = 'none';
			ct.style.height = tabheight+'px';
			abtn = myId;
			process = false;
			clearInterval(id);	
	}
	else
	{
		pt.style.height = (jprev-speed) +'px';
		ct.style.height = (jcurr+speed) +'px';
	}
}

function handleScrollTabs(e)
{
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	if(targ.nodeName == "A")
		targ = targ.parentNode;
	if(targ.className != "taboff" || process == true) return false;
	myId = parseInt(targ.id.substr(targ.id.length-1,1));
	document.getElementById("tabsbt"+abtn).className = "taboff";
	document.getElementById("tabsbt"+myId).className = "tabon";
	ct = document.getElementById("tabsd"+myId);
	pt = document.getElementById("tabsd"+abtn);	
	getData("stab", myId);
	if((abtn == 1 || abtn == 2) && (myId == 1 || myId == 2))
	{
		process = true;
		document.getElementById("tabsd"+abtn).style.display = "none";
		document.getElementById("tabsd"+myId).style.display = "block";
		document.getElementById("buttonwrapper1").style.borderBottom = "1px solid #929292";
		document.getElementById("buttonwrapper2").style.borderBottom = "none";
		abtn = myId;
		process = false;
	}
	else if((abtn == 1 || abtn == 2) && (myId == 3 || myId == 4))
	{
		process = true;
		document.getElementById("tabsd"+myId).style.display = "block";
		pt.style.height = tabheight+'px';
		ct.style.height = 0+'px';
		id = setInterval('scrolleffect()', 10);		
		document.getElementById("buttonwrapper1").style.borderBottom = "none";
		document.getElementById("buttonwrapper2").style.borderBottom = "1px solid #929292";
	}
	else if((abtn == 3 || abtn == 4) && (myId == 3 || myId == 4))
	{
		process = true;
		document.getElementById("tabsd"+abtn).style.display = "none";
		document.getElementById("tabsd"+myId).style.display = "block";
		document.getElementById("buttonwrapper1").style.borderBottom = "none";
		document.getElementById("buttonwrapper2").style.borderBottom = "1px solid #929292";
		abtn = myId;
		process = false;
	}
	else if((abtn == 3 || abtn == 4) && (myId == 1 || myId == 2))
	{
		process = true;
		document.getElementById("tabsd"+myId).style.display = "block";
		pt.style.height = tabheight+'px';
		ct.style.height = 0+'px';
		id = setInterval('scrolleffect()', 10);
		document.getElementById("buttonwrapper1").style.borderBottom = "1px solid #929292";
		document.getElementById("buttonwrapper2").style.borderBottom = "none";
	}
	return false;
}

function initActivateLinks()
{
	var links = document.getElementsByTagName("a");
	for(var i=0; i<links.length; i++)
	{
		if(links[i].href && links[i].rel == "external")
		{
			links[i].onclick = function () {window.open(this.href);return false;};
		}
		if(links[i].href && links[i].rel == "parent")
		{
			links[i].onclick = function () {parent.window.location.href = this.href;return false;};
		}
	}
}		

function changeClass(e, cls)
{
	for(var i=0; i<e.childNodes.length; i++)
	{
		var node = e.childNodes[i];
		node.className = cls;
	}
}

function handleNsTab(e)
{
	changeClass(document.getElementById("nsBtnTabContainer"), "dtab");
	changeClass(document.getElementById("tc2"), "tcd2inactive");
	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 = "atab";
	var aTabId = parseInt(targ.id.substr(targ.id.length-1,1));
	var e = document.getElementById("tcd2"+aTabId);
	e.className = "tcd2active";
	getData("nstab", aTabId);	
	if(aTabId == 4)
		document.getElementById("tb"+aTabId).style.border = "none";
	return false;
}

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 getData(cid, tid)
{
	if(cid == "stab")
	{
		var e = document.getElementById("tabsd"+tid);
			if(tid == 4) 
				tid = 37;
			else if(tid == 1)
				tid = 3;
			else if(tid == 3)
				tid = 1;
			
		var u = "/home_tabs/tabsdata"+tid+".html";
	}
	else if(cid == "nstab")
	{
		var e = document.getElementById("tcd2"+tid);
		var u = "/home_tabs/tabsdata"+(tid+4)+".html";
	}
	if (e.innerHTML == "")
	{
		var xhr = createXMLHTTPObject();
		if(xhr)
		{
			e.innerHTML = "Getting content. Please wait...";
			xhr.open("GET", u, true);
			xhr.setRequestHeader('Content-Type', 'text/html');
			xhr.onreadystatechange = function()
			{
				if(xhr.readyState == 4)
				{
					if(xhr.status == 200)
					{
						result = xhr.responseText;
						e.innerHTML = result;
						initActivateLinks();
					}
				}
			}
			xhr.send(null);
		}
	}
}

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 showrightads()
{
		var ww = f_clientWidth();
		if (document.getElementById && ww > 0)
		{
			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");
		}
}

function showRollOver(oid)
{
		var robj = document.getElementById(oid);
		if(robj.style.display != "block")
			robj.style.display = "block";
}

function hideRollOver(oid)
{
		var robj = document.getElementById(oid);
		if(robj.style.display != "none")
			robj.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";
		}
	}

function init(stid, nstid)
{
	var W3CDOM = document.createElement && document.getElementById;
	if(!W3CDOM) return;
	//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>');
		}
		
	var e = document.getElementById("sbox");
	e.onclick = afaqsSearch;
	document.getElementById("buttonwrapper1").onclick = handleScrollTabs;
	document.getElementById("buttonwrapper2").onclick = handleScrollTabs;
	document.getElementById("tabsbt"+stid).className = "tabon";
	document.getElementById("tabsd"+stid).style.display = "block";
	getData("stab", stid);
	if(stid == 3 || stid == 4)
	{
		document.getElementById("buttonwrapper1").style.borderBottom = "none";
		document.getElementById("buttonwrapper2").style.borderBottom = "1px solid #929292";
	}
	abtn = stid;
	
	document.getElementById("nsBtnTabContainer").onclick = handleNsTab;
	document.getElementById("tb"+nstid).className = "atab";
	document.getElementById("tcd2"+nstid).className = "tcd2active";
	getData("nstab", nstid);
	initActivateLinks();
	showrightads();
	window.onresize = showrightads;
}

//]]>-->