var ie4 = (document.all != null);

function get(obj) {
	return document.getElementById(obj);
}

function getReal(el, type, value) {
	temp = el;
	while ((temp != null) && (temp.tagName != "BODY")) {
		if (eval("temp." + type) == value) {
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}

function hideShownDropDowns() {
	if (get('open_select_box')) {
		var el = getReal(window.event.srcElement, "id", "select_box");
		//alert(el.id);
		if (get('open_select_box').style.visibility=='visible' && el.tagName == 'BODY') {
			get('open_select_box').className='select_box_main_close';
			get('open_select_box').filters[0].apply();
			get('open_select_box').style.visibility='hidden';
			get('open_select_box').filters[0].play();
			get('r3c1').style.backgroundImage='url(images/select_box/select_box_14.gif)';
			get('r3c1').style.backgroundPosition="center center";
			get('r3c1').style.backgroundRepeat="repeat-x";
			get('r3c5').style.backgroundImage='url(images/select_box/select_box_12.gif)';
			get('r3c5').style.backgroundPosition="center center";
			get('r3c5').style.backgroundRepeat="repeat-x";
			//get('open_select_box_top').blur();		
		}
	}
}

if (ie4) {
	window.onload = write_scroll_box;
	document.onclick = hideShownDropDowns;
}

function write_scroll_box() {
	if (get('select_box')) {
		scroller_width = getScrollerWidth();
		get('r1c2').style.width=129-scroller_width-6;
		get('r2c12').style.width=126-scroller_width;
		get('r3c2').style.width=129-scroller_width-6;
		get('r1c4').style.width=scroller_width-5;
		get('r2c45').style.width=scroller_width+1;
		get('r3c4').style.width=scroller_width-5;
		get('br1c2').style.width=129-scroller_width-6;
		get('br1c4').style.width=scroller_width-5;
	}
}

function change_select_box(obj) {
	if (get('open_select_box').style.visibility=='visible') {
		get('open_select_box').className='select_box_main_close';
		//get('open_select_box').filters[0].apply();
		get('open_select_box').style.visibility='hidden';
		//get('open_select_box').filters[0].play();
		get('r3c1').style.backgroundImage='url(images/select_box/select_box_14.gif)';
		get('r3c1').style.backgroundPosition="center center";
		get('r3c1').style.backgroundRepeat="repeat-x";
		get('r3c5').style.backgroundImage='url(images/select_box/select_box_12.gif)';
		get('r3c5').style.backgroundPosition="center center";
		get('r3c5').style.backgroundRepeat="repeat-x";
		get('open_select_box_top').blur();
	}
	else
	{
		get('open_select_box').className='select_box_main';
		get('r3c1').style.backgroundImage='url(images/select_box/right_bottom_rect.gif)';
		get('r3c1').style.backgroundPosition="center center";
		get('r3c1').style.backgroundRepeat="repeat-x";
		get('r3c5').style.backgroundImage='url(images/select_box/left_bottom_rect.gif)';
		get('r3c5').style.backgroundPosition="center center";
		get('r3c5').style.backgroundRepeat="repeat-x";
		//get('open_select_box').filters[0].apply();
		get('open_select_box').style.visibility='visible';
		//get('open_select_box').filters[0].play();
		//get('open_select_box_top').focus();
	}
}

function option_over(obj) {
	obj.style.backgroundImage='url(images/select_box/option_bg_over.gif)';
	obj.style.backgroundPosition="center center";
	obj.style.backgroundRepeat="repeat-x";
	obj.style.cursor="default";
}

function option_out(obj) {
	obj.style.backgroundImage='url(images/select_box/option_bg.gif)';
	obj.style.backgroundPosition="center center";
	obj.style.backgroundRepeat="repeat-x";
}

function option_select(obj) {
	get('r2c12').style.color='#1f529d';
	get('r2c12').innerHTML=obj.innerHTML;
	if (get('r2c12').innerHTML!='בחר עיר')
		get('id').value=obj.id;
	change_select_box();
}

function getScrollerWidth() {
    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.background = 'green';
	scr.style.top = '0px';
    scr.style.left = '0px';
    scr.style.width = '100px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';

    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '200px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.scrollWidth;
	//alert("wNoScroll="+wNoScroll);
	// Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.scrollWidth;
	//alert("wScroll="+wScroll);
    // Remove the scrolling div from the doc
    document.body.removeChild(document.body.lastChild);

    // Pixel width of the scroller
    return (wNoScroll - wScroll);
}

if (ie4) {
	//window.onload = alert('hello');
	//document.onclick = alert('clicking');
}

var blinks,r;
blinks=14;
function NewSubmit() {
    if (get('select_box_main').value) {
        get('id').value = get('select_box_main').value;
        get('select_box_form').submit()
    }
    else {
        alert(get('select_box_main').value);
    }
}
function select_box_submit() {
    if (get('id').value)
	    
		get('select_box_form').submit()
	else {
		r=0;
		slide_line();
	}
}

function slide_line() {
	r++;
	if (r<blinks) {
		if (get('r2c12').innerHTML=='בחר עיר') {
			if (get('r2c12').style.color=='#1f529d')
				get('r2c12').style.color='#FF0000'
			else
				get('r2c12').style.color='#1f529d';
		}
		var t=setTimeout("slide_line()",100);
	}
	else
		get('r2c12').style.color='#1f529d';
}
