function fill(combo, name, src)
{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.status != 200)
			{
				alert("שגיאה! - " + xmlhttp.status);
				return;
			}
			var doc = new ActiveXObject("Microsoft.XMLDOM");
			doc.async = false;
			doc.loadXML(xmlhttp.responseText);
			var nodes = doc.selectNodes("xml/rs:data/z:row");
			combo.length = 1;
			for (i=0; i < nodes.length; i++)
			{
				var opt = document.createElement("OPTION");
				opt.value = nodes[i].getAttribute("ID");
				opt.text = nodes[i].getAttribute("Name");
				combo.add(opt);
			}
			xmlhttp = null;
			doc = null;
		}
	}
	xmlhttp.open("GET", "getxml.asp?" + name + "=" + src.value, true);
//	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send();
}

function updateClicks(id)
{
	 var myAjax = new Ajax.Request(
	   'updateClicks.asp?AdvertiseID='+id,
	   {
		method: 'get', 
		onComplete: function(response) { 
		 	//alert(response.responseText);
			if (response.responseText != '0') { alert('איראה שגיאה'); }
			
		}
		
	   }
	);	
}
function add(src, tar)
{
	for (i = 0; i < src.options.length; i++)
	{
		if (src.options[i].selected)
		{
			exists = false;
			for (j = 0; j < tar.options.length; j++)
				if (tar.options[j].value == src.options[i].value)
					exists = true;
			if (!exists)
			{
				var opt = document.createElement("OPTION");
				tar.options.add(opt);
				opt.innerText = src.options[i].innerText;
				opt.value = src.options[i].value;
			}
		}
		src.options[i].selected = false;
	}
}

function remove(src)
{
	for (i = src.options.length-1; i >= 0; i--)
		if (src.options[i].selected)
			src.options.remove(i);
}

function filterletter(src, letter)
{
	var full = document.getElementById("temp");
	if (!full)
	{
		full = document.createElement("SELECT")
		src.parentElement.appendChild(full);
		full.id = "temp";
		full.style.display = "none";
		for (i = 1; i < src.options.length; i++)
		{
			full.options.add(opt = document.createElement("OPTION"));
			opt.value = src.options[i].value;
			opt.innerText = src.options[i].innerText;
		}
	}
	for (i = src.options.length-1; i > 0; i--)
		src.options[i] = null;;
	for (i = 0; i < full.options.length; i++)
		if (letter == "" || full.options[i].innerText.charAt(0) == letter)
		{
			src.options.add(opt = document.createElement("OPTION"));
			opt.value = full.options[i].value;
			opt.innerText = full.options[i].innerText;
		}
	if (letter != "" && src.options.length > 1) src.selectedIndex = 1;
	src.fireEvent("onchange");
}

function redirectSearch()
{
	oForm = document.searchPortals;
	if (oForm.query.value == "")
	{
		alert("יש לרשום מילת חיפוש");
		return false;
	}
	for (i=0; i<oForm.rdSearchSite.length; i++)
		if (oForm.rdSearchSite[i].checked)
		{
			window.open(oForm.rdSearchSite[i].value + oForm.query.value);
			return true;
		}
	alert("יש לבחור מנוע חיפוש");
	return false;
}

function btnSubmit_Click(oForm)
{
	oForm.submit();
}

/*function window.onscroll()
{
	obj = document.getElementById("sidebanner");
	if (!obj) return;
	obj.style.top = document.body.scrollTop;
}*/

function printPage()
{
	args = "top=100, left=100, height=500, width=650, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("print.asp", "Print", args);
}

function overData()
{
	var obj = window.event.srcElement;
	if (obj.tagName == "TD")
	{
		if (obj.parentElement.className.indexOf("click") < 0)
			obj.parentElement.className += " over";
	}
	else if (obj.tagName == "TH")
	{
		obj.className = "over";
	}
}

function outData()
{
	var obj = window.event.srcElement;
	if (obj.tagName == "TD")
	{
		if (obj.parentElement.className.indexOf("over") > 0)
			obj.parentElement.className = obj.parentElement.className.replace(" over", "");
	}
	else if (obj.tagName == "TH")
	{
		obj.className = "";
	}
}

function showHotAd(ID,Type)
{
	//args = "top=0, left=0, height=675, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showhotad.asp?AdvertiseID=" + ID + "&Type=" + Type);
}

function showAdPic(ID)
{
	args = "top=0, left=0, height=675, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showPhotos.asp?AdvertiseID=" + ID, "Advertise"+ID, args);
}

function showPic(ID)
{
	args = "top=0, left=0, height=675, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open("showPhoto.asp?FileID=" + ID, "Photo_"+ID, args);
}

