window.onerror=function(){return true;}
window.onload=function(){pload=1;}
try{document.domain="walla.co.il";}
catch(e){}
var aid,url,walla_cfocus=TopOpenPopup=null,pload=0;
var dataObj,cacheObj=new Array();
function GetXmlHttpObject(){
	var xmlHttp;
	try{ xmlHttp=new XMLHttpRequest(); }
	catch(e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){	try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ return false; } } }
	return xmlHttp;
}
function getURL(u,a){
	url=u;aid=a;
	if(cacheObj[url] != null) {
	 	try{
			document.getElementById(aid).style.display="block";
	 		document.getElementById(aid).innerHTML = cacheObj[url]; 
	 	}catch(e){}
		return;
	}
	if(!dataObj) dataObj=GetXmlHttpObject();
	dataObj.open("POST",url,true);
	dataObj.onreadystatechange=function(){
		if (dataObj.readyState==4){ 
			if (dataObj.status==200){
		    	try{
					document.getElementById(aid).style.display="block"; 
					document.getElementById(aid).innerHTML = cacheObj[url] = dataObj.responseText; 
				}catch(e){}
		    }
		}
	}
	dataObj.send(null);
}
var fetchRows = function(){ getURL("http://"+arguments[0]+"/?w=/"+arguments[1]+"/"+arguments[2]+"/"+arguments[3]+"/@@/"+arguments[4],arguments[5]); }
function TopHidePopup(){
	if (TopOpenPopup!=null){
		TopOpenPopup.style.display="none";
		TopOpenPopup=null;
	}
	document.onclick=null;
}
function TopShowPopup(objname,e){
	var obj=document.getElementById(objname);
	if (obj==null)return;
	if (TopOpenPopup!=null){
		if (TopOpenPopup==obj){	TopHidePopup();return; }
		TopHidePopup();
	}
	TopOpenPopup=obj; 
	obj.style.display="block";
	if (!e) var e = window.event; 
	e.cancelBubble= true;
	if(e.stopPropagation)e.stopPropagation();
	document.onclick=TopHidePopup;
}
function containsDOM (container, containee){
  var isParent = false;
  do{
    if ((isParent = container == containee)) break;
    containee = containee.parentNode;
  } while(containee != null);
  return isParent;
}
function zoomOver(elem){
	if(pload){
		try{
			elem.style.height=elem.offsetHeight+"px"; 
			elem.style.width=elem.offsetWidth+"px";
			var imgs=elem.getElementsByTagName("img");
			for(var i=0;i<imgs.length;i++) if(imgs[i].className.indexOf("zoom")>=0) addClass(imgs[i],"zoomOver");
		}catch(e){}
	}
}
function zoomOut(elem){
	var imgs=elem.getElementsByTagName("img");
	for(var i=0;i<imgs.length;i++) if(imgs[i].className.indexOf("zoom")>=0) removeClass(imgs[i],"zoomOver"); 
}
function divHider(iid){ try{document.getElementById(iid).style.display="none";}catch(e){} }
function SetIframeHeight(iid,h,w){ try{ document.getElementById(iid).height=h; document.getElementById(iid).width=w; }catch(e){} }
function addClass(elem,className){elem.className=elem.className+" "+className;}
function removeClass(elem,className){var regx=new RegExp(className,"g");elem.className=elem.className.replace(regx,"");}
function openWindow(url,wwidth,wheight){if(!wwidth)wwidth=800; if(!wheight)wheight=""; window.open(url,null,"width="+wwidth+",height="+wheight+",status=yes,toolbar=no,menubar=no,location=no");}
function showFlash(divName,obj){ document.getElementById(divName).innerHTML=obj; }
function include_once(func_name,func_file){	if(eval("typeof window."+func_name+" != 'function'")){ try{ document.write(unescape("%3Cscript src='http://www.walla.co.il/2009/@/js/"+func_file+".js' type='text/javascript'%3E%3C/script%3E")); } catch(e){} } }
function include_once_inject(func_name,func_file,oid){ if(eval("typeof window."+func_name+" != 'function'")){ try{ var ni = document.getElementById(oid); var newdiv = document.createElement('script'); newdiv.setAttribute('src',"http://www.walla.co.il/2009/@/js/"+func_file+".js"); ni.appendChild(newdiv); } catch(e){} } }
var locS = window.document.referrer;
if((typeof(top.TOOLBAR)=="undefined" || typeof(top.TOOLBAR)=="unknown") && top.location!=location && locS.indexOf("walla.co.il")<0 && locS.indexOf("srch.co.il")<0 && locS.indexOf("zedo.com")<0 && locS.indexOf("khanwars.co.il")<0) top.location.href = document.location.href ; 

