var browser = checkBrowser();
var win = null;
var downloadWin = null;
var addFavStrip = null;
var wMusicLink = "http://music.walla.co.il";
var r = null;
var oldonload = window.onload;
document.domain = "walla.co.il";

window.onload = (typeof window.onload != "function") ? newOnload : function() { oldonload(); newOnload(); };
function newOnload(){
	var oldonload1 = window.onscroll;
	window.onscroll = (typeof window.onscroll != "function") ? hideStrip : function() { oldonload1(); hideStrip(); };
}


if (document.addEventListener) {  // all browsers except IE before version 9
	document.addEventListener("mousedown", function (e) {hideGenreMenu(e);}, false);
	window.addEventListener("resize", function (e) {if(typeof(rePosMenu) == "function") {rePosMenu();}}, false);
} else {
	if (document.attachEvent) {   // IE before version 9
	    document.attachEvent("onmousedown", function (e) {hideGenreMenu(e);});
	    window.attachEvent("onresize", function (e) {if(typeof(rePosMenu) == "function") {rePosMenu();}});
	}
}

function hideGenreMenu(e) {
	if (document.getElementById("toolbarGenre") != null) {
		if(typeof(document.getElementById("toolbarGenre")) == "object") {
			var fobj = nn6 ? e.target : event.srcElement;
			var clsArr = fobj.className.split(" ");
			for(i=0;i<clsArr.length;i++) {
				if (clsArr[i].indexOf("toolbarGenreContainer") == -1 && clsArr[i].indexOf("toolbarGenre") == -1 && clsArr[i].indexOf("toolbarGenreItem") == -1 && clsArr[i].indexOf("toolbarGenreItemDevider") == -1) {
					if(document.getElementById("toolbarGenre").style.display=="block") {
						document.getElementById("toolbarGenre").style.display="none";
					}
				}
			}		
		}
	}
}

function include_once_music(func_name,func_file){	
	//alert(func_name);
	if(eval("typeof window."+func_name+" != 'function'")){ try{ document.write(unescape("%3Cscript src='"+wMusicLink+"/"+func_file+".js' type='text/javascript'%3E%3C/script%3E")); } catch(e){} } 
}
function replaceOrAddOrRemoveMyParam(href,paramName,ParamValue,toRemove)
{
   // ----- this function is replacing or deleting paramter from url string  in radio only becouse of the "&" char -----
		if(href.indexOf("&"+paramName+"=") > -1){
			var tempPostfix=href.substring(href.indexOf("&"+paramName+"=")+1,href.length);
				if(tempPostfix.indexOf("&") > -1){
					tempPostfix=tempPostfix.substring(tempPostfix.indexOf("&"),href.length);
				}else
				tempPostfix="";
			href=href.substring(0,href.indexOf("&"+paramName+"="));
			href += tempPostfix;
		}
	if(toRemove)
		return(href);
	else				
		return(href+"&"+paramName+"="+ParamValue);
}
function Evt(elemEvt,evtCn,evtVal,evtPage,DivName,eventType){ try{ document.getElementById("cnImg").src="http://events.walla.co.il/events.asp?version=9&c=radio.homepage.&Provider=&location=walla.radio.&event_type="+eventType+"&Keys="+evtVal+";"+evtCn+"&DIvName="+DivName+"&page_location="+evtPage+"&un=&geo=WNE&url="+elemEvt.href; }catch(e){} }

function radioPagingOnclickJsFunc(pageNum)
{
	// ----- this function is used for pagging in radio ONLY -----
	var toRemove = false;
	if(pageNum == 1)//if page is 1 remove the pageing param
	toRemove = true;
	location.href=replaceOrAddOrRemoveMyParam(location.href,"page",pageNum,toRemove);
}

function ajaxIt(l,func,funcParam){
	try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');}catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}
	if(r){
		r.onreadystatechange = function() {
			if (r.readyState == 4 && r.status == 200){
				if (typeof(funcParam) == "undefined" || funcParam == "") { 
					if(typeof(func) != "undefined" && func != "") 
						eval(func+"(r.responseText);");
				} else {
					eval(funcParam);
				}
			}
		}
		r.open('GET', l, true);
		r.send(null);
	}
}
function findPosX(obj) {
        var curleft = 0;
        if(obj.offsetParent)
               while(1){
                       curleft += obj.offsetLeft;
                       if(!obj.offsetParent)break;
                       obj = obj.offsetParent;
               }
        else if(obj.x)
        curleft += obj.x;
        return curleft;
}

function findPosY(obj) {
        var curtop = 0;
        if(obj.offsetParent)
               while(1){
                       curtop += obj.offsetTop;
                       if(!obj.offsetParent)break;
                       obj = obj.offsetParent;
               }
        else if(obj.y)
        curtop += obj.y;
        return curtop;
}
function getObjCords(objId)
{
 var obj = document.getElementById(objId);
 if(obj)
 	return({x:findPosX(obj),y:findPosY(obj)});
 else
 	return(false);
}

function getWindowSize () {
	var myWidth = 0, myHeight = 0;
	   if(typeof(window.innerWidth) == "number") {
					   //Non-IE
					   myWidth = window.innerWidth;
					   myHeight = window.innerHeight;
	   } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
					   //IE 6+ in "standards compliant mode"
					   myWidth = document.documentElement.clientWidth;
					   myHeight = document.documentElement.clientHeight;
	   } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
					   //IE 4 compatible
					   myWidth = document.body.clientWidth;
					   myHeight = document.body.clientHeight;
	   }

	return{x:myWidth,y:myHeight};	
}

function getWindowCenterCords(objWidth,objHeight)
{
	
	var myWidth = 0, myHeight = 0;
   if(typeof(window.innerWidth) == "number") {
	   //Non-IE
	   myWidth = window.innerWidth;
	   myHeight = window.innerHeight;
   } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	   //IE 6+ in "standards compliant mode"
	   myWidth = document.documentElement.clientWidth;
	   myHeight = document.documentElement.clientHeight;
   } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	   //IE 4 compatible
	   myWidth = document.body.clientWidth;
	   myHeight = document.body.clientHeight;
   }
  	var _x = 0;	var _y = 0;
	var offsetX = 0;var offsetY = 0;
	var _windowBottom =0 , _windowLeft =0 ;
	//IE
	if(!window.pageYOffset){
		//strict mode
		if(!(document.documentElement.scrollTop == 0)){
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}//quirks mode
		else{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
			
		}
	}//w3c
	else{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}
	_x = ((myWidth-objWidth)/2)+offsetX;
	_y = ((myHeight-objHeight)/2)+offsetY;

	_windowLeft = ((myWidth-objWidth)+offsetX)/2;
	_windowBottom = (myHeight-objHeight )+offsetY;
	return{x:_x,y:_y,windowBottom:_windowBottom,windowLeft:_windowLeft};	
}

