main_script = "ajax.php?";


function getE(id) {
	return document.getElementById(id);
}

// controlla se una stringa rappresenta un numero intero
function is_numeric_str(str) {
	var filter=/^[0-9]{1,}$/i;
	if (filter.test(str)) {
		return true;
	}
	else {
		return false;
	}
}

function doAjaxRequestXml(type, query_str, is_admin) {
	var oXmlDom = zXmlDom.createDocument();
	oXmlDom.onreadystatechange = function () {
		if (oXmlDom.readyState == 4) {
			if (oXmlDom.parseError.errorCode == 0) {
				var oRoot = oXmlDom.documentElement;
				
				if (type=="locations_list" || type=="locations_list_search") {		// lista di localita' collegate alla regione passata
					getE("id_regione_localita").length = 0;
					var oData = oRoot.getElementsByTagName("location");
					
					if (type=="locations_list_search")
						getE("id_regione_localita").options[0] = new Option("[ tutte le località di questa regione ]", "0");
					
					for (var i=0; i<oData.length; i++) {
						this_file = null;
						this_name = null;
						var oCurrentChild = oData[i].firstChild;
						
						do {
							switch (oCurrentChild.tagName) {
								case "id":
									this_id = oCurrentChild.text;
									break;
								case "name":
									this_name = oCurrentChild.text;
									break;
							}
						} while (oCurrentChild = oCurrentChild.nextSibling);
						
						getE("id_regione_localita").options[getE("id_regione_localita").length] = new Option(this_name, this_id);
					}
				}
				else if (type=="structures_list_search") {
					getE("step1_new__id_prodotto_hotel").length = 0;
					var oData = oRoot.getElementsByTagName("location");
					
					getE("step1_new__id_prodotto_hotel").options[0] = new Option("[ tutte le strutture di questa località ]", "0");
					
					for (var i=0; i<oData.length; i++) {
						this_file = null;
						this_name = null;
						var oCurrentChild = oData[i].firstChild;
						
						do {
							switch (oCurrentChild.tagName) {
								case "id":
									this_id = oCurrentChild.text;
									break;
								case "name":
									this_name = oCurrentChild.text;
									break;
							}
						} while (oCurrentChild = oCurrentChild.nextSibling);
						
						getE("step1_new__id_prodotto_hotel").options[getE("step1_new__id_prodotto_hotel").length] = new Option(this_name, this_id);
					}
				}
			}
		}
	};
	
	var main_script_path = main_script;
	if (is_admin)
		main_script_path = '../'+main_script
	
	//window.location = main_script_path+query_str;
	oXmlDom.load(main_script_path+query_str);
}

mw=null;
function openWindowDimBars(FileName,w,h,barre) {
	myWindow=window.open(FileName,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+barre+',resizable=0,top=10,left=10,width='+w+',height='+h);
	return myWindow;
}

function isObject(a) {
	return (a && typeof a == 'object') || isFunction(a);
}
function isFunction(a) {
	return typeof a == 'function';
}

