function validate_required() {	
if(document.form3.jmGroupSize.options[document.form3.jmGroupSize.selectedIndex].value=="plsSpecify")
  	{
     alert("You must specify the group size!");return false;
    }
  else
    {
    return true;
    }
	
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required()==false)
  {document.form3.jmGroupSize.focus();return false;}
  }
}

function hideDiv(div_id) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 		
		document.getElementById(div_id).style.display='none';
	} 
	else { 
		if (document.layers) { // Netscape 4 			
			document.div_id.display='none';
		} 
		else { // IE 4 					
			document.div_id.style.display='none';
		} 
	} 
}

function showDiv(div_id) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById(div_id).style.display='block';
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.div_id.display='block';
		} 
		else { // IE 4 
			document.div_id.style.display='block';
		} 
	} 
} 

//Function to return specific words//


function set_txtSearchByName(choosenAreaResort) {
	if(choosenAreaResort != 'Select a resort'){
		var txtSearchBox = document.form1.txtSearchByName;	
		txtSearchBox.value=choosenAreaResort;
	}
}

function remove_Location(location,criteria) {

}

function add_Location(location) {
	var the_list = document.getElementById('criteria_list');
	var newlistitem = document.createElement('li');
	newlistitem.innerHTML = 'In '+location;
	the_list.appendChild(newlistitem);
	
	document.form1.txtLocation.value=document.form1.txtLocation.value+location+', ';
}

function add_Airport(ap) {
	var the_list = document.getElementById('criteria_list');
	var newlistitem = document.createElement('li');
	newlistitem.innerHTML = 'Near '+ap+' Airport';
	the_list.appendChild(newlistitem);
	
	document.form1.txtAirport.value=ap;
}

function show_PostWiz_Div(){
//	showDiv('post-wizard-container1');
	//hideDiv('forum-container');
}
/*
function showhideDiv_step1(div_id){
	if (div_id=='haveALocationCriteria'){
		showDiv('location_hidden_form');
		showDiv('help_box2');
		hideDiv('help_box1');
	}
	else {
		hideDiv('location_hidden_form');
		showDiv('help_box1');
		hideDiv('help_box2');
	}
}
//onchange="showhideDiv_step1(document.form1.jmLocation.options[document.form1.jmLocation.selectedIndex].value);"//
*/
//-----------------------------------------//

//-----------------------------------------//
//************* Ajax DB fetch *************//

function addCountries() {
	document.getElementById("jmCountry").length = 1;
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
		var responseString = xmlhttp.responseText;
		//document.write responseString;
		var countryArray = responseString.split(",");
		
		for (var i in countryArray) {
			
			if (document.getElementById) { // DOM3 = IE5, NS6 		
				//document.getElementById(div_id).style.display='none';
				var newOption = document.createElement("OPTION");
				document.getElementById("jmCountry").options.add(newOption);
				newOption.innerText = countryArray[i];
			} 
			else { 
				if (document.layers) { // Netscape 4 			
					//document.div_id.display='none';
					var newOption = document.createElement("OPTION");
					document.jmCountry.options.add(newOption);
					newOption.innerText = countryArray[i];
				} 
			}			
		}
		
			if (document.getElementById) { // DOM3 = IE5, NS6 
	 			set_txtSearchByName(document.getElementById("jmCountry").options[document.getElementById("jmCountry").selectedIndex].value);
			} 
				else { 
					if (document.layers) { // Netscape 4 
						set_txtSearchByName(document.form1.jmCountry.options[document.form1.jmCountry.selectedIndex].value);
				} 
			}		
					
		}else 
		{
			//document.getElementById("ani_resort").style.display='block';
		}
	  }
	  
	//xmlhttp.open('GET','http://localhost/chalets/my-templates/chalets/db/countries.php',true);
	xmlhttp.open('GET','http://testing.yadabyte.com/chalet/my-templates/chalets/db/countries.php',true);
	xmlhttp.send();
}

var selArea = document.getElementById("jmArea");