function slowlyFadeOut(divId,elmOpc,sec)
{
		var element = document.getElementById(divId);
		if(!elmOpc || parseInt(elmOpc) == 100){
			if(!sec) sec=1000;
			elmOpc = 100;
			element.style.opacity = 1;
  			element.style.filter = 'alpha(opacity = ' + 100 + ')';
		}
		if( parseInt(elmOpc) > 0 ){
			element.style.opacity = elmOpc/100;
  			element.style.filter = 'alpha(opacity = ' + elmOpc + ')';
			setTimeout("slowlyFadeOut('"+divId+"','"+(parseInt(elmOpc) - 5)+"',"+(sec/5)+")",sec);
		}else{
				element.style.display="none";
				element.style.opacity = 1;
  				element.style.filter = 'alpha(opacity = ' + 100 + ')';
		}
}
function slowlyFadeIn(divId,elmOpc,sec)
{
		var element = document.getElementById(divId);
		if(!elmOpc || parseInt(elmOpc) == 0){
			if(!sec) sec=1000;
			elmOpc = 0;
			element.style.opacity = 0;
  			element.style.filter = 'alpha(opacity = ' + 0 + ')';
		}
		if( parseInt(elmOpc) < 100 ){
			element.style.opacity = elmOpc/100;
  			element.style.filter = 'alpha(opacity = ' + elmOpc + ')';
			setTimeout("slowlyFadeIn('"+divId+"','"+(parseInt(elmOpc) + 5)+"',"+(sec/5)+")",sec);
		}else{
				element.style.display="block";
				element.style.opacity = 1;
  				element.style.filter = 'alpha(opacity = ' + 100 + ')';
		}
}
function alertAbs(html,timeToFadeOut,isFadeIn,cssClass,objIdToAttchToBox)
{
			var theAlertDiv = document.createElement("div");
	        theAlertDiv.style.position = "absolute";
	        theAlertDiv.style.zIndex = "10000";
			theAlertDiv.id="theAlertAbsDiv"+(Math.random()*1000)+"_"+(Math.random()*1000)+"_"+(Math.random()*1000);
			document.body.appendChild(theAlertDiv);
			if(!timeToFadeOut || parseInt(timeToFadeOut) <= 0 ){
				var theAlertDivX = document.createElement("div");
				theAlertDivX.innerHTML="X";
				theAlertDivX.style.textAlign="right";
				theAlertDiv.appendChild(theAlertDivX);
				theAlertDivX.setAttribute("onclick","document.getElementById('"+theAlertDiv.id+"').style.display='none'"); 
			}
			theAlertDiv.innerHTML+=html;
			if(cssClass)
				theAlertDiv.className=cssClass;
			else 
				theAlertDiv.className="alertAbs";
			
			if(isFadeIn){
				theAlertDiv.style.opacity = 0;
	 			theAlertDiv.style.filter = 'alpha(opacity = ' + 0 + ')';
			}
		if(objIdToAttchToBox)
			var centerCoords = getObjCords(objIdToAttchToBox);	
		else
			var centerCoords = getWindowCenterCords(theAlertDiv.clientWidth,theAlertDiv.clientHeight);
		
		theAlertDiv.style.top = centerCoords.y + "px";
		theAlertDiv.style.left = centerCoords.x + "px" ;
		
		if(isFadeIn)slowlyFadeIn(theAlertDiv.id);
		if(timeToFadeOut && parseInt(timeToFadeOut) > 0 )setTimeout("slowlyFadeOut('"+theAlertDiv.id+"')",parseInt(timeToFadeOut));
}	
function alertAbsBulidDiv(divId,timeToFadeOut,isFadeIn,cssClass,divX,objIdToAttchToBox,showAtBottom,theCenterDivIdForMeasure)
{
			var theAlertDiv = document.getElementById(divId);
	        theAlertDiv.style.position = "absolute";
	        theAlertDiv.style.zIndex = "10000";
			if(!timeToFadeOut || parseInt(timeToFadeOut) <= 0 ){
				var theAlertDivX = document.getElementById(divX);
				//theAlertDivX.setAttribute("onclick","alert(1); document.getElementById('"+theAlertDiv.id+"').style.display='none';"); 
				eval("theAlertDivX.onclick = function(){document.getElementById('"+theAlertDiv.id+"').style.display='none';};");
			}
			
			if(cssClass)
				theAlertDiv.className=cssClass;
			else 
				theAlertDiv.className="alertAbs";
			
			if(isFadeIn){
				theAlertDiv.style.opacity = 0;
	 			theAlertDiv.style.filter = 'alpha(opacity = ' + 0 + ')';
			}
			theDivWidth =  (theAlertDiv.clientWidth)?theAlertDiv.clientWidth: theAlertDiv.style.width ;
			theDivHeight =  (theAlertDiv.clientHeight)?theAlertDiv.clientHeight: theAlertDiv.style.height ;
		var centerCoords;	
		if(objIdToAttchToBox)
		{
			
			 centerCoords = getObjCords(objIdToAttchToBox);	
		}
		else
		{if(showAtBottom)
			{
				if(theCenterDivIdForMeasure != "")
				{
				var elemnt ;
				if(document.getElementById(theCenterDivIdForMeasure))
					elemnt = document.getElementById(theCenterDivIdForMeasure);
				else
					elemnt = document.body;
				
				centerCoords = getWindowCenterCords(elemnt.clientWidth,parseInt(theDivHeight) );
				centerCoords.y = centerCoords.windowBottom ;
				centerCoords.x = centerCoords.x;
				}
			}
			else
			{
			 	centerCoords = getWindowCenterCords(parseInt(theDivWidth),parseInt(theDivHeight));
			}
		}
		theAlertDiv.style.top = centerCoords.y + "px";
		theAlertDiv.style.left = centerCoords.x + "px" ;
		if(theCenterDivIdForMeasure == "" || !document.getElementById(theCenterDivIdForMeasure))
		{
			theAlertDiv.style.left = ((parseInt(document.body.clientWidth)/2)-(parseInt(theDivWidth)/2))+"px";
		}
		
		
		if(isFadeIn)
			slowlyFadeIn(theAlertDiv.id);
		else	
			theAlertDiv.style.display="block";
		if(timeToFadeOut && parseInt(timeToFadeOut) > 0 )setTimeout("slowlyFadeOut('"+theAlertDiv.id+"')",parseInt(timeToFadeOut));
}	
//BEGIN autoComplete class
	function addLoadEvent(func) { //function to add load events in page that will excute after page was load
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
	    window.onload = func; 
	  } else { 
	    window.onload = function() { 
	      if (oldonload) { 
	        oldonload(); 
	      } 
	      func(); 
	    } 
	  } 
	} 
	function slowlyOpen(divId,orginalHeight,sec)
	{
		var div = document.getElementById(divId);
		div.style.display="block";
		if(!orginalHeight || orginalHeight <= 0){
			orginalHeight=div.offsetHeight;
			if(!sec) sec=10;
			div.style.height=0 + "px";
		}
		if((parseInt(div.style.height)+30) < parseInt(orginalHeight)){
			div.style.height = (parseInt(div.style.height) + 30) + "px"
			setTimeout("slowlyOpen('"+divId+"',"+orginalHeight+","+(sec/5)+")",sec);
		}else{
			div.style.height = parseInt(orginalHeight) + "px";
		}
	}
	function fireEvent(obj,evt){
		var fireOnThis = obj;
		if( document.createEvent ) {
		  var evObj = document.createEvent('MouseEvents');
		  evObj.initEvent( evt, true, false );
		  fireOnThis.dispatchEvent(evObj);
		} else if( document.createEventObject ) {
		  fireOnThis.fireEvent('on'+evt);
		}
	}
	function slowlyClose(divId,orginalHeight,sec)
	{
		var div = document.getElementById(divId);
		
		if(!orginalHeight || orginalHeight <= 0){
			orginalHeight=div.offsetHeight;
			if(!sec) sec=10;
			div.style.height=orginalHeight + "px";
		}
		if((parseInt(div.style.height) - 30) > 0){
			div.style.height = (parseInt(div.style.height) - 30) + "px"
			setTimeout("slowlyClose('"+divId+"',"+orginalHeight+","+(sec/5)+")",sec);
		}else{
			div.style.display="none";
			div.style.height = "";
		}
	}
	
    function autoComplete(theTextBoxId, href, suggestDivClassName, suggestDivSelectedClassName,permitOnclick,suggestDivDir,excuteOnclick,childsClassNameForKeys,jsToExcuteEveryKeyPress,textBoxClassForKeyPress) {
        //set global name with random
        this.genrateName = "autoCompleteGlobalObj" + Math.floor(Math.random() * 10000) + "_" + Math.floor(Math.random() * 10000) + "_" + Math.floor(Math.random() * 10000);
        var currentActiveAutoCompleteObj;//current aout complete object handle 
        eval(this.genrateName + " = this;")
        this.urlArr = new Array();//keep ajax calls in js array so we wont need to re call the server again
        this.href = href;
		this.childsClassNameForKeys = childsClassNameForKeys;
        this.selectedNode = null;
        this.typedLetters = ""; 
        this.textBox = document.getElementById(theTextBoxId);
        this.textBox.setAttribute("autocomplete","off");
		this.textBoxDefaultTxt = this.textBox.value;
		this.textBoxDefaultClass=this.textBox.className;
		this.textBoxClassForKeyPress = textBoxClassForKeyPress;
        this.searchNode = document.createElement("div");
        this.searchNode.style.position = "relative";
        this.searchNode.style.display = "inline";
        this.searchNode.style.zoom = "1";
		if(this.textBox.clientWidth > 0)
			this.searchNode.style.width = this.textBox.clientWidth;
		if(this.textBox.clientHeight > 0)
			this.searchNode.style.height = this.textBox.clientHeight + 5;

	//alert(this.textBox.clientWidth + " - - - - " + this.textBox.offsetWidth);
        this.suggestDiv = document.createElement("div");
        this.suggestDiv.className = suggestDivClassName;
        //this.suggestDiv.style.width = this.textBox.clientWidth;
        this.suggestDiv.style.display = "none";
        this.suggestDiv.style.position = "absolute";

		this.suggestDiv.style.top = this.textBox.clientHeight+7;
		if(!suggestDivDir || suggestDivDir == "rtl")
			this.suggestDiv.style.right = "0";
		else
		this.suggestDiv.style.left = "0";
        this.suggestDiv.style.zIndex = "10000";
		this.suggestDiv.id=this.genrateName+"suggestDiv";
        this.textBox.parentNode.replaceChild(this.searchNode, this.textBox);
        this.searchNode.appendChild(this.textBox);
		this.searchNode.appendChild(this.suggestDiv);
		this.suggestDiv.onclick=function(e){
					currentActiveAutoCompleteObj.showDiv(e);
					};
        this.nextObject = function() {
            var n;
           if (!this.selectedNode){
			  if(this.childsClassNameForKeys && this.childsClassNameForKeys != ""){
					n =  this.selectedNode = this.arrByClassForKeys[0];
					this.arrByClassForKeysCurrIndex = 0;
				}else{
					n =  this.selectedNode = this.suggestDiv.firstChild;
				}
		      }else{	
			 	if(this.childsClassNameForKeys && this.childsClassNameForKeys != ""){
					this.arrByClassForKeysCurrIndex += 1;
					n = this.arrByClassForKeys[this.arrByClassForKeysCurrIndex];
				}else{
					n = this.selectedNode.nextSibling;
					 while (n && n.nodeType != 1) n = n.nextSibling
				}
			 }
	        if (!n){ this.selectedNode = null; }// this.selectedNode = this.suggestDiv.firstChild;
            else this.selectedNode = n;
            this.setSelectedNode(this.selectedNode);
        }
        this.previousObject = function() {
            var p;
		    if (!this.selectedNode){
				if(this.childsClassNameForKeys && this.childsClassNameForKeys != ""){
					p =  this.selectedNode = this.arrByClassForKeys[this.arrByClassForKeys.length - 1];
					this.arrByClassForKeysCurrIndex = this.arrByClassForKeys.length - 1;
				}else{
					p =  this.selectedNode = this.suggestDiv.lastChild;
				}
		    }else{	
			 	if(this.childsClassNameForKeys && this.childsClassNameForKeys != ""){
					this.arrByClassForKeysCurrIndex -= 1;
					p = this.arrByClassForKeys[this.arrByClassForKeysCurrIndex];
					
				}else{
					p = this.selectedNode.previousSibling;
					while (p && p.nodeType != 1) p = p.previousSibling
				}
			 }
            if (!p) this.selectedNode = null; //this.selectedNode = this.suggestDiv.lastChild;
            else this.selectedNode = p;
            this.setSelectedNode(this.selectedNode);
        }
        this.setSelectedNode = function(selectedObj) {
		var Arr ;
			if(jsToExcuteEveryKeyPress && jsToExcuteEveryKeyPress != "")
			eval(jsToExcuteEveryKeyPress);
			if(this.childsClassNameForKeys && this.childsClassNameForKeys != "")
            	 Arr = this.arrByClassForKeys;
			else
				Arr = this.suggestDiv.childNodes;	 
                for (var i = 0; i < Arr.length; i++) {
                    if (selectedObj != Arr[i]) {
                        if (Arr[i].className) Arr[i].className = Arr[i].className.replace(" " + suggestDivSelectedClassName, "");
                    }else {
                        Arr[i].className += " " + suggestDivSelectedClassName;
						
                        this.selectedNode = Arr[i];
						
								if(this.childsClassNameForKeys && this.childsClassNameForKeys != "")
									this.textBox.value = Arr[i].title;
								else
									this.textBox.value = Arr[i].innerHTML;
				    }
                }
		
		//  if(!permitOnclick)
                	if (!selectedObj) this.textBox.value = this.typedLetters;
        }
		
        this.autoCompleteKeyUp = function(e) {
            var evt = e || window.event;
            var target = evt.target || evt.srcElement;
			
            if (currentActiveAutoCompleteObj.textBox.value.length > 2) {
                if (evt.keyCode == 40 || evt.keyCode == 38)//arrow up or down
                    currentActiveAutoCompleteObj.moveSelected(e);
                else if (evt.keyCode == 13 || evt.keyCode == 27) {
                    currentActiveAutoCompleteObj.hideDiv();
					if(excuteOnclick && currentActiveAutoCompleteObj.selectedNode.onclick)
						fireEvent(currentActiveAutoCompleteObj.selectedNode,"click");
					
                }else {
                    currentActiveAutoCompleteObj.typedLetters = this.value;
                    currentActiveAutoCompleteObj.ajaxIt(currentActiveAutoCompleteObj.href + '&searchWord=' + encodeURI(this.value), currentActiveAutoCompleteObj.suggestDiv);
                }
            }
            else {
                currentActiveAutoCompleteObj.hideDiv();
                currentActiveAutoCompleteObj.suggestDiv.innerHTML = "";
            }
            return true;
        }
        this.textBox.onkeyup = this.autoCompleteKeyUp;
        eval("this.textBox.onclick = function() { currentActiveAutoCompleteObj = " + this.genrateName + ";if(this.value == '" + this.textBoxDefaultTxt + "'){ this.value='';  if(currentActiveAutoCompleteObj.textBoxClassForKeyPress && currentActiveAutoCompleteObj.textBoxClassForKeyPress != '') this.className = currentActiveAutoCompleteObj.textBoxClassForKeyPress; }}");
		eval("this.textBox.onblur = function() { if(this.value == ''){ this.value='" + this.textBoxDefaultTxt + "';if(currentActiveAutoCompleteObj.textBoxDefaultClass && currentActiveAutoCompleteObj.textBoxDefaultClass != '') this.className = currentActiveAutoCompleteObj.textBoxDefaultClass; } }");
        this.ajaxIt = function(url, div) {
            currentActiveAutoCompleteObj.selectedNode = null;
			currentActiveAutoCompleteObj.suggestDiv.style.height="";
             if (currentActiveAutoCompleteObj.urlArr && currentActiveAutoCompleteObj.urlArr[url]) {//if is response is in our array dont ajax it
                {
					currentActiveAutoCompleteObj.handelAjaxRet(currentActiveAutoCompleteObj.urlArr[url], div);
					evalObjJavascript(currentActiveAutoCompleteObj.urlArr[url],"script");
				}
            }else {
		if (r) {
			r.abort();
			r = null;
		}
			
                try { r = new XMLHttpRequest(); } catch (e) { try { r = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { r = new ActiveXObject('Microsoft.XMLHTTP'); } }
                if (r) {
                    r.onreadystatechange = function() {
                        if (r.readyState == 4 && r.status == 200) {
                            currentActiveAutoCompleteObj.urlArr[url] = r.responseText;
                            currentActiveAutoCompleteObj.handelAjaxRet(r.responseText, div);
							
							if(currentActiveAutoCompleteObj.childsClassNameForKeys && currentActiveAutoCompleteObj.childsClassNameForKeys != "")
								currentActiveAutoCompleteObj.arrByClassForKeys = currentActiveAutoCompleteObj.getChildrenArray(currentActiveAutoCompleteObj.childsClassNameForKeys,currentActiveAutoCompleteObj.suggestDiv);
							
							evalObjJavascript(r.responseText,"script");
                        }
                    }
                    r.open('GET', url, true);
                    r.send(null);
                }
            }
        }
        this.handelAjaxRet = function(responseText, div) {
        	if(responseText.length < 10 ){
				currentActiveAutoCompleteObj.hideDiv();
				return;
			}
		  div.innerHTML = responseText;
          if(!permitOnclick)
		    for (var i = 0; i < div.childNodes.length; i++) {
               
			   if(!excuteOnclick)
			    div.childNodes[i].onclick = function(evt) { currentActiveAutoCompleteObj.hideDiv(); currentActiveAutoCompleteObj.setSelectedNode(this); return false; }
                //div.childNodes[i].href = "javascript:void(0)";
            }
			currentActiveAutoCompleteObj.showDiv();
        }
        this.moveSelected = function(e) {
			currentActiveAutoCompleteObj.showDiv();
            
				var charCode;
	            var evt = e || window.event;
	            charCode = evt.keyCode;
	            if (charCode == 40)//arrow up or down
	                currentActiveAutoCompleteObj.nextObject();
	            else if (charCode == 38)
	                    currentActiveAutoCompleteObj.previousObject();
                
            return false;
        }
        this.suggestDiv.onkeydown = this.moveSelected;
        this.hideDiv = function(e) {
            currentActiveAutoCompleteObj.suggestDiv.style.display = "none";
			//if(currentActiveAutoCompleteObj.suggestDiv.style.display == "block")
			//slowlyClose(currentActiveAutoCompleteObj.suggestDiv.id);
            document.onclick = null;
          if(!permitOnclick)
		    return false;
        }
        this.showDiv = function(e,height) {
        	if(currentActiveAutoCompleteObj.suggestDiv.style.display == "none")
			//slowlyOpen(currentActiveAutoCompleteObj.suggestDiv.id);
				currentActiveAutoCompleteObj.suggestDiv.style.display = "block";
            if (!e) var e = window.event;
            if (e) { e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation();}
           
		    document.onclick = currentActiveAutoCompleteObj.hideDiv;
            return false;
        }
		this.getChildrenArray = function ( strClassName, obj ) {
							    var ar = arguments[2] || new Array();
							    var re = new RegExp("\\b" + strClassName + "\\b", "g");
							    if ( re.test(obj.className) ) ar.push( obj );
							    for ( var i = 0; i < obj.childNodes.length; i++ )
							        this.getChildrenArray( strClassName, obj.childNodes[i], ar );
							    return ar;
							}
		this.arrByClassForKeys = new Array();	
		this.arrByClassForKeysCurrIndex = 0;				
    }
//END autoComplete class
function clearSelection(obj)
{
 //.clearSelection{-webkit-user-select:none;-moz-user-select:none;user-select: none;}/*ff and chrom only for ie use unselectable="on"*/ 
	if(obj.unselectable)
		obj.unselectable="on";
	else
	{	
		if(obj.className.indexOf("clearSelection") <  0)	
			obj.className+=" clearSelection";
	}
	obj.onmouseover=obj.onmouseover.toString().replace("clearSelection(this)","");	
}
  function setPlayBtn(sender,isSmall) {
  	//this function get object from onmouseover event and set play btn
	//example: <img onmouseover="setPlayBtn(this)"  src="http://mscWNE.walla.co.il/archive/656173-38.jpg" />
  	 var  playBtnImgDiv = document.createElement('div');
     playBtnImgDiv.style.position = "relative";
	 playBtnImgDiv.style.zIndex = 2;
     playBtnImgDiv.style.height = sender.offsetHeight;
     playBtnImgDiv.style.width = sender.offsetWidth;
	 
	 
     var  playBtnImgDivInner = document.createElement('div');
     playBtnImgDivInner.style.height = sender.offsetHeight;
     playBtnImgDivInner.style.width = sender.offsetWidth;
	
	 var picSize= (isSmall) ? picSize="small" :picSize="big";
	 
     playBtnImgDivInner.style.backgroundImage = 'url(http://iscWNE.walla.co.il/w9/v/radio/icons/play_'+picSize+'.png)';
     playBtnImgDivInner.style.backgroundRepeat = "no-repeat";
     playBtnImgDivInner.style.backgroundPosition = "50% 50%";
     playBtnImgDivInner.style.position = "absolute";
	 playBtnImgDivInner.style.zIndex = 3;
	 playBtnImgDivInner.className+=" playBtnOpacity";
     var genrateName = "theAbsPlayBtn"+Math.random()*1000 + Math.round(((new Date()).getTime() - Date.UTC(1970, 0, 1)) / 1000)+Math.random()*1000;
     playBtnImgDivInner.id = genrateName;

     playBtnImgDiv.appendChild(playBtnImgDivInner);
     eval("playBtnImgDiv.onmouseout =function() { document.getElementById('" + genrateName + "').style.display = 'none';}");
     eval("playBtnImgDiv.onmouseover = function() { document.getElementById('" + genrateName + "').style.display = 'block';}");
     sender.onmouseover = "";
	 
     sender.parentNode.replaceChild(playBtnImgDiv, sender);
     playBtnImgDiv.appendChild(sender);
 }
function itemsArr() {
     //-----this function is creating object for sorting arrays   ------//
	    this.items = new Array();
        this.sortBy = 0;
        this.add = function() {
            var i = 0;
            var temArrStr = "";
            var currIndex = this.items.length++;
            this.items[currIndex] = new Array();
            for (i = 0; i < arguments.length; i++) {
                this.items[currIndex][i] = arguments[i];
				
            }
        }
	   var	objDivToGetSon=document.createElement("DIV");
		function getLastSonText(objStr)
		{
			objDivToGetSon.innerHTML = objStr;
			if(!objDivToGetSon.firstChild || objDivToGetSon.firstChild.nodeType == 3)//3 = TEXT_NODE
				return(objDivToGetSon.firstChild.nodeValue);	
			else
				return(getLastSonText(objDivToGetSon.firstChild.innerHTML));		
		}
        this.sortIt = function(sortColNum, desc) {
            if(sortColNum == "" || sortColNum > this.items[0].length ||  sortColNum < 1)
			sortColNum=1;
			
			this.sortBy = sortColNum -1;
            if (desc)
                eval("this.items.sort(function(a, b) { var x = getLastSonText(a[" + this.sortBy + "]).toLowerCase(); var y = getLastSonText(b[" + this.sortBy + "]).toLowerCase(); return ((y < x) ? -1 : ((y > x) ? 1 : 0));});");
            else
                eval("this.items.sort(function(a, b) { var x = getLastSonText(a[" + this.sortBy + "]).toLowerCase(); var y = getLastSonText(b[" + this.sortBy + "]).toLowerCase();  return ((x < y) ? -1 : ((x > y) ? 1 : 0));});");
        }
       
    }

function xmlhttpGetObj (strURL, divName, alignCenter,isCached) {
	if (typeof(isCached) == "undefined") isCached = true;
	var xmlHttpReq = false;
	var self = this;
	var alignText = '';
	var divHeight;
	var marginTop;
	var elm = (typeof(divName) == "string") ? document.getElementById(divName) : divName;
	
	if (elm) {
		elm.style.textAlign = 'center';
		if (alignCenter) {
			divHeight = elm.offsetHeight;
			marginTop = parseInt((divHeight - 16) / 2);
			alignText = "style='margin-top:"+marginTop+"px;'";
			elm.style.height = divHeight + 'px';
			elm.innerHTML = "<img src='http://iscWNE.walla.co.il/w9/v/radio/icons/ajax-loader.gif' border='0' "+alignText+" />";
		}
		
		if (isCached) {
			if(cacheObj[strURL] != null) {
				try {
					elm.style.height = '';
					elm.innerHTML = cacheObj[strURL]; 
					evalObjJavascript(cacheObj[strURL],"script");
				} catch(e){}
				return;
			}
		} else {
			cacheObj = [];
		}

		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
		};
			self.xmlHttpReq.open('GET', strURL);
			self.xmlHttpReq.onreadystatechange = function() {
				if (self.xmlHttpReq.readyState == 4) {
					if (alignCenter) {
						elm.style.height = '';
					}
					if (divName != "") {
						elm.innerHTML = cacheObj[strURL] = self.xmlHttpReq.responseText;
						evalObjJavascript(self.xmlHttpReq.responseText,"script");
					} else {
						return self.xmlHttpReq.responseText;
					}
				};
			};
		self.xmlHttpReq.send(null);
	}
};

