
//Link maker---------------------------------------------------------------------------

	function clearRadioSelection (which) {
		if (which != "regionsRow" && which != "productsRow") {
			switch (which) {
				case "countriesRow":
					cual = "rdoCountry";
					break;
				case "activitiesRow":
					cual = "rdoActivity";
					break;
				case "typesRow":
					cual = "rdoType";
					break;
			}
			theForm = document.linkCreation;
			eval("obj = theForm."+cual+";");
			amount = obj.length;
			for (i = 0; i < amount; i++) {
				obj[i].checked = false;
			}
		}
	}

	function showOptions(value, which) {
		obj = document.getElementById(which);
		if (value) {
			obj.style.display = 'block';
		}
		else {
			obj.style.display = 'none';
		}
		if (which == "countriesRow") {
			reg = document.getElementById('regions');
			regRow = document.getElementById('regionsRow');

			prod = document.getElementById('products');
			prodRow = document.getElementById('productsRow');

			regId = document.getElementById('txtRegionId');
			regName = document.getElementById('txtRegionName');

			prodId = document.getElementById('txtProductId');
			prodName = document.getElementById('txtProductName');
			if (value) {
				reg.style.display = 'block';
				regRow.style.display = 'none';
				prod.style.display = 'block';
				prodRow.style.display = 'none';
			}
			else {
				reg.style.display = 'none';
				regRow.style.display = 'none';
				prod.style.display = 'none';
				prodRow.style.display = 'none';
			}
			regId.value = "";
			regName.value = "";
			prodId.value = "";
			prodName.value = "";
			
			checks = document.linkCreation.chkLinkOptions;
			for (i = 0; i < document.linkCreation.chkLinkOptions.length; i++) {
				if (checks[i].value == "region" || checks[i].value == "product") {
					checks[i].checked = false;
				}
			}
		}
		clearRadioSelection (which);
	}
	
	function submitLinkCreation() {
		theForm = document.linkCreation;
		theForm.create.value = 1;
		theForm.submit();
	}

	function addSelectedInfo (which, value) {
		theForm = document.linkCreation;
		eval("theForm."+which+".value = '"+value+"';");
	}
	
	function showLinkDestination (page) {
		var address = page; //dirección de la página
		var op_tool = 1;  //barra de herramientas
		var op_loc_box = 1; //barra de direcciones
		var op_dir =  1; //vinculos/links
		var op_stat = 1;  //barra de estado  
		var op_menu = 1; //barra de menú
		var op_scroll = 1; //visibilidad de scrolls
		var op_fullscr = 0; //visibilidad de scrolls
		var op_resize = 1; //permitir cambiar el tamaño de la ventana
		var op_wid = screen.width; //ancho de la ventanta
		var op_heigh = screen.height; //alto de la ventana
		var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories=" + op_dir + ",status=" + op_stat 
		+ ",menubar=" + op_menu + ",scrollbars="  + op_scroll + ",resizable=" + op_resize + ",fullscreen=" + op_fullscr
		+ ",width=" + op_wid + ",height=" + op_heigh;
		//var win3 = window.open("", "FotoGaleria", option);  
		//alert(address);

		var newWindow = window.open(address, "ShowDestination", option);
		window.opener = self;
		newWindow.focus();
	}

	function regionSearch () {
		theForm = document.linkCreation;
		obj = theForm.rdoCountry;
		amount = obj.length;
		selected = -1;
		for (i = 0; i < amount; i++) {
			if (obj[i].checked == true) {
				selected = obj[i].value;
			}
		}
		if (selected == -1) {
			alert("You must choose a country");
		}
		else {			
			var address = "regionSearch.php?country="+selected; //dirección de la página
			var op_tool = 0;  //barra de herramientas
			var op_loc_box = 0; //barra de direcciones
			var op_dir =  0; //vinculos/links
			var op_stat = 1;  //barra de estado  
			var op_menu = 0; //barra de menú
			var op_scroll = 1; //visibilidad de scrolls
			var op_fullscr = 0; //visibilidad de scrolls
			var op_resize = 1; //permitir cambiar el tamaño de la ventana
			var op_wid = 400; //ancho de la ventanta
			var op_heigh = 300; //alto de la ventana
			var op_top = (screen.height/2) - (op_heigh/2);
			var op_left = (screen.width/2) - (op_wid/2);
			var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories=" + op_dir + ",status=" + op_stat 
			+ ",menubar=" + op_menu + ",scrollbars="  + op_scroll + ",resizable=" + op_resize + ",fullscreen=" + op_fullscr
			+ ",width=" + op_wid + ",height=" + op_heigh + ",top=" + op_top + ",left=" + op_left;
			//var win3 = window.open("", "FotoGaleria", option);  
			//alert(address);
	
			var newWindow = window.open(address, "PickRegion", option);
			window.opener = self;
			newWindow.focus();
		}
	}

	function productSearch () {
		theForm = document.linkCreation;
		objType = theForm.rdoType;
		amount = objType.length;
		selectedType = -1;
		for (i = 0; i < amount; i++) {
			if (objType[i].checked == true) {
				selectedType = objType[i].value;
			}
		}
		if (selectedType == -1) {
			alert("You must choose a product type");
		}

		objCountry = theForm.rdoCountry;
		amount = objCountry.length;
		selectedCountry = -1;
		for (i = 0; i < amount; i++) {
			if (objCountry[i].checked == true) {
				selectedCountry = objCountry[i].value;
			}
		}
		if (selectedCountry == -1) {
			alert("You must choose a country");
		}
		else {
			selectedRegion = theForm.txtRegionId.value;
			if (selectedRegion == -1 || selectedRegion == "") {
				alert("You must choose a region");
			}
		}

		/*
		objActivity = theForm.rdoActivity;
		amount = objActivity.length;
		selectedActivity = -1;
		for (i = 0; i < amount; i++) {
			if (objActivity[i].checked == true) {
				selectedActivity = objActivity[i].value;
			}
		}
		if (selectedActivity == -1) {
			alert("You must choose an activity");
		}
		*/
		
		if (selectedType != -1 && selectedCountry != -1 && selectedRegion != -1 && selectedRegion != "") {
			var address = "productSearch.php?type="+selectedType+"&country="+selectedCountry+"&region="+selectedRegion; //dirección de la página
			var op_tool = 0;  //barra de herramientas
			var op_loc_box = 0; //barra de direcciones
			var op_dir =  0; //vinculos/links
			var op_stat = 1;  //barra de estado  
			var op_menu = 0; //barra de menú
			var op_scroll = 1; //visibilidad de scrolls
			var op_fullscr = 0; //visibilidad de scrolls
			var op_resize = 1; //permitir cambiar el tamaño de la ventana
			var op_wid = 400; //ancho de la ventanta
			var op_heigh = 300; //alto de la ventana
			var op_top = (screen.height/2) - (op_heigh/2);
			var op_left = (screen.width/2) - (op_wid/2);
			var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories=" + op_dir + ",status=" + op_stat 
			+ ",menubar=" + op_menu + ",scrollbars="  + op_scroll + ",resizable=" + op_resize + ",fullscreen=" + op_fullscr
			+ ",width=" + op_wid + ",height=" + op_heigh + ",top=" + op_top + ",left=" + op_left;
			//var win3 = window.open("", "FotoGaleria", option);  
			//alert(address);
	
			var newWindow = window.open(address, "PickProduct", option);
			window.opener = self;
			newWindow.focus();
		}
	}