function openPage(url)
{
	args = "top=0, left=0, height=500, width=700, status=no, toolbar=no, menubar=no, scrollbars=yes, location=no";
	window.open(url, "popupPage", args);
}

function img_onmouseover(source_pic){
	var imgSrc = new Image();
	imgSrc.src=source_pic;
	img_0.src=imgSrc.src;
}

function mov_onmouseover(source_mov){
	obj = document.getElementById("mov_0");
	obj.fileName = source_mov;
}

function showHide(id)
{
	//var obj = window.event.srcElement;
	oDiv = document.getElementById(id);
	if (oDiv)
	{
		if (oDiv.style.display == "none")
		{
			oDiv.style.display = "";
		}
		else
		{
			oDiv.style.display = "none";
		}
	}
}
function showAd(url,id)
{			
	var obj = window.event.srcElement;
	URL = url + "_result_box.asp?AdvertiseID="+id;
	if(document.all("AdDetails_" + id).innerHTML=="")
	{
  		document.all("AdDetails_" + id).innerHTML="<iframe  src='" + URL + "' width='100%' height='430' frameborder='0' scrolling='auto'></iframe>";
		obj.parentElement.className += " click";
	 }
	else
	 {
		document.all("AdDetails_" + id).innerHTML="";
		obj.parentElement.className = obj.parentElement.className.replace(" click", "");
	 }	
}

function loadPage(url)
{
	var obj = window.event.srcElement;
	window.location.replace(url + obj.value);
}

function select_on_click(sel)
{ 

	 var i; 
	 //var sel = document.getElementByID(id);
	 var opt = sel.options[sel.selectedIndex]; 

	 if (opt.id != "") { 
	  opt.id = opt.uniqueID; 
	 } 
	 else { 
	  opt.id = ""; 
	 } 
	 for (i=0; i < sel.options.length; i++) { 
	  if (sel.options[i].id != "") { 
	   sel.options[i].selected = true; 
	  } 
	 } 
} 

function login(form)
{
	if (((form.Email.value == "" || !form.Email.value.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/)) && form.Username.value == "") || form.Password.value == "")
	{
		alert("יש להקליד שם משתמש או אימייל וסיסמה");
		return false;
	}
	form.submit();
}

function tenderlogin(form)
{
	if ((form.Username.value == "") || form.Password.value == "")
	{
		alert("נא להקליד שם משתמש וסיסמא");
		return false;
	}
	form.submit();
}

function contact(form)
{
	if (form.Email.value == "" || !form.Email.value.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/) || form.ContactName.value == "")
	{
		alert("יש להזין שם  מלא ואימייל");
		return false;
	}
	form.submit();
}

function setHomepage()
{
	document.body.style.behavior="url(#default#homepage)";
	document.body.setHomePage("http://www.bonimonline.co.il")	
}

function addFavorite()
{
	window.external.AddFavorite('http://www.bonimonline.co.il','בונים אונליין')
}


function NewWindow(mypage,myname,w,h,scroll,pos){
var	win;
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

//----------------------------- NO RIGHT CLICK -------------------------------
// (C) 2003 CodeLifter.com
// Source: CodeLifter.com
// Do not remove this header

// Set the message for the alert box
am = "כל הזכויות שמורות לבונים אונליין";

// do not edit below this line
// ===========================
bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"

function nrc(e) {
   if (bNS && e.which > 1){
      alert(am)
      return false
   } else if (bIE && (event.button >1)) {
     alert(am)
     return false;
   }
}

document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = nrc;
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
/***********************************************
* Disable select-text script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
* Modified here to exclude form tags properly and cross browser by jscheuer1
***********************************************/

//form tags to omit:
var omitformtags=["input", "textarea", "select"]

function disableselect(e){
for (i = 0; i < omitformtags.length; i++)
if (omitformtags[i]==(e.target.tagName.toLowerCase()))
return;
return false
}

function reEnable(){
return true
}

function noSelect(){
	if (typeof document.onselectstart!="undefined"){
		document.onselectstart=new Function ("return false")
		if (document.getElementsByTagName){
		tags=document.getElementsByTagName('*')
		for (j = 0; j < tags.length; j++){
			for (i = 0; i < omitformtags.length; i++)
				if (tags[j].tagName.toLowerCase()==omitformtags[i]){
					tags[j].onselectstart=function(){
						document.onselectstart=new Function ('return true')
						}
						tags[j].onmouseup=function(){
						document.onselectstart=new Function ('return false')
					}
				}
			}
		}
	}
	else{
		document.onmousedown=disableselect
		document.onmouseup=reEnable
	}
}

window.onload=noSelect;