function evalObjJavascript(tobj,scriptStr){
    var TmpHtml = tobj;
    var oEval = TmpHtml.search('<' + scriptStr + '>');
	
    var Max = 30;
    for (i = 0; i < Max && oEval >= 0; i++) {
        var tmp = TmpHtml.substring(oEval, TmpHtml.length).search('</' + scriptStr + '>');
       
        sEval = TmpHtml.substring(oEval + 8, oEval + tmp);
        execScriptRunner(sEval);
        
        TmpHtml = TmpHtml.substring(oEval + tmp + 9, TmpHtml.length);
        oEval = TmpHtml.search('<' + scriptStr + '>');
    }
    
    return false;
};

function execScriptRunner(txt){
    //_alert("exec sxcript runner")
    if (typeof browser != 'string') {var browser = checkBrowser();}
    Saf=/a/.__proto__=='//';
            
    if (browser == 'IE' || browser == 'chrome') {
        try {          
		if (window.execScript) {        // Internet Explorer and Google Chrome
			execScript (txt, "JavaScript");
		} else {
			if (window.eval) {
				eval (txt);
			}
		}
        } 
        catch (err) {
           // alert('error:' + err);
        };
    } else {
	    var wal_global = this; 
	    if (wal_global.eval) {
	        wal_global.eval(txt);
	    } else {
	    	eval(txt);
	    }
        if (Saf == true) {
        	IncludeJS(txt);
        }
        //return  wal_global.eval ? wal_global.eval(txt) : eval(txt);
    }
    return false;
};