function addRegions(country){
	document.getElementById("jmArea").length = 1;
	if (country=="")
	  {
	  //document.getElementById("txtHint").innerHTML="";
	  return;
	  } 
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  
	xmlhttp.onreadystatechange=function()
	  {
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200){
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
			var responseString = xmlhttp.responseText;
			//document.write responseString;
			var regionsArray = responseString.split(",");
			
			for (var i in regionsArray) {
					if (document.getElementById) { // DOM3 = IE5, NS6 		
						//document.getElementById(div_id).style.display='none';
						var newOption = document.createElement("OPTION");
						document.getElementById("jmArea").options.add(newOption);
						newOption.innerText = regionsArray[i];
					} 
					else { 
						if (document.layers) { // Netscape 4 			
							//document.div_id.display='none';
							var newOption = document.createElement("OPTION");
							document.jmArea.options.add(newOption);
							newOption.innerText = regionsArray[i];							
						} 
					} 
			}	 
			
			if (document.getElementById) { // DOM3 = IE5, NS6 
				document.getElementById("ani_region").style.display='none';
				set_txtSearchByName(document.getElementById("jmCountry").options[document.getElementById("jmCountry").selectedIndex].value);
			} 
			else { 
				if (document.layers) { // Netscape 4 	
					document.ani_region.style.display='none';
					set_txtSearchByName(document.form1.jmCountry.options[document.form1.jmCountry.selectedIndex].value);
				} 
			} 						
				
		//selArea.options[selArea.options.length] = new Option("Andalucia",'Andalucia');
		}else 
		{
			if (document.getElementById) { // DOM3 = IE5, NS6 
				document.getElementById("ani_region").style.display='block';
			} 
			else { 
				if (document.layers) { // Netscape 4 
					document.ani_region.style.display='block';
				} 
			} 	
		}
	  }  	  
	  
	//xmlhttp.open('GET','http://localhost/chalets/my-templates/chalets/db/regions.php?country=' + country,true);
	xmlhttp.open('GET','http://testing.yadabyte.com/chalet/my-templates/chalets/db/regions.php?country=' + country,true);
	xmlhttp.send();
}

function addResorts(country2, region){
	document.getElementById("jmResort").length = 1;
	if (region=="")
	  {
	  //document.getElementById("txtHint").innerHTML="";
	  return;
	  } 
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
			var responseString = xmlhttp.responseText;
			//document.write responseString;
			var resortsArray = responseString.split(",");
			
			for (var i in resortsArray) {
				
				if (document.getElementById) { // DOM3 = IE5, NS6 		
					//document.getElementById(div_id).style.display='none';
					var newOption = document.createElement("OPTION");
					document.getElementById("jmResort").options.add(newOption);
					newOption.innerText = resortsArray[i];
				} 
				else { 
					if (document.layers) { // Netscape 4 			
						//document.div_id.display='none';
						var newOption = document.createElement("OPTION");
						document.jmResort.options.add(newOption);
						newOption.innerText = resortsArray[i];
					} 
				}						
				
			}
			
			if (document.getElementById) { // DOM3 = IE5, NS6 
				document.getElementById("ani_resort").style.display='none';
				set_txtSearchByName(document.getElementById("jmArea").options[document.getElementById("jmArea").selectedIndex].value);
			} 
			else { 
				if (document.layers) { // Netscape 4 
					document.ani_resort.style.display='none';
					set_txtSearchByName(document.form1.jmArea.options[document.form1.jmArea.selectedIndex].value);
				} 
			} 		
	 	
		}else 
		{
			if (document.getElementById) { // DOM3 = IE5, NS6 			
				document.getElementById("ani_resort").style.display='block';
			} 
			else { 
				if (document.layers) { // Netscape 4 
					document.ani_resort.style.display='block';
				} 
			} 	
		}
	  }
	  
	//xmlhttp.open('GET','http://localhost/chalets/my-templates/chalets/db/resorts.php?country=' + country2 + '&region=' + region,true);
	xmlhttp.open('GET','http://testing.yadabyte.com/chalet/my-templates/chalets/db/resorts.php?country=' + country2 + '&region=' + region,true);
	xmlhttp.send();
}


//*********************************************//
