// ############ Radio Comp #####################
var wMartistChCnt = 0;

function wMRadioCheckbox(obj, id , e){
	hiddenObj = document.getElementById("radioItem_"+id);
	if(hiddenObj){
		if(parseInt(hiddenObj.value) == 0){
			hiddenObj.value = 1;
			document.getElementById("radioItemImg_"+id).src = "http://iscWNE.walla.co.il/w9/v/radio/channels/checkbox_on.gif";
			obj.className=obj.className.replace("wMitemBlock","wMitemBlockSelected");
			
		} else {
			hiddenObj.value = 0;
			document.getElementById("radioItemImg_"+id).src = "http://iscWNE.walla.co.il/w9/v/radio/channels/checkbox_off.gif";
			obj.className=obj.className.replace("wMitemBlockSelected","wMitemBlock");
		};
	};
	
};
function wMRadioSelectGenre(divName){
	var ret="";
	arr = document.getElementsByName("radioItem");
	for(var cnt=0; cnt<arr.length; cnt++){
		if(parseInt(arr[cnt].value) == 1){
			if (ret != "") ret += ",";
			var itemId = arr[cnt].id.split("_")[1];
			ret = ret + itemId;
			//Evt(this,"cn_${clicksDivName}",itemId,cnt,"0");
		}
	}
	if (ret != "") {
		playerPopUp(ret, "channel");
		Evt(this,divName,"channel",ret,"radio_playChannel");
	} else {
		alert("יש לבחור ערוצים");
	}
};	

function wMadditionCh(e){
	if(document.getElementById("wMitemsAbsDiv").style.display == "none") {
		var divToControl = document.getElementById("wMitemsAbsDiv");
		var radioSep = document.getElementById("radioSep");
		document.getElementById("wMadditional").innerHTML = "סגור";
		divToControl.style.display = "block";
		radioSep.style.height = "283px";
		//openSlow(divToControl);
		
		//window.onclick = wMadditionCh;
	} else {
		document.getElementById("wMitemsAbsDiv").style.display = "none";
		document.getElementById("wMadditional").innerHTML = "ערוצים נוספים";
		document.getElementById("radioSep").style.height = "220px";
		//window.onclick = "";
	}
	stopBubbling(e);		
};