function checkBrowser(){ 
    var navFamily = navigator.userAgent.toLowerCase();
    if (navFamily.indexOf('msie') != -1) {
        var ver = parseFloat(navFamily.substring(navFamily.indexOf('msie') + 5, navFamily.length));
        scriptStr = 'SCRIPT';
        navFamily = 'IE';
    } else {
        if (navFamily.indexOf('gecko') != -1) {
	        if (navFamily.indexOf('chrome') != -1) {
	            var ver = parseFloat(navFamily.substring(navFamily.indexOf('chrome') + 6, navFamily.length));
	            scriptStr = 'script';
	            navFamily = 'chrome';
            } else {
                var ver = parseFloat(navFamily.substring(navFamily.indexOf('gecko') + 6, navFamily.length));
                scriptStr = 'script';
                navFamily = 'Gecko';
			}
        } else {
        	scriptStr = 'script';
            navFamily = 'Gecko';
        } 
	}
    return navFamily;
};

function playerPopUp (id, item_type, isSuscribe, sender) {
	var playerUrl = wMusicLink+"/player&isPopUp=1&type=" + item_type + "&itemId=" + id;
	var iMyWidth = (window.screen.width/2) - 250;
	var iMyHeight = (window.screen.height/2) - 350;
	var winH = (/Chrome/i.test(navigator.userAgent)) ? "545" :  "540";
	var props = "height=" + winH + ",width=700,left=" + iMyWidth + ",top=" + iMyHeight + ",toolbar=0,menubar=0,location=0,scrollbars=0,status=0,resizable=0";

	if ((item_type == "channel" || item_type == "album") && isSuscribe == 1) {
		if(globUserDidPay == "0") {	
			pageAction = item_type;
			handleAlert(sender,pageAction);
			return;
		}
	}
	
	if (!win || win.closed) {
		win = window.open(playerUrl, "playerPopWin", props);
	} else {
		win.close();
		win = window.open(playerUrl, "playerPopWin", props);
	}
}