//Login--------------------------------------------------------------------------------

	function checkLogin () {
		currentForm = document.loginForm;
		allOK = true;
		errorMsg = "The following problems were encountered when trying to login:";
				
		if (currentForm.username.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter your username";
		}
		if (currentForm.password.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter your password";
		}
		
		if (allOK) {
			currentForm.submit();
		}
		else {
			alert(errorMsg);
		}
	}

	function logout () {
		currentForm = document.logoutForm;
		r = false;
		r = confirm ("You are about to logout from the administration console. Are you sure?");
		if (r) {
			currentForm.logoutProcess.value = 1;
			currentForm.submit();
		}
	}
	
	function relogin () {
		currentForm = document.reloginForm;
		currentForm.submit();
	}

//Visitors report---------------------------------------------------------------------------

	function visitorFilterFields (val, which) {
		eval("theField = document.getElementById('"+which+"');");
		if (val) {
			theField.disabled = false;
		}
		else {
			theField.disabled = true;
		}
		theField.value = "";
	}

//Index selection---------------------------------------------------------------------------

	function submitSelection (type, name, code) {
		theForm = document.selectionForm;

		theForm.clicking.value = 1;
		theForm.code.value = code;
		theForm.name.value = name;
		theForm.type.value = type;
		if (type == "country") {
			theForm.page.value = "countryInfo";
		}
		if (type == "region") {
			theForm.page.value = "regionInfo";
		}
		if (type == "activity") {
			theForm.page.value = "activityInfo";
		}
		if (type == "testimonials") {
			theForm.page.value = "testimonials";
		}
		if (type == "tips") {
			theForm.page.value = "traveltips";
		}
		if (type == "about") {
			theForm.page.value = "aboutus";
		}
		if (type == "contact") {
			theForm.page.value = "contactus";
		}
		if (type == "contactme") {
			theForm.page.value = "contactme";
		}
		if (type == "activities") {
			theForm.page.value = "activities";
		}
		if (type == "wishlist") {
			theForm.page.value = "wishlist";
		}
		if (type == "product") {
			if (name == "Hotels") {
				if (code == -1) {
					theForm.page.value = "hotelSearch";
				}
				else {
					theForm.page.value = "hotelDetail";
				}
			}
			if (name == "Tours") {
				if (code == -1) {
					theForm.page.value = "tourSearch";
				}
				else {
					theForm.page.value = "tourDetail";
				}
			}
			if (name == "Transportation") {
				if (code == -1) {
					theForm.page.value = "transportSearch";
				}
				else {
					theForm.page.value = "transportDetail";
				}
			}
			if (name == "Suggested itineraries") {
				if (code == -1) {
					theForm.page.value = "itinerarySearch";
				}
				else {
					theForm.page.value = "itineraryDetail";
				}
			}
		}
		
		theForm.submit();
	}

	function removeItem (type) {
		currentForm = document.deselectionForm;
		currentForm.type.value = type;
		currentForm.removing.value = 1;
		currentForm.submit();
	}
	
	//'<? print($_SESSION['visitHistory'][$_SESSION['visitHistoryCount'] - 1]['type']); ?>','<? print($_SESSION['visitHistory'][$_SESSION['visitHistoryCount'] - 1]['itemName']); ?>',<? print($_SESSION['visitHistory'][$_SESSION['visitHistoryCount'] - 1]['itemCode']); ?>,'<? print($_SESSION['visitHistory'][$_SESSION['visitHistoryCount'] - 1]['page']); ?>'
	//function goBack (type, name, code, page) {
	function goBack () {
		//theForm = document.goBackForm;
		
		//theForm.code.value = code;
		//theForm.name.value = name;
		//theForm.type.value = type;
		//theForm.page.value = "countryInfo";
		//theForm.submit();
		//setTimeout("alert(\"Listo\")", 2000);
		history.go(-1);
		//window.location.reload(true);
		//alert("Atras");
		//alert("Refrescando");
	}

