function addLoadEvent(func) {
    var oldonload = window.onload;

    if (typeof window.onload != 'function') {

        window.onload = func;

    }

    else {
        window.onload = function() {

            if (oldonload) {

                oldonload();

            }

            func();

        }
    }
}

var timer=new Array();
		var browser = navigator.appName;
		var ver=0;
		if(browser=="Netscape" || browser=="Opera")
			ver=1;
		function scroller(asd,updown,aaa){
			var thediv=document.getElementById(asd);
			if(updown==1){
				var thehight=thediv.childNodes[ver].offsetHeight-parseInt(thediv.style.height);
				if(aaa==1)
					thediv.scrollTop=thehight;
				aaa=0;
				if(thediv.scrollTop==0)
					thediv.scrollTop=thehight;
				thediv.scrollTop=thediv.scrollTop-1;
			}
			else{
				if(aaa==document.getElementById(asd).scrollTop)
					thediv.scrollTop=0;
				aaa=thediv.scrollTop;
				thediv.scrollTop=thediv.scrollTop+1;
			}
				timer[asd]=setTimeout("scroller('"+asd+"',"+updown+","+aaa+")",40);
		}
		function stopscroller(asd2){
					clearTimeout(timer[asd2]);
		}

function open_select(id,select) {
	var div = document.getElementById("select"+id);
	if (div.style.display == '')
		document.getElementById("select"+id).style.display = 'none';
	else{
		//alert(document.getElementById("area").selectedIndex)
		if(id==2 && document.getElementById("area").selectedIndex == -1)
			document.getElementById("select"+id).style.display = 'none';
		else
			document.getElementById("select"+id).style.display = '';

	}

	/*if (document.getElementById(select))
	{
		document.getElementById(select).focus();
	}*/
	
}
function close_select(id) {
	document.getElementById("select"+id).style.display = 'none';
}

function select_option(select,value,flag) {
	document.getElementById("select_combo"+select).innerHTML = value;
//	document.getElementById(input).value = id;
	if(select == 1 && flag == 1)
	{
		document.getElementById("select_combo2").innerHTML = "בחר עיר";		
		document.getElementById("city").selectedIndex = 0;
	}
	close_select(select);
}

function ons(num,value,flag){
	var item=document.getElementById(value);
	select_option(num,item.options[item.selectedIndex].text, flag);
 }

 function openWindow(URL, winName, width, height){


	if(height=='' || !height)
	height=screen.height/2
	height_factor = ((screen.height/100)*85)
	if(height>=height_factor)
		height=height_factor;


	if(width=='' || !width)
		width=screen.width/2
	width_factor = ((screen.width/100)*95)
	if(width>=width_factor)
		width=width_factor;

	var top=((screen.height-height)/2)-(screen.height/20)
	var left=(screen.width - width) / 2 ;

		win=window.open(URL, winName, 'toolbar=no,location=no,directories=no,status=1,menubar=no,scrollbars=yes,resizable=1,copyhistory=no,width='+width+',height='+height+',top='+top+',left='+left+'');
		win.focus();
}