var testresults;
function checkemail(email_addr) {
	var filter=/^[\'+\\./0-9A-Z^_\`a-z{|}~\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+){1,3}$/i;
	if (filter.test(email_addr)) {
		testresults = true;
	}
	else {
		testresults = false;
	}
	
	return(testresults);
}

// effettua la paginazione delle foto nelle schede in pop-up
function dg_photogallery_pagination(pics_array, direction) {
	if (pics_array.length>0) {
		var tot_pages = Math.ceil(pics_array.length/3)-1;
		var new_page = parseInt(getE("this_page").innerHTML);
		if (direction=='prev')	{new_page--;}
		else					{new_page++;}
		
		if (new_page<0)			{new_page = 0;}
		if (new_page>tot_pages)	{new_page = tot_pages;}
		
		// calcola gli indici delle foto nell'array
		var i1 = new_page*3;
		var i2 = i1+1;
		var i3 = i2+1;
		
		// controlla se gli indici calcolati esistono nell'array, ed estrae le rispettive foto
		if (pics_array.length>=(i1+1)) {
			getE("thumb_1").src = pics_array[i1][0];
			getE("box_thumb1").style.display = "";
		}
		else {
			getE("box_thumb1").style.display = "none";
		}
		
		if (pics_array.length>=(i2+1)) {
			getE("thumb_2").src = pics_array[i2][0];
			getE("box_thumb2").style.display = "";
		}
		else {
			getE("box_thumb2").style.display = "none";
		}
		
		if (pics_array.length>=(i3+1)) {
			getE("thumb_3").src = pics_array[i3][0];
			getE("box_thumb3").style.display = "";
		}
		else {
			getE("box_thumb3").style.display = "none";
		}
		
		getE("this_page").innerHTML = new_page;
		
		// mostra o nasconde le frecce di navigazione
		if (new_page==0) {
			getE("prev_btn").style.display = "none";
		}
		else if (new_page>0) {
			getE("prev_btn").style.display = "";
		}
		
		if (new_page==tot_pages) {
			getE("next_btn").style.display = "none";
		}
		else if (new_page<tot_pages) {
			getE("next_btn").style.display = "";
		}
	}
}

// visualizza lo zoom della foto cliccata, passando come parametro la posizione della thumb (da 1 a 3)
function dg_photogallery_zoom(pics_array, pic_num) {
	if (pic_num>=1 && pic_num<=3) {
		var this_index = ((parseInt(getE("this_page").innerHTML)*3)+pic_num)-1;
		
		if (pics_array.length>=this_index) {
			getE("zoom").src = pics_array[this_index][1];
			
			if (pics_array[this_index][2].length>0) {
				getE("this_label").innerHTML = pics_array[this_index][2];
			}
			else {
				getE("this_label").innerHTML = '';
			}
		}
	}
}

/*
	Inserisce dinamicamente un filmato Flash.
	Per scavalcare il blocco di IE 6, che altrimenti ne richiede l'attivazione manuale.
*/
function print_flash_movie(nomefile, width, height, version) {
	var str;
	
	str = ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + '" WIDTH="' + width + '" HEIGHT="' + height + '">');
	str = str + ('<PARAM NAME=movie VALUE="' + nomefile + '">');
	str = str + ('<PARAM NAME=quality VALUE=high>');
	str = str + ('<embed src="' + nomefile + '" quality=high ');
	str = str + ('swLiveConnect="FALSE" WIDTH="' + width + '" HEIGHT="' + height + '" border="0" TYPE="application/x-shockwave-flash"');
	str = str + ('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed></OBJECT>');
	
	document.write(str);
}

// DG Platinum - gestori degli eventi dei tasti nel modulo di prenotazione hotel/ville
function dg_step_add_bookmarks() {		// aggiunge la prenotazione agli appunti
	getE("s2submit_save").disabled = true;
	getE("add_bookmarks").value = "1";
	getE("this_form").submit();
}

