$(function(){
	var s_today = new   Date();
	var today = s_today.getFullYear()+'-'+((s_today.getMonth()+1)>9?(s_today.getMonth()+1):('0'+(s_today.getMonth()+1)))+'-'+(s_today.getDate()>9?s_today.getDate():('0'+s_today.getDate()));
	s_today.setUTCDate((s_today.getUTCDate()+1));
	var tomorrow = s_today.getFullYear()+'-'+((s_today.getMonth()+1)>9?(s_today.getMonth()+1):('0'+(s_today.getMonth()+1)))+'-'+(s_today.getDate()>9?s_today.getDate():('0'+s_today.getDate())); 
	s_today.setUTCDate((s_today.getUTCDate()+6));
	var seven = s_today.getFullYear()+'-'+((s_today.getMonth()+1)>9?(s_today.getMonth()+1):('0'+(s_today.getMonth()+1)))+'-'+(s_today.getDate()>9?s_today.getDate():('0'+s_today.getDate()));
	$('#checkindate').val(today);
	$('#sdate').val(today);
	$('#checkoutdate').val(seven);
	$('#edate').val(seven);
	$('#checkindate').doubleDatePicker({minDate:today});  
	$('#checkoutdate').doubleDatePicker({minDate:tomorrow,firstCal:'checkindate'});
	$('#sdate').doubleDatePicker({minDate:today});  
	$('#edate').doubleDatePicker({minDate:tomorrow,firstCal:'sdate'});
	//外部事件绑定
	$('#id_checkindate').bind('click',function(){$('#checkindate').focus();});
	$('#id_checkoutdate').bind('click',function(){$('#checkoutdate').focus();});
	$('#id_sdate').bind('click',function(){$('#sdate').focus();});
	$('#id_edate').bind('click',function(){$('#edate').focus();});
	$('#search_room').bind('click',function(){getSingleRoom();});
	getSingleRoom();
	//getAllRoom();
});

function chk(){
	document.f1.submit();	
}

//添加到收藏
function addFav(info_id,title,url,price,info_type,cust_id){
	if(info_id=='')
		info_id=new Date().getTime();
	 $.ajax({
			   type: 'POST',
			   url: 'http://www.51766.com/www2009/userbox/box_ajax.jsp',
			   data: 'action=addFavorite&cust_id='+cust_id+'&info_id='+info_id +'&title='+escape(title)+'&price='+price+'&info_type='+info_type+'&url='+url,
			   beforeSend:function(){
			   		document.body.disabled=true;
			   },
			   success: function(msg){
			   		document.body.disabled=false;
			     	alert(msg);
			   },
			   error:function(msg){
			   		document.body.disabled=false;
			   		alert('添加“关注”失败！请稍后重试。');
			   }
		});
}

function getSingleRoom(){
	$("#singleroom").load("/www2009/ajax/shop_hotel_room_ajax.jsp", {type:'0',sdate:$('#checkindate').val(),edate:$('#checkoutdate').val(),cust_id: $('#cust_id').val(),info_id:$('#info_id').val()});
	$('#sdate').val($('#checkindate').val());
	$('#edate').val($('#checkoutdate').val());
}
function getAllRoom(){
	$("#allroom").load("/www2009/ajax/shop_hotel_room_ajax.jsp", {type:'1',cust_id: $('#cust_id').val(),info_id:$('#info_id').val()});
}