var linkToSearch = "";
var omG = 0;

// <jsFunction>
// SearchClick(id)
// the function show and hide the top menu of Search
// </jsFunction>
function SearchClick(id)
{
	var index;
	theId = document.getElementById("SearchId" + id);
	if (id==8)
	{
		if(theId.className == "SearchTopLink")
		{
			theId.className = "SearchTopLinkPress";
			for(index = 1;index<8;index++)
			{
				try {
					document.getElementById("SearchId" + index).className = "SearchTopLink";
				} catch(ex) {}
			}
			document.getElementById("SearchAdvDiv").style.display = "none";
			document.getElementById("SearchPoweredDiv").className = "SearchPowered";
		}
		else
		{
			theId.className = "SearchTopLink";
			document.getElementById("SearchAdvDiv").style.display = "";
			document.getElementById("SearchPoweredDiv").className = "SearchPoweredHide";
		}
	}
	else
	{
		if(theId.className == "SearchTopLink")
		{
			theId.className = "SearchTopLinkPress";
			document.getElementById("SearchId8").className = "SearchTopLink";
			document.getElementById("SearchAdvDiv").style.display = "";
			document.getElementById("SearchPoweredDiv").className = "SearchPoweredHide";
		}
		else
		{
			theId.className = "SearchTopLink";
		}
	}
	
	
	switch(id)
	{
		case 1:
			web = getOpzIntBol(web);
			google = 0;
			break;
		case 2:
			forums = getOpzIntBol(forums);
			google = 0;
			break;
		case 3:
			images = getOpzIntBol(images);
			google = 0;
			break;
		case 4:
			blogs = getOpzIntBol(blogs);
			google = 0;
			break;
		case 5:
			shopping = getOpzIntBol(shopping);
			google = 0;
			break;
		case 6:
			flix = getOpzIntBol(flix);
			google = 0;
			break;
		case 7:
			wiki = getOpzIntBol(wiki);
			google = 0;
			break;
		case 8:
			google = getOpzIntBol(google);
			if (google == 1)
			{
				web = 0;
				forums = 0;
				images = 0;
				blogs = 0;
				shopping = 0;
				flix = 0;
				wiki = 0;
			}
			else
			{
				web = 1;
				forums = 1;
				images = 1;
				blogs = 0;
				shopping = 0;
				flix = 0;
				wiki = 0;
			}
			if (document.getElementById("q").value != "")
			{
				SeacrhClick();
			}
			break;
	}
}

// <jsFunction>
// getOpzIntBol(b)
// 
// </jsFunction>
function getOpzIntBol(b)
{
	if (!Boolean(b) == true)
		return 1;
	else
		return 0;
}

// <jsFunction>
// SeacrhClick()
// the function send the query string to the search link
// </jsFunction>
function SeacrhClick()
{
	if (document.getElementById("q").value == "")
	{
		document.getElementById("q").value = "נא להקליד מילת חיפוש";
		return false;
	}
	else
	{
		linkToSearch = "http://www.tapuz.co.il/Search/include/fromHP.asp?q=" + escape(document.getElementById("q").value)
		if (Boolean(web))
			linkToSearch += "&web=1";
		if (Boolean(forums))
			linkToSearch += "&forums=1";
		if (Boolean(images))
			linkToSearch += "&images=1";
		if (Boolean(blogs))
			linkToSearch += "&blogs=1";
		if (Boolean(shopping))
			linkToSearch += "&shopping=1";
		if (Boolean(flix))
			linkToSearch += "&flix=1";
		if (Boolean(wiki))
			linkToSearch += "&wikipedia=1";
		if (Boolean(google))
			linkToSearch += "&google=1";
	
		linkToSearch += "&om=1";
		linkToSearch += "&omG=" + omG;
	
		window.location.href = linkToSearch;
	}
}

function SeacrhClickPress(e)
{
	if (document.all)
    {
        if(event.keyCode==13)
        { 
            SeacrhClick();
        }
     }
     else
     {
        if(e.keyCode==13)
        { 
            SeacrhClick();
        }
     }
}