/*ad implementation */
function adt_wallpaper(ad_id){ //tapet
	var adtWF=function () { 
		if(document.getElementById('top_banner_outer')) document.getElementById('top_banner_outer').style.display="none";
		if(document.getElementById('topTick_sep')) document.getElementById('topTick_sep').style.display="none";
	};
	var adt_oldonload = window.onload; 
	window.onload = (typeof window.onload != "function") ? function(){adtWF;} : function() { adt_oldonload(); adtWF(); };
	adtShow("tapet");	
}

/* ad helpers */
function adtReturnObjects(){
	for(var i=0;i<adt_object_counter;i++) document.getElementById(adt_object_holders[i].did).innerHTML = adt_object_holders[i].content;
}
var _preInt;
var adt_object_holders= new Array();
var adt_object_counter=0;
function adtHideObjects(){
	var ttt67y= document.getElementById('playerDiv').innerHTML;
	if(ttt67y!=""){
		clearInterval(_preInt);
		adt_object_holders[adt_object_counter++] = {did:"playerDiv",content:document.getElementById("playerDiv").innerHTML};
		document.getElementById("playerDiv").innerHTML="";
	}
}
function adt_prestitial_2(aid){
	try{
		_preInt = setInterval("adtHideObjects()",10);
	}
	catch(e){}
}
function adtGetTarget(link){
	for(var key in adtAds){
		var obj = adtAds[key];
		if(unescape(obj.clickTAG) == link){ return(obj["target"]); }
	}
	return("_blank");
}
function adtEvent(adid,evname){
	var evname=evname.toLowerCase();
	var adt_eventads="http://"+window.Fusion.adServer+"/";
	var _adt_eventarr = adt_eventarr[adid];
	if(!window.adpreviewenabled){ window.adpreviewenabled="0"; }
	for(var i=0; i<_adt_eventarr.length; i++){
		var eventname=evname+":";
		if(_adt_eventarr[i].search(evname)!=-1){
			var realevent=_adt_eventarr[i].split(eventname);
			var rndm = new Number(Math.round(Math.random() * Math.pow(2,24)));
			realevent[1]=realevent[1].replace("event/","event/"+rndm);
			return(adt_eventads+realevent[1]);
			break;
		}
	}
}
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 adtShow(elem_name){
	try{
		document.getElementById(elem_name).style.display="block";
		if(adtTags[elem_name]) if(adtTags[elem_name].tg!="") document.getElementById(elem_name).innerHTML=adtTags[elem_name].tg;
	}catch(e){}
}
function adtHide(elem_name){
	try{
		document.getElementById(elem_name).style.display="none";
		if(adtTags[elem_name]) if(adtTags[elem_name].tg!="") document.getElementById(elem_name).innerHTML="";
	}catch(e){}
}
function adtCdn(adURL){
	if(adURL.indexOf(".html")>-1 && adURL.indexOf("ad_frames")>-1){
		adURL=adURL.replace("x.wcdn.co.il", "x.walla.co.il");
	}
	else{
		if(window.Fusion.parameters["cdn"]){
			adURL=adURL.replace("x.walla.co.il", "x.wcdn.co.il");
			if(window.Fusion.parameters["cdn"]=="WBE"||window.Fusion.parameters["cdn"]=="wbe"){ adURL=adURL.replace("x.wcdn.co.il", "xWBE.wcdn.co.il"); }
			if(window.Fusion.parameters["cdn"]=="WNE"||window.Fusion.parameters["cdn"]=="wne"){ adURL=adURL.replace("x.wcdn.co.il", "xWNE.wcdn.co.il"); }
		}
		else{
			adURL=adURL.replace("x.wcdn.co.il", "xWBE.wcdn.co.il");
		}
	}
	return(adURL);
}
function adtTPT(tptURL){ 
	try{ 
		document.getElementById("cnImg").src=tptURL; 
	} 
	catch(e){
		var oImg=document.createElement("img");
		oImg.setAttribute('src', tptURL);
		oImg.setAttribute('style', 'height:1px;width:1px;display:none;');
		oImg.setAttribute('id', 'cnImg'+Math.floor(Math.random()*10));
		document.body.appendChild(oImg);
	} 
}
function adtCount(aid){
	var d = new Date();
	var tptURL = "http://fus.walla.co.il/event/"+d.getTime()+Math.ceil(100*Math.random())+"/"+window.Fusion.mediaZone+"/"+aid+"/click";
	return(tptURL);
}
//ads holders
var adtAds=new Array();
var adtTags=new Array();
var adtLoader=new Array();var adtV=0;
var adt_eventarr=new Array();
//tag register
function adtTag(div,tag){ adtTags[div] = {tg:tag}; }

