// JavaScript Document
function Cache(action){
	if(action.indexOf("?") < 0){
		var	parameter = '?';
	}else{
		var parameter = '&';
	}  
	return action+parameter+'cache='+Math.random();
}

function AjaxPage(div_id,action){
		$("#"+div_id).load(Cache(action));

}
//---------- facility.php ------------------//
function AddFac(){
	if($('#name').val()==""){
		alert("Please input name"); 
		$('#name').focus();
	}else if($('#type').val()==""){
		 alert("Please select type"); 
		 $('#type').focus();
	}else{
		$.post("facility_add.php", { 
		   type:$('#type').val(),
		   name:$('#name').val(),
		   name_en:$('#name_en').val()
		});
		getData('div_show','facility.php');
	}
}
function Confirm(object,name,del_page,re_page) {
	if (confirm("Do you want to delete "+name+" !!! ") == true) {
		getData('div_show',del_page);//delete no
		 var return_page =setTimeout("getData('div_show','"+re_page+"')",0500) 
		//getData('div_show',re_page);//re-page
			return true; 
		} 
			return false;   	
}
function update(id,self_page) {	
if(self_page=="category"){H=200;}else{H=120;}
			window.open("update_"+self_page+".php?id="+id+"","mywindow","menubar=0,resizable=0,scrollbars=0,height="+H+",width=350");					
}
function check(self_page){
	      if (document.getElementById(self_page).name.value=="") {
			   alert("Please input name");  
			   document.getElementById(self_page).name.focus();         
			   return false;
	     } if (document.getElementById(self_page).type.value=="") {
			   alert("Please select type");  
			   document.getElementById(self_page).type.focus();         
			   return false;
	     }else{
			 postData('blank',self_page+'_add.php');
		  var wait_show =setTimeout("getData('div_show','"+self_page+".php?page='+document."+self_page+".page.value)",1000) 
			    return false;
		 }	   
}
function add_sub_cat(){
		window.open("add_sub_category.php","mywindow","menubar=0,resizable=0,scrollbars=0,height=250,width=370");					
}
function add_accom(){
		window.open("add_accom_1.php","mywindow","menubar=0,location=0,resizable=0,scrollbars=1,height=650,width=780,directories=0");					
}
function add_between_price(){
		window.open("add_between_price.php","mywindow","menubar=0,resizable=0,scrollbars=0,height=100,width=400");					
}
function check_reserv(reserv_no){
		window.open("check_reserv.php?reserv_no="+reserv_no+"","mywindow","menubar=0,resizable=0,scrollbars=1,height=700,width=600");					
}
function update_accom(acc_id){
		window.open("update_accom.php?acc_id="+acc_id+"","mywindow","menubar=0,resizable=0,scrollbars=1,height=650,width=780");					
}
function focus_box(i){
 i.style.borderColor='#7F9DB9';
 i.style.backgroundColor='#FFFFFF';
 }
function blur_box(i){
 i.style.borderColor='#7F9DB9';
 i.style.backgroundColor='#FBFBFB';
 }


function AddRoomType(acc_id,date_type){
	$("#add_room_type_"+date_type).load('update_add_roomtype.php',{ 
		date_type:date_type
	});
}

function AddRoomBed(count_bed,date_type){
	$("#add_room_type_"+date_type).load('update_add_roomtype.php',{ 
		count_bed:count_bed,
		date_type:date_type
	});

	$("#add_bad_type_"+date_type).load('update_add_roombed.php',{ 
		count_bed:count_bed,
		date_type:date_type,
		acc_id:$('#update_id').val()
	});
}

function Loading(div_id){
	$("#"+div_id).html("<div id=save_data>Saving Data...<br><img src=\"img/sending.gif\" /></div>");
}
function LoadingSearchKey(){
	$('#box_keyword').hide();
	$('#loading_keyword').show(document.keyword.submit());
	//$('#loading_keyword').show();
}
function LoadingSearchPrice(){
	$('#box_search').hide();
	$('#loading_price').show(document.form_price.submit());
	//$('#loading_price').show();
}
function AddRoom(count_bed,date_type){
	var pre_data =    $("#add_bad_type_"+date_type).find("input").serialize();
	var data  = pre_data+'&type_room_name='+$('#type_room_name_'+date_type).val()+'&acc_id='+$('#update_id').val()+'&date_type='+date_type+'&update=add';
	//alert(data);
	$("#room_type_"+date_type).load('update_roomtype.php',data);
}
function DelRoom(acc_id,type_no,date_type){
    if(confirm("Do you want to delete room!!! ") == true) {
		$("#room_type_"+date_type).load('update_roomtype.php',{ 
			acc_id:acc_id,
			type_no:type_no,
			date_type:date_type,
			update:'del'
		});
	}
}
function DelBed(acc_id,bed_no,date_type){
    if(confirm("Do you want to delete bed!!! ") == true) {
		$("#room_type_"+date_type).load('update_roomtype.php',{ 
			acc_id:acc_id,
			bed_no:bed_no,
			date_type:date_type,
			update:'del_bed'
		});

	}
}


function add_photo_more_photo(acc_id,count,type){

		$("#add_more_photo_"+type).load('add_more_photo.php',{ 
			acc_id:acc_id,
			count:count,
			type:type
		});
}

function del_photo_acc(photo_no){
	    if(confirm("Do you want to delete photo!!! ") == true) {
			$("#photo_"+photo_no).load('del_photo_accom.php',{ photo_no:photo_no});
		}
}