function remove_last(isAlbum,item_id,playlist,counter) {
	var params = "&isAlbum=" + isAlbum + "&item_id=" + item_id + "&pl=" + playlist + "&counter=" + counter;
	var playlist_url = "?w=/1/1/@@/radio/playlist/playlist_actions&op=delete_last" + params;
	
	ajaxIt(playlist_url,"");
	if (document.getElementById("mymusic")) {
		var rand = parseInt(Math.random()*1000);
		var strURL = "/?w=/1/1/@@/radio/my_music/mymusic.comp&isAjax=1&rand=" + rand;
		var elm = document.getElementById("mymusic");
		tmpPointer = function() {xmlhttpGetObj (strURL, elm, true,false);}
		setTimeout("tmpPointer()",1500);
	}
}

function add_to_playlist (type,playlist_id,song_id) {
	var playlist_url = "?w=/1/1/@@/radio/playlist/playlist_actions&op=" + type+ "&playlist_id=" + playlist_id + "&song_id=" + song_id;
	ajaxIt(playlist_url,"");
	
	if (document.getElementById("mymusic")) {
		var rand = parseInt(Math.random()*1000);
		var strURL = "/?w=/1/1/@@/radio/my_music/mymusic.comp&isAjax=1&rand=" + rand;
		var elm = document.getElementById("mymusic");
		tmpPointer = function() {xmlhttpGetObj (strURL, elm, true,false);}
		setTimeout("tmpPointer()",1500);
	}
	//xmlhttpGetObj (playlist_url, "", 0);
}



