var base_url='http://www.switzerlandhotel.net/restclient2/';
//http://www.switzerlandhotel.net/restclient2/home2
//http://localhost:8080/restclient/';

$(function(){
    
          //Set Default Date
          var current=new Date();
          $("#checkin").val($.datepicker.formatDate('yy-mm-dd',current));
          current.setDate(parseInt(current.getDate()) + parseInt(1)); 
          $("#checkout").val($.datepicker.formatDate('yy-mm-dd',current));
          
	  $("#checkin").datepicker({ 
								dateFormat: 'yy-mm-dd', 
								minDate: new Date(), 
								maxDate: '+1y',
								beforeShowDay:false,
                                                                onSelect: function(dateText, inst) { 
                                                                        
                                                                          var dateValues = dateText.split('-');
                                                                          var objDate = new Date(dateValues[0],dateValues[1],dateValues[2]);
                                                                          if (!isNaN(objDate)){
                                                                             objDate.setDate(parseInt(objDate.getDate()) + parseInt(1));
                                                                             objDate.setMonth(parseInt(objDate.getMonth())-1)
                                                                             $("#checkout").val($.datepicker.formatDate('yy-mm-dd',objDate));
                                                                          }
                                                                }});
                                                            
	 $("#checkout").datepicker({ 
								dateFormat: 'yy-mm-dd', 
								minDate: new Date(), 
								maxDate: '+1y',
      								beforeShowDay:false});
	 $("#pik-date1").click(function(){
	      $("#checkin").focus();
	 });
         
	 $("#pik-date2").click(function(){
	    $("#checkout").focus();
	 });
	 
	  $("#checkin").focus(function () {
                    $(this).blur();
                });
				
	  $("#checkout").focus(function () {
                    $(this).blur();
                });
          
           
           
           $("#distination").autocomplete({
			source: base_url+"home2/destination",
			minLength: 2,
			select: function( event, ui ) {
                            $("#distination").val(ui.item.value);
			}
	   }); 
           
           $("#NoRooms").change(function(){
               
                var rnV=$(this).val();
                $(".rnX").hide();
                if(rnV>1){
                   for(var i=2;i<=rnV;i++){
                      var id=$("#rn"+i);
                      $(id).show();
                      //$("#rn2").show();
                   }
                } 
                 
           });
           

  });
  
/**
 * Comment
 */
function showage(the,id) {
    var val=$(the).val();
    //alert('xxx');
    var r1=$("#"+id+"_rage1");
    var r2=$("#"+id+"_rage2");
    var rx=$("#"+id+"_rage"+val);
    if(val>0){
        $("#cage1,#cage2").show();
        if(val==1) $(r2).hide();
        if(val==2) $(r1).show();
        $(rx).show();
    }else{
        $(r1).hide();
        $(r2).hide();
    }
    return false;
}
function IsValidAvaiableForm(){
            
   if($("#distination").isEmpty()){
      alert("Please enter destination.");
      $("#distination").focus();
      return false;
   }
   
    if($("#checkin").isEmpty()){
      alert("Please select check in date.");
      $("#checkin").focus();
      return false;
   }
    if($("#checkout").isEmpty()){
      alert("Please select check out date");
      $("#checkout").focus();
      return false;
   }
   $.blockUI({message:$("#loading")});
   return true;
}