function stopBubbling(e)	{
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function wMartistCh(toDo,clicksDivName){
	if (toDo == "init") {
		wMartistChCnt = (wMartistChannel.length > 1) ? Math.ceil((wMartistChannel.length-1)*Math.random()) : 0;
	} else {
		wMartistChCnt += toDo;
		if(!wMartistChannel && !wMartistChannel[wMartistChCnt] && toDo==1)  wMartistChCnt = 0;
		if(wMartistChCnt < 0 && toDo==-1)  wMartistChCnt = wMartistChannel.length-1;
	}
	
	if (typeof(document.getElementById("wMartistChImg")) == "object") {
		if (wMartistChannel[wMartistChCnt].is_subscribe == "1") {
			var retHTML = '';
			retHTML = '<div style="cursor:pointer;width:120px;height:120px;overflow:hidden;" onclick="Evt(this,&quot;main_Radio&quot;,' + wMartistChannel[wMartistChCnt].id + ',&quot;1&quot;,&quot;radio_playArtistChannel&quot;);playerPopUp(' + wMartistChannel[wMartistChCnt].id + ', \'channel\', \'' + wMartistChannel[wMartistChCnt].is_subscribe + '\', this);" style="cursor:pointer;">';
				retHTML += '<img src="' + wMartistChannel[wMartistChCnt].imgSrc + '"/>';
				retHTML += '<div style="position:relative;width:114px;.width:120px;height:15px;.height:21px;margin-top:-21px;font:bold 12px arial;color:#fff;background-color:#000; -moz-opacity:.80; filter:alpha(opacity=80); opacity:.80;text-align:center;padding:3px">למנויים בלבד</div>';
			retHTML += '</div>';
			document.getElementById("wMartistChImg").innerHTML = retHTML;
		} else {
			document.getElementById("wMartistChImg").innerHTML = '<img width="120" height="120" src="' + wMartistChannel[wMartistChCnt].imgSrc + '" onclick="Evt(this,&quot;main_Radio&quot;,' + wMartistChannel[wMartistChCnt].id + ',&quot;1&quot;,&quot;radio_playArtistChannel&quot;);playerPopUp(' + wMartistChannel[wMartistChCnt].id + ', \'channel\', \'' + wMartistChannel[wMartistChCnt].is_subscribe + '\', this);" style="cursor:pointer;"/>';		
		}
		document.getElementById("wMartistChTitle").innerHTML = '<span style="cursor:pointer;" onclick="Evt(this,&quot;main_Radio&quot;,' + wMartistChannel[wMartistChCnt].id + ',&quot;1&quot;,&quot;radio_playArtistChannel&quot;); playerPopUp(' + wMartistChannel[wMartistChCnt].id + ', \'channel\', \'' + wMartistChannel[wMartistChCnt].is_subscribe + '\', this);">' + wMartistChannel[wMartistChCnt].display_name + '</span>';
		
		if(document.getElementById('wMartistCh').style.display == 'none')
			document.getElementById('wMartistCh').style.display = 'block';
	} else {
		setTimeOut("wMartistCh('" + toDo + "','" + clicksDivName + "')",200);
	}
};

function radioSerchFunction(value, loc){
	valueObj = document.getElementById(value);
	if(valueObj && valueObj.value != "") {
		if (typeof(loc) == "undefined") {
			location.href="/search/"+encodeURI(valueObj.value);
		} else {
			location.href="/" + loc + "/" + encodeURI(valueObj.value);
		}
	}
}


/* My Music Comp */
function mM_highlight(row,on,icons) {row.className = (on) ? "mM_row_inner_hover" :  "mM_row_inner";}

/* Hot Items */
function hideAllHotDivs() {	
	if(document.getElementById("hotLeftClips"))
		document.getElementById("hotLeftClips").className="hotItemContinerHide";
	if(document.getElementById("hotLeftArtists"))
		document.getElementById("hotLeftArtists").className="hotItemContinerHide";
	if(document.getElementById("hotLeftSongs"))
		document.getElementById("hotLeftSongs").className="hotItemContinerHide";
	if(document.getElementById("hotLeftDownloads"))
		document.getElementById("hotLeftDownloads").className="hotItemContinerHide";
}

function showHotDiv(idStr,toolBarBtnId) {
	hideAllHotDivs();	
	document.getElementById(idStr).className="hotItemContinerShow";
	selectMyTab(toolBarBtnId,false);
}

function changeAllChildrenByClass(elm,className,style) {
	for(var i = 0 ; i  < elm.childNodes.length; i++)
	{
		if(elm.childNodes[i].className && elm.childNodes[i].className.indexOf(className) > -1)
		{
			eval(style);
		}
	}
}

function get_nextsibling(n) {
	var	x = (n.nextSibling)?n.nextSibling:false;
		while (x.nodeType!=1 && x.nextSibling)
		  {
			 x=x.nextSibling;
		  }
	return x;
}

function get_previoussibling(n) {
	var	x = (n.previousSibling)?n.previousSibling:false;
		while (x.nodeType!=1 && x.previousSibling )
		  {
			  x=x.previousSibling;
		  }
	return x;
}

function selectMyTab(toolBarBtnId,onEvent) {
	toolBarBtn=document.getElementById(toolBarBtnId);
	changeAllChildrenByClass(toolBarBtn.parentNode,"hot5Sep","elm.childNodes[i].style.color='#FFFFFF';");
	changeAllChildrenByClass(toolBarBtn.parentNode,"hotNavBtnSelected","elm.childNodes[i].className=elm.childNodes[i].className.replace('hotNavBtnSelected','');");
	
	toolBarBtn.className=toolBarBtn.className+" hotNavBtnSelected";
	var leftElm = get_nextsibling(toolBarBtn);
	var rightElm = get_previoussibling(toolBarBtn);
	if(leftElm && leftElm.className && leftElm.className.indexOf("hot5Sep") > -1)
	leftElm.style.color="#252525";
	if(rightElm && rightElm.className && rightElm.className.indexOf("hot5Sep") > -1)
	rightElm.style.color="#252525";
	
}


/* recommended */ 
function searchGenre(val) {
	if(val)
		document.getElementById("genreHidd").value=val;
	else
		document.getElementById("genreForm").removeChild(document.getElementById("genreHidd"));
	document.getElementById("genreForm").submit();
}

function orderBy(val) {
	var hrefCleanFromPaggingParams = replaceOrAddOrRemoveMyParam(location.href,"page",val,true);
	if(val && val != -1)
	location.href=replaceOrAddOrRemoveMyParam(hrefCleanFromPaggingParams,"orderBy",val,false);
	else
	{
		var hrefCleanFromPaggingParams = replaceOrAddOrRemoveMyParam(hrefCleanFromPaggingParams,"orderBy",val,true);
		location.href=hrefCleanFromPaggingParams;
	}
}