//Admin menu selection---------------------------------------------------------------------------------------------------

	function submitAdminSelection (pag) {
		theForm = document.pageSelectionForm;
		theForm.page.value = pag;
		theForm.submit();
	}

//Wishlist---------------------------------------------------------------------------------------------------------------

	function addToWishList (id, name, type) {
		theForm = document.addWishListForm;
		theForm.wscode.value = id;
		theForm.wsname.value = name;
		theForm.wstype.value = type;
		theForm.page.value = "wishlist";
		theForm.submit();
	}
	
	function removeFromWishList (pos, prevPage) {
		theForm = document.removeWishListForm;
		theForm.pos.value = pos;
		theForm.page.value = "wishlist";
		theForm.previousPage.value = prevPage;	
		theForm.submit();
	}
	
	function emptyWishList(prevPage) {
		theForm = document.emptyWishListForm;
		theForm.page.value = "wishlist";
		theForm.previousPage.value = prevPage;	
		theForm.submit();
	}
	
	//NUEVO NUEVO NUEVO

	function saveInfo (which, value) {
		frame = document.getElementById("saveClientFrm");
		frame.src = "saveClientInfo.php?which="+which+"&value="+value;
	}

	function continueToSend() {
		theForm = document.sendWishList;
		theForm.submit();
	}

	function continueBrowsing() {
		theForm = document.continueToBefore;
		theForm.submit();
	}
	
	/*
	function backToWishlist() {
		theForm = document.backWishList;
		theForm.submit();
	}
	*/
	
	function checkInfo (formName) {
		allOK = true;
		msg = "";
		theForm = eval("document."+formName);
		
		if (theForm.name.value == "") {
			allOK = false;
			msg = msg+"\n-You must input your name";
		}
		if (theForm.email.value == "" && theForm.phone.value == "") {
			allOK = false;
			msg = msg+"\n-You must input at least one way for contacting you";
		}
		todaysDate = new Date();
		if (theForm.arrival.value != theForm.departure.value || theForm.arrival.value != todaysDate || theForm.arrival.value != todaysDate) {
			if (theForm.arrival.value > theForm.departure.value) {
				allOK = false;
				msg = msg+"\n-Departure date can't be set prior than the arrival date";
			}
		}
		if (allOK) {
			return ("OK");
		}
		else {
			return (msg);
		}	
	}
	
	function checkoutWishList() {
		theForm = document.wishListForm;
		msg = checkInfo("wishListForm");
		if (msg == "OK") {
			theForm.submit();
		}
		else {
			msgFinal = "The following errors were encountered:";
			msgFinal = msgFinal+msg;
			alert (msgFinal);
		}
	}
	
	function sendContactMe() {
		theForm = document.contactMeForm;
		msg = checkInfo("contactMeForm");
		if (msg == "OK") {
			theForm.submit();
		}
		else {
			msgFinal = "The following errors were encountered:";
			msgFinal = msgFinal+msg;
			alert (msgFinal);
		}
	}
	
	function performSearch() {
		theForm = document.performSearch;
		theForm.submit();
	}
	
	function submitItemPages(pag) {
		theForm = document.itemPages;
		theForm.currentPage.value = pag;
		theForm.submit();
	}

//Dynamic functionality-----------------------------------------------------------------------------

	function checkAllCountries() {
		theForm = document.contactMeForm;
		if (theForm.chkCountriesAll.checked == true) {
			for (i = 0; i < theForm.elements.length; i++) {
				if (theForm.elements[i].type == "checkbox" && theForm.elements[i].name == "chkCountries[]") {
					theForm.elements[i].checked = true;
				}
			}
		}
		else {
			for (i = 0; i < theForm.elements.length; i++) {
				if (theForm.elements[i].type == "checkbox" && theForm.elements[i].name == "chkCountries[]") {
					theForm.elements[i].checked = false;
				}
			}
		}
	}
	
	function uncheckAllCountries() {
		theForm = document.contactMeForm;
		theForm.chkCountriesAll.checked = false;
	}

	function checkAllActivities() {
		theForm = document.contactMeForm;
		if (theForm.chkActivitiesAll.checked == true) {
			for (i = 0; i < theForm.elements.length; i++) {
				if (theForm.elements[i].type == "checkbox" && theForm.elements[i].name == "chkActivities[]") {
					theForm.elements[i].checked = true;
				}
			}
		}
		else {
			for (i = 0; i < theForm.elements.length; i++) {
				if (theForm.elements[i].type == "checkbox" && theForm.elements[i].name == "chkActivities[]") {
					theForm.elements[i].checked = false;
				}
			}
		}
	}
	
	function uncheckAllActivities() {
		theForm = document.contactMeForm;
		theForm.chkActivitiesAll.checked = false;
	}