function dg_step2_next(add_resort) {
	getE("s2submit_forward").disabled = true;
	getE("add_bookmarks").value = "0";
	
	var found_checks = false;
	for (var i=0; i<getE("this_form").elements.length; i++) {		// controlla se e' stato selezionata una struttura o se e' stato compilato im campo "other"
		var e = getE("this_form").elements[i];
		if (e.type.toLowerCase()=='checkbox' && e.id.substr(0, 8).toLowerCase()=='s2check_' && e.checked) {
			found_checks = true;
		}
	}
	
	if (getE("step2moretext").value>"" && getE("modified_other").value=='1') { found_checks = true; }
	
	if (!found_checks) {
		alert('Plaese select one or more accommodations, or fill in the "Other accommodation" field.');
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	getE("add_resort").value = add_resort;
	getE("this_form").submit();
}

function dg_step3_next() {		// questa funzione viene usata sia dallo step 3 che dal 4
	getE("s2submit_forward").disabled = true;
	getE("add_bookmarks").value = "0";
	getE("this_form").submit();
}

function dg_step5_next(is_hotel) {
	getE("s2submit_forward").disabled = true;
	getE("add_bookmarks").value = "0";
	
	var aFrom = getE("arrival_date").value.split('-');
	var dFrom = new Date();
	dFrom.setFullYear(aFrom[2], aFrom[0], aFrom[1]);
	
	var aTo = getE("departure_date").value.split('-');
	var dTo = new Date();
	dTo.setFullYear(aTo[2], aTo[0], aTo[1]);
	
	if (parseInt(aFrom[2]+aFrom[0]+aFrom[1])>=parseInt(aTo[2]+aTo[0]+aTo[1])) {
		alert("Plaese note that the departure date must be highest then the arrival date.");
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	if (getE("arrival_place").value=="") {
		alert('Please fill in the "Arrival place/APT" field.');
		getE("arrival_place").focus();
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	if (getE("departure_place").value=="") {
		alert('Please fill in the "Departure place/APT" field.');
		getE("departure_place").focus();
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	if (getE("grp_name").value=="") {
		alert('Please fill in the "Guest/Grp name" field.');
		getE("grp_name").focus();
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	if (getE("people_adults").value=="" || isNaN(getE("people_adults").value)) {
		alert('Please fill in the "Number of adults" field.');
		getE("people_adults").focus();
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	if (getE("people_kids").value=="" || isNaN(getE("people_kids").value)) {
		alert('Please fill in the "Number of kids" field.');
		getE("people_kids").focus();
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	if (is_hotel) {
		if (parseInt(getE("hotel_accomod_single").value)<1 && parseInt(getE("hotel_accomod_double").value)<1 && parseInt(getE("hotel_accomod_triple").value)<1 && parseInt(getE("hotel_accomod_junior").value)<1 && parseInt(getE("hotel_accomod_onebed_suite").value)<1 && parseInt(getE("hotel_accomod_twobeds_suite").value)<1) {
			alert('Please select the hotel accommodation you prefer.');
			getE("hotel_accomod_single").focus();
			getE("s2submit_forward").disabled = false;
			return;
		}
	}
	
	getE("this_form").submit();
}

function dg_step6_next() {
	if (!checkemail(getE("this_email").value) || !is_valid_password(getE("this_password").value, 5, 50)) {
		alert('Please insert your e-mail address and your personal password.');
		getE("s2submit_forward").disabled = false;
		return false;
	}
	
	return true;
}

function dg_step7_next() {
	getE("s2submit_forward").disabled = true;
	getE("add_bookmarks").value = "0";
	
	if (!getE("privacy").checked) {
		alert('Please read the privacy policy and click on the "Consent for processing of personal data" box.');
		getE("s2submit_forward").disabled = false;
		return;
	}
	
	getE("this_form").submit();
}

function dg_step5_update_hotel_accomodation() {		// aggiorna la lista di valori nei menu' SELECT di "Hotel accomodation" quando vengono modificati il numero di adulti o di bambini
	if (isObject(getE("hotel_accomodation_div"))) {
		// effettua questo controllo per fare in modo che nei campi di inserimento del numero di adulti e bambini ci siano solo numeri
		if (getE("people_adults").value>"") {
			if (isNaN(parseInt(getE("people_adults").value).toString())) {
				getE("people_adults").value = "";
			}
			else {
				getE("people_adults").value = parseInt(getE("people_adults").value);
			}
		}
		if (getE("people_kids").value>"") {
			if (isNaN(parseInt(getE("people_kids").value).toString())) {
				getE("people_kids").value = "";
			}
			else {
				getE("people_kids").value = parseInt(getE("people_kids").value);
			}
		}
		
		// calcola il numero totale di adulti e bambini
		var people_tot = 0;
		if (getE("people_adults").value>"")		{ people_tot  = parseInt(getE("people_adults").value); }
		if (getE("people_kids").value>"")		{ people_tot += parseInt(getE("people_kids").value);   }
		
		getE("hotel_accomod_single").length = 0;
		getE("hotel_accomod_double").length = 0;
		getE("hotel_accomod_triple").length = 0;
		getE("hotel_accomod_junior").length = 0;
		getE("hotel_accomod_onebed_suite").length = 0;
		getE("hotel_accomod_twobeds_suite").length = 0;
		
		for (var i=0; i<=people_tot; i++) {
			getE("hotel_accomod_single").options[getE("hotel_accomod_single").length] = new Option(" "+i+" ", i);
			getE("hotel_accomod_double").options[getE("hotel_accomod_double").length] = new Option(" "+i+" ", i);
			getE("hotel_accomod_triple").options[getE("hotel_accomod_triple").length] = new Option(" "+i+" ", i);
			getE("hotel_accomod_junior").options[getE("hotel_accomod_junior").length] = new Option(" "+i+" ", i);
			getE("hotel_accomod_onebed_suite").options[getE("hotel_accomod_onebed_suite").length] = new Option(" "+i+" ", i);
			getE("hotel_accomod_twobeds_suite").options[getE("hotel_accomod_twobeds_suite").length] = new Option(" "+i+" ", i);
		}
	}
}

function dg_step5_preselect_hotel_accomodation(hotel_accomod_single, hotel_accomod_double, hotel_accomod_triple, hotel_accomod_junior, hotel_accomod_onebed_suite, hotel_accomod_twobeds_suite) {		// pre-seleziona i menu' SELECT "Hotel accomodation" in base ai dati presenti nel cookie
	if (isObject(getE("hotel_accomodation_div"))) {
		if ((getE("hotel_accomod_single").length+1)>=hotel_accomod_single) {
			getE("hotel_accomod_single").options[hotel_accomod_single].selected = true;
		}
		if ((getE("hotel_accomod_double").length+1)>=hotel_accomod_double) {
			getE("hotel_accomod_double").options[hotel_accomod_double].selected = true;
		}
		if ((getE("hotel_accomod_triple").length+1)>=hotel_accomod_triple) {
			getE("hotel_accomod_triple").options[hotel_accomod_triple].selected = true;
		}
		if ((getE("hotel_accomod_junior").length+1)>=hotel_accomod_junior) {
			getE("hotel_accomod_junior").options[hotel_accomod_junior].selected = true;
		}
		if ((getE("hotel_accomod_onebed_suite").length+1)>=hotel_accomod_onebed_suite) {
			getE("hotel_accomod_onebed_suite").options[hotel_accomod_onebed_suite].selected = true;
		}
		if ((getE("hotel_accomod_twobeds_suite").length+1)>=hotel_accomod_twobeds_suite) {
			getE("hotel_accomod_twobeds_suite").options[hotel_accomod_twobeds_suite].selected = true;
		}
	}
}
// ----------------------------------------------------------------------------------- 

// DG Platinum - Processo di prenotazione Fase 3 di 8 - Apre e chiude i blocchi di form dei singoli servizi. il parametro booleano "from_checkbox" dice se la funzione e' stata richiamata dall'onClick sul checkbox di selezione
function dg_step3_form_blocs(id, from_checkbox) {
	if (isObject(getE("step4extras_"+id))) {
		if (typeof from_checkbox!='boolean' || from_checkbox!=true) {
			from_checkbox = false;
		}
		
		if (!from_checkbox) {
			if (getE("step4extras_"+id).style.display=="") {
				getE("step4extras_"+id).style.display = "none";
			}
			else {
				getE("step4extras_"+id).style.display = "";
			}
		}
		else {		// se la funzione e' stata richiamata dall'onclick sul checkbox
			if (getE('s2check_'+id).checked) {
				getE("step4extras_"+id).style.display = "";
			}
			else {
				getE("step4extras_"+id).style.display = "none";
			}
		}
	}
}


// DG Platinum - gestisce il submit della pagina contatti
function dg_contacts_submit() {
	if (getE('nome').value=="" || getE('cognome').value=="" || getE('email').value=="" || getE('messaggio').value=="" || !getE('privacy').checked) {
		alert("Please fill in all the required fields (marked with an asterisc), read the privacy policy and click on the \"Consent for processing of personal data\" box.");
		getE('invia').disabled = false;
		return false;
	}
	
	if (!checkemail(getE('email').value)) {
		alert("Please enter a valid e-mail address.");
		getE('invia').disabled = false;
		return false;
	}
	
	return true;
}

function confirmLink(theLink, confirmMsg) {
	if (typeof(window.opera) != 'undefined') {
		return true;
	}
	
	var is_confirmed = confirm(confirmMsg);
	return is_confirmed;
}

// controlla se una stringa rappresenta una password valida; solo alfanumerica e con un numero minimo e massimo di caratteri
function is_valid_password(str, min_chars, max_chars) {
	var filter=/^[a-z0-9]{1,}$/i;
	if (filter.test(str) && str.length>=min_chars) {
		if (max_chars>=min_chars) {
			if (str.length<=max_chars) {
				return true;
			}
			else {
				return false;
			}
		}
		else {
			return true;
		}
	}
	else {
		return false;
	}
}

// submit del modulo di registrazione
function dg_register_submit() {
	if (isNaN(getE("id_utente_tipo").value) || parseInt(getE("id_utente_tipo").value)<1 || getE("nome").value=="" || (getE("societa").value=="" && parseInt(getE("id_utente_tipo").value)!=3) || getE("indirizzo").value=="" || getE("cap").value=="" || getE("citta").value=="" || isNaN(getE("idstato").value) || parseInt(getE("idstato").value)<1 || getE("telefono1").value=="" || getE("fax").value=="") {
		alert('Please fill in all required fields, marked with the asterisc char (*).');
		getE("s2submit_forward").disabled = false;
		return false;
	}
	
	if (!checkemail(getE("email").value)) {
		alert("Please insert a valid e-mail address.");
		getE("email").focus();
		getE("s2submit_forward").disabled = false;
		return false;
	}
	
	if (!getE("privacy").checked) {
		alert('Please read the privacy policy and click on the "I agree" box.');
		getE("s2submit_forward").disabled = false;
		return false;
	}
	
	return true;
}

// DG Platinum - modulo di ricerca, segna il campo "company" come obbligatorio o opzionale in base alla tipologia di utenza selezionata
function dg_register_change_usertype() {
	if (parseInt(getE("id_utente_tipo").value)==3) {
		getE("societa_label").innerHTML = "Company:";
	}
	else {
		getE("societa_label").innerHTML = "* Company:";
	}
}

// DG Platinum - visualizza o nasconde degli oggetti in base alla selezione fatta su altri
function dg_display_obj(obj_check, val, obj_display, obj_field) {
	if (parseInt(getE(obj_check).value)==val) {
		getE(obj_display).style.display = '';
		getE(obj_field).focus();
	}
	else {
		getE(obj_display).style.display = 'none';
	}
}

// DG Platinum - controlli sui campi obbligatori nel modulo di Wedding Planner
function dg_wedding_submit() {
	getE('s2submit_forward').disabled = true;
	var messaggio = null;
	var focus_obj = null;
	if (getE("bride_name").value=="") {
		messaggio = 'Please fill in the field: Bride\'s first & last name.';
		focus_obj = "bride_name";
	}
	else if (getE("groom_name").value=="") {
		messaggio = 'Please fill in the field: Groom\'s first & last name.';
		focus_obj = "groom_name";
	}
	else if (getE("phone_num").value=="") {
		messaggio = 'Please fill in the field: Phone number.';
		focus_obj = "phone_num";
	}
	else if (getE("fax_num").value=="") {
		messaggio = 'Please fill in the field: Fax number.';
		focus_obj = "fax_num";
	}
	else if (!checkemail(getE("email").value)) {
		messaggio = 'Please insert a valid e-mail address.';
		focus_obj = "email";
	}
	else if (parseInt(getE("wd_bride_religion").value)<1) {
		messaggio = 'Please fill in the field: Bride\'s religion.';
		focus_obj = "wd_bride_religion";
	}
	else if (getE("span_wd_bride_religion_other").style.display!='none' && getE("wd_bride_religion_other").value=="") {
		messaggio = 'Please specify the Bride\'s religion, if it\'s not on the list.';
		focus_obj = "wd_bride_religion_other";
	}
	else if (parseInt(getE("wd_groom_religion").value)<1) {
		messaggio = 'Please fill in the field: Groom\'s religion.';
		focus_obj = "wd_groom_religion";
	}
	else if (getE("span_wd_groom_religion_other").style.display!='none' && getE("wd_groom_religion_other").value=="") {
		messaggio = 'Please specify the Groom\'s religion, if it\'s not on the list.';
		focus_obj = "wd_groom_religion_other";
	}
	else if (parseInt(getE("wd_citizenship").value)<1) {
		messaggio = 'Please fill in the field: Country of citizenship.';
		focus_obj = "wd_citizenship";
	}
	else if (getE("wedding_date").value=="") {
		messaggio = 'Please fill in the field: Approximate wedding date.';
		focus_obj = "wedding_date";
	}
	else if (parseInt(getE("wd_location").value)<1) {
		messaggio = 'Please fill in the field: Wedding location.';
		focus_obj = "wd_location";
	}
	else if (parseInt(getE("wd_ceremony_type").value)<1) {
		messaggio = 'Please fill in the field: Type of ceremony.';
		focus_obj = "wd_ceremony_type";
	}
	else if (getE("span_wd_ceremony_type_other").style.display!='none' && getE("wd_ceremony_type_other").value=="") {
		messaggio = 'Please specify the type of ceremony, if it\'s not on the list.';
		focus_obj = "wd_ceremony_type_other";
	}
	else if (parseInt(getE("wd_ceremony_location").value)<1) {
		messaggio = 'Please fill in the field: Preferred location for ceremony.';
		focus_obj = "wd_ceremony_location";
	}
	else if (getE("span_wd_ceremony_location_other").style.display!='none' && getE("wd_ceremony_location_other").value=="") {
		messaggio = 'Please specify the preferred location for ceremony, if it\'s not on the list.';
		focus_obj = "wd_ceremony_location_other";
	}
	else if (parseInt(getE("wd_guests").value)<1) {
		messaggio = 'Please fill in the field: Number of guests.';
		focus_obj = "wd_guests";
	}
	else if (parseInt(getE("wd_accomodation_type").value)<1) {
		messaggio = 'Please fill in the field: Type of accommodation required for Bride & Groom.';
		focus_obj = "wd_accomodation_type";
	}
	else if (parseInt(getE("wd_room_type").value)<1) {
		messaggio = 'Please fill in the field: Room type for Bride & Groom.';
		focus_obj = "wd_room_type";
	}
	else if (getE("accomodation_nights_num").value=="" || !is_numeric_str(getE("accomodation_nights_num").value)) {
		messaggio = 'Please fill in the field: Number of nights that accommodation is required for Bride & Groom (you can insert digits only).';
		focus_obj = "accomodation_nights_num";
	}
	else if ((getE("accomodation_people_num_party").value=="" || !is_numeric_str(getE("accomodation_people_num_party").value)) && parseInt(getE("wd_guests").value)!=1) {
		messaggio = 'Please fill in the field: Approximate number of people in your party for whom you would like accommodation (you can insert digits only).';
		focus_obj = "accomodation_people_num_party";
	}
	else if ((getE("accomodation_nights_num_party").value=="" || !is_numeric_str(getE("accomodation_nights_num_party").value)) && parseInt(getE("wd_guests").value)!=1) {
		messaggio = 'Please fill in the field: Approximate number of nights for which your party would like accommodation (you can insert digits only).';
		focus_obj = "accomodation_nights_num_party";
	}
	else if (parseInt(getE("wd_accomodation_type_party").value)<1) {
		messaggio = 'Please fill in the field: Type of accommodation required for your party.';
		focus_obj = "wd_accomodation_type_party";
	}
	else if (parseInt(getE("wd_room_type_party").value)<1) {
		messaggio = 'Please fill in the field: Type of rooms for your party.';
		focus_obj = "wd_room_type_party";
	}
	else if (!getE("privacy").checked) {
		messaggio = 'Please read the privacy policy and click on the "Consent for processing of personal data" box.';
		focus_obj = "privacy_txt";
	}
	
	if (messaggio!=null) {
		alert(messaggio);
		getE(focus_obj).focus();
		getE("s2submit_forward").disabled = false;
		return;
	}
	else {
		getE('this_form').submit();
	}
}

// DG Platinum - controlla la selezione del numero di ospiti, e se non ce ne sono disabilita i campi relativi agli ospiti
function dg_wedding_guests() {
	if (parseInt(getE("wd_guests").value)==1) {		// solo marito e moglie (niente ospiti)
		getE("l_accomodation_people_num_party").innerHTML = "Approximate number of people in your party for whom you would like accommodation:";
		getE("l_accomodation_nights_num_party").innerHTML = "Approximate number of nights for which your party would like accommodation:";
	}
	else {
		getE("l_accomodation_people_num_party").innerHTML = "* Approximate number of people in your party for whom you would like accommodation:";
		getE("l_accomodation_nights_num_party").innerHTML = "* Approximate number of nights for which your party would like accommodation:";
	}
}

function dg_wedding_reset_form() {
	getE('this_form').reset();
	getE("l_accomodation_people_num_party").innerHTML = "* Approximate number of people in your party for whom you would like accommodation:";
	getE("l_accomodation_nights_num_party").innerHTML = "* Approximate number of nights for which your party would like accommodation:";
	getE("span_wd_bride_religion_other").style.display = 'none';
	getE("span_wd_groom_religion_other").style.display = 'none';
	getE("span_wd_ceremony_type_other").style.display = 'none';
	getE("span_wd_ceremony_location_other").style.display = 'none';
}

// DG Platinum - area riservata: submit del modulo di modifica e-mail
function dg__reserved__modify_email() {
	if (getE('form_password').value=="" || !checkemail(getE('form_newemail').value)) {
		alert('Please write your password and the new e-mail address in correct form.');
		getE('form_password').value = "";
		getE('form_newemail').value = "";
		getE('form_submit').disabled = false;
		return false;
	}
	
	return true;
}

// DG Platinum - area riservata: submit del modulo di modifica password
function dg__reserved__modify_pwd() {
	if (getE('form_password').value=="" || getE('form_newpassword').value=="" || getE('form_newpassword1').value=="") {
		alert('Please type your current password and the new one.');
		getE('form_password').value = "";
		getE('form_newpassword').value = "";
		getE('form_newpassword1').value = "";
		getE('form_submit').disabled = false;
		return false;
	}
	
	if (!is_valid_password(getE("form_password").value, 5, 50) || !is_valid_password(getE("form_newpassword").value, 5, 50)) {
		alert('New password is not in the correct form.');
		getE('form_newpassword').value = "";
		getE('form_newpassword1').value = "";
		getE('form_submit').disabled = false;
		return false;
	}
	
	if (getE("form_newpassword").value!=getE("form_newpassword1").value) {
		alert('New password doesn\'t match repeated password.');
		getE('form_newpassword').value = "";
		getE('form_newpassword1').value = "";
		getE('form_submit').disabled = false;
		return false;
	}
	
	return true;
}

// area riservata - submit del modulo di modifica profilo utente
function dg__reserved__modify_profile() {
	if (isNaN(getE("id_utente_tipo").value) || parseInt(getE("id_utente_tipo").value)<1 || getE("nome").value=="" || (getE("societa").value=="" && parseInt(getE("id_utente_tipo").value)!=3) || getE("indirizzo").value=="" || getE("cap").value=="" || getE("citta").value=="" || isNaN(getE("idstato").value) || parseInt(getE("idstato").value)<1 || getE("telefono1").value=="" || getE("fax").value=="") {
		alert('Please fill in all required fields, marked with the asterisc char (*).');
		getE("form_submit").disabled = false;
		return false;
	}
	
	return true;
}

// DG Platinum - pending reservations: "select all" delle prenotazioni per la cancellazione
function dg__pending_reserv__select_all() {
	var check_val = getE("del_select_all").checked;
	
	if (check_val) {		// per evitare di far sballare il contatore delle prenotazioni selezionate
		if (parseInt(getE("del_selected_tot").value)>0) {
			getE("del_selected_tot").value = "0";
		}
	}
	
	for (i=0; i<getE("this_form").elements.length; i++) {
		if (getE("this_form").elements[i].type.toLowerCase()=='checkbox' && getE("this_form").elements[i].id.indexOf('del_checkbox_', 0)==0) {
			getE("this_form").elements[i].checked = check_val;
			dg__pending_reserv__delete_counter(getE("del_select_all"));
		}
	}
	
	if (check_val) {
		getE("del_select_all").title = 'unselect all';
		getE("del_select_all__link").title = 'unselect all';
	}
	else {
		getE("del_select_all").title = 'select all';
		getE("del_select_all__link").title = 'select all';
	}
}

// DG Platinum - pending reservations: incrementa o decrementa il contatore delle prenotazioni selezionate per la cancellazione
function dg__pending_reserv__delete_counter(obj_check) {
	if (obj_check.checked) {
		getE("del_selected_tot").value = parseInt(getE("del_selected_tot").value)+1;
	}
	else if (parseInt(getE("del_selected_tot").value)>0) {
		getE("del_selected_tot").value = parseInt(getE("del_selected_tot").value)-1;
	}
}

// DG Platinum - pending reservations: cancellazione delle prenotazioni selezioante
function dg__pending_reserv__delete() {
	getE("btn_delete").disabled = true;
	var deleting_sel = parseInt(getE("del_selected_tot").value);
	
	if (deleting_sel>0) {
		var plural_str = "";
		if (deleting_sel>1) {plural_str = "s";}
		
		if (confirm("You are about to delete "+deleting_sel+" pending reservation"+plural_str+".\nDo you want to confirm this operation?")) {
			getE("this_action").value = "1";
			
			getE("this_form").submit();
		}
	}
	else {
		alert("Please, select the pending reservations you want to delete.");
	}
	getE("btn_delete").disabled = false;
}

function init__jScrollPane() {
	var contentjscroller;
	var contentdiv = document.getElementById('content');
	if (contentdiv) {
		contentjscroller = document.createElement('div');
		contentjscroller.className = 'contentjscroll';
		contentjscroller.innerHTML = contentdiv.innerHTML + '<br />';
		contentdiv.innerHTML = '';
		contentdiv.appendChild(contentjscroller);
	}
	
	$(function()
	{
		$('.contentjscroll').jScrollPane({scrollbarWidth:12,showArrows:true});
	});
}

// DG Platinum - admin: apre e chiude il blocco "more options" di servizi ed extra
function admin_explode_services_more_opt(id_serv) {
	if (isObject(getE('more_opt_'+id_serv))) {
		if (getE('more_opt_'+id_serv).style.display=='') {
			getE('more_opt_'+id_serv).style.display = 'none';
			getE('more_opt_exploder_'+id_serv).src = 'img/ico_explode.gif';
			getE('more_opt_exploder_'+id_serv).title = 'mostra i campi "more options"';
		}
		else {
			getE('more_opt_'+id_serv).style.display = '';
			getE('more_opt_exploder_'+id_serv).src = 'img/ico_implode.gif';
			getE('more_opt_exploder_'+id_serv).title = 'nascondi i campi "more options"';
		}
	}
}
