function get(el) {
	return document.getElementById(el);
}

var categoriesArray = new Array();

categoriesArray[0] = "<li class=\"noBorder\">ערוצים נבחרים:</li><li><a href=\"/online/55/HP_305.html\">ניו אייג'</a></li><li id=\"botNav301\"><a href=\"/online/55/HP_301.html\">תיירות</a></li><li><a href=\"/online/1/HP_468.html\">יהדות</a></li><li><a href=\"/online/47/HP_307.html\">טלוויזיה</a></li><li><a href=\"/online/1/HP_459.html\">ירוק</a></li><li><a href=\"/online/1/HP_478.html\">ברנז'ה</a></li><li><a href=\"/online/1/HP_312.html\">בעולם</a></li><li><a href=\"/online/1/HP_479.html\">דעות</a></li><li id=\"botNav80\" class=\"noBorder\"><a href=\"/online/HP_80.html\">תמונות</a></li>";
categoriesArray[1] = "<li id=\"botNav487\"><a href=\"/online/1/HP_487.html\">מבזקים</a></li><li id=\"botNav404\"><a href=\"/online/1/HP_404.html\">פוליטי/מדיני</a></li><li id=\"botNav875\"><a href=\"/online/1/HP_875.html\">צבא וביטחון</a></li><li id=\"botNav402\"><a href=\"/online/1/HP_402.html\">בארץ</a></li><li id=\"botNav312\"><a href=\"/online/1/HP_312.html\">בעולם</a></li><li id=\"botNav459\"><a href=\"/online/1/HP_459.html\">ירוק</a></li><li id=\"botNav468\" ><a href=\"/online/1/HP_468.html\">יהדות</a></li><li id=\"botNav311\"><a href=\"/online/1/HP_311.html\">בריאות</a></li><li id=\"botNav478\"><a href=\"/online/1/HP_478.html\">ברנז'ה</a></li><li id=\"botNav479\"><a href=\"/online/1/HP_479.html\">דעות</a></li><li id=\"botNav350\" class=\"noBorder\"><a href=\"/online/1/HP_350.html\">תמונות</a></li>";
categoriesArray[16] = "<li id=\"botNav1903\"><a href=\"/online/16/HP_1903.html\">שוק ההון</a></li><li id=\"botNav1901\"><a href=\"/online/16/HP_1901.html\">בארץ</a></li><li id=\"botNav1902\"><a href=\"/online/16/HP_1902.html\">צרכנות</a></li><li id=\"botNav1924\" class=\"noBorder\"><a href=\"/online/16/HP_1924.html\">טכנולוגיה</a></li>";
categoriesArray[3] = "<li id=\"botNav629\"><a href=\"/online/3/HP_629.html\">כדורגל</a></li><li id=\"botNav620\"><a href=\"/online/3/HP_620.html\">כדורסל</a></li><li id=\"botNav605\"><a href=\"/online/3/HP_605.html\">עוד ספורט</a></li><li><a href=\"http://www.nrg.co.il/online/3/livegames.php\">לוח תוצאות</a></li><li id=\"botNav631\"><a href=\"/online/3/statistics.html\">סטטיסטיקות</a></li><li id=\"botNav350\" class=\"noBorder\"><a href=\"/online/3/HP_350.html\">תמונות</a></li>";
categoriesArray[43] = "<li id=\"botNav863\"><a href=\"/online/43/HP_863.html\">בריאות הגוף</a></li><li id=\"botNav865\"><a href=\"/online/43/HP_865.html\">בריאות הנפש</a></li><li id=\"botNav864\"><a href=\"/online/43/HP_864.html\">תזונה וכושר</a></li><li id=\"botNav395\"><a href=\"/online/43/HP_395.html\">משפחה</a></li><li id=\"botNav866\"><a href=\"/online/43/HP_866.html\">ניו אייג'</a></li><li id=\"botNav391\" class=\"noBorder\"><a href=\"/online/43/HP_391.html\">קהילות בריאות</a></li>";
categoriesArray[7] = "<li id=\"botNav1001\"><a href=\"/online/7/HP_1001.html\">לוקאלי</a></li><li id=\"botNav1002\"><a href=\"/online/7/HP_1002.html\">אינטרנשיונל</a></li><li id=\"botNav1010\"><a href=\"/online/7/HP_1010.html\">פפראצי</a></li><li id=\"botNav350\" class=\"noBorder\"><a href=\"/online/7/HP_350.html\">תמונות</a></li>";
categoriesArray[54] = "<li id=\"botNav869\"><a href=\"/online/54/HP_869.html\">ירושלים</a></li><li id=\"botNav870\"><a href=\"/online/54/HP_870.html\">מרכז</a></li><li id=\"botNav874\"><a href=\"/online/54/HP_874.html\">שרון</a></li><li id=\"botNav871\"><a href=\"/online/54/HP_871.html\">שפלה</a></li><li id=\"botNav872\"><a href=\"/online/54/HP_872.html\">צפון</a></li><li id=\"botNav873\" class=\"noBorder\"><a href=\"/online/54/HP_873.html\">דרום</a></li>";
categoriesArray[53] = "<li id=\"botNav101\"><a href=\"/online/53/HP_101.html\">נדל\"ן</a></li><li id=\"botNav102\"><a href=\"/online/53/HP_102.html\">צרכנות פיננסית</a></li><li id=\"botNav103\"><a href=\"/online/53/HP_103.html\">ביטוח</a></li><li id=\"botNav104\"><a href=\"/online/53/HP_104.html\">קנייה נבונה</a></li><li id=\"botNav105\"><a href=\"/online/53/HP_105.html\">קריירה ועבודה</a></li><li id=\"botNav106\" class=\"noBorder\"><a href=\"/online/53/HP_106.html\">משפחה</a></li>";
categoriesArray[47] = "<li id=\"botNav306\"><a href=\"/online/47/HP_306.html\">תרבות ואמנות</a></li><li id=\"botNav307\"><a href=\"/online/47/HP_307.html\">טלוויזיה</a></li><li id=\"botNav308\"><a href=\"/online/47/HP_308.html\">קולנוע</a></li><li id=\"botNav309\"><a href=\"/online/47/HP_309.html\">מוזיקה</a></li><li id=\"botNav310\"><a href=\"/online/47/HP_310.html\">ספרות</a></li><li id=\"botNav350\" class=\"noBorder\"><a href=\"/online/47/HP_350.html\">תמונות</a></li>";
categoriesArray[55] = "<li id=\"botNav301\"><a href=\"/online/55/HP_301.html\">תיירות</a></li><li id=\"botNav302\"><a href=\"/online/55/HP_302.html\">אופנה ועיצוב</a></li><li id=\"botNav303\"><a href=\"/online/55/HP_303.html\">אוכל</a></li><li id=\"botNav305\"><a href=\"/online/55/HP_305.html\">ניו-אייג'</a></li><li id=\"botNav350\" class=\"noBorder\"><a href=\"/online/55/HP_350.html\">תמונות</a></li>";
categoriesArray[29] = '<li id="botNav320"><a href="/online/29/HP_320.html">רק בריאות</a></li><li id="botNav321"><a href="/online/29/HP_321.html">הריון וילדים</a></li><li id="botNav322"><a href="/online/29/HP_322.html">תזונה וכושר</a></li><li class="noBorder" id="botNav314"><a href="/online/55/HP_314.html">גוף ונפש</a></li>';