//Database report browsing----------------------------------------------------------------------------------------------

	function submitDBPages (pag) {
		theForm = document.itemPages;
		theForm.currentPage.value = pag;
		theForm.submit();
	}

	function submitDBProgressFilter () {
		theForm = document.filters;
		theForm.submit();
	}

	function submitDataPages (pag) {
		theForm = document.itemPages;
		theForm.currentPage.value = pag;
		theForm.submit();
	}

	function submitDataStatusFilter () {
		theForm = document.filters;
		theForm.submit();
	}


//FIN DE NUEVO NUEVO NUEVO

//Hotels browsing--------------------------------------------------------------------------------------------------------

	function submitHotel (cod) {
		theForm = document.hotelDetails;
		theForm.code.value = cod;
		theForm.submit();
	}

	function submitHotelBack () {
		theForm = document.hotelBack;
		theForm.submit();
	}

	function submitHotelPages (pag) {
		theForm = document.hotelPages;
		theForm.currentPage.value = pag;
		theForm.submit();
	}

//Tours browsing--------------------------------------------------------------------------------------------------------

	function submitTour (cod) {
		theForm = document.tourDetails;
		theForm.code.value = cod;
		theForm.submit();
	}

	function submitTourBack () {
		theForm = document.tourBack;
		theForm.submit();
	}

	function submitTourPages (pag) {
		theForm = document.tourPages;
		theForm.currentPage.value = pag;
		theForm.submit();
	}

//Transportation browsing--------------------------------------------------------------------------------------------------------

	function submitTransport (cod) {
		theForm = document.transportDetails;
		theForm.code.value = cod;
		theForm.submit();
	}

	function submitTransportBack () {
		theForm = document.transportBack;
		theForm.submit();
	}

	function submitTransportPages (pag) {
		theForm = document.transportPages;
		theForm.currentPage.value = pag;
		theForm.submit();
	}

//Itineraries browsing--------------------------------------------------------------------------------------------------------

	function submitItinerary (cod) {
		theForm = document.itineraryDetails;
		theForm.code.value = cod;
		theForm.submit();
	}

	function submitItineraryBack () {
		theForm = document.itineraryBack;
		theForm.submit();
	}

	function submitItineraryPages (pag) {
		theForm = document.itineraryPages;
		theForm.currentPage.value = pag;
		theForm.submit();
	}

//Lodging administration--------------------------------------------------------------------------------------------------

	function addLodging () {
		currentForm = document.lodgingForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editLodging (cod) {
		currentForm = document.lodgingForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteLodging (cod) {
		currentForm = document.lodgingForm;
		r = false;
		r = confirm ("You are about to delete a lodge/hotel. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateLodging (cod, status) {
		currentForm = document.lodgingForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkAddLodgingFields() {
		currentForm = document.lodgingForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add a lodge/hotel:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the lodging type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the lodge's price range";
		}
		if (currentForm.image.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must browse for and select a display image";
		}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the lodge's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the lodge's state";
		}
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the lodge";
		}
		
		if (!allOK) {
			alert(errorMsg);
			return (false);
		}
		return (true);
	}

	function checkModLodgingFields() {
		currentForm = document.lodgingForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to modify the selected lodge/hotel:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the lodging type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the lodge's price range";
		}
		//if (currentForm.image.value == "") {
			//allOK = false;
			//errorMsg = errorMsg + "\n-You must browse for and select a display image";
		//}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the lodge's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the lodge's state";
		}
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the lodge";
		}

		if (!allOK) {
			alert (errorMsg);
			return (false);
		}
		return (true);
	}


//Tour administration--------------------------------------------------------------------------------------------------

	function addTour () {
		currentForm = document.tourForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editTour (cod) {
		currentForm = document.tourForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteTour (cod) {
		currentForm = document.tourForm;
		r = false;
		r = confirm ("You are about to delete a tour. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateTour (cod, status) {
		currentForm = document.tourForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkAddTourFields() {
		currentForm = document.tourForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add a tour:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the tour type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the tour's price range";
		}
		if (currentForm.image.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must browse for and select a display image";
		}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the tour's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the tour's state";
		}
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the tour";
		}
		
		if (!allOK) {
			alert(errorMsg);
			return (false);
		}
		return (true);
	}

	function checkModTourFields() {
		currentForm = document.tourForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to modify the selected tour:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the tour type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the tour's price range";
		}
		//if (currentForm.image.value == "") {
			//allOK = false;
			//errorMsg = errorMsg + "\n-You must browse for and select a display image";
		//}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the tour's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the tour's state";
		}
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the tour";
		}

		if (!allOK) {
			alert (errorMsg);
			return (false);
		}
		return (true);
	}



//Transportation administration--------------------------------------------------------------------------------------------------

	function addTransport () {
		currentForm = document.transportForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editTransport (cod) {
		currentForm = document.transportForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteTransport (cod) {
		currentForm = document.transportForm;
		r = false;
		r = confirm ("You are about to delete a transportation option. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateTransport (cod, status) {
		currentForm = document.transportForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkAddTransportFields() {
		currentForm = document.transportForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add the transportation:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the transportation type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the transportation's price range";
		}
		if (currentForm.image.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must browse for and select a display image";
		}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the transportation's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the transportation's state";
		}
/*
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the transportation";
		}
*/

		if (!allOK) {
			alert(errorMsg);
			return (false);
		}
		return (true);
	}

	function checkModTransportFields() {
		currentForm = document.transportForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to modify the selected transportation:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the transportation type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the transportation's price range";
		}
		//if (currentForm.image.value == "") {
			//allOK = false;
			//errorMsg = errorMsg + "\n-You must browse for and select a display image";
		//}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the transportation's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the transportation's state";
		}

/*
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the transportation";
		}
*/

		if (!allOK) {
			alert (errorMsg);
			return (false);
		}
		return (true);
	}