//fly registerer
function adtRegister(ad_id,space_name,posX,posY,bopen){
	adtAds[ad_id] = {spn:space_name,x:posX,y:posY,event_count: arguments[5],clickTAG: arguments[6],target: arguments[7]};
	try{ eval("adt_"+space_name+"(ad_id);"); }catch(e){}	
	if(bopen=="yes"){
		adtConnector("show",ad_id);
	}
}

function adtConnector(cmd,ad_id){
	switch(cmd){
		case "cpmv":	
			try{ 
				adtTPT(adt_imp); 
				//adtTPT("http://rtserver.walla.co.il/rtserver/adt_stats.php");
			}catch(e){}
			break;
		case "event":
			try{
				var my_event=ad_id.split(",");
				adtTPT(adtEvent(my_event[0],my_event[1]));//adid,event_name
			}catch(e){}
			break;
		case "linkTo":
			try{
				var my_event=ad_id.split(",");
				if(my_event[1]!=undefined){
					if(my_event[1]=="_blank"){ window.open(my_event[0],""); }
					else{ window.location.href = my_event[0]; }
				}
				else{
					var _myTarget = adtGetTarget(ad_id);
					if(_myTarget=="_blank"){ window.open(my_event[0],""); }
					else{ window.location.href = my_event[0]; }						 
				}
			}catch(e){ 
				window.location.href=ad_id; 
			}
			break;
		case "popup":
			window.open(ad_id,"");
			break;		
		case "count":
			//window.Fusion.countAdvertEvent(ad_id, 'click');
			try{
				var my_event=ad_id.split(",");
				var my_ev=adtAds[my_event[0]].event_count;
				var my_eve=my_ev.split(",");
				if(my_eve[my_event[1]-1]) adtTPT(adtCount(my_eve[my_event[1]-1]));
				else adtTPT(adtCount(my_event[0]));
			}catch(e){ adtTPT(adtCount(ad_id)); }
			break;
		case "play":
			//if(king_reg!=0) ad_id=king_reg;
			elem_name = 'expandsubholder_'+ad_id+adtAds[ad_id].spn;
			elem_name1 = 'expandLayer_'+ad_id+adtAds[ad_id].spn;
			
			//document.getElementById(elem_name1).style.position = "static";
			
			if(document.getElementById(elem_name).style.display=="none"){
				adtShow(elem_name);
				adtHide(elem_name1);
			}
			else{
				adtShow(elem_name1);
				adtHide(elem_name);
			}
			break;
		case "show":
			elem_name = 'expandsubholder_'+ad_id+adtAds[ad_id].spn;
			elem_name1 = 'expandLayer_'+ad_id+adtAds[ad_id].spn;
			elem_id=document.getElementById(elem_name);
			if(elem_id){ elem_pos= findPos(elem_id);}			
			//document.getElementById(elem_name1).style.top=parseInt(adtAds[ad_id].y)+parseInt(elem_pos[1])+"px";
			document.getElementById(elem_name1).style.top=parseInt(adtAds[ad_id].y)+"px";
			//document.getElementById(elem_name1).style.left=parseInt(adtAds[ad_id].x)+parseInt(elem_pos[0]) +"px";
			document.getElementById(elem_name1).style.left=parseInt(adtAds[ad_id].x) +"px";
			document.getElementById(elem_name1).style.zIndex="999999";
			adtShow(elem_name1);
			window.Fusion.countAdvertEvent(ad_id, 'click');
			break;
		case "hide":
			adtHide('expandLayer_'+ad_id+adtAds[ad_id].spn);
			break;
	}
}

