/*
 * generate 2 random 10 digit numbers
 */
var dcrnd=Math.floor(Math.random()*9999999999);
var dcrnd1 = Math.floor(Math.random()*9999999999);

function switchSearch(sElem)
{	
	if(!sElem.checked)
		return;
	var ts=sElem.value;
	if ((ts!="http://msxml.excite.com/info.xcite/search/web/")&&(ts!="http://www.dogpile.com/info.dogpl/search/web/"))
	{		
		if(ts.indexOf(";")>=0)
		{
			ts=ts.split(";")[1] + "?" + ts.split(";")[0] + "=@@GetSW@@";
		}/*
		if (ts.indexOf('portelo')>0) {
			ts=sElem.value;
			ts=ts.split(";")[1] + "?" + ts.split(";")[0] + "=escape('@@GetSW@@')";
			alert(ts);
		}*/
	}
	else
	{
			ts=ts+"@@GetSW@@";
	}

	sElem.value=ts;
}


function validateForm(form)
{
	if (document.Form1.txtSearch.value=="")
	{
		alert(".חובה להכניס ערך לחיפוש");
	}
	else
	{
		for(i=0;i<form.RadioGroup.length;i++)
		{
		if(form.RadioGroup[i].checked==true && (form.RadioGroup[i].value.indexOf("@@GetSW@@")>0 || form.RadioGroup[i].value=="http://www.morfix.co.il/defaultp.asp"))
			{
				var tv=form.RadioGroup[i].value
				if (tv=="http://www.dogpile.com/info.dogpl/search/web/")
				{
					form.action="http://www.dogpile.com/info.dogpl/search/web/"+document.Form1.txtSearch;
					form.method="post";
					//alert(tv);
					form.submit();			
				}
				if (tv=="http://www.ynet.co.il/home/1,7340,L-283,00.html?SearchType=TopNav&criteria=@@GetSW@@&txtSearchString=@@GetSW@@&txtChanID=5&select1=Web")
				{
					
					if(document.Form1.target=="_blank")
					{
						window.open("http://goop.co.il/Goop/pl_html/incodeserch.aspx?name="+document.Form1.txtSearch.value,'');
					}
					else
					{
						parent.location="http://goop.co.il/Goop/pl_html/incodeserch.aspx?name="+document.Form1.txtSearch.value;			
					}
					break;			
				}
				var tv=form.RadioGroup[i].value
				if (tv=="http://msxml.excite.com/info.xcite/search/web/")
				{
					form.action="http://msxml.excite.com/info.xcite/search/web/"+document.Form1.txtSearch;
					form.method="post";
					form.submit();
				}
				if(tv=="http://www.morfix.co.il/defaultp.asp")
				{
					form.action="http://www.morfix.co.il/defaultp.asp";
					form.method="post";
					form.submit();
					return;
				}
				// escaping the search query
				if (tv.indexOf('portelo')>0) {
					tv=tv.replace("@@GetSW@@",escape(document.Form1.txtSearch.value));
				}
				else {
					tv=tv.replace("@@GetSW@@",document.Form1.txtSearch.value);
					tv=tv.replace("@@GetSW@@",document.Form1.txtSearch.value);
				}
				if(document.Form1.target=="_blank")
				{
					window.open(tv,'');
				}
				else
				{
					parent.location=tv;
					break;			
				}
			}
		}
	}
	return false;
}

function openPop(url,w,h)
{
	var baseURL='http://www.goop.co.il/goop/pl_pops/';
	url=baseURL + url;
	window.open(url,"pop","width="+w+",height="+h+",resizable,scrollbars=true");
}