//Itinerary administration--------------------------------------------------------------------------------------------------

	function addItinerary () {
		currentForm = document.itineraryForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editItinerary (cod) {
		currentForm = document.itineraryForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteItinerary (cod) {
		currentForm = document.itineraryForm;
		r = false;
		r = confirm ("You are about to delete an itinerary. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateItinerary (cod, status) {
		currentForm = document.itineraryForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function setOutstandingItinerary (cod, status) {
		currentForm = document.itineraryForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdOutstand.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkAddItineraryFields() {
		currentForm = document.itineraryForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add an itinerary:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the itinerary type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the itinerary's price range";
		}
		if (currentForm.image.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must browse for and select a display image";
		}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the itinerary's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the itinerary's state";
		}
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the itinerary";
		}
		
		if (!allOK) {
			alert(errorMsg);
			return (false);
		}
		return (true);
	}

	function checkModItineraryFields() {
		currentForm = document.itineraryForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to modify the selected itinerary:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.type.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the itinerary type";
		}
		if (currentForm.description.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a brief description";
		}
		if (currentForm.priceRange.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the itinerary's price range";
		}
		//if (currentForm.image.value == "") {
			//allOK = false;
			//errorMsg = errorMsg + "\n-You must browse for and select a display image";
		//}
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the itinerary's country";
		}
		if (currentForm.state.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the itinerary's state";
		}
		oneChecked = 0;
		for (i = 0; i < currentForm.elements.length; i++) {
			if (currentForm.elements[i].type == "checkbox") {
				if (currentForm.elements[i].checked) {
					oneChecked = 1;
				}
			}
		}
		if (oneChecked == 0) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select at least one activity to describe the itinerary";
		}

		if (!allOK) {
			alert (errorMsg);
			return (false);
		}
		return (true);
	}