function getAjaxResponseText(responseText,senderId) 
{
	//alertAbs(responseText,3000,true,"",senderId);
	sysAlerBottom(responseText,"top_toolbar");
}
function hideMyDiv(id) {
	document.getElementById(id).style.display="none";
	if(window.onclick == "hideMyDiv("+id+")")
		window.onclick="";
};

function showMyDiv(id) {
	document.getElementById(id).style.display="none";
	window.onclick="hideMyDiv("+absDivId+")";	
};
function sysAlertError(msg,btnMsg,btnUrl,theCenterDivIdForMeasure)
{
		if(btnMsg != ""){
			document.getElementById("didntPayMsgHref").innerHTML=btnMsg;  
			document.getElementById("didntPayMsgHref").href=btnUrl;
		}else{
			document.getElementById("didntPayMsgHref").style.display="none";
		}
		document.getElementById("didntPayMsgTxt").innerHTML=msg;
		alertAbsBulidDiv("didntPayMsg",0,false,"ssss","didntPayMsgX","",false,theCenterDivIdForMeasure);
}
function sysAlerBottom(msg,theCenterDivIdForMeasure)
{
	var favDiv = document.getElementById("thanksMsg");
	centerCoords = getWindowCenterCords(document.body.clientWidth,40);
	centerCoords.y = centerCoords.windowBottom;
	
	document.getElementById("thanksMsgTxt").innerHTML = msg;
	favDiv.style.top = centerCoords.y + "px"
	favDiv.style.display = "block";
	setTimeout("slowlyFadeOut('thanksMsg')",3000);
}
function fav_item(itemId,itemType,sender,remove,userDidPay,url,isFav,extraParamsR) {  
	if (typeof(isFav) == "undefined" || isFav == null) {
		var urlStr="http://www.walla.co.il";
		if (url!=""){
			urlStr=url;
		}
		
		if(globUserDidPay == "0") {	
			pageAction = "fav";
			if (location.href.indexOf("/song/") > -1)
				pageAction = "song";
			handleAlert(sender,pageAction);
			/* sysAlertError( "הוספת שירים לסיפרייה האישית הינה למנויים בלבד"
							 , "לחץ כאן לרכישת מנוי" 
							 , urlStr,"top_toolbar" ); */
			
			return(false);
		}
		if(typeof(remove) == "undefined" || remove == null) remove = ""; 
		ajaxIt("?w=/1/1/@@/radio/addToFavorite&itemId="+itemId+"&itemType="+itemType+"&remove="+ remove + extraParamsR, "", "getAjaxResponseText(r.responseText,\""+sender.id+"\")" );
		if(typeof(remove) != "undefined" && remove != "") location.reload(true);
	}	
		
	 refreshMyMusicComp();
}

function refreshMyMusicComp() {
	if (document.getElementById("mymusic") || window.opener != null) {
		var rand = parseInt(Math.random()*1000);
		var strURL = "/?w=/1/1/@@/radio/my_music/mymusic.comp&isAjax=1&rand=" + rand;
		var elm = (document.getElementById("mymusic")) ? document.getElementById("mymusic") : window.opener.document.getElementById("mymusic");
		tmpPointer = function() {xmlhttpGetObj (strURL, elm, true,false);}
		setTimeout("tmpPointer()",1500);
	}
}

function down_item_fb(itemId, itemType, path) {
	var url = "https://www.facebook.com/connect/uiserver.php?app_id=133472246670311&method=permissions.request&display=page&next=https%3A//friends.walla.co.il/%3Fw%3D/@billing/songs/main%26itemId%3D" + itemId + "%26itemType%3D" + itemType + "%26path%3D" + path + "%26app_id%3D3%26fctest%3D1&response_type=token&fbconnect=1&perms=publish_stream,user_birthday,user_hometown,email,user_hometown";
	var left = (screen.width / 2) - (683 / 2);
	var top = (screen.height / 2) - (550 / 2);
	
	down_itemWin = window.open(url, "down_itemWin", "width=683,height=550,location=yes,scrollbars=yes,status=yes,menubar=no,resizable=yes,scrollbars=0,left=" + left + ", top=" + top);
	if (window.focus) {down_itemWin.focus()};
}

function down_item(itemId,itemType,sender, path) {
	var itemPath = (typeof(path) == "string") ? path : "selectPayment";
	var url ="https://friends.walla.co.il/?w=/@billing/songs/main&itemId="+itemId+"&itemType="+itemType+"&path=" + itemPath + "&app_id=3";
	var left = (screen.width / 2) - (683 / 2);
	var top = (screen.height / 2) - (550 / 2);
	
	down_itemWin = window.open(url, "down_itemWin", "width=683,height=550,location=yes,scrollbars=yes,status=yes,menubar=no,resizable=yes,scrollbars=0,left=" + left + ", top=" + top);
	if (window.focus) {down_itemWin.focus()};
};

function lyrics_item (itemId,display_name,itemType,sender) {
	var extraParam = "";
	if(itemType == "clip")
	{
		itemType="song";
		extraParam="&clip=1";
	}
	location.href="/"+itemType+"/"+itemId+"/"+display_name+extraParam;
	
};
function share_item (id) {alert("Lyrics: itemId - " + id); };
var playing_currentItem = 0;
var playing_currentSrc = "";