function setRuller() {
 var navAppl;
 var navCategoryId;
 
 switch(appl) {
	case 18: {navAppl=0; navCategoryId=18;} break;	// חגים
	case 24: navAppl=0; break;						// מגזינים
	case 80: {navAppl=0; navCategoryId=80;} break;	// תמונות
	default: {navAppl=appl; navCategoryId=categoryId;}
 }

 try {
  if(ref.indexOf('HP_350')>0 || ref.indexOf('HP_80')>0) navCategoryId=350;
 } catch(e) {}
 
 if(navAppl!=-1) {  
  try{get("topNav"+navAppl).className="current";} catch(err){}
  var showAll='<li class="leftLink noBorder"><a href="#" onclick="allChannels(); return false;">הצג את כל הערוצים...</a></li>';
  get("bottomNav").innerHTML = categoriesArray[navAppl] + showAll;
} else {
   get("bottomNav").innerHTML = showAll;
}
 if(navCategoryId!=-1 && navCategoryId!="") { //***
  var activeCategory=get("botNav"+navCategoryId);
  	if(activeCategory) {
  		activeCategory.className="current";
		if(activeCategory.previousSibling) activeCategory.previousSibling.style.background='none'; /* className="noBorder" */
		activeCategory.parentNode.style.width="945px"; /* get by id */
  		activeCategory.parentNode.style.paddingRight="15px"; /* get by id */
  }
 }
}

setRuller();


/* SEARCH FORM FUNCTIONS */

function goSearch(btn,engine) {
	searchTab=engine;
	btn.parentNode.className="search"+engine;
	  switch(engine) {
		case '144':
		 get("typeOf144").style.display="inline";
		 get("query").className="short";
		 break;
		default:
		 get('typeOf144').style.display="none";
		 get('query').className="";
//		 if (document.searchOptions.query.value!='') validateMyPage();
		 break;
	  }
}

var submitBtn = get("send_search");

