/* START - AJAX COMMON FUNCTIONS */
function update(result, ui_id){
	var div = $(ui_id);
	if (result.status==Http.Status.OK){
		//alert(result.responseText);
		//return false;
		window.location='SearchResult.htm';
		return false;
		//ui_id.innerHTML = result.responseText;
		//document.getElementById(ui_id).innerHTML = result.responseText;
		//document.getElementById('showpost21').style.display = "none";
		
	}else{
		div.innerHTML = "An error occurred (" + result.status.toString() + ").";
		div.innerHTML = "";
	}
}// end update()


//function showrecords('Http.Cache.GetNoCache','newsresult',DestinationFrom,destloc,destlocid,dep_date,ret_date,trip_type,AdultCnt,Childcnt,InfantCnt,Flightclass){
function showrecords(cache_method,ui_id,DestinationFrom,destloc,destlocid,dep_date,ret_date,AdultCnt,Childcnt,InfantCnt,Flightclass){



for (var i=0; i < document.frmsearch.trip_type.length; i++)
   {
   if (document.frmsearch.trip_type[i].checked)
      {
      	var rad_val = document.frmsearch.trip_type[i].value;
      }
   }
//alert(rad_val);
//return false ;
var SDate = document.getElementById('dep_date').value;    	
var EDate =  document.getElementById('ret_date').value;

if(rad_val == 'ROUNDTRIP') {
		 //   alert(SDate) ; 
		//	alert(EDate) ; 
			  
        var alertReason1 =  'Return Date must be greater than or equal to  Departure Date.' 
        var alertReason2 =  'Return Date can not be less than Departure Date.';
    	
        var endDate = new Date(EDate);    	
        var startDate= new Date(SDate);
         
		// alert(endDate) ; 
		// alert(startDate) ;
           if(SDate != '' && EDate != '' && startDate > endDate)
        {
    	    alert(alertReason1);
    	    document.getElementById('ret_date').value = "";
    	    return false;
        }
        else if(SDate == '')	
        {
            alert("Please enter Departure Date");
			document.getElementById('dep_date').focus() ;
            return false;
        }
    else if(EDate == '')	
        {
            alert("Please enter Return Date");
			document.getElementById('ret_date').focus() ;
            return false;
        }	    
}else if(rad_val == 'ONEWAY') {
	if(SDate == '')	
        {
            alert("Please enter Departure Date");
			document.getElementById('dep_date').focus() ;
            return false;
        }
}
if(document.getElementById('destloc').value == ''){
	alert('Please Enter the Destination Name.');
	document.getElementById('destloc').focus();
	return false ; 
}

document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block' ; 

	
Http.get({
		url: "search-result.php?DestinationFrom="+DestinationFrom+"&destloc="+destloc+"&destlocid="+destlocid+"&dep_date="+dep_date+"&ret_date="+ret_date+"&trip_type="+rad_val+"&AdultCnt="+AdultCnt+"&Childcnt="+Childcnt+"&InfantCnt="+InfantCnt+"&Flightclass="+Flightclass,
		callback: update,
		cache: cache_method	
	}, [ui_id]);
}//