function play_item (itemId, itemType, sender, imgRoll) {
	//try {
		player.isPrev = 1;
		if(!player.isPlaying) {
			//player.playPreview(playing_currentItem,false);
			playing_currentItem = parseInt(itemId);
			player.playPreview(parseInt(itemId),true);
			//playing_currentSrc = sender.src;
			sender.src = "http://i.walla.co.il/w9/v/radio/icons/listen_X.gif";
			sender.removeAttribute("onmouseout");
			sender.removeAttribute("onmouseover");
		} else {
			var stopAndPlay = (playing_currentItem != itemId) ? true : false;
			document.getElementById("preview_" + playing_currentItem).src = "http://i.walla.co.il/w9/v/radio/icons/listen_grey.gif";
			playing_currentItem = 0;
			player.playPreview(parseInt(itemId),false);
			sender.src = "http://i.walla.co.il/w9/v/radio/icons/listen_grey.gif";
			sender.setAttribute("onmouseout", "this.src='http://iscWBE.wcdn.co.il/w9/v/radio/icons/listen_grey.gif'");
			sender.setAttribute("onmouseover", "this.src='http://iscWBE.wcdn.co.il/w9/v/radio/icons/listen_red.gif'");
			
			if (stopAndPlay) {
				playing_currentItem = parseInt(itemId);
				player.playPreview(parseInt(itemId),true);
				sender.src = "http://i.walla.co.il/w9/v/radio/icons/listen_X.gif";
				sender.removeAttribute("onmouseout");
				sender.removeAttribute("onmouseover");
			}
		};
	//} catch(e) {}
};


/////////////////// cookies //////////////////////
function createCookie(name,value,days) {
	if (checkCookieEnabled()) {
		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=/";
	} else {
		alert("cookies are not enabled in this browser");
	}
}

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,"",0);
}

// checking if cookies are enabled
function checkCookieEnabled () {
	var cookieEnabled=(navigator.cookieEnabled)? true : false
	//if not IE4+ nor NS6+
	if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
		document.cookie="testcookie"
		cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false
	}
	//return cookieEnabled;
	return true;
}

function disableSelection(target, state) {
	if (!state || typeof(state) == "undefined") {
		if (typeof target.onselectstart!="undefined")
			target.onselectstart = function(){return false} //IE route
		else if (typeof target.style.MozUserSelect!="undefined") 
			target.style.MozUserSelect = "none"; //Firefox route
		else 
			target.onmousedown = function(){return false} //All other route (ie: Opera)
		target.style.cursor = "default";
	} else {
		if (typeof target.onselectstart!="undefined")
			target.onselectstart = function(){return true} //IE route
		else if (typeof target.style.MozUserSelect!="undefined") 
			target.style.MozUserSelect = "text"; //Firefox route
		else 
			target.onmousedown = function(){return true} //All other route (ie: Opera)
		target.style.cursor = "default";
	}
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return {x: myWidth, y: myHeight}
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return {x: scrOfX, y: scrOfY}
}


function fadeBg(isShow, isLoaderImg, divId, isColor) {
	var loadDiv = document.getElementById("loading");
	if (loadDiv) {
		if (typeof(divId) == "undefined" || divId == "") {
			if (isShow) {
				loadDiv.style.width = document.body.scrollWidth + "px" ;
				loadDiv.style.height = document.body.scrollHeight + "px";
				loadDiv.style.top = "0px";
				loadDiv.style.left = "0px";			
				loadDiv.style.display = "block";
				loadDiv.style.backgroundColor = "#000";
				loadDiv.innerHTML = "";
				
				if (typeof(isColor) != "undefined") {
					loadDiv.style.backgroundColor = "#000";
				}
				
				// if (isLoaderImg) {
					// divHeight = loadDiv.offsetHeight;
					// marginTop = parseInt((divHeight - 16) / 2);
					// alignText = "style='margin-top:"+marginTop+"px;'";
					// loadDiv.style.height = divHeight + 'px';
					// loadDiv.innerHTML = "<img src='http://iscWNE.walla.co.il/w9/v/radio/player_new/ajax-loader.gif' "+alignText+"/>";
				// } else {
					// loadDiv.innerHTML = "";
				// }
			} else {
				document.getElementById("loading").style.display = "none";
			}
		} else {
			var placeHolder = document.getElementById(divId);
			loadDiv.innerHTML = "";
			loadDiv.style.left = findPosX(placeHolder);
			loadDiv.style.top = findPosY(placeHolder);
			loadDiv.style.width = placeHolder.offsetWidth;
			loadDiv.style.height = placeHolder.offsetHeight;
			loadDiv.style.display = "block";
		}
	}
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
	  	// Firefox, Opera 8.0+, Safari
	  	xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
	  	try {
	    	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  	catch (e) {
	    	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	}
	return xmlHttp;
}

var addEvent = function(elem, type, eventHandle) {
    if (elem == null || elem == undefined) return;
    if ( elem.addEventListener ) {
        elem.addEventListener( type, eventHandle, false );
    } else if ( elem.attachEvent ) {
        elem.attachEvent( "on" + type, eventHandle );
    }
};

function getCurrentTime() {
	var currentTime = new Date().getTime();
	var localOffset = (-1) * new Date().getTimezoneOffset() * 60000;
	var stamp = Math.round(new Date(currentTime + localOffset).getTime() / 1000);
	
	return stamp;
}

function emailCommit(){	
   var emailRegx = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}/;
	if(document.email_form.to_name.value.length<1) {alert("חובה להקליד את שם הנמען"); document.email_form.to_name.focus(); return false;}
	if(!emailRegx.test(document.email_form.to.value) || document.email_form.to.value.length<1) {alert("חובה להקליד כתובת דואר אלקטרוני תקינה בדואר של החבר"); document.email_form.to.focus(); return false;}
	if (document.email_form.from_name.value.length<1) {alert("חובה להקליד את שם השולח"); document.email_form.from_name.focus(); return false;}
	if(!emailRegx.test(document.email_form.from_email.value) || document.email_form.from_email.value.length<1) {alert("חובה להקליד כתובת דואר אלקטרוני תקינה בדואר של השולח"); document.email_form.from_email.focus(); return false;}
	document.getElementById("GUI_COMMIT_EMAIL").style.display="block";
	document.getElementById("GUI_COMPOSE_EMAIL").style.display="none";
	document.email_form.submit();
}

function handleAlert(obj,pageFrom) {
	try {
		var userAlertContainer = document.getElementById("userAlertContainer");

		if ((userAlertContainer.style.display == "none" || userAlertContainer.style.display == "") && globUserDidPay == "0") {
			if (globUserDidPay == "0") {
				var retUrl = escape(wMusicLink + "/userHandle&item=" + pageFrom);
				var loginIfrm = document.getElementById("loginIfrm");
				if (loginIfrm) {loginIfrm.src = "https://friends.walla.co.il/?w=/@login.dynamic&layout=mM&ReturnURL=" + retUrl;}
				if ((pageFrom == "fav" || pageFrom == "channel" || pageFrom == "album") && typeof(obj) == "object") document.getElementById("objOnClick").value = obj.getAttribute("onclick");
			}
			showHideAlert(true, "userAlertContainer");
		} else {
			showHideAlert(false, "userAlertContainer");
		}
	} catch(e) {}
}