function validateMyPage(nn) {

 var queryString = document.searchOptions.query.value;
 submitBtn.disabled=true;
 submitBtn.style.filter="alpha(opacity=40)";
 submitBtn.style.opacity=".5;";

 if(queryString == "") {	 
	 alert("אנא הזן שאילתא");
	 document.searchOptions.query.focus();
	 submitBtn.disabled=false;
	 submitBtn.style.filter="alpha(opacity=100)";
	 submitBtn.style.opacity="1";
	 return false;
 } 

 else

 {
	submitPage(nn);
	return true;
 }
}


//var searchTab="Nrg";
function submitPage(nn){



 switch(searchTab) {
   case 'Nrg':
	 document.searchOptions.searchAction.value = "search";
	 document.searchOptions.action = "http://www.nrg.co.il/online/search.html";
	 document.searchOptions.cof.value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1";
	 document.searchOptions.submit();
     break;
   case 'Web':
	 document.searchOptions.action = "http://www.nrg.co.il/online/search.html";
	 document.searchOptions.searchAction.value = "googleSearch";
//	 document.searchOptions.cof.value="type="+nn;
	 document.searchOptions.submit();
     break;
   case '144':
     var url="http://www.b144.co.il/search.aspx?"
	 var myQuery=encodeURI(document.searchOptions.query.value);
     if (get("typeOf144").value==2) {
		 document.searchOptions.searchAction.value = "businessSearch";	
	     url=url+"txtBuisness="+myQuery+"&txtBuisnessName=&txtCity=&m=&sitecode=5&subsitecode=5&site=nrg";
		 url="http://www.nrg.co.il/luach_nrg/owa/count_hit?board_num=60&url="+escape(url);
	 }
	 else {
		document.searchOptions.searchAction.value = "peoplesSearch";	
	    url=url+"txtNamePrivate="+myQuery+"&txtCityPrivate=&_private=0&p=&sitecode=5&subsitecode=5&site=nrg";
		url="http://www.nrg.co.il/luach_nrg/owa/count_hit?board_num=60&url="+escape(url);
	 }
	 window.open(url, "_blank","","status=1,toolbar=1,width=850,height=600");
	 submitBtn.style.filter="alpha(opacity=100)";
	 submitBtn.style.opacity="1";
	 submitBtn.disabled=false;
     break;
 }
}

/* END SEARCH */

function setHomePage() {
	if (navigator.userAgent.indexOf("Firefox")==-1) { //IE
		get("headerLogo").style.behavior='url(#default#homepage)'; get("headerLogo").setHomePage('http://www.nrg.co.il/');
	} else sh("MakeHomeFF"); // FF
}


/* animated open/close allChannels */

 function getStyle(el) {
 	var myObj=nrg.$(el);
	if(window.getComputedStyle)
		return window.getComputedStyle(myObj,null);
	else
		return myObj.currentStyle;
 }
 
 function nrg_resize(el,step,newHeight) {
	resizeInterval = window.resizeInterval || true;
 	if(nrg.$(el)){
		clearInterval(resizeInterval);
		// shrink or enlarge ?
		var vstep=(parseInt(getStyle(el).height)<newHeight) ? step : (-1)*step;
		var d=new Date(); d=d.getTime();
		resizeInterval=setInterval("nrg_resizeMe('"+el+"','"+vstep+"','"+newHeight+"')",60);
 	}
 }
 
 function nrg_resizeMe(el,vstep,newHeight) {
	var currentHeight = parseInt(getStyle(el).height);
	if(currentHeight==newHeight) {
		if(newHeight==0) nrg.$(el).style.display="none";
		clearInterval(resizeInterval);
		window.lastStepTime=false;
//		alert("done");
		return;
	}
	var vdir=(vstep<0) ? -1 : 1; // remember vertical direction
	var remainingHeight=Math.abs(currentHeight-newHeight);
	if(remainingHeight<Math.abs(vstep)) vstep=remainingHeight*vdir; // if remainder < step
	else {
		var currentTime = new Date().getTime();
		lastStepTime = window.lastStepTime || false;
		var intervalTime=(lastStepTime) ? currentTime-lastStepTime : 0;
		if(intervalTime>60) {
			var nextStep=Math.abs(vstep)/30*intervalTime;
			vstep=(nextStep < remainingHeight) ? nextStep*vdir : remainingHeight*vdir;
		}
	}
	nrg.$(el).style.height=parseFloat(currentHeight)+parseFloat(vstep)+"px";
	window.lastStepTime=new Date().getTime();
 }
 
 function allChannels() {
 	nrgChannels_open = window.nrgChannels_open || false;
 	if(nrgChannels_open==true) {
		nrg_resize("nrgChannels",50,0);
		window.nrgChannels_open=false;
	}
	else {
		nrg.$("nrgChannels").style.display="block";
		nrg_resize("nrgChannels",50,nrg.$("nrgChannels").scrollHeight);
		window.nrgChannels_open=true;
	}
 }
/* end animated open */
