// JavaScript Document
//Function change link to view default hotels in each country
function viewdefaulthotels(frm){
	if(frm.txtcountname.selectedIndex != 0){
		frm.action = 'defaulthotels.php?count=' + frm.txtcountname.options[frm.txtcountname.selectedIndex].value;
		frm.submit();
	}
	else{
		frm.action = 'defaulthotels.php';
		frm.submit();
	}
}

function viewHotelHome(defaultCountry)
{
	with (window.document.frmListHotel) {
		if (cboCountry.selectedIndex != 0) {
/*			window.location.href = 'index.php?count=' + defaultCountry;
		} else {*/
			window.location.href = 'index.php?count=' + cboCountry.options[cboCountry.selectedIndex].value;
		}
	}
}

function viewHotel()
{
	with (window.document.frmListHotel) {
		if (cboCountry.selectedIndex != 0) {
/*			window.location.href = 'index.php';
		} else {*/
			window.location.href = 'index.php?count=' + cboCountry.options[cboCountry.selectedIndex].value;
		}
	}
}

function viewHotelsTariff()
{
	with (window.document.frmListHotel) {
		if (cboCountry.selectedIndex != 0) {
/*			window.location.href = 'index.php';
		} else {*/
			window.location.href = 'index.php?view=tariff&count=' + cboCountry.options[cboCountry.selectedIndex].value;
		}
	}
}

function viewDefaultHotel(qStr)
{
//	alert(qStr);
	var urlLink = window.location.href;
//	alert(urlLink);
	with (window.document.frmListHotel) {
		if (cboCountry.selectedIndex != 0) {
/*			window.location.href = urlLink;
		} else {*/
			window.location.href = 'index.php?'+qStr+'&dhcount=' + cboCountry.options[cboCountry.selectedIndex].value;
		}
	}
}

function viewHotelConference()
{
	with (window.document.frmListHotel) {
		if (cboCountry.selectedIndex != 0) {
/*			window.location.href = 'index.php';
		} else {*/
			window.location.href = 'index.php?view=conference&count=' + cboCountry.options[cboCountry.selectedIndex].value;
		}
	}
}

function checkAddHotelForm()
{
//	alert(tinyMCE.get("txthotdescrpt").getContent());
	
	with (window.document.frmAddHotel) {
		if(txthotname.value == ""){
			alert("Please enter hotel name!");
			txthotname.focus();
			return;
		}
		else {
			if(txthotemail.value != ""){
				if(txthotemail.value.indexOf ('@',0) == -1 || txthotemail.value.indexOf ('.',0) == -1) {
					alert ("The Email field requires a \"@\" and a \".\" be used. \n\nPlease re-enter the Email address.")
					txtcustemail.select();
					txtcustemail.focus();
					return;
				}
			}				
			if(txthoturl.value != ""){
				if(txthoturl.value.indexOf ('www',0) == -1 || txthoturl.value.indexOf ('.',0) == -1) {
					alert ("The URL field requires a \"www\" and a \".\" be used. \n\nPlease re-enter the URL address.")
					txthoturl.select();
					txthoturl.focus();
					return;
				}
				/*
				if(txthoturl.value.indexOf ('http://',0) == -1 || txthoturl.value.indexOf ('.',0) == -1) {
					alert ("The URL field requires a \"http://\" and a \".\" be used. \n\nPlease re-enter the URL address.")
					txthoturl.select();
					txthoturl.focus();
					return;
				}
				*/
			}
			if(txthotloc.selectedIndex == 0){
				alert("Please select hotel location!");
				txthotloc.focus();
				return;
			}
			else
/*				if(txthotcat.selectedIndex == 0){
					alert("Please select hotel category!");
					txthotcat.focus();
					return;
				}
				else{*/
					txthotname.value = trim(txthotname.value);
					txthotdescrpt.value = trim(txthotdescrpt.value);
					txthotaddress.value = trim(txthotaddress.value);
					txthottelno.value = trim(txthottelno.value);
					txthotfaxno.value = trim(txthotfaxno.value);
					txthotemail.value = trim(txthotemail.value);
					txthoturl.value = trim(txthoturl.value);
					txthotnote.value = trim(txthotnote.value);
					txthotnumroom.value = trim(txthotnumroom.value);
					submit();
//				}
		}
	}
}

