// JavaScript Document
function viewTour()
{
	with (window.document.frmListTour) {
		if (cboCountry.selectedIndex != 0) {
/*			window.location.href = 'index.php';
		} else {*/
			window.location.href = 'index.php?count=' + cboCountry.options[cboCountry.selectedIndex].value;
		}
	}
}

// JavaScript Document
function viewOptionalTour()
{
	with (window.document.frmListTour) {
		if (cboCountry.selectedIndex != 0) {
/*			window.location.href = 'index.php';
		} else {*/
			window.location.href = 'index.php?view=optional&count=' + cboCountry.options[cboCountry.selectedIndex].value;
		}
	}
}

function checkAddTourForm()
{
	with (window.document.frmAddTour) {
		if (txttourcat.selectedIndex == 0) {
			alert('Choose the package tours category');
			txttourcat.focus();
			return;
		} else if (isEmpty(txttourcode, 'Enter tours code', true)) {
			return;
		} else if (isEmpty(txttourname, 'Enter tours name', true)) {
			return;
		} else if (isEmpty(txttourdurat, 'Enter tours duration', true)) {
			return;
		}/* else if (isEmpty(txttourdurat1, 'Enter number of night(s)', true)) {
			return;
		} else if(isBigger(txttourdurat1,txttourdurat, 'Number of day(s) must bigger than number of night(s)')){
			return;
		}*/ else if (isEmpty(txttouritine, 'Enter tours itineraries', true)) {
			return;
		}/* else if(txttourdescrpt.value == ""){
			alert("Enter tours description!");
			return;
		} else if (isEmpty(txttourothers, 'Enter package tours others', true)) {
			return;
		}*/ else {
			txttourcode.value = trim(txttourcode.value);
			txttourname.value = trim(txttourname.value);
			txttourdurat.value = trim(txttourdurat.value);
			txttouritine.value = trim(txttouritine.value);
//			txttourdescrpt.value = trim(txttourdescrpt.value);
			txttourothers.value = trim(txttourothers.value);
			submit();
		}
	}
}

function checkAddTourRateForm()
{
	with (window.document.frmAddTourRate) {
		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 addTour(tourcatId,countId, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	window.location.href = 'index.php?view=add&count=' + countId + '&tcat=' + tourcatId + qstr;
}

function addTourRate(tourId,tourcatId,countId, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	window.location.href = 'index.php?view=addrate&count=' + countId + '&tcat=' + tourcatId + '&tour=' + tourId + qstr;
}

function modifyTour(tourId,tourcatId,countId, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	window.location.href = 'index.php?view=add&count=' + countId + '&tcat=' + tourcatId + '&tour=' + tourId + '&bck=1'+qstr;
}

function deleteTour(tourId, tourcatId, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if (confirm('Delete this package tours?')) {
		window.location.href = 'processTour.php?action=delete&tour=' + tourId + '&tcat=' + tourcatId + qstr;
	}
}

function deleteSelectedTour(frm, qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if(confirmdelcheckeditems('Package tour(s)',frm)){
		frm.action="processTour.php?action=delselected" + qstr;
		frm.submit();
	}
}

function publishSelectedTour(frm,qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if(confirmpubcheckeditems('Package tour(s)',frm)){
		frm.action="processTour.php?action=pubselected"+qstr;
		frm.submit();
	}
}

function unpublishSelectedTour(frm,qstr)
{
	qstr = (qstr!="")?"&"+qstr:qstr;
	if(confirmunpubcheckeditems('Package tour(s)',frm)){
		frm.action="processTour.php?action=unpubselected"+qstr;
		frm.submit();
	}
}

function deleteToursImage(tourId,imageId)
{
	if (confirm("Delete this image")) {
		window.location.href = "processTour.php?action=deleteImage&tour=" + tourId + "&img=" + imageId;
	}
}

function deletePrice(tourId,priceId)
{
	if (confirm("Delete this price")) {
		window.location.href = "processTour.php?action=deletePrice&tour=" + tourId + "&prc=" + priceId;
	}
}

function deleteDfaultHotel(tourId,dhotelId)
{
	if (confirm("Delete this default hotel")) {
		window.location.href = "processTour.php?action=deleteDHotel&tour=" + tourId + "&dh=" + dhotelId;
	}
}

function deleteValidDate(tourId,validId)
{
	if (confirm("Delete this validation date")) {
		window.location.href = "processTour.php?action=deleteDate&tour=" + tourId + "&valid=" + validId;
	}
}

function uploadImage(countId, tourcatId, tourId, pageNum)
{
	window.location.href='index.php?view=add&page=' + pageNum + '&count=' + countId + '&tcat='+ tourcatId + '&tour=' + tourId + '&bck=1';
}