
function js_func(){
document.advsearchform.search.value=1;
document.advsearchform.sear.value=1;
document.advsearchform.pageNumber.value=1;
document.advsearchform.action="advanced_search.php";
document.advsearchform.submit();
}

function clear_drop_down(listbox)
{
	var numberOfOptions = listbox.length;
	for (var i=1; i<numberOfOptions; i++) {
		 //Note: Always remove(1) and NOT remove(i)
		 listbox.remove(1);
	}
}

function chg_enable(value)
{
	if(value == 1)
	{
		document.advsearchform.keyword_txt.disabled=false;	
		document.advsearchform.continent.disabled=true;
		document.advsearchform.country.disabled=true;
		clear_drop_down(document.advsearchform.country);
		if(document.advsearchform.country_temp)
		{
			document.advsearchform.country_temp.disabled=true;
			clear_drop_down(document.advsearchform.country_temp);
		}
		document.advsearchform.region1.disabled=true;
		clear_drop_down(document.advsearchform.region1);
		document.advsearchform.region2.disabled=true;
		clear_drop_down(document.advsearchform.region2);
		document.advsearchform.continent.value=0;
		document.advsearchform.keyword_txt.focus();
	}
	else if(value == 2)
	{
		document.advsearchform.keyword_txt.value='';
		document.advsearchform.keyword_txt.disabled=true;
		document.advsearchform.continent.disabled=false;
		document.advsearchform.country.disabled=false;
		if(document.advsearchform.country_temp)
		{
			document.advsearchform.country_temp.disabled=false;
		}
		document.advsearchform.region1.disabled=false;
		document.advsearchform.region2.disabled=false;
	}
}

function ClearAllEntries()
{
	document.advsearchform.keyword_txt.disabled=false;	
	document.advsearchform.keyword_txt.value = "";
	document.advsearchform.continent.disabled=false;
	document.advsearchform.continent.value=0;
	if(document.advsearchform.country)
	{
		clear_drop_down(document.advsearchform.country);
	}
	if(document.advsearchform.country_temp)
	{
		clear_drop_down(document.advsearchform.country_temp);
	}
	clear_drop_down(document.advsearchform.region1);
	clear_drop_down(document.advsearchform.region2);
	document.advsearchform.minprice_input.value = "";
	document.advsearchform.maxprice_input.value = "";
	document.advsearchform.num_persons[0].selected = true;
	document.advsearchform.start_date.value = "";
	document.advsearchform.end_date.value = "";
	document.advsearchform.num_persons.value = 0;
	if(document.advsearchform.keyword_txt.style.visibility = "visible")
		document.advsearchform.keyword_txt.focus();
	for(var i=0;i<document.advsearchform.acc_check.length;i++)
		document.advsearchform.acc_check[i].checked = true;
	return false;
}

function clear_all_advanced_search_options()
{
	/*
	document.advsearchform.continent.disabled=false;
		document.advsearchform.country.disabled=true;
		clear_drop_down(document.advsearchform.country);
		if(document.advsearchform.country_temp)
		{
			document.advsearchform.country_temp.disabled=true;
			clear_drop_down(document.advsearchform.country_temp);
		}
		document.advsearchform.region1.disabled=true;
		clear_drop_down(document.advsearchform.region1);
		document.advsearchform.region2.disabled=true;
		clear_drop_down(document.advsearchform.region2);
		document.advsearchform.continent.value=0;
		document.advsearchform.minprice_input.value = "";
		document.advsearchform.maxprice_input.value = "";
		document.advsearchform.num_persons[0].selected = true;
		document.advsearchform.start_date.value = "";
		document.advsearchform.end_date.value = "";
		document.advsearchform.num_persons.value = 0;
		*/
}

function Show_search_options(value)
{
	document.getElementById("search_options_container").style.display = "block";
	//alert(document.getElementById("advanced_flag").value);
	if(value == "1")
	{
		document.getElementById("search_advanced_options_container").style.display = "block";
	}
	else if(value == "0")
	{
		document.getElementById("search_advanced_options_container").style.display = "none";
	}
	document.getElementById("search_results_container").style.display = "none";
}

function Show_advanced_option()
{
	if(document.getElementById("search_advanced_options_container").style.display == "none")
	document.advsearchform.reset();
	document.getElementById("search_advanced_options_container").style.display = "block";
	document.getElementById("ahref_text_1").style.display = "none";
	document.getElementById("ahref_text_2").style.display = "block";
	document.advsearchform.hide_advanced_option_by_user.value = "0";	
	temp_key = document.advsearchform.keyword_txt.value;
	
	document.advsearchform.keyword_txt.value = temp_key;
	//document.getElementById("advanced_flag").value = "2";
}