// <jsFunction>
// FlixPlay(attch,msgID)
// this function create the player in HP in Flix section
// </jsFunction>
function FlixPlay(attch,msgID,pic,autostart,link)
{
	var AdvSound;
	if (readCookie("AdvSound")=="true")
	{
		AdvSound = "false";
	}
	else
	{
		AdvSound = "true";
		createCookie("AdvSound","true",1/3);
	}
	
	if (autostart == "false")
	{
		AdvSound = "true";
	}
	
	document.getElementById("FlixPlayerDiv").innerHTML = "";
	document.getElementById("FlixPlayerDiv").innerHTML = "<object id='playerObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='165' height='139' align='middle'>" +
		"<param name='allowScriptAccess' value='sameDomain' />" +
		"<param id='flashVideoMovie'  name='movie' value='HP/HPimages/FlixPlayer_Mute_11.swf?link="+link+"&file="+attch+"&Pic=" + pic + "&autoStart=" + autostart + "&AdvSound=" + AdvSound + "&ADV_file=" + introclip + "&mediaId=" + msgID + "' />" +
		"<param name='quality' value='high' />" +
		"<param name='bgcolor' value='#ffffff' />" +
		"<embed id='flashVideoMovieEMBD' src='HP/HPimages/FlixPlayer_Mute_11.swf?link="+link+"&file="+attch+"&Pic=" + pic + "&autoStart=" + autostart + "&AdvSound=" + AdvSound + "&ADV_file=" + introclip + "&mediaId=" + msgID + "' quality='high' bgcolor='#ffffff' width='165' height='139'  align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
		"</object>";
}

function New_FlixPlay( attch, msgID, pic, autostart, link, divName )
{
	var AdvSound = "false";
	if (autostart == "false") AdvSound = "true";

      var SrcURL = "HP/HPimages/FlixPlayer_Mute_11.swf?link="      + link      + 
	                                               "&file="      + attch     + 
				                             "&Pic="       + pic       + 
								     "&autoStart=" + autostart + 
								     "&AdvSound="  + AdvSound  + 
								     "&ADV_file="  + introclip + 
								     "&mediaId="   + msgID ;
	if ( document.getElementById(divName) )
      {
	 document.getElementById(divName).innerHTML = "";
	 document.getElementById(divName).innerHTML = 
	   "<object id='playerObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
	   "   codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' " +
	   "   width='152' height='114' align='middle'>" +
	   "<param name='allowScriptAccess' value='sameDomain' />" +
	   "<param id='flashVideoMovie' name='movie' value='" + SrcURL + "' />" +
	   "<param name='quality' value='high' />" +
	   "<param name='bgcolor' value='#ffffff' />" +
	   "<embed id='flashVideoMovieEMBD' " +
	   "       src='" + SrcURL + "' " +
         "	     quality='high' bgcolor='#ffffff' " +
	   "       width='152' height='114' align='middle' " +
	   "       allowScriptAccess='sameDomain' " +
	   "       type='application/x-shockwave-flash' " +
	   "       pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
	   "</object>";
	}   
}

function writeMavchena()
{
	document.getElementById("MavchenaDiv").innerHTML = "";
	document.getElementById("MavchenaDiv").innerHTML = "<object id='playerObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='113' height='288' align='middle'>" +
		"<param name='allowScriptAccess' value='sameDomain' />" +
		"<param id='flashVideoMovie'  name='movie' value='HP/HPimages/Mavhinot_11.swf?xmlFile=http://www.tapuz.co.il/hp/mavhena.xml' />" +
		"<param name='quality' value='high' />" +
		"<param name='bgcolor' value='#ffffff' />" +
		"<param name='wmode' VALUE='transparent' />" +
		"<embed id='flashVideoMovieEMBD' wmode='transparent' src='HP/HPimages/Mavhinot_11.swf?xmlFile=http://www.tapuz.co.il/hp/mavhena.xml' quality='high' bgcolor='#ffffff' width='113' height='288'  align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
		"</object>";
}

function writeFlashLogoPar(fname)
{
	document.getElementById("LogoImgDiv").innerHTML = "";
	document.getElementById("LogoImgDiv").innerHTML = "<object id='logoObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='238' height='77' align='middle'>" +
		"<param name='allowScriptAccess' value='sameDomain' />" +
		"<param id='flashVideoMovie'  name='movie' value='" + fname + "' />" +
		"<param name='quality' value='high' />" +
		"<param name='bgcolor' value='#ffffff' />" +
		"<param name='wmode' VALUE='transparent' />" +
		"<embed id='logoObj' wmode='transparent' src='" + fname + "' quality='high' bgcolor='#ffffff' width='238' height='77'  align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
		"</object>";
}

function writeFlashBannerBetihut()
{
	if (parseInt(window.screen.availWidth) > 1000)
	{
	    document.getElementById("bannerBetihutDiv").innerHTML = "";
	    document.getElementById("bannerBetihutDiv").innerHTML = "<object id='bannerBetihutObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='40' height='240' align='middle'>" +
		    "<param name='allowScriptAccess' value='sameDomain' />" +
		    "<param id='flashVideoMovie'  name='movie' value='HP/HPimages/logo_icon2a.swf' />" +
		    "<param name='quality' value='high' />" +
		    "<param name='bgcolor' value='#ffffff' />" +
		    "<param name='wmode' VALUE='transparent' />" +
		    "<embed id='bannerBetihutObj' wmode='transparent' src='HP/HPimages/logo_icon2a.swf' quality='high' bgcolor='#ffffff' width='40' height='240'  align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
		    "</object>";
		if (!tapuz_browser_is.ie)
		{
		    document.getElementById("bannerBetihutDiv").style.left = "240px";
		}
    }
}

