function __getMouseX(e) {
	if(e.pageX) {
		return e.pageX;
	} else if (e.clientX) {
		return e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	} else {
		return 0;
	}
}

function __getMouseY(e) {
	if(e.pageY) {
		return e.pageY;
	} else if (e.clientY) {
		return e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	} else {
		return 0;
	}
}

function __getElement(id) {
	return document.getElementById(id);
}

function __createElement(name) {
	return document.createElement(name);
}

var __checkbox = new Array();

function __checkbox_add(id) {
	__checkbox[__checkbox.length] = id;
}

function __checkbox_select() {
	for(var a = 0; a < __checkbox.length; a++) {
		__getElement(__checkbox[a]).checked = true;
	}
}

function __getCounties(list_counties) {
	if(list_counties != null) {
		for(var a = 0; a < country.length; a++) {
			var option = __createElement("option");
			
			option.value = country[a][0];
			option.text = country[a][1];
			
			try {
				list_counties.add(option, null);
			} catch(e) {
				list_counties.add(option);
			}
		}
	}
}

function __getLocalities(list_counties, list_localities) {
	if(list_counties != null && list_localities != null) {
		list_localities.length = 0;
		
		var county = list_counties.selectedIndex;
		
		for(var a = 0; a < country[county][2].length; a++) {
			var option = __createElement("option");
			
			option.value = country[county][2][a][0];
			option.text = country[county][2][a][1];
			
			
			try {
				list_localities.add(option, null);
			} catch(e) {
				list_localities.add(option);
			}
		}
	}
}

function Menu(id) {
	left = __getElement("menu_" + id + "_left");
	body = __getElement("menu_" + id + "_body");
	right = __getElement("menu_" + id + "_right");
	
	if(body.className == "inactive") {
		left.src = "/images/menu/over_left.gif";
		body.className = "over";
		right.src = "/images/menu/over_right.gif";
	} else {
		left.src = "/images/menu/inactive_left.gif";
		body.className = "inactive";
		right.src = "/images/menu/inactive_right.gif";
	}
}

/**********************/
/*     __MainMenu     */
/**********************/

function __MainMenu(id) {
	left = __getElement("mainmenu_" + id + "_left");
	body = __getElement("mainmenu_" + id + "_body");
	right = __getElement("mainmenu_" + id + "_right");
	
	if(body.className == "inactive") {
		left.src = "/images/menu/over_left.gif";
		body.className = "over";
		right.src = "/images/menu/over_right.gif";
	} else {
		left.src = "/images/menu/inactive_left.gif";
		body.className = "inactive";
		right.src = "/images/menu/inactive_right.gif";
	}
}

/*********************/
/*     __SubMenu     */
/*********************/

function __SubMenu(id) {
	left = __getElement("submenu_" + id + "_left");
	body = __getElement("submenu_" + id + "_body");
	right = __getElement("submenu_" + id + "_right");
	
	if(body.className == "inactive") {
		left.src = "/images/submenu/over_left.gif";
		body.className = "over";
		right.src = "/images/submenu/over_right.gif";
	} else {
		left.src = "/images/submenu/inactive_left.gif";
		body.className = "inactive";
		right.src = "/images/submenu/inactive_right.gif";
	}
}

function Scroll_Start(id, timeoutvar, height) {
	element = __getElement(id);
	
	if(eval(timeoutvar)) {
		element.style.top = parseInt(element.style.top) - 1 + "px"
		
		if(parseInt(element.style.top) < -element.offsetHeight) {
			element.style.top = height + "px"
		}
	}
	
	if(element.offsetHeight > height - 10 || element.offsetHeight == 0) {
		timeoutvar2 = setTimeout("Scroll_Start('" + id + "', '" + timeoutvar + "', " + height + ")", 35);
	} else {
		element.style.top = "0px";
	}
}

/********************/
/*     __Select     */
/********************/

function __Select_Add(obj_select, var_value, var_text, var_before, var_selected) {
	var obj_option = __createElement("option");
	
	obj_option.value = var_value;
	obj_option.text = var_text;
	obj_option.selected = var_selected;
	
	try {
		obj_select.add(obj_option, var_before)
	} catch(e) {
		obj_select.add(obj_option);
	}
}

function __Select_Clear(obj_select) {
	obj_select.length = 0;
}

function __Select_FindByValue(obj_select, var_value) {
	for(var a = 0; a < obj_select.length; a++) {
		if(obj_select.options[a].value == var_value) {
			return obj_select.options[a];
		}
	}
}

/************************/
/*     __CountyList     */
/************************/

function __CountyList(var_country, obj_county) {
	for(var a = 0; a < var_country.length; a++) {
		__Select_Add(obj_county, var_country[a][0], var_country[a][1], null, false);
	}
}

/**************************/
/*     __LocalityList     */
/**************************/

function __LocalityList(var_country, var_county, obj_locality) {
	if(var_county > 0) {
		for(var a = 0; a < var_country.length; a++) {
			if(var_county == var_country[a][0]) {
				var_county = a;
				a = var_country.length;
			}
		}
		
		for(var a = 0; a < var_country[var_county][2].length; a++) {
			__Select_Add(obj_locality, var_country[var_county][2][a][0], var_country[var_county][2][a][1], null, false);
		}
	}
}