function Hide_advanced_option()
{
	document.getElementById("search_advanced_options_container").style.display = "none";
	document.getElementById("ahref_text_1").style.display = "block";
	document.getElementById("ahref_text_2").style.display = "none";
	document.advsearchform.hide_advanced_option_by_user.value = "1";
	//document.getElementById("advanced_flag").value = "1";
	clear_all_advanced_search_options();
}

function Delete_Current_Value(value)
{
	var value1 = document.advsearchform.keyword_txt.value;
	if(value1 == value)
	{
		document.advsearchform.keyword_txt.value = "";
		document.advsearchform.keyword_txt.focus();
	}
}

function move_to_page(pageNum)
{
	document.advsearchform.pageNumber.value = pageNum;
	document.advsearchform.submit();
}
function Show_advanced_option_From_SearchBox(hide_option,key_val) {

	
		
		Show_advanced_option()
		
	
}
function Show_advanced_option2(hide_option,key_val) {
	
		if( (document.getElementById("search_advanced_options_container").style.display == "block") && !checkMainSearchFormChanged()) {
			document.getElementById("search_advanced_options_container").style.display = "none";
			document.getElementById("ahref_text_1").style.display = "block";
			document.getElementById("ahref_text_3").style.display = "none";	
		}			
		else if(document.getElementById("search_advanced_options_container").style.display == "none") {
			temp_key = document.mainsearchform.query.value;	
			gallery_option = document.mainsearchform.gallery_search.checked;		
			document.mainsearchform.reset();
			document.getElementById("search_advanced_options_container").style.display = "block";			
			document.mainsearchform.query.value = temp_key;
			document.mainsearchform.gallery_search.checked = gallery_option;
			document.getElementById("ahref_text_1").style.display = "none";
			document.getElementById("ahref_text_3").style.display = "block";
		}
	
		
	
}
function Hide_advanced_option2(){
	document.getElementById("search_advanced_options_container").style.display = "none";	
	
	document.getElementById("ahref_text_1").style.display = "block";
	document.getElementById("ahref_text_3").style.display = "none";	
	
}
function checkMainSearchFormChanged() {
	
	
	if( (document.mainsearchform.continent.selectedIndex != 0) || (document.mainsearchform.country.selectedIndex != 0) || (document.mainsearchform.region1.selectedIndex != 0) || (document.mainsearchform.region2.selectedIndex != 0)) {
		return true;
		
	}
	
	if((document.mainsearchform.num_persons.selectedIndex != 0)) {
		return true;
	}	
	
	if((document.mainsearchform.minprice_input.value != '') || (document.mainsearchform.maxprice_input.value != '') ) {
		return true;
	}
	if((document.mainsearchform.start_date.value != '') || (document.mainsearchform.end_date.value != '') ) {
		return true;
	}
	
	for(i=0;i<document.mainsearchform.elements.length;i++) {
		if(document.mainsearchform.elements[i].type=="checkbox") {
			if(document.mainsearchform.elements[i].name != 'gallery_search') {
				if(!document.mainsearchform.elements[i].checked) {
					return true;
				}
			}
		}
	}
	
	return false;
}

function Show_advanced_option3()
{
	if(document.getElementById("search_advanced_options_container").style.display == "none")
	document.advsearchform.reset();
	document.getElementById("search_advanced_options_container").style.display = "block";
	document.getElementById("ahref_text_1").style.display = "none";
	document.getElementById("ahref_text_3").style.display = "block";
	
}

function Hide_advanced_option3()
{
	document.getElementById("search_advanced_options_container").style.display = "none";
	document.getElementById("ahref_text_1").style.display = "block";
	document.getElementById("ahref_text_3").style.display = "none";	
	//document.getElementById("advanced_flag").value = "1";
	clear_all_advanced_search_options();
}

function Show_search_options2(value)
{
	document.getElementById("search_options_container").style.display = "block";
     //##########################################################################
     //##########################################################################
     //##########################################################################
     //document.getElementById("ahref_text_1").style.display = "block";
	//document.getElementById("ahref_text_3").style.display = "none";
      //##########################################################################
     //##########################################################################
     //##########################################################################

	//alert(document.getElementById("advanced_flag").value);
	if(value == "1")
	{
		//document.getElementById("search_advanced_options_container").style.display = "block";
	}
	else if(value == "0")
	{
		//document.getElementById("search_advanced_options_container").style.display = "none";
	}
	document.getElementById("search_results_container").style.display = "none";
}

