var bodyWidth = 0, bodyHeight = 0;var FONT_NORM='12';var CUR_FONT=FONT_NORM;var PARENT_DIR="";
function initWinSize(){
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		bodyWidth = window.innerWidth;
		bodyHeight = window.innerHeight;
		scrollLeft= window.pageXOffset;
		scrollTop= window.pageYOffset;
		bType=0;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		bodyWidth = document.documentElement.clientWidth;
		bodyHeight = document.documentElement.clientHeight;
		scrollLeft= document.documentElement.scrollLeft;
		scrollTop= document.documentElement.scrollTop;
		bType=1;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		bodyWidth = document.body.clientWidth;
		bodyHeight = document.body.clientHeight;
		scrollLeft= document.body.scrollLeft;
		scrollTop= document.body.scrollTop;
		bType=1;
	}
}
initWinSize();
var myrules = {
	'.menubt' : function(element){
		element.onmouseover = function(){element.className="menubt_on";};
		element.onmouseout = function(){element.className="menubt";}},
	'.picBox' : function(element){
		element.onmouseover = function(){
			var elem;
			if (element.childNodes[1]) elem=element.childNodes[1];
			else if (element.childNodes[0]) elem=element.childNodes[0];
			if (elem) {elem.className="on";}
		};
		element.onmouseout = function(){
			var elem;
			if (element.childNodes[1]) elem=element.childNodes[1];
			else if (element.childNodes[0]) elem=element.childNodes[0];
			if (elem) {elem.className="off";}
		};
		element.onclick = function(){
			var elem;
			if (element.childNodes[0]) {
				elem=element.childNodes[0];
				if (elem.childNodes[0]) window.location=elem.childNodes[0].href;
			}
		};}
};
function getHeadlines(){
	x_getHTMLHeadlines(EDITION_NO, dispHeadlines);
}
function dispHeadlines(res){
	for(var i in res) {
		HEADLINES[i]=new Array();
		HEADLINES[i]['HEADLINE_ID']=res[i].HEADLINE_ID;
		HEADLINES[i]['CONTENT']=res[i].CONTENT.replace(/###/, " - ");
		HEADLINES[i]['SECTION_NAME']=res[i].SECTION_NAME;
	}
	document.getElementById('ticker').style.display="inline";
	setHeadline();
}
function nextHeadline(){
	window.clearTimeout(hdlTimer);
	if (++indexHdl == HEADLINES.length) indexHdl=0;
	setHeadline();
}
function prevHeadline(){
	window.clearTimeout(hdlTimer);
	if (--indexHdl == -1) indexHdl=HEADLINES.length-1;
	setHeadline();
}
function setHeadline(){
	document.getElementById('hdlSection').innerHTML=HEADLINES[indexHdl]['SECTION_NAME'];
	document.getElementById('hdlLink').innerHTML="<a href='"+PARENT_DIR+"hd.php?st="+HEADLINES[indexHdl]['HEADLINE_ID']+"'>"+HEADLINES[indexHdl]['CONTENT']+"</a>";
	hdlTimer=setTimeout("nextHeadline();", hdltvar);
}
function md(){
	if(document.getElementById('mr')){
		if(LANGUAGE=="AR")
			document.getElementById('mr').style.right=(bodyWidth-(document.getElementById('more-menu').offsetLeft)-document.getElementById('more-menu').offsetWidth)+"px";
		else
			document.getElementById('mr').style.left=((document.getElementById('more-menu').offsetLeft))+"px";
		document.getElementById('mr').style.display="block";
	}
}
function mc() {
	if (document.getElementById('mr'))document.getElementById('mr').style.display="none";
}
function goSec(secId){
	if (document.getElementById('sec'+secId)) {
		tmp=parseInt(document.getElementById('sec'+secId).parentNode.parentNode.parentNode.offsetTop);
		tmp += parseInt(document.getElementById('sec'+secId).offsetTop);
		tmp += 170;
		window.scroll(0,tmp);
	}
}
function st(){
	window.scroll(0,0);
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
function osd(){
	initWinSize();
	try{
		var divs;
		if (document.getElementsByTagName)
			divs = document.body.getElementsByTagName("DIV");
		else divs = document.all.tags["div"];

		for (var i=0;i<divs.length;i++) {
			if (divs[i].id.length>20) {
				if (divs[i].id.substring(0,7)=="http://") {
					var pos=findPos(divs[i]);
					if((pos[1]<=bodyHeight+scrollTop) && pos[1]>scrollTop-180) {
						divs[i].innerHTML = "<img src='" + divs[i].id + "' />";
						divs[i].id="";
					}
				}
			}
		}
	}catch(E){}
}
function checkSrch(){
	var srchField = document.getElementById("srch");
	if (srchField.value!="") {
		window.open("http://www.google.com/search?q="+srchField.value+"+site:"+URL_BASE+"/html/story.php");
	}
	else {
		srchField.value = "أدخل معطيات البحث";
		setTimeout("document.getElementById('srch').value='';", 1000);
	}
	return false;
}
function winLoad(){getHeadlines();}
window.onload=winLoad;
window.onscroll=osd;