// 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;
		}
	}
}

function checkAddTourForm()
{
	with (window.document.frmAddTour) {
		if (txttourcat.selectedIndex == 0) {
			alert('Choose the package tours category');
			txttourcat.focus();
			return;
		} else if (isEmpty(txttourcode, 'Enter package tours code', true)) {
			return;
		} else if (isEmpty(txttourname, 'Enter package tours name', true)) {
			return;
		} else if (isEmpty(txttourdurat, 'Enter number of day(s)', 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 package tours itineraries', true)) {
			return;
		} else if (isEmpty(txttourdescrpt, 'Enter package tours description', true)) {
			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 if (txtUserType.selectedIndex == 0) {
			alert('Choose the user type');
			txtUserType.focus();
			return;
		} else {
			submit();
		}
	}
}

function addTour(tourcatId,countId,pageNum)
{
	window.location.href = 'index.php?view=add&page='+ pageNum + '&count=' + countId + '&tourcat=' + tourcatId;
}

function addTourRate(tourId,tourcatId,countId,pageNum)
{
	window.location.href = 'index.php?view=addrate&page=' + pageNum + '&count=' + countId + '&tourcat=' + tourcatId + '&tour=' + tourId + '&bck=1';
}

function modifyTour(tourId,tourcatId,countId,pageNum)
{
	window.location.href = 'index.php?view=add&page=' + pageNum + '&count=' + countId + '&tourcat=' + tourcatId + '&tour=' + tourId + '&bck=1';
	//'index.php?view=modify&tour=' + tourId;
}

function deleteTour(tourId, tourcatId, pageNum)
{
	if (confirm('Delete this package tours?')) {
		window.location.href = 'processTour.php?action=delete&page=' + pageNum + '&tour=' + tourId + '&tourcat=' + tourcatId;
	}
}

function deleteImage(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 + '&tourcat='+ tourcatId + '&tour=' + tourId + '&bck=1';
}
