var moredeststr="";

function searchtrip(){	

	var destination="";

    var searchstr="http://www.chinaodysseytours.com/tours/toursearch.php?ms=en";
	
	var si=0;
	
	try{
	   var tlobj=document.getElementById("triplength");	
	   if(parseInt(tlobj.value)>0){		   
		   si++;
		    searchstr+="&l="+tlobj.value;
	   }
	}
	catch(err)
	{		
		
	}	
	try{
	   var scobj=document.getElementById("startcity");
	   if(parseInt(scobj.value)>0){		   
		    si++;
		    searchstr+="&s="+scobj.value;
	   }
	}
	catch(err)
	{
		
	}
	try{
	   var ecobj=document.getElementById("endcity");
	   if(parseInt(ecobj.value)>0){		   
		   si++;
		    searchstr+="&e="+ecobj.value;
	   }
	}
	catch(err)
	{
		
	}
	
	//¼Æ»®³ÇÊÐ
   try{	

	   var planobj=document.getElementsByName("planto");
	   for(var i=0;i<planobj.length;i++){ 

		   if(planobj[i].checked){

	       destination+=planobj[i].value+",";

		   si++;	
		   }

	  }
	  searchstr+="&q="+destination;

    }
	catch(err)
	{
		
	}	

	if(si==0){

		alert("Please choose at least one destination. The more information you provide, the better your search results will be.");

		return;

	}	


	document.location.href=searchstr;
}

function mymouseover(){

	document.getElementById("sbt13").src="http://www.chinaodysseytours.com/tours/image/searchbt2.gif";

}

function mymouseout(){

	document.getElementById("sbt13").src="http://www.chinaodysseytours.com/tours/image/searchbt1.gif";
}
function showtriptype(nType){
	var obj=null;
	
    for(var i=1;i<=4;i++){
	   obj=document.getElementById("mylistitem"+i);
	   if(obj!=null){
	       if(i==nType) obj.style.display="";
	       else obj.style.display="none";
	   }
	}
	
}
function searchdestination(index){
	
	var destination="http://www.chinaodysseytours.com/tours/toursearch.php?l="+index+"&q=";
    var planobj=document.getElementsByName("planto1"); 
	var dCount=0;
    for(var i=0;i<planobj.length;i++){ 
		if(planobj[i].checked){
		  dCount++;
	      destination+=planobj[i].value+" ";
		}
    }	
	if(dCount==0){
	    alert("Please choose at least one destination. The more information you provide, the better your search results will be.")	;
		return;
	}
	document.location.href=destination;
	
}
function FindATour(){
	var posturl="http://www.chinaodysseytours.com/tours/toursearch.php?ms=0";
	var lengthobj=document.getElementById("triplength1");	
	var startcityobj=document.getElementById("startcity1");
	if(lengthobj.value=="0" && startcityobj.value=="0"){
		 alert("Please choose at least one option. The more information you provide, the better your search results will be.");
		 return;
	}
	if(lengthobj.value!="0") posturl+="&l="+lengthobj.value;
	if(startcityobj.value!="0") posturl+="&s="+startcityobj.value;
	
	document.location.href=posturl;
	
}
function searchtrip3(){
	
	var aobj=document.getElementById("a1");
	var posturl="http://www.chinaodysseytours.com/tours/toursearch.php?ms=0";	
	if(aobj.style.display=="none"){
		//¼òµ¥ËÑË÷destination2 triplength2 triptype2 startcity2 endcity2
		var stype=parseInt(document.getElementById("searchtype1").value);
		
		var svalue="";
		
		
		if(stype==2)
		{
			svalue=document.getElementById("triplength2").value;
			if(parseInt(svalue)==0){
			    alert("please select trip length.");
				return;
			}
			posturl+="&t=1&l="+svalue;
		}
		else if(stype==3)
		{
			svalue=document.getElementById("triptype2").value;
			if(parseInt(svalue)==0){
			    alert("please select trip type.");
				return;
			}
			posturl+="&t=3&p="+svalue;
		}
		else if(stype==4)
		{
			svalue=document.getElementById("startcity2").value;
			if(parseInt(svalue)==0){
			    alert("please select start city.");
				return;
			}
			posturl+="&s="+svalue;
		}
		else if(stype==5)
		{
			svalue=document.getElementById("endcity2").value;
			if(parseInt(svalue)==0){
			    alert("please select end ctiy.");
				return;
			}
			posturl+="&e="+svalue;
		}		
		else
		{
			svalue=document.getElementById("destination2").value;
			if(svalue==""){
			    alert("please enter destination.");
				return;
			}
			posturl+="&t=2&q="+svalue;
			
			
		}
		document.location.href=posturl;
	}
	else
	{
		//¸´ÔÓËÑË÷
		var optioncount=0;
		svalue=document.getElementById("triplength3").value;
		if(parseInt(svalue)>0){
			  posturl+="&l="+svalue;
			  optioncount++;
		}
		
		
		svalue=document.getElementById("triptype3").value;
			if(parseInt(svalue)>0){
			   posturl+="&p="+svalue;
			   optioncount++;
			}			
		svalue=document.getElementById("startcity3").value;
			if(parseInt(svalue)>0){
			  posturl+="&s="+svalue;
			  optioncount++;
			}
		svalue=document.getElementById("endcity3").value;
			if(parseInt(svalue)>0){
			    posturl+="&e="+svalue;
				optioncount++;
			}
		
		var planobj=document.getElementsByName("planto"); 
	    var dCount=0;
		var destination="";
        for(var i=0;i<planobj.length;i++){ 
		   if(planobj[i].checked){
		     dCount++;
	         destination+=planobj[i].value+" ";
		   }
        }	
		
		if(dCount>0){
		    posturl+="&q="+destination;	
			optioncount++;
		}	
		if(optioncount==0){
		    
			alert("Please choose at least one option. The more information you provide, the better your search results will be.");
				return;
			 
		}
		else
		{			
			document.location.href=posturl;
		}
		
	}
	
	
}
function searchtypechange(){
    var myvalue=document.getElementById("searchtype1").value;
	var lengthobj=document.getElementById("triplength2")
	var typeobj=document.getElementById("triptype2")
	var startobj=document.getElementById("startcity2")
	var endobj=document.getElementById("endcity2")
	var destobj=document.getElementById("destination2")
	
	lengthobj.style.display="none";
	typeobj.style.display="none";
	startobj.style.display="none";
	endobj.style.display="none";
	destobj.style.display="none";
	
	if(myvalue=="2")
	{
		lengthobj.style.display="";
	}
	else if(myvalue=="3")
	{
		typeobj.style.display="";
	}
	else if(myvalue=="4")
	{
		startobj.style.display="";
	}
	else if(myvalue=="5")
	{
		endobj.style.display="";
	}
	else
	{
		destobj.style.display="";
	}
}
function changetextbox(tbname,index)
{
   var textobj=document.getElementById(tbname);
   if(textobj.value!="" || (textobj.value=="" && index==1)){
	   textobj.setAttribute("className","watermark");
	   textobj.setAttribute("class","watermark");
   }   
   else 
   { 
	   textobj.setAttribute("className","watermarked");
	   textobj.setAttribute("class","watermarked");
   }
   
}
function OnSearchClick(){
   alert(event.keyCode);
   if(event.keyCode=='ENTER')
   {   
       searchtrip3();
   }
	
}
