var http = null;

function get_connection(){
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer"){
		http = new ActiveXObject("Microsoft.XMLHTTP");

	} else {
		http = new XMLHttpRequest();

	}
}





function get_subregions(language){

	var region = document.getElementById('region').options[document.getElementById('region').selectedIndex].value;
	//var language = document.getElementById('ae_language').value;
	var url = '/rpc.php/get_subregions/?language='+ language + '&region=' + region;
	//alert(url);
	http.open('get', url);
	http.onreadystatechange = handle_subregions;
	http.send(null);
}

function handle_subregions(){


	if (http.readyState == 4){
		var subregion = document.getElementById('subregion').value;
		//alert(subregion);
		var response = http.responseXML;
		var subregions = response.getElementsByTagName('subregion');
		var id = 0;
		var name = '';

		document.forms['search'].subregion.options.length = 0		
		document.forms['search'].subregion.options[0] = new Option(' ', '0');

		for (i = 0; i < subregions.length; i++)
		{
			id = subregions[i].getAttribute('id');
			name = subregions[i].getAttribute('name');
			document.forms['search'].subregion.options[i + 1] = new Option(name, id);

			if(document.forms['search'].subregion.options[i + 1].value == subregion)
				document.forms['search'].subregion.options[i + 1].selected = true;
		}

	}
}


get_connection();


function open_window(url, width, height, scroll) {

	if(scroll == '')	scroll = 'no';

	window.open(
		url, '_blank', 'height=' + height + ', width=' + width +', menubar=no, toolbar=no, status=yes, scrollbars=' + scroll
	);
}



function changeImagemap(str){


}





// JavaScript Document
function preloadImages( ) {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function unblur() {
	this.blur();
}

function blurLinks() {
	links = document.getElementsByTagName("a");
	for(i=0; i<links.length; i++) {
		links[i].onfocus = unblur;
	}
	inputs = document.getElementsByTagName("input");
	for(i=0; i<inputs.length; i++) {
		if (inputs[i].type == 'button' || inputs[i].type == 'submit') {
			inputs[i].onfocus = unblur;
		}
	}
}

function setFocus(obj) {
	x = document.getElementById(obj);
	x.focus();
}

function flashObjects (objPath,objWidth,objHeight,objTitle,objParam,wmode,altPath,altWidth,altHeight,altTitle) {
	document.write('<object type="application/x-shockwave-flash" data="'+objPath+'"width="'+objWidth+'" height="'+objHeight+'" '+objParam+'> \
					<param name="movie" value="'+objPath+'" /> \
					<param name="quality" value="high" /> \
					<param name="wmode" value="'+wmode+'" /> \
					<img src="'+altPath+'" width="'+altWidth+'" height="'+altHeight+'" alt="'+altTitle+'" /></object>');
}