// <jsFunction>
// onLoadTODO()
// the function run from ONLOAD of Body
// </jsFunction>
function onLoadTODO()
{
	SetAsrto();
}

function SetAsrto()
{
	if (document.getElementById('astrologyDiv') && 1==1)
	{
		
		try
		{
			astrologyId = parseInt(document.getElementById('astrologyDiv').innerHTML);
			astrologyStr =	"<div style='overflow:hidden;height:90px;'>" +
								"<div style='float:left;width:150px;'>"+
									"<a href='/HP/Include/HpPersonalClick.asp?who=4&ParentId="+ signId[astrologyId] +"&TheId=0&TheUrl=/astrology/default.asp$signId="+ signId[astrologyId] +"' style='color:black;font-family:arial;text-decoration:none;font-size:12px;'>" +
										"<strong>" + signname[astrologyId] + ":</strong><br>" + sign[astrologyId] + 
									"</a>" +
									"<br>" +
									"<a href='/HP/Include/HpPersonalClick.asp?who=4&ParentId="+ astrologyId +"&TheId=0&TheUrl=/astrology/default.asp$signId="+astrologyId+"' style='color:#5280A1;font-family:arial;text-decoration:none;font-size:12px;'>" +
										"<img src='/HP/HPimages/FlixArrow.gif' border='0'>&nbsp;לתחזית המורחבת של תפוז" +
									"</a>" +
									"<br>" +
									"<a href='http://www.flix.co.il/tapuz/channel.asp?c=55' style='color:#5280A1;font-family:arial;text-decoration:none;font-size:12px;'>" +
										"<img src='/HP/HPimages/FlixArrow.gif' border='0'>&nbsp;תחזית שבועית בוידאו" +
									"</a>" +
								"</div>" +
								"<div style='float:right;width:70px;'>"+
									"<img src='/HP/HPimages/astro/ico_" + astrologyId + ".gif' alt='' border='0' />" +
								"</div>" +
								"<div id='astrologyIdDiv' style='float:right;display:none;'>" + astrologyId + "</div>"
							"</div>"
			document.getElementById('astrologyDiv').innerHTML = astrologyStr;
		}
		catch(e)
		{}
	}
}

//=============================coockie===================================
function createCookie(name,value,days)
{
	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=/";
}

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,"",-1);
}
//=============================cookie====================================


//=============================Flix======================================
function getMediaGradeByStars(mediaGrade,starColor)
{
	if(mediaGrade==0)
		return(0);
	var starsStr = '';
	var i = 0;
	var roundedMediaGrade = parseInt(mediaGrade);
	if(starColor)
	{
		if(mediaGrade!=roundedMediaGrade)
		{
			starsStr = '<img align="absmiddle" src="/flix/images/HalfStar_'+starColor+'.gif">';
		}
		for(i = 0 ; i < roundedMediaGrade ; i++)
		{
			starsStr += '<img align="absmiddle" src="/flix/images/Star_'+starColor+'.gif">';
		}
	}
	else
	{
		if(mediaGrade!=roundedMediaGrade)
		{
			starsStr = '<img align="absmiddle" src="/flix/images/HalfStar.gif">';
		}
		for(i = 0 ; i < roundedMediaGrade ; i++)
		{
			starsStr += '<img align="absmiddle" src="/flix/images/Star.gif">';
		}
	}
	return(starsStr);
}
//=============================Flix======================================

function CapiutValid()
{
		
	if (document.getElementById("AgeRange").value == 0)
	{
		document.getElementById("AgeFrom").value = 16
		document.getElementById("AgeTo").value   = 24
	}
	if (document.getElementById("AgeRange").value == 1)
	{
		document.getElementById("AgeFrom").value = 25
		document.getElementById("AgeTo").value   = 35
	}
	if (document.getElementById("AgeRange").value == 2)
	{
		document.getElementById("AgeFrom").value = 36
		document.getElementById("AgeTo").value   = 45
	}
	if (document.getElementById("AgeRange").value == 3)
	{
		document.getElementById("AgeFrom").value = 45
		document.getElementById("AgeTo").value   = 54
	}
	if (document.getElementById("AgeRange").value == 4)
	{
		document.getElementById("AgeFrom").value = 55
		document.getElementById("AgeTo").value   = 120
	}
		
	if (document.getElementById("mySex").value=='' || document.getElementById("ReqSex").value=='' || document.getElementById("AgeFrom").value=='' || document.getElementById("AgeTo").value=='')
	{
		alert('יש לבחור את כל שלושת השדות');
		//return false; 
	}
	else
	{
		//return true;
		document.getElementById("simpleSearch").submit();
	}
}