function showHideAlert(visible, divId) {
	var userAlertContainer = document.getElementById(divId);
	if (visible) {
		fadeBg(true,false);
		var aHeigt = (globUserDidPay == "1") ? "206" : "275";
		centerCoords = getWindowCenterCords(447,aHeigt);
		userAlertContainer.style.top = centerCoords.y + "px";
		userAlertContainer.style.left = centerCoords.x + "px";
		userAlertContainer.style.display = "block" ;
	} else {
		fadeBg(false,false);
		userAlertContainer.style.display = "none";
	}	
}

function refreshUserLoginTop (userName, returnUrl) {
	try {
		if (userName == "אורח") return;
		var htmlStr = '<span class="red_color w2b" style="padding-left: 3px;">שלום XXX</span>&nbsp<a class="userConnection" href="http://friends.walla.co.il/?w=/@logout&ReturnURL=' + returnUrl + '">התנתק/י</a>&nbsp; | &nbsp;עזרה';
		document.getElementById("userLogin").innerHTML = htmlStr.replace(/XXX/i, userName);
	} catch(e) {}
}

/* mailTo */
function CheckEmail(src) {
	if(src.length==0){
		return false;
	}
	else{
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		return regex.test(src);
	}
}
function submitForm(formName) {
	document.foo.doThis.value = action;
	document.foo.doThis.submit();
}

/* comp.show.artists.by.letters */
function changeMyImg(elm,src) {
	elm.style.background="url("+src+") no-repeat";
}

/* comp.song.icons */ 
function emailink(){
	window.location = "mailto:"+"?subject= " + "&body="+window.location.href;
}


/* paging */
function paggingSubmit(value){
	var elm;
	hiddenPageNum=document.getElementById("pageNum1")
	if(value == 0)
		hiddenPageNum.parentNode.removeChild(hiddenPageNum);
	else
		hiddenPageNum.value=value;
	document.getElementById("paggingForm").submit();
}

function skipPurchase() {
	var dontDisplay = document.getElementById("rememberMe");
	if(dontDisplay.checked) {
		createCookie('userStatusRemember',1,30);
	} else {
		createCookie('userStatusRemember',1,0);
	}
	showHideAlert(false, 'alertContainerStatus');
}

function getRedirect(value){
	location.href = value; 
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function hideStrip() {
	try {
	var elm = document.getElementById("thanksMsg");
	if (typeof(elm) == "object") {
		if (elm.style.display == "block") {
			//clearTimeOut(addFavStrip);
			elm.style.display = "none";
		}
	}
	}catch(e) {}
}

function alphaNumeric(e) {
     var k;
     document.all ? k = e.keyCode : k = e.which;
      return ((k > 64 && k < 91) || (k > 96 && k < 123) || (k > 1447 && k < 1515) || k == 8 || (k > 48 && k < 57) || k == 33 || k == 45 || k == 95 || k == 39 || k == 32);
}


/* autocomplete functions */
function autoCompleteUpdateCSS(obj,type){
	var _thisId = obj.id.substring(1, obj.id.length);
	var _thisT = document.getElementById("T" + _thisId);
	var _thisS = document.getElementById("S" + _thisId);
	if (type==1) {
		obj.className=obj.className.replace(" autoCompOnmOut","");
		obj.className += " autoCompOnmOver";
	} else {
		obj.className=obj.className.replace(" autoCompOnmOver","");
		obj.className += " autoCompOnmOut";
	}
}

function updateScrollerTop(scrollDiv,parentObj) {
	var x = y = z = "";
	x = parentObj.offsetHeight + 10;
	z = parseInt(scrollDiv.style.top);
	y = parseInt(scrollDiv.offsetHeight);
	
	objArr[wMwheelScrollSelectedId].wMsDiv.style.top = -((x * z) / y);
	eval("scrollPosPx" + wMwheelScrollSelectedId + " = " + parseInt(scrollDiv.style.top) + ";");
	
}

function onKeyPressAutoComp(obj) {
	if(obj) {
		var index;
			if(obj.index)
			index =obj.index;
			if(!index)
			index = obj.getAttribute("index"); 
		index=parseInt(index);
		wMwheelScrollSelectedId=1;
		var scrollDiv = document.getElementById("autoCompleteRslt_"+wMwheelScrollSelectedId);
		var conteiner = document.getElementById("autoCompleteRslt_directParent_"+wMwheelScrollSelectedId);	
			if((parseInt((index+1) * obj.clientHeight) + parseInt(obj.clientHeight)) >  parseInt(conteiner.offsetHeight))	{
				if(scrollDiv.offsetHeight > conteiner.offsetHeight) {
					scrollDiv.style.top = ((scrollDiv.offsetHeight - conteiner.offsetHeight)*-1)  + "px";
					//console.debug(((scrollDiv.offsetHeight - conteiner.offsetHeight)*-1));
				}
			} else {
				scrollDiv.style.top =  "0px";
			}
			updateScrollerTop(scrollDiv,conteiner);
	
	}
}

function checkSearchInput_2012(elm,isOut){
	if(elm.value=="" && isOut==1){
		if(elm.value == "") elm.value = "חפש: שירים, אמנים, אלבומים...";
		elm.style.color = "gray";
		//elm.blur();
	} else {
		
		if(elm != "" && elm.value == "חפש: שירים, אמנים, אלבומים...") elm.value = "";
		elm.style.color = "#000";
		elm.focus();
	}
	
}

function switchVals_2012(elm){
	var elmObj = (typeof(elm) == "string") ? document.getElementById(elm) : elm;
	
	if(elmObj != "" && elmObj.value != "חפש: שירים, אמנים, אלבומים...")
		window.location = "/search/" + encodeURI(elmObj.value);
	else 
		checkSearchInput_2012(elmObj);
}

function pagingAjax(pageNum, divId, searchWord, extraParam) {
	url = "http://music.walla.co.il/?w=/1/1/@@/radio/comps/" + divId + "&pageNum=" + pageNum;
	if(typeof(extraParam) == "string") url += extraParam;
	if (searchWord != "") url += "&searchWord=" + encodeURI(searchWord);
	
	if(jQuery("#" + divId).height() >= jQuery("#" + divId + "_wrapper").height()) 
		jQuery("#" + divId + "_wrapper").height(jQuery("#" + divId).height());
	else 	
		jQuery("#" + divId + "_wrapper").css("height", jQuery("#" + divId + "_wrapper").height());
		
	jQuery("#" + divId).fadeOut("fast", function() {
		jQuery.ajax({
			type: 'POST',
			url: url,
			dataType: "html",
			cache: true,
			beforeSend: function(){
				jQuery("#" + divId + "_wrapper").css("text-align", "center");
				divHeight = jQuery("#" + divId + "_wrapper").height();
				marginTop = parseInt((divHeight - 16) / 2);
				alignText = "style='margin-top:" + marginTop + "px;'";
				jQuery("#" + divId + "_wrapper").html("<div id='" + divId + "'></div><img src='http://iscWNE.walla.co.il/w9/v/radio/icons/ajax-loader.gif' border='0' "+alignText+" id='" + divId + "_ajaxLoader'/>");
			},
			success: function(data){
				jQuery("#" + divId + "_ajaxLoader").remove();
				jQuery("#" + divId).fadeIn("fast");
				jQuery("#" + divId).html(data);
			}
		});
	});
}
