function update_country_list( form_name, continent_id, country_id )
{
	var form = document.forms[ form_name ];

	var continent_select = form.elements[continent_id];
	var country_select = form.elements[country_id];
	

	var continent = continent_select.options[ continent_select.selectedIndex ].value;

	if( continent == '-nocontinent-' )
	{
		alert('Please select a Continent');
		return;
	}

	var counter = 0;

	for( var country in continents[ continent ] )
	{
		country_id = continents[ continent ][ country ];

		if( counter == 0 )
		{
			country_select.options[ counter ] = new Option( 'Any Country', country );
			counter ++;
		}

		country_select.options[ counter ] = new Option( country_id, country );
		counter ++;
	}
	
	country_select.length = counter;
	country_select.selectedIndex = 0;
}

function update_region_list( form_name, country_id, region_id )
{
	var form = document.forms[ form_name ];

	var country_select = form.elements[country_id];
	var region_select = form.elements[region_id];

	var country = country_select.options[ country_select.selectedIndex ].value;

	if( country == '-nocountry-' )
	{
		alert('Please select a Country');
		return;
	}

	var counter = 0;

	for( var region in regions[ country ] )
	{
		region_id = regions[ country ][ region ];

		if( counter == 0 )
		{
			region_select.options[ counter ] = new Option( 'Any Region', region );
			counter ++;
		}

		region_select.options[ counter ] = new Option( region_id, region );
		counter ++;
	}
	
	region_select.length = counter;
	region_select.selectedIndex = 0;
}

function update_city_list( form_name, region_id, city_id )
{
	var form = document.forms[ form_name ];

	var region_select = form.elements[region_id];
	var city_select = form.elements[city_id];

	var region = region_select.options[ region_select.selectedIndex ].value;

	if( region == '-noregion-' )
	{
		alert('Please select a Region');
		return;
	}

	var counter = 0;

	for( var city in cities[ region ] )
	{
		city_id = cities[ region ][ city ];

		if( counter == 0 )
		{
			city_select.options[ counter ] = new Option( 'Any City', '' );
			counter ++;
		}

		city_select.options[ counter ] = new Option( city_id, city );
		counter ++;
	}
	
	city_select.length = counter;
	city_select.selectedIndex = 0;
}

function goto_region( form_name, country_id, region_id )
{
	var form = document.forms[form_name];

	// Get the value of the country & region
	var country_select = form.elements[country_id];
	var region_select = form.elements[region_id];

	var country = country_select.options[ country_select.selectedIndex ].value;
	var region = region_select.options[ region_select.selectedIndex ].value;

	if( region == '-noregion-' )
	{
		alert('Please select a region')
		return;
	}

	window.location.href = "/" + country + "/" + region;
}

	function checkForm(theform) {
		var message = '';
		if((theform.name.value.length || theform.email.value.length == 0)||(theform.name.value.length=='Your name' || theform.email.value.length == 0)) {
			alert('Please complete all boxes.');
			return(false);
		}
		return(true);
	}



function validateInput() {
var form = document.forms['head_search'];

	// Get the value of the country 
	var country_select = form.elements['country'];
	

	
        if (country_select.selectedIndex == 0) {
		alert('Please select a country')
		return false;
	
	}


	return true;
}




function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid e-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid e-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid e-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid e-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid e-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid e-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid e-mail address")
		    return false
		 }

 		 return true					
	}



function validateRegistrationInput(form) {
	
	// Get the value of the name
	var name = form.elements['name'];
	
	if (name.value == "Your name" || name.value == "") {
	   alert("Please enter your name.");
	   name.focus();	
	   return false;	 		
	}



	var emailID=form.email
	
	
	if ((emailID.value==null)||(emailID.value=="")||(emailID.value=="Your e-mail address")){
		alert("Please enter your email address.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
}


function ShowHideCollapsibleArea(strAreaId, link)

{

	var oCollAreaDiv = document.getElementById(strAreaId);


	if (oCollAreaDiv.style.display == 'none')

	{

		oCollAreaDiv.style.display = 'block';

		link.innerHTML = "Hide details";

	}

	else

	{		

		oCollAreaDiv.style.display = 'none';

		link.innerHTML = "Read more about this hotel";

	}



	

}





	
