function country_selected(country_id) {
	var form = document.forms[0];

	var l = regions[country_id].length;

	form.region_id.options.length = l;
	form.region_id.selectedIndex = 0;
	for (i = 0; i < l; i++) {
		var information = regions[country_id][i].split(":");
		var region_id = information[0];
		var region = information[1];
		form.region_id.options[i + 1] = new Option(region, region_id);
	} 
}


function validEmail(email) {
invalidChars = " /:,;"
if (email == "") {
    return false
}

for (i=0; i<invalidChars.length; i++) {
    badChar = invalidChars.charAt(i)
    if (email.indexOf (badChar,0) != -1) {
        return false
    }
}  // for (i=o.. 

atPos = email.indexOf ("@",1)

if (atPos == -1) {
    return false
}

if ( email.indexOf ("@", atPos+1) != -1) {
    return false
}
periodPos = email.indexOf (".", atPos)

if ( periodPos == -1) {
    return false
}

if ( periodPos+3 > email.length)    {
    return false
}
return true
}  // validEmail 


function checkRegionform(region,country) {
errors = "";
if(document.region.elements[region].value == "")
	errors += "\nYou have to write a region";

if(document.region.elements[country].value == "")
	errors += "\nYou have to choose a country";
	
if (errors != "") {
	alert(errors)
	return false;
} else {
	return true
}
}

function checkHotelform(region,country) {
var form = document.forms[0];
errors = "";
if(form.elements[region].value == "")
	errors += "\nYou have to write a region";

if(form.elements[country].value == "")
	errors += "\nYou have to choose a country";
	
if (errors != "") {
	alert(errors)
	return false;
} else {
	return true
}
}

function checkUserform(username,password) {
errors = "";
if(!validEmail(document.forms[0].elements[username].value))
	errors += "\nYour email address is not valid";

if(document.forms[0].elements[password].value == "")
	errors += "\nYou have to type a password";
	
if(document.forms[0].elements[password].value != document.forms[0].passwordcheck.value)
	errors += "\nYou passwords does not match";
	
if (errors != "") {
	alert(errors)
	return false;
} else {
	return true
}
}


function PopupImage(img) {
	titre="Thumbnail Picture from Thailand Media Bank";
	w=open("",'image','width=535,height=335,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}