function reloadAds(did,sp_name){
	window.Fusion.loadAds(true, function () {
		window.Fusion.updateSpace(did, sp_name);
	});
}

window.size = function() {
var w = 0;
var h = 0;
//IE
if(!window.innerWidth) {
	//strict mode
	if(!(document.documentElement.clientWidth == 0)) {
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	} else {
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
}
//w3c
else {
	w = window.innerWidth;
	h = window.innerHeight;
}
return {width:w,height:h};
}

// October Addons - 05.10.2011 

// Top News Ticker

var topTick=[];
topTick.topTickId="topTickHolder";
function removeTextElems2(elem){
	try{for(var i=elem.childNodes.length;i>0;i--){if(elem.childNodes[i-1].nodeType==3) elem.removeChild(elem.childNodes[i-1]);}}
	catch(e){}
}
topTick.init=function(){
	var i;
	topTick.elem=document.getElementById(topTick.topTickId);
	if(topTick.elem!=null){
		for(i=topTick.elem.childNodes.length;i>0;i--){if(topTick.elem.childNodes[i-1].nodeType==3) topTick.elem.removeChild(topTick.elem.childNodes[i-1]);}
		topTick.elem.style.top=0;
		topTick.scrollHeight=topTick.elem.childNodes[0].clientHeight;
		topTick.resume();
		topTick.interval=setInterval("topTick.topTickScroll()",50);
	}
}
topTick.topTickScroll=function(){
	if(!topTick.isPaused)topTick.elem.style.top=parseInt(topTick.elem.style.top)-1;
	if(Math.abs(parseInt(topTick.elem.style.top))==topTick.scrollHeight){
		topTick.elem.style.top=0;
		topTick.elem.appendChild(topTick.elem.firstChild);
		clearInterval(topTick.interval);
		try{setTimeout("topTick.interval=setInterval('topTick.topTickScroll()',50)",3000);}catch(e){}
	}
}
topTick.pause=function(){try{topTick.isPaused=1;}catch(e){}}
topTick.resume=function(){try{topTick.isPaused=0;}catch(e){}}
try{setTimeout("topTick.init()",3000);}catch(e){}

// comp.top5

var myD = document.location.host;
var now=new Date();
var d = new Date(now.getFullYear()+1,now.getMonth(),now.getDate());
var top5ArrImgPos = new Array('15%','50%','80%');
function tabPressedN(num, domain){
	obj = document.getElementById('top5Tab_' + num);
	parentObj = obj.parentNode;
	for(x=0; x<parentObj.childNodes.length; x++){
		if(parentObj.childNodes[x].tagName == "A"){
			_thisKey = parentObj.childNodes[x].id.split('_')[1];
			if(parentObj.childNodes[x].id != obj.id) {
				if(document.getElementById('top5Content_' + parseInt(_thisKey))){
					removeClass(parentObj.childNodes[x], 'hd_tab_curr');
					document.getElementById('top5Content_' + parseInt(_thisKey)).style.display = "none";
				};
			} else {
				if(document.getElementById('top5Content_' + parseInt(_thisKey))){
					num = _thisKey;
					addClass(obj, 'hd_tab_curr');
					document.getElementById('top5Content_' + parseInt(_thisKey)).style.display = "block";
				};
			}
		};
	};

	if(domain != undefined) {myD = domain};
	document.getElementById('arrImgTop5').style.right = top5ArrImgPos[num];
	var curCookie = "top5SelectedTab=" + num +"; expires=" + d.toGMTString() + "; domain=" + myD;
	document.cookie = curCookie;
};

// get value by cookie name
function getCookie(name){
	var i, key, reg=/^\s+|\s+$/g, arr=document.cookie.split(';');
	for (i=0;i<arr.length;i++){
		key=arr[i].substr(0,arr[i].indexOf('='));
		key=key.replace(reg,'');
		if (key==name){
			return unescape(arr[i].substr(arr[i].indexOf('=')+1));
	    }
	}
	return null;
}

function shkufitShown(minutes){
	var un = getCookie('nick') || '';
	minutes = parseInt(minutes) || 0;
	var dailyCount = (parseInt(getCookie('shkufitDaily')) || 0) + 1;
	var shkufitWaitExpire = new Date();
	shkufitWaitExpire.setTime(shkufitWaitExpire.getTime()+60*1000*minutes);
	var shkufitDailyExpire = new Date(shkufitWaitExpire.getFullYear(), shkufitWaitExpire.getMonth(), shkufitWaitExpire.getDate(), 23, 59, 59, 999);
	document.cookie = 'shkufitWait=1; expires=' + shkufitWaitExpire.toGMTString() + "; path=/; domain=walla.co.il" ;
	document.cookie = 'shkufitDaily='+dailyCount+'; expires=' + shkufitDailyExpire.toGMTString() + "; path=/; domain=walla.co.il" ;
	document.getElementById('img1').src='http://events.walla.co.il/events.asp?version=9&location='+wallaApp.location+'&event_type=1&DIvName=SliderImp&page_location=6&un='+un;
}

function shkufitDone(age, gender){
	var un = getCookie('nick') || '';
	var shkufitDataExpire = new Date();
	shkufitDataExpire.setTime(shkufitDataExpire.getTime()+1000*60*60*24*90);
	age = (age==undefined || age==null ? -1 : age);
	gender = (gender==undefined || gender==null ? -1 : gender);
	document.getElementById('img1').src='http://a.walla.co.il/slide.asp?location='+wallaApp.location+'&age='+age+'&gender='+gender+'&un='+un;
	document.cookie = 'shkufitData=' +age+ ',' + gender + '; expires=' + shkufitDataExpire.toGMTString() + '; path=/; domain=walla.co.il';
}

function shkufitClose(){
	var un = getCookie('nick') || '';
	document.getElementById('img1').src='http://a.walla.co.il/slide.asp?location='+wallaApp.location+'&close=1&un='+un;
}

function shkufitTimeout() {
	var un = getCookie('nick') || '';
	document.getElementById('img1').src='http://a.walla.co.il/slide.asp?location='+wallaApp.location+'&close=2&un='+un;
}

function domReady(fn){
    if(!document.readyState && document.addEventListener) {
        document.addEventListener( "domContentLoaded", fn);
    }
    else {
        setTimeout(/in/.test(document.readyState) ? function(){domReady(fn)} : fn, 50)
    }
}

/*
function top5GetCookie(){
	var selectedKey;
	var nameEQ = 'top5SelectedTab' + "=";
	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) selectedKey = c.substring(nameEQ.length,c.length);
	}
	if(isNaN(selectedKey)){
		selectedKey = ${comp.defaultTab};
	};
	return selectedKey;
};
*/
