var searchArea=new Object();
searchArea.initial=function(width,mySearchAreaName,myPopUpName,searchBoxName,searchBoxFormName,searchBoxID,popUpEnable,searchBoxHeight,maxresult)
{
	this.width=width;
	this.mySearchAreaName=mySearchAreaName;
	this.mySearchAreaObject=null;//=document.getElementById(mySearchAreaName);
	this.myPopUpName=myPopUpName;
	this.searchBoxName=searchBoxName;
	this.searchBoxFormName=searchBoxFormName;
	this.myPopUpObject=null;
	this.searchBoxObject=null;
	this.resultPopUpDescription=null;
	this.popUpEnable=popUpEnable;
	this.mySearchAreaLeft=0;
	this.mySearchAreaTop=0;
	this.searchBoxID=searchBoxID;
	this.searchBoxHeight=searchBoxHeight;
	this.resultConnect=null;
	this.displayed="none";
	this.timer=1500;
	this.displayedFlag=false;
	this.timeobject=null;
	this.footer=null;
	this.containerObj=null;
	this.maxresult=maxresult;
	this.phraseArea=null;
	this.searchNetoArea=null;
	this.adverArea=null;
	this.footerarea=null;
	this.structure=null;
}
searchArea.initial.prototype={
create:function()
{
var objBody = document.getElementsByTagName("body").item(0);
var objTemp;
var tempcolr;
if(isDarkedBorder)
tempcolr=darkedcolors
else
tempcolr=colors
	//alert(tempcolr[curr_butt-1])
	objTemp = document.createElement("div");//area
	objTemp.setAttribute('id',this.mySearchAreaName);
	objTemp.setAttribute('border',1);
	objTemp.setAttribute('dir','rtl');
	objTemp.setAttribute('align',"center");
	objTemp.setAttribute('borderColor',tempcolr[curr_butt-1]);
	if(ie)
	objTemp.setAttribute('className',"mySearchAreaClass");
	else
objTemp.setAttribute('class',"mySearchAreaClass");
	objTemp.style.display = 'none';
	objTemp.style.position = 'absolute';
	objTemp.style.top = '0';
	objTemp.style.left = '0';
	objTemp.style.zIndex = '0';
objTemp.style.border = 1;
	//objTemp.innerHTML="fffffffffffffffff"
 	objBody.insertBefore(objTemp, objBody.nextSibling);
	this.mySearchAreaObject=document.getElementById(this.mySearchAreaName);

if(this.popUpEnable)
	{
	objTemp = document.createElement("div");//pop up
	objTemp.setAttribute('id',this.myPopUpName);
	objTemp.style.display = 'none';
	objTemp.style.position = 'absolute';
	if(ie)
objTemp.setAttribute('className',"popupClass");
	else
objTemp.setAttribute('class',"popupClass");
objTemp.setAttribute('dir','rtl');
objTemp.setAttribute('align','right');
	objTemp.style.top = '0';
	objTemp.style.left = '0';
	objTemp.style.zIndex = '0';
 	//objBody.insertBefore(objTemp, objBody.firstChild);
	
this.mySearchAreaObject.appendChild(objTemp)
	this.myPopUpObject=document.getElementById(this.myPopUpName);
	}



	this.mySearchAreaObject.style.width=this.width+"px"
//this.mySearchAreaObject.style.align="center"
	//this.mySearchAreaObject.style.backgroundColor=colors[curr_butt-1]
//this.mySearchAreaObject.style.backgroundColor="white"
/*if(ie){}
else
	{
this.mySearchAreaObject.style.borderWidth="3px"
this.mySearchAreaObject.style.borderLeftWidth=3
this.mySearchAreaObject.style.borderRightWidth=3
this.mySearchAreaObject.style.borderTopWidth=3
this.mySearchAreaObject.style.borderBottomWidth=3

	}*/

this.mySearchAreaObject.style.borderLeftWidth="2px"
this.mySearchAreaObject.style.borderRightWidth="2px"
this.mySearchAreaObject.style.borderTopWidth="2px"
this.mySearchAreaObject.style.borderBottomWidth="2px"

this.mySearchAreaObject.style.borderLeftColor=tempcolr[curr_butt-1]
this.mySearchAreaObject.style.borderRightColor=tempcolr[curr_butt-1]
this.mySearchAreaObject.style.borderTopColor=tempcolr[curr_butt-1]
this.mySearchAreaObject.style.borderBottomColor=tempcolr[curr_butt-1]

this.mySearchAreaObject.style.borderLeftColor=colors[curr_butt-1]
this.mySearchAreaObject.style.borderRightColor=colors[curr_butt-1]
this.mySearchAreaObject.style.borderTopColor=colors[curr_butt-1]
this.mySearchAreaObject.style.borderBottomColor=colors[curr_butt-1]
//this.mySearchAreaObject.style.borderLeftWidth=2
this.mySearchAreaObject.style.borderLeftStyle="outset"
this.mySearchAreaObject.style.borderRightStyle="inset"
this.mySearchAreaObject.style.borderTopStyle="outset"
this.mySearchAreaObject.style.borderBottomStyle="inset"
if(this.searchBoxID!="")
objTemp = document.getElementById(this.searchBoxID);
else
objTemp=eval("document."+this.searchBoxFormName+"."+this.searchBoxName);
this.searchBoxObject=objTemp;
//alert(this.searchBoxObject.offsetLeft+"**")
this.searchBoxObject.style.position="absolute"
//alert(this.searchBoxObject.clientLeft)
//alert(this.searchBoxObject.offsetLeft+"----")
	this.searchBoxObject.style.position="relative";
//alert(this.searchBoxObject.offsetLeft+"......")

this.mySearchAreaLeft=this.searchBoxObject.offsetLeft//-(this.searchBoxObject.offsetWidth/2)//+"px"//-(this.searchBoxObject.offsetWidth/2))+"px"//this.searchBoxObject.offsetLeft;
//
	//this.mySearchAreaObject.style.left="200"
//alert(this.searchBoxObject.offsetLeft-this.searchBoxObject.offsetWidth)
	//alert((this.searchBoxObject.offsetLeft-(this.searchBoxObject.offsetWidth/2)))
	this.mySearchAreaTop=(this.searchBoxObject.offsetTop+this.searchBoxHeight+3);
//alert(this.mySearchAreaLeft+"**")
	this.mySearchAreaObject.style.left=this.mySearchAreaLeft+"px"

		//document.getElementById("rr1").style.left=this.mySearchAreaLeft+"pt"
this.mySearchAreaObject.style.top=this.mySearchAreaTop+"px"
//alert(document.getElementById("rr1").style.left+"======")

	this.searchBoxObject.onfocus = function (e) {
	netoSearch.searchBoxChecked(e);
	//alert()
	}
this.structure=new searchAreaStructure.initial(this)
	



this.mySearchAreaObject.onmouseover=function(e)
	{
	netoSearch.displayedFlag=false;
//document.getElementById("wsp").innerHTML=document.getElementById("wsp").innerHTML+"<br>area over"
	if(netoSearch.timeobject!=null)
clearTimeout(netoSearch.timeobject)//////////////////////////////////////////
	}







this.mySearchAreaObject.onmouseout=function(e)
	{
	

if(!netoSearch.isContained(netoSearch.mySearchAreaObject,e) && !netoSearch.isContained(netoSearch.searchBoxObject,e))
		{
	netoSearch.displayedFlag=true;
	//document.getElementById("wsp").innerHTML=document.getElementById("wsp").innerHTML+"<br>area out="+netoSearch.displayedFlag
//netoSearch.mySearchAreaObject.style.display="none";
netoSearch.timeobject=setTimeout("netoSearch.hideArea()", netoSearch.timer);
		}
	}



this.searchBoxObject.onmouseout=function(e)
	{
//if(netoSearch.isContained(netoSearch.searchBoxObject,e))
	//return;

if(!netoSearch.isContained(netoSearch.mySearchAreaObject,e) && !netoSearch.isContained(netoSearch.searchBoxObject,e))
		{
//netoSearch.mySearchAreaObject.style.display="none";
//document.getElementById("wsp").innerHTML=document.getElementById("wsp").innerHTML+"<br>box out"
netoSearch.displayedFlag=true;
//document.getElementById("wsp").innerHTML=document.getElementById("wsp").innerHTML+"<br>box out="+netoSearch.displayedFlag
netoSearch.timeobject=setTimeout("netoSearch.hideArea()", netoSearch.timer);
		}
	}



this.searchBoxObject.onmouseover=function(e)
	{
		netoSearch.displayedFlag=false;
		if(netoSearch.timeobject!=null)
clearTimeout(netoSearch.timeobject)////////////////////////////////
		//document.getElementById("wsp").innerHTML=document.getElementById("wsp").innerHTML+"<br>cox over"
		if(netoSearch.mySearchAreaObject.style.display=="none"){
//if((netoSearch.resultConnect.results.length>0 || netoSearch.resultConnect.resultsAdver.length>0) && netoSearch.searchBoxObject.value!="")
if((netoSearch.resultConnect.results.length>0 || netoSearch.resultConnect.resultsAdver.length>0 || netoSearch.resultConnect.searches.length>0) && netoSearch.searchBoxObject.value!="")
	{
	//alert("run")
netoSearch.resultConnect.run();
	}}
	}

this.resultConnect=new connectionResultObject.initial();

},
isContained:function(m, e){
	var e=window.event || e
	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
	if (c==m)
		return true
	else
		return false
},
hideArea:function()
	{
clearTimeout(this.timeobject);
	this.timeobject=null
		//document.getElementById("wsp").innerHTML=document.getElementById("wsp").innerHTML+"<br>hideArea="+this.displayedFlag
if(this.displayedFlag)
		{
	//document.getElementById("wsp").innerHTML=document.getElementById("wsp").innerHTML+"="+this.displayedFlag
this.mySearchAreaObject.style.display="none";
//this.adverArea.innerHTML=""
//this.phraseArea.innerHTML=""
clearallW()
		}
},

searchBoxChecked:function(e)
{
var evtobj=window.event? window.event : e;
if(evtobj.type=="focus")
	{
this.searchBoxObject.onfocus="";
this.searchBoxObject.onkeyup = function (e) {
	runSearch()
	}
this.searchBoxObject.onblur = function (e) {
netoSearch.searchBoxblur();
	}

if(this.resultConnect.results.length>0 && this.searchBoxObject.value!="")
	{
	//alert("run")
this.resultConnect.run();
	}
	else if(this.searchBoxObject.value!="")
		{
runSearch()
		}
}
},
searchBoxblur:function()
{
this.searchBoxObject.onkeyup="";
this.searchBoxObject.onblur="";
this.searchBoxObject.onfocus = function (e) {
netoSearch.searchBoxChecked(e);
	}
	
//document.getElementById("bodys").innerHTML=""
},
resultsDisplay:function()
	{
	//alert(this.resultConnect.results+"****")
this.phraseArea.style.display="none";
this.phraseArea.innerHTML="";
var ssstr=""
var maxcurrentresult=maxResult
	if(maxcurrentresult>this.resultConnect.results.length)
maxcurrentresult=this.resultConnect.results.length
for(ii=0;ii<maxcurrentresult;ii++)
	{
tempstr=this.resultConnect.results[ii].replace(this.resultConnect.newValue,"<span class='underlinephraseResult'>"+this.resultConnect.newValue+"</span>")
ssstr+="<div onmouseover='rover(this)' onmouseout='rout(this)' class='phraseResultover'><a href='#' onclick='inserttex(\""+this.resultConnect.results[ii]+"\")' class='phraseResultText'>"+tempstr+"</a></div>"
	}//##F6F6F6
	//alert(ssstr)
	if(ssstr!="")
		{
var separator=separatorDiv.replace("[title]",separatorDivResultTitle)
	separator=separator.replace("[bcolor]",colors[curr_butt-1])
//document.getElementById("aar").value=ssstr
this.phraseArea.innerHTML=separator+ssstr //this.resultConnect.results.join("<br>")
this.phraseArea.style.display="block";
this.mySearchAreaObject.style.display="block";
		}
		else
		{
this.mySearchAreaObject.style.display="none";
clearall()
		}
	//alert(ssstr)
	},

resultsAdverDisplay:function()
	{
	//alert("a")
//if(this.resultConnect.allResultsAdver[0]!=null && typeof this.resultConnect.allResultsAdver[0]!="undefined")
//var tempstr=this.resultConnect.allResultsAdver[0]
var advercontent=""
var maxadver=maxAdverResult
	if(maxadver>this.resultConnect.resultsAdver.length)
	maxadver=this.resultConnect.resultsAdver.length
	//alert(maxadver)
for(y=0;y<maxadver;y++)
		{
	//alert(this.resultConnect.resultsAdver[y]+"***")
	if(this.resultConnect.resultsAdver[y]!=null && typeof this.resultConnect.resultsAdver[y]!="undefined" && this.resultConnect.resultsAdver[y]!="")
			{
		//alert("pp")
if(y==(maxadver-1))
	advercontent+="<span class='oneAdverResultContainer'>"+this.resultConnect.resultsAdver[y]+"</span>"
else
	advercontent+="<span class='oneAdverResultContainer'>"+this.resultConnect.resultsAdver[y]+"</span>"+"<hr class='adverHr'>"
			}
//advercontent+="<span class='oneAdverResultContainer'>"+this.resultConnect.resultsAdver[y]+"</span>"

		}
		if(advercontent!="" && typeof advercontent!="undefined" && advercontent!="undefined")
		{
//alert(advercontent+"----")
// this.adverArea.innerHTML="<hr color='"+colors[curr_butt-1]+"'>"+advercontent
var tempseparatorDiv=separatorDiv
var separator=tempseparatorDiv.replace("[title]",separatorDivAdverTitle)
	separator=separator.replace("[bcolor]",colors[curr_butt-1])
	this.adverArea.innerHTML=separator+advercontent
this.adverArea.innerHTML=separator+advercontent
	//alert(separator+"<br>"+advercontent)
this.adverArea.style.display="block";
this.mySearchAreaObject.style.display="block";
		}
	},
		netoSearchDisplay:function()
	{
		this.searchNetoArea.style.display="none";
		this.searchNetoArea.innerHTML="none";
var netoSearchcontent=""
var maxresult=maxNetoSearchResult
	if(maxresult>this.resultConnect.searches.length)
	maxresult=this.resultConnect.searches.length
	//alert("maxresult="+maxresult)
for(y=0;y<maxresult;y++)
		{
	//alert(this.resultConnect.resultsAdver[y]+"***")
	if(this.resultConnect.searches[y]!=null && typeof this.resultConnect.searches[y]!="undefined" && this.resultConnect.searches[y]!="")
netoSearchcontent+=this.resultConnect.searches[y][0]

		}
		if(netoSearchcontent!="" && typeof netoSearchcontent!="undefined" && netoSearchcontent!="undefined")
		{
//alert(advercontent+"----")
// this.searchNetoArea.innerHTML="<hr color='"+colors[curr_butt-1]+"'>"+netoSearchcontent
var separator=separatorDiv.replace("[title]",separatorDivSearchTitle)
	separator=separator.replace("[bcolor]",colors[curr_butt-1])
this.searchNetoArea.innerHTML="<br>"+separator+netoSearchcontent
this.searchNetoArea.style.display="block";
this.mySearchAreaObject.style.display="block";
		}
	},
resultsAdverDisplayL:function()
	{
	//alert("a")
//if(this.resultConnect.allResultsAdver[0]!=null && typeof this.resultConnect.allResultsAdver[0]!="undefined")
//var tempstr=this.resultConnect.allResultsAdver[0]
var advercontent=""
var maxadver=maxAdverResult
	if(maxadver>this.resultConnect.resultsAdver.length)
	maxadver=this.resultConnect.resultsAdver.length
	//alert(maxadver+"=maxadver")
for(y=0;y<maxadver;y++)
		{
	//alert(this.resultConnect.resultsAdver[y]+"***")
	if(this.resultConnect.resultsAdver[y]!=null && typeof this.resultConnect.resultsAdver[y]!="undefined" && this.resultConnect.resultsAdver[y]!="")
			{
	if(y==(maxadver-1))
	advercontent+="<span class='oneAdverResultContainer'>"+this.resultConnect.resultsAdver[y]+"</span>"
else
	advercontent+="<span class='oneAdverResultContainer'>"+this.resultConnect.resultsAdver[y]+"</span>"+"<hr class='adverHr' width='100%'>"

			}
		}
		if(advercontent!="" && typeof advercontent!="undefined" && advercontent!="undefined")
		{
//alert(advercontent+"----")
// this.adverArea.innerHTML="<hr color='"+colors[curr_butt-1]+"'>"+advercontent
//this.adverArea.innerHTML="<br><div class='padded' style='background-color: #ffebc7; font-size: 10px'>פרסומות</div>"+advercontent
	var separator=separatorDiv.replace("[title]",separatorDivAdverTitle)
	separator=separator.replace("[bcolor]",colors[curr_butt-1])
this.adverArea.innerHTML="<br>"+separator+"<br>"+advercontent
this.adverArea.style.display="block";
this.mySearchAreaObject.style.display="block";
		}
	}

}