//State administration--------------------------------------------------------------------------------------------------

	function addState () {
		currentForm = document.stateForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editState (cod) {
		currentForm = document.stateForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteState (cod) {
		currentForm = document.stateForm;
		r = false;
		r = confirm ("You are about to delete a state or region. If there are products linked to this state/region, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateState (cod, status) {
		currentForm = document.stateForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkStateFields () {
		currentForm = document.stateForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.country.value == -1) {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the state's country";
		}
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the state's name";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}


//Country administration--------------------------------------------------------------------------------------------------

	function addCountry () {
		currentForm = document.countryForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editCountry (cod) {
		currentForm = document.countryForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteCountry (cod) {
		currentForm = document.countryForm;
		r = false;
		r = confirm ("You are about to delete a country. If there are products linked to this country, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateCountry (cod, status) {
		currentForm = document.countryForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkAddCountryFields (rcvdMax) {
		currentForm = document.countryForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add a lodge/hotel:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.mainImg.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must browse for and select the homepage image";
		}
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the country description/information";
		}
		else {
			tmpCnt = currentForm.info.value;
			tmpCnt = stripHTML(tmpCnt);
			if (tmpCnt.length > rcvdMax) {
				allOK = false;
				errorMsg = errorMsg + "\n-Maximum allowed chars for information is " + rcvdMax;
			}
		}

		if (!allOK) {
			alert(errorMsg);
			return (false);
		}	
	}

	function checkModCountryFields (rcvdMax) {
		currentForm = document.countryForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to modify the selected lodge/hotel:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		/*
		if (currentForm.mainImg.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must browse for and select the homepage image";
		}
		*/
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the country description/information";
		}
		else {
			tmpCnt = currentForm.info.value;
			tmpCnt = stripHTML(tmpCnt);
			if (tmpCnt.length > rcvdMax) {
				allOK = false;
				errorMsg = errorMsg + "\n-Maximum allowed chars for information is " + rcvdMax;
			}
		}

		if (!allOK) {
			alert (errorMsg);
			return (false);
		}	
	}


//Weather administration--------------------------------------------------------------------------------------------------

	function editWeather (cod) {
		currentForm = document.weatherForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

//Activity administration--------------------------------------------------------------------------------------------------

	function addActivity () {
		currentForm = document.activityForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editActivity (cod) {
		currentForm = document.activityForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteActivity (cod) {
		currentForm = document.activityForm;
		r = false;
		r = confirm ("You are about to delete an activity. If there are products linked to this activity, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateActivity (cod, status) {
		currentForm = document.activityForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function setOutstanding (cod, status) {
		currentForm = document.activityForm;
		currentForm.outstandingStatus.value = status;
		currentForm.cmdOutstanding.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkAddActivityFields(rcvdMax) {
		currentForm = document.activityForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add an activity:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.mainImg.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must browse for and select the homepage image";
		}
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the activity's description/information";
		}
		else {
			tmpCnt = currentForm.info.value;
			tmpCnt = stripHTML(tmpCnt);
			if (tmpCnt.length > rcvdMax) {
				allOK = false;
				errorMsg = errorMsg + "\n-Maximum allowed chars for information is " + rcvdMax;
			}
		}
	
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

	function checkModActivityFields(rcvdMax) {
		currentForm = document.activityForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to modify the selected activity:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the activity's description/information";
		}
		else {
			tmpCnt = currentForm.info.value;
			tmpCnt = stripHTML(tmpCnt);
			if (tmpCnt.length > rcvdMax) {
				allOK = false;
				errorMsg = errorMsg + "\n-Maximum allowed chars for information is " + rcvdMax;
			}
		}

		if (!allOK) {
			alert (errorMsg);
		}	
		return (allOK);
	}

//User administration----------------------------------------------------------------------

	function addUser () {
		currentForm = document.userForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editUser (cod) {
		currentForm = document.userForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteUser (cod) {
		currentForm = document.userForm;
		r = false;
		r = confirm ("You are about to delete a user. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateUser (cod, status) {
		currentForm = document.userForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkUserFields () {
		currentForm = document.userForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add/update your user information:";
				
		if (currentForm.username.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a username";
		}
		if (currentForm.password.value == "" || currentForm.password2.value == "") {
			if (currentForm.password.value == "") {
				allOK = false;
				errorMsg = errorMsg + "\n-You must enter a valid password";
			}
			if (currentForm.password2.value == "") {
				allOK = false;
				errorMsg = errorMsg + "\n-You must retype the password entered above";
			}
		}
		else {
			if (currentForm.password.value != currentForm.password2.value) {
				allOK = false;
				errorMsg = errorMsg + "\n-Passwords don't match";
			}
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Lodging type administration--------------------------------------------------------------------------------------------------

	function addLodgeType () {
		currentForm = document.lodgeTypeForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editLodgeType (cod) {
		currentForm = document.lodgeTypeForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteLodgeType (cod) {
		currentForm = document.lodgeTypeForm;
		r = false;
		r = confirm ("You are about to delete a lodge type. If there are products linked to this lodge type, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateLodgeType (cod, status) {
		currentForm = document.lodgeTypeForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkLodgeTypeFields () {
		currentForm = document.lodgeTypeForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the lodge type's name";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Transportation type administration--------------------------------------------------------------------------------------------------

	function addTransportType () {
		currentForm = document.transportTypeForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editTransportType (cod) {
		currentForm = document.transportTypeForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteTransportType (cod) {
		currentForm = document.transportTypeForm;
		r = false;
		r = confirm ("You are about to delete a transportation type. If there are products linked to this transportation type, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateTransportType (cod, status) {
		currentForm = document.transportTypeForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkTransportTypeFields () {
		currentForm = document.transportTypeForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the transportation type's name";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Tour type administration--------------------------------------------------------------------------------------------------

	function addTourType () {
		currentForm = document.tourTypeForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editTourType (cod) {
		currentForm = document.tourTypeForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteTourType (cod) {
		currentForm = document.tourTypeForm;
		r = false;
		r = confirm ("You are about to delete a tour type. If there are products linked to this tour type, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateTourType (cod, status) {
		currentForm = document.tourTypeForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkTourTypeFields () {
		currentForm = document.tourTypeForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the tour type's name";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Itinerary type administration--------------------------------------------------------------------------------------------------

	function addItineraryType () {
		currentForm = document.itineraryTypeForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editItineraryType (cod) {
		currentForm = document.itineraryTypeForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteItineraryType (cod) {
		currentForm = document.itineraryTypeForm;
		r = false;
		r = confirm ("You are about to delete a itinerary type. If there are products linked to this itinerary type, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateItineraryType (cod, status) {
		currentForm = document.itineraryTypeForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkItineraryTypeFields () {
		currentForm = document.itineraryTypeForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the itinerary type's name";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//E-mails for Reservations administration----------------------------------------------------------------------------------------

	function addEmailReserve () {
		currentForm = document.emailForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editEmailReserve (cod) {
		currentForm = document.emailForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteEmailReserve (cod) {
		currentForm = document.emailForm;
		r = false;
		r = confirm ("You are about to delete an e-mail address. You must make sure to leave at least ONE e-mail address available for delivery. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateEmailReserve (cod, status) {
		currentForm = document.emailForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkEmailFields () {
		currentForm = document.emailForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the owner's name";
		}
		if (currentForm.email.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the e-mail address";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//----------------
//-----COLORS-----
//----------------

//Background color administration----------------------------------------------------------------

	function editBackgroundColor () {
		if (checkBGColorFields()) {
			currentForm = document.backgroundForm;
			currentForm.cmdModify.value = 1;
			currentForm.submit();
		}
	}

	function checkBGColorFields () {
		currentForm = document.backgroundForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.hexValue.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the color for the background";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Menu color administration----------------------------------------------------------------

	function editMenuColor () {
		if (checkMenuColorFields()) {
			currentForm = document.menuColorForm;
			currentForm.cmdModify.value = 1;
			currentForm.submit();
		}
	}

	function checkMenuColorFields () {
		currentForm = document.menuColorForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.hexValue.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the color for the menus";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Menu text color administration----------------------------------------------------------------

	function editMenuTextColor () {
		if (checkMenuTextColorFields()) {
			currentForm = document.menutextColorForm;
			currentForm.cmdModify.value = 1;
			currentForm.submit();
		}
	}

	function checkMenuTextColorFields () {
		currentForm = document.menutextColorForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.hexValue.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the color for the text on the menus";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Top bar color administration----------------------------------------------------------------

	function editTopBarColor () {
		if (checkTopBarColorFields()) {
			currentForm = document.topbarColorForm;
			currentForm.cmdModify.value = 1;
			currentForm.submit();
		}
	}

	function checkTopBarColorFields () {
		currentForm = document.topbarColorForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.hexValue.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the color for the top bar";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Tooltip text color administration----------------------------------------------------------------

	function editTooltipColor () {
		if (checkTooltipColorFields()) {
			currentForm = document.tooltipColorForm;
			currentForm.cmdModify.value = 1;
			currentForm.submit();
		}
	}

	function checkTooltipColorFields () {
		currentForm = document.tooltipColorForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.hexValue.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the text color for the map tooltips";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Title text color administration----------------------------------------------------------------

	function editTitleColor () {
		if (checkTitleColorFields()) {
			currentForm = document.titleColorForm;
			currentForm.cmdModify.value = 1;
			currentForm.submit();
		}
	}

	function checkTitleColorFields () {
		currentForm = document.titleColorForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.hexValue.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the text color for the titles";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Footer color administration----------------------------------------------------------------

	function editFooterColor () {
		if (checkFooterColorFields()) {
			currentForm = document.footerColorForm;
			currentForm.cmdModify.value = 1;
			currentForm.submit();
		}
	}

	function checkFooterColorFields () {
		currentForm = document.footerColorForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.hexValue.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the text color for the footer";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//--------------------
//-----END COLORS-----
//--------------------

//Price range administration--------------------------------------------------------------------------------------------------

	function addPriceRange () {
		currentForm = document.priceRangeForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editPriceRange (cod) {
		currentForm = document.priceRangeForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deletePriceRange (cod) {
		currentForm = document.priceRangeForm;
		r = false;
		r = confirm ("You are about to delete a price range. If there are products linked to this price range, this could render the information in the database unstable. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activatePriceRange (cod, status) {
		currentForm = document.priceRangeForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function setOutstandingPriceRange (cod, status) {
		currentForm = document.priceRangeForm;
		currentForm.outstandingStatus.value = status;
		currentForm.cmdOutstanding.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkPriceRangeFields() {
		currentForm = document.priceRangeForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add a price range:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a valid name";
		}
	
		if (!allOK) {
			alert(errorMsg);
		}	
		return (allOK);
	}


//Website Filter administration----------------------------------------------------------------

	function activateWebFilters (cod, status) {
		currentForm = document.filtersForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

//Contact us administration----------------------------------------------------------------

	function editContactInfo () {
		currentForm = document.contactInfoForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.submit();
	}

	function checkContactInfoFields () {
		currentForm = document.contactInfoForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the contact us page information";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//About us administration----------------------------------------------------------------

	function editAboutInfo () {
		currentForm = document.aboutInfoForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.submit();
	}

	function checkContactInfoFields () {
		currentForm = document.aboutInfoForm;
		allOK = true;
		errorMsg = "The following problems were encountered:";
				
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the about us page information";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Testimonies administration----------------------------------------------------------------------

	function addTestimonial () {
		currentForm = document.testimonyForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editTestimonial (cod) {
		currentForm = document.testimonyForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteTestimonial (cod) {
		currentForm = document.testimonyForm;
		r = false;
		r = confirm ("You are about to delete a testimony. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateTestimonial (cod, status) {
		currentForm = document.testimonyForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkTestimonialFields () {
		currentForm = document.testimonyForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add/update the testimonial:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the person's name";
		}
		if (currentForm.location.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the location/address of the person";
		}
		if (currentForm.date.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must select the date when the testimony was made or added";
		}
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the testimony information";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Travel tips administration----------------------------------------------------------------------

	function addTravelTip () {
		currentForm = document.travelTipForm;
		currentForm.cmdAddNew.value = 1;
		currentForm.submit();
	}

	function editTravelTip (cod) {
		currentForm = document.travelTipForm;
		currentForm.cmdModifySelected.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function deleteTravelTip (cod) {
		currentForm = document.travelTipForm;
		r = false;
		r = confirm ("You are about to delete a travel tip. Are you sure?");
		if (r) {
			currentForm.cmdDelete.value = 1;
			currentForm.codigoActual.value = cod;
			currentForm.submit();
		}
	}

	function activateTravelTip (cod, status) {
		currentForm = document.travelTipForm;
		currentForm.activeStatus.value = status;
		currentForm.cmdActivate.value = 1;
		currentForm.codigoActual.value = cod;
		currentForm.submit();
	}

	function checkTravelTipFields () {
		currentForm = document.travelTipForm;
		allOK = true;
		errorMsg = "The following problems were encountered while trying to add/update the travel tip:";
				
		if (currentForm.name.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter a description/name for the travel tip";
		}
		if (currentForm.info.value == "") {
			allOK = false;
			errorMsg = errorMsg + "\n-You must enter the travel tip information";
		}
		if (!allOK) {
			alert(errorMsg);
		}
		return (allOK);
	}

//Filtering product pages-----------------------------------------------------------------

	function submitFilterOptions () {
		currentForm = document.filteringOptions;
		currentForm.submit();
	}

//Dynamic site----------------------------------------------------------------------------

	function refillStates(formName) {
		currentForm = eval("document."+formName);
		country = currentForm.country.options[currentForm.country.selectedIndex].value;
		cantidadLimpiar = currentForm.state.length;
		for (i = 0; i <= cantidadLimpiar; i++) {
			currentForm.state.options[i] = null;
		}
		currentForm.state.length = 0;
		count = 1;
		cantEstados = estados.length;
		for (i = 0; i < cantEstados; i++) {
			if (estados[i][0] == country) {
				currentForm.state.options[count] = new Option(estados[i][2], estados[i][1]);
				count++;
			}
		}
		if (count > 1) {
			currentForm.state.options[0] = new Option("Choose one...", -1, true, true);
		}
		else {
			currentForm.state.options[0] = new Option("No states available", -1, true, true);
		}
	}


//Ventanas Pop-Up ------------------------------------------------------------------------

	function showContactMe () {
		//abrirVentana ("contactme.php", "ContactMe", 525);
		submitSelection('contactme', '', -1);
	}

	function viewWishlist () {
		//abrirVentana ("wishlist.php", "WishList", 525);
		submitSelection('wishlist', '', -1);
	}

	function abrirVentana (pagina, nombre, width) {
		var address = pagina; //dirección de la página
		var op_tool = 0;  //barra de herramientas
		var op_loc_box = 0; //barra de direcciones
		var op_dir =  0; //vinculos/links
		var op_stat = 1;  //barra de estado  
		var op_menu = 0; //barra de menú
		var op_scroll = 1; //visibilidad de scrolls
		var op_resize = 0; //permitir cambiar el tamaño de la ventana
		var op_wid = width; //ancho de la ventanta
		var op_heigh = 500; //alto de la ventana
		var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories=" + op_dir + ",status=" + op_stat 
		+ ",menubar=" + op_menu + ",scrollbars="  + op_scroll + ",resizable=" + op_resize 
		+ ",width=" + op_wid + ",height=" + op_heigh;
		//var win3 = window.open("", "FotoGaleria", option);  
		//alert(address);

		var newWindow = window.open(address, nombre, option);
		window.opener = self;
		newWindow.moveTo(screen.width/2 - (width/2), screen.height/2-250);
		newWindow.focus();
	}


	function abrirEditor (tipo, formName, itemName) {
		//editado = eval("document." + formName + "." + itemName + ".value");
		//if (editado == "") {
		//	var plantilla = eval("document." + formName + "." + cual + ".value");
		//}
		//else {
		//	var plantilla = -1;
		//}
		var address = "editor.php?tipo="+tipo+"&formName="+formName+"&itemName="+itemName; //dirección de la página
		var op_tool = 0;  //barra de herramientas
		var op_loc_box = 0; //barra de direcciones
		var op_dir =  0; //vinculos/links
		var op_stat = 1;  //barra de estado  
		var op_menu = 0; //barra de menú
		var op_scroll = 1; //visibilidad de scrolls
		var op_resize = 0; //permitir cambiar el tamaño de la ventana
		var op_wid = 650; //ancho de la ventanta
		var op_heigh = 650; //alto de la ventana
		var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories=" + op_dir + ",status=" + op_stat 
		+ ",menubar=" + op_menu + ",scrollbars="  + op_scroll + ",resizable=" + op_resize 
		+ ",width=" + op_wid + ",height=" + op_heigh;
		var newWindow = window.open(address, "editor", option);
		window.opener = self;
		newWindow.moveTo(screen.width/2-300, screen.height/2-375);
		newWindow.focus();
	}


// Image preload and swaping functions------------------------------------------------------

	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
//-------------------------------------------------------------------------------

    function KeyDownHandler(btn) {
        // process only the Enter key
        if (event.keyCode == 13) {
            // cancel the default submit
            event.returnValue=false;
            event.cancel = true;
            // submit the form by programmatically clicking the specified button
            btn.click();
        }
    }

	function fls_DoFSCommand(command, args) { 
		if (command == "submit_selection") { 
			pieces = args.split(",");
			pieces[0] = pieces[0].substr(1, pieces[0].length - 2);
			pieces[1] = pieces[1].substr(1, pieces[1].length - 2);
			submitSelection (pieces[0], pieces[1], pieces[2]);
		}
		if (command == "remove_selection") { 
			args = args.substr(1, args.length - 2);
			removeItem (args);
		}
	}

	function flws_DoFSCommand(command, args) { 
		if (command == "wish_submit") { 
			viewWishlist();
		}
	}

	function numbersParenthesisOrDashesOnly (e) {
		var unicode = e.charCode? e.charCode : e.keyCode
		//alert ("Code> "+unicode);
		if (unicode!=8 && unicode != 45 && unicode != 40 && unicode != 41) { //if the key isn't the backspace key or the dash (-) (which we should allow)
			if (unicode < 48 || unicode > 57) { //if not a number
				return (false); //disable key press
			}
		}
	}

//-------------------------------------------------------------------------------

function stripHTML(oldCnt) {
	var re = /<\S[^><]*>/g;
	newCnt = oldCnt.replace(re, "");
	return (newCnt);
}

//---------------------------------------------------------------------------------

function BorrarImg (Id) {
	document.frmborrado.ID.value=Id;
	document.frmborrado.submit();	
}

function MostrarImg (Dir, Img) {
	myurl = "MostrarImg.php?Dir="+Dir+"&Img="+Img;
	Vwd = 400;
	Vhg = 360;
	reWin = window.open (myurl,'determined','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+Vwd+',height='+Vhg+',top='+(screen.height / 2)+',left='+(screen.width / 2));
	reWin.moveTo (screen.width/2 - Vwd/2, screen.height/2 - Vhg/2);
}

//---------------------------------------------------------------------------------