function checkAddRoomForm()
{
	with (window.document.frmAddRoomHotel) {
		if(txtroomname.value == ""){
			alert("Please enter room category name!");
			txtroomname.focus();
			return;
		}
/*		else
			if(txtroomdescrpt.value == ""){
				alert("Please enter room category description!");
				txtroomdescrpt.focus();
				return;
			}*/
			else {
				txtroomname.value = trim(txtroomname.value);
				txtroomdescrpt.value = trim(txtroomdescrpt.value);
				submit();
			}
	}
}

function checkAddConferenceForm()
{
	with (window.document.frmAddConferenceHotel) {
		if(conf_file1.value == ""){
			alert("Please select a conference file!");
			conf_file1.focus();
			return;
		}
		else {
//			conf_file1.value = trim(conf_file1.value);
			submit();
		}
	}
}

function checkAddHotelRateForm()
{
	with (window.document.frmAddHotelRate) {
		if (s_day.selectedIndex == 0) {
			alert('Choose the start date');
			s_day.focus();
			return;
		} else if (s_mnth.selectedIndex == 0) {
			alert('Choose the start month');
			s_mnth.focus();
			return;
		} else if (s_year.selectedIndex == 0) {
			alert('Choose the start year');
			s_year.focus();
			return;
		} else if (e_day.selectedIndex == 0) {
			alert('Choose the end date');
			e_day.focus();
			return;
		} else if (e_mnth.selectedIndex == 0) {
			alert('Choose the ent month');
			e_mnth.focus();
			return;
		} else if (e_year.selectedIndex == 0) {
			alert('Choose the end year');
			e_year.focus();
			return;
		} else {
			submit();
		}
	}
}

function addHotel(locId, countId, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	window.location.href = 'index.php?view=add&count=' + countId + '&loc=' + locId + qstr;
}

function modifyHotel(hotId, locId, countId, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	window.location.href = 'index.php?view=add&loc=' + locId + '&count=' + countId + '&hot=' + hotId + qstr;
}

function deleteHotel(hotId, locId, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if (confirm('Delete this hotel?')) {
		window.location.href = 'processHotel.php?action=delete&hot=' + hotId + '&loc=' + locId + qstr;
	}
}

function deleteSelectedHotel(frm, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if(confirmdelcheckeditems('Hotel(s)',frm)){
		frm.action="processHotel.php?action=delselected" + qstr;
		frm.submit();
	}
}

function publishSelectedHotel(frm,qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if(confirmpubcheckeditems('Hotel(s)',frm)){
		frm.action="processHotel.php?action=pubselected"+qstr;
		frm.submit();
	}
}

function unpublishSelectedHotel(frm,qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if(confirmunpubcheckeditems('Hotel(s)',frm)){
		frm.action="processHotel.php?action=unpubselected"+qstr;
		frm.submit();
	}
}

function deleteHotelImage(hotId,imageId)
{
	if (confirm("Delete this image?")) {
		window.location.href = "processHotel.php?action=deleteImage&hot=" + hotId + "&img=" + imageId;
	}
}

function deleteHotelConferenceFile(hotId)
{
	if (confirm("Delete this conference file?")) {
		window.location.href = "processHotel.php?action=deleteConf&hot=" + hotId;
	}
}

function deleteHotelPrice(hotId,priceId)
{
	if (confirm("Delete this price")) {
		window.location.href = "processHotel.php?action=deletePrice&hot=" + hotId + "&prc=" + priceId;
	}
}

function deleteHotelValidDate(hotId,validId)
{
	if (confirm("Delete this validation date")) {
		window.location.href = "processHotel.php?action=deleteDate&hot=" + hotId + "&valid=" + validId;
	}
}

function addRoom(hotId, locId,countId,qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	window.location.href = 'index.php?view=addroom&count=' + countId + '&loc=' + locId + '&hot=' + hotId + qstr;
}

function modifyRoom(roomId, hotId,locId,countId,qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	window.location.href = 'index.php?view=addroom&count=' + countId + '&loc=' + locId + '&hot=' + hotId + '&room=' + roomId + qstr;
}

function deleteRoom(roomId, hotId, locId,qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if (confirm('Delete this room type?')) {
		window.location.href = 'processHotel.php?action=deleteroom&room=' + roomId + '&hot=' + hotId + '&loc=' + locId + qstr;
	}
}