function check_avilableupdate(form, fill)
{
	window.form = form;
	var url = "avilable_req.php?";
	
	var size = form.elements.length;
	
	for(i = 0 ; i < size; i++)
	{
		current = form.elements[i];	
		if(current.name=='check_in')
		{
			window.arr_date=escape(current.value)
		}
		if(current.name=='check_out')
		{
			window.dep_date=escape(current.value)
		}
		if(current.name=='rooms')
		{
			window.rooms=escape(current.value)
		}
		if(current.name=='smokPreference')
		{
			window.smoke=escape(current.value)
		}
		if(current.name=='regid')
		{
			window.regid=escape(current.value)
		}
		if(current.name=='adults')
		{
			window.adults=escape(current.value)
		}
		if(current.name=='roomPreference')
		{
			window.room_type=escape(current.value)
		}
		if(current.name=='childs')
		{
			window.childs=escape(current.value)
		}
		if(current.type !="checkbox")
		{
			url += "&" + current.name + "=" + escape(current.value);
		}
		else
		{
			url += "&" + current.name + "=" + escape(current.checked);
		}
	}
 	processByStatus(url, fill,"check_avilableupdateDone","check_avilableError");
} 

function check_avilableupdateDone()
{	
window.location="update_room_app.php?roomPreference=" +window.room_type + "&day=" + days_between(window.arr_date,window.dep_date)+ "&arrival=" + window.arr_date+ "&dep=" + window.dep_date + "&smoke=" + window.smoke+ "&rooms=" + window.rooms+ "&adults=" + window.adults+ "&childs=" + window.childs+ "&regid=" + window.regid;
}

function check_avilableupdateError()
{
	
}
function check_avilable(form, fill)
{
	window.form = form;
	var url = "avilable_req.php?";
	
	var size = form.elements.length;
	
	for(i = 0 ; i < size; i++)
	{
		current = form.elements[i];	
		if(current.name=='check_in')
		{
			window.arr_date=escape(current.value)
		}
		if(current.name=='check_out')
		{
			window.dep_date=escape(current.value)
		}
		if(current.name=='rooms')
		{
			window.rooms=escape(current.value)
		}
		if(current.name=='smokPreference')
		{
			window.smoke=escape(current.value)
		}
		if(current.name=='adults')
		{
			window.adults=escape(current.value)
		}
		if(current.name=='roomPreference')
		{
			window.room_type=escape(current.value)
		}
		if(current.type !="checkbox")
		{
			url += "&" + current.name + "=" + escape(current.value);
		}
		else
		{
			url += "&" + current.name + "=" + escape(current.checked);
		}
	}
	processByStatus(url, fill,"check_avilableDone","check_avilableError");
} 

function check_avilableDone()
{	
	window.location="room_app.php?roomPreference=" +window.room_type + "&day=" + days_between(window.arr_date,window.dep_date)+ "&arrival=" + window.arr_date+ "&dep=" + window.dep_date + "&smoke=" + window.smoke+ "&rooms=" + window.rooms+ "&adults=" + window.adults+ "&childs=" + window.childs;
}

function check_avilableError()
{
	
}

function register(form, fill)
{
	window.form = form;
	var url = "reserve_req.php?";
	
	var size = form.elements.length;
	
	for(i = 0 ; i < size; i++)
	{
		current = form.elements[i];	
			if(current.type !="checkbox")
		{
			url += "&" + current.name + "=" + escape(current.value);
		}
		else
		{
			url += "&" + current.name + "=" + escape(current.checked);
		}
	}
	process(url, fill);
} 

function load_res(form, fill)
{
	window.form = form;
	var url = "load_req.php?";
	
	var size = form.elements.length;
	
	for(i = 0 ; i < size; i++)
	{
		current = form.elements[i];	
			if(current.type !="checkbox")
		{
			url += "&" + current.name + "=" + escape(current.value);
		}
		else
		{
			url += "&" + current.name + "=" + escape(current.checked);
		}
	}
	process(url, fill);
}

function update_register(form, fill)
{
	window.form = form;
	var url = "update_reserve_req.php?";
	
	var size = form.elements.length;
	
	for(i = 0 ; i < size; i++)
	{
		current = form.elements[i];	
			if(current.type !="checkbox")
		{
			url += "&" + current.name + "=" + escape(current.value);
		}
		else
		{
			url += "&" + current.name + "=" + escape(current.checked);
		}
	}
	process(url, fill);
} 
function save_rooms(form, fill)
{
	window.form = form;
	var url = "room_confg_req.php?";
	
	var size = form.elements.length;
	
	for(i = 0 ; i < size; i++)
	{
		current = form.elements[i];	
			if(current.type !="checkbox")
		{
			url += "&" + current.name + "=" + escape(current.value);
		}
		else
		{
			url += "&" + current.name + "=" + escape(current.checked);
		}
	}
	process(url, fill);
} 
function check_avilableError()
{
	
}

function save_reserve(form, fill)
{
	window.form = form;
	var url = "admin_room_req.php?";
	
	var size = form.elements.length;
	
	for(i = 0 ; i < size; i++)
	{
		current = form.elements[i];	
			if(current.type !="checkbox")
		{
			url += "&" + current.name + "=" + escape(current.value);
		}
		else
		{
			url += "&" + current.name + "=" + escape(current.checked);
		}
	}
	process(url, fill);
} 


function days_between(date1, date2) {

date1 = date1.split("-");
  date2 = date2.split("-");
  var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
  var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
  var daysApart = Math.abs(Math.round((sDate-eDate)/86400000));
  return daysApart;
}