function TODOPageOrder(Order)
{
      //-----------------------------------------------------
      var obTP1 = document.getElementById("divTapuzPeople");
      var obTP2 = document.getElementById("divTapuzPeople2");	 
      if (obTP1 && obTP2 ) 
	{
        obTP1.innerHTML = obTP2.innerHTML;
        obTP2.innerHTML = "";	     
      }
      //-----------------------------------------------------

	if (Order == 1)
	{
		var objParent   = document.getElementById("LeftBodyDiv");
		var personalObj = document.getElementById("PageOrder_PersonalDiv");
		var bannerObj2  = document.getElementById("PageOrder_Banner2");
		var bannerObj3  = document.getElementById("PageOrder_Banner3");
		var blogsObj    = document.getElementById("PageOrder_Blogs");			
		var forumsObj   = document.getElementById("PageOrder_Forums");					
		var forumsObj2  = document.getElementById("PageOrder_Forums2");	
		
		if (objParent)
		{
		 if (personalObj && bannerObj2)						
		     objParent.insertBefore(personalObj,bannerObj2);		
		    
		 if (blogsObj && bannerObj3)				    
		     objParent.insertBefore(blogsObj,bannerObj3);		
		    
		 if (forumsObj && bannerObj3)								    
		     objParent.insertBefore(forumsObj,bannerObj3);						
		    
		 if (forumsObj2 && bannerObj3)								    		    
		     objParent.insertBefore(forumsObj2,bannerObj3);								
		}     
	}
}

function showPersonalHelp()
{
	var objPersonalHelpDiv   = document.getElementById("personalHelpDiv");
	var objPersonalHelpDivBG = document.getElementById("personalHelpDivBG");
	
	if (objPersonalHelpDiv.style.display == "none")
	{
		objPersonalHelpDiv.style.display   = "";
		objPersonalHelpDivBG.style.display = "";
	}
	else
	{
		objPersonalHelpDiv.style.display   = "none";
		objPersonalHelpDivBG.style.display = "none";
	}
}

function fChangePersOrder(po)
{
 window.location.href = "?PageOrder=" + po;
}


// <jsFunction>
// BlogTvPlay(link,PicLink,title,broadcast)
// this function create the BlogTv preview in HP in BlogTv section
// </jsFunction>
function BlogTvPlay(link,PicLink,title,broadcast)
{
	document.getElementById("BlogTvPlayerDiv").innerHTML = "";
	document.getElementById("BlogTvPlayerDiv").innerHTML = "<object id='playerObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='180' height='135' align='middle'>" +
		"<param name='allowScriptAccess' value='sameDomain' />" +
		"<param id='flashVideoMovie' name='movie' value='HP/HPimages/Hp_BlogTV.swf?link="+link+"&PicLink="+PicLink+"&title="+title+"&broadcast="+broadcast.toLowerCase()+"' />" +
		"<param name='quality' value='high' />" +
		"<param name='bgcolor' value='#ffffff' />" +
		"<embed id='flashVideoMovieEMBD' src='HP/HPimages/Hp_BlogTV.swf?link="+link+"&PicLink="+PicLink+"&title="+title+"&broadcast="+broadcast.toLowerCase()+"' quality='high' bgcolor='#ffffff' width='180' height='135'  align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
		"</object>";
}

// <jsFunction>
// BlogTvPlay(link,PicLink,title,broadcast)
// this function create the BlogTv preview in HP in BlogTv section
// </jsFunction>
function New_BlogTvPlay( link, PicLink, title, broadcast )
{
      var SrcURL = "HP/HPimages/Hp_BlogTV.swf?link="      + link     +
	                                      "&PicLink="   + PicLink  +
							  "&title="     + title    +
							  "&broadcast=" + broadcast.toLowerCase();
	
	if (document.getElementById("BlogTvPlayerDiv"))
	{
	  document.getElementById("BlogTvPlayerDiv").innerHTML = "";
	  document.getElementById("BlogTvPlayerDiv").innerHTML = 
	      "<object id='playerObj' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " +
		"   codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' " +
		"   width='152' height='114' align='middle'>" +
		"<param name='allowScriptAccess' value='sameDomain' />" +
		"<param id='flashVideoMovie' name='movie' value='" + SrcURL + "' />" +
		"<param name='quality' value='high' />" +
		"<param name='bgcolor' value='#ffffff' />" +
		"<embed id='flashVideoMovieEMBD' " +
		"       src='" + SrcURL + "' " +
		"       quality='high' bgcolor='#ffffff' " +
		"       width='152' height='114' align='middle' " +
		"       allowScriptAccess='sameDomain' " +
		"       type='application/x-shockwave-flash' " +
		"       pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
		"</object>";
	}	
}
