var _ROW_N_AIRPORT = 8;
var _ROW_N_DATE = 9;

function take_date(id, value){
	//alert("ID= " + id + " , data= " + value);
}

function _0(num){
	return (num<10?"0":"") + num;
};

theFirstDate = new Date();
theSecondDate = new Date();
theSecondDate.setDate(theSecondDate.getDate()+1);

Search = {
	options:{
		from:"bform[checkin]",
		to:"bform[checkout]",
		trigger_from:"f_trigger_a",
		trigger_to:"f_trigger_b",
		override:false
	},
	calendarSetup:function(){
		var cal_from = Calendar.setup({
			inputField     :    Search.options.from,           //*
			ifFormat       :    "%d-%m-%Y",
			showsTime      :    false,
			button         :    Search.options.trigger_from,
			weekNumbers	   :	false,
			step           :    1,
			firstDay       :    1,
			dateStatusFunc :	Search.noOldDays,
			onUpdate	   :	Search.upDate,
			electric       :    false
		});
		var cal_to = Calendar.setup({
			inputField     :    Search.options.to,           //*
			ifFormat       :    "%d-%m-%Y",
			showsTime      :    false,
			button         :    Search.options.trigger_to, 
			weekNumbers	   :	false,
			step           :    1,
			firstDay       :    1,
			dateStatusFunc :	Search.noOldDaysTheSecond,
			onUpdate       :    Search.upDateTheSecond,
			electric       :    false
		});
		var cal_from2 = Calendar.setup({
			inputField     :    Search.options.from,           //*
			ifFormat       :    "%d-%m-%Y",
			showsTime      :    false,
			weekNumbers	   :	false,
			step           :    1,
			firstDay       :    1,
			dateStatusFunc :	Search.noOldDays,
			onUpdate	   :	Search.upDate,
			electric       :    false
		});
		var cal_to2 = Calendar.setup({
			inputField     :    Search.options.to,           //*
			ifFormat       :    "%d-%m-%Y",
			showsTime      :    false,
			weekNumbers	   :	false,
			step           :    1,
			firstDay       :    1,
			dateStatusFunc :	Search.noOldDaysTheSecond,
			onUpdate       :    Search.upDateTheSecond,
			electric       :    false
		});
	},
	init:function(){
		if(arguments.length == 1 && typeof(arguments[0]) == "object"){
			for(var ind in arguments[0]){
				Search.options[ind] = arguments[0][ind];
			}
		}
		if(Search.options.override){
			for(o in Overrides){
				Calendar.prototype[o] = Overrides[o];
			}
		}
		Search.calendarSetup();
	},
	noOldDays:function(date,y,m,d){
		var blockDate = new Date();
		blockDate.setDate(blockDate.getDate()-1);
		if(date<(blockDate)){
			return true;
		}else{
			return false;
		}
	},
	upDate:function(cal){
		theFirstDate = cal.date;
		if (document.forms['search_flyers']){
			if ( (theSecondDate.getTime()<=cal.date.getTime()) && (document.forms['search_flyers'].TRIP_TYPE[1].checked==true) ){
				theSecondDate = cal.date;
				theSecondDate = new Date(theFirstDate.getFullYear(),theFirstDate.getMonth(),theFirstDate.getDate());
				theSecondDate.setDate(theSecondDate.getDate()+1);
				var theString = _0(theSecondDate.getDate())+"-"+_0(theSecondDate.getMonth()+1)+"-"+theSecondDate.getFullYear();
				document.getElementById(Search.options.to).value = theString;
			}
		} else {
			if (theSecondDate.getTime()<=cal.date.getTime()){
				theSecondDate = cal.date;
				theSecondDate = new Date(theFirstDate.getFullYear(),theFirstDate.getMonth(),theFirstDate.getDate());
				theSecondDate.setDate(theSecondDate.getDate()+1);
				var theString = _0(theSecondDate.getDate())+"-"+_0(theSecondDate.getMonth()+1)+"-"+theSecondDate.getFullYear();
				document.getElementById(Search.options.to).value = theString;
			}
		}
	},
	upDateTheSecond:function(cal){
		if (document.forms['search_flyers']){
			if(document.forms['search_flyers'].TRIP_TYPE[1].checked==true){
				theSecondDate = cal.date;
			}
		} else {
			theSecondDate = cal.date;
		}
	},
	noOldDaysTheSecond:function(date,y,m,d){
		var fgiorno = theFirstDate.getDate();
		var fmese = theFirstDate.getMonth();
		var fanno = theFirstDate.getFullYear();
	
		var secondBlockDate = new Date(fanno,fmese,fgiorno);
//		secondBlockDate.setDate(secondBlockDate.getDate()-1);
	
		if(date<secondBlockDate){
			
			return true;
		}else{
			return false;
		}
	}
};

var Overrides = {
	showAtElement:function (el, opts) {
	var self = this;
	var p = Calendar.getAbsolutePos(el);
	if (!opts || typeof opts != "string") {
		this.showAt(p.x, p.y + el.offsetHeight);
		return true;
	}
	function fixPosition(box) {
		if (box.x < 0)
			box.x = 0;
		if (box.y < 0)
			box.y = 0;
		var cp = document.createElement("div");
		var s = cp.style;
		s.position = "absolute";
		s.right = s.width = "0px";
		document.body.appendChild(cp);
		var br = Calendar.getAbsolutePos(cp);
		document.body.removeChild(cp);
		if (Calendar.is_ie) {
			br.x += document.body.scrollLeft;
		} else {
			br.x += window.scrollX;
		}
		var tmp = box.x + box.width - br.x;
		if (tmp > 0) box.x -= tmp;
	}
	this.element.style.display = "block";
	Calendar.continuation_for_the_fucking_khtml_browser = function() {
		var w = self.element.offsetWidth;
		var h = self.element.offsetHeight;
		self.element.style.display = "none";
		var valign = opts.substr(0, 1);
		var halign = "l";
		if (opts.length > 1) {
			halign = opts.substr(1, 1);
		}
		// vertical alignment
		switch (valign) {
			case "T": p.y -= h; break;
			case "B": p.y += el.offsetHeight; break;
			case "C": p.y += (el.offsetHeight - h) / 2; break;
			case "t": p.y += el.offsetHeight - h; break;
			case "b": break; // already there
		}
		// horizontal alignment
		switch (halign) {
			case "L": p.x -= w; break;
			case "R": p.x += el.offsetWidth; break;
			case "C": p.x += (el.offsetWidth - w) / 2; break;
			case "l": p.x += el.offsetWidth - w; break;
			case "r": break; // already there
		}
		p.width = w;
		p.height = h + 40;
		self.monthsCombo.style.display = "none";
		fixPosition(p);
		self.showAt(p.x, p.y);
	};
	if (Calendar.is_khtml)
		setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10);
	else
		Calendar.continuation_for_the_fucking_khtml_browser();
	}
};
var append = function(func,callback){
	return function(){
		try{
			func();
		}catch(e){};
		try{
			callback();
		}catch(e){};
	}
};
//////////////////////////
function childage(num,lang) {
	var age;
	if (lang=="ita") {age = "Et&agrave; bambini: "};
	if (lang=="eng") {age = "Children age: "};
	if (lang=="deu") {age = "Jahre kinder: "};
	if (lang=="fra") {age = "Ag&eacute; enfants: "};
	if (num!=0) {var testo = " "+age;} else {var testo = " ";};
	for (i=1;i<=num;i++) {
		testo += "<select name='eta_bambino_"+i+"' class='selee' id='eta_bambino"+i+"'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option></select> ";		}
	document.getElementById("childage").innerHTML = testo;
}


function valida_cerca_hotel() {
	var testo_err = "Per cortesia:\n\n";
	var mancato_ins = false;		

	if (document.forms['cerca_hotel']['ss'].value == '') {
		testo_err = testo_err + '- inserisci la DESTINAZIONE\n\n';
		mancato_ins = true; 
	}
	if (document.forms['cerca_hotel']['ss'].value != '' && document.forms['cerca_hotel']['ss'].value.length < 3) {
		testo_err = testo_err + '- devi inserire almeno 3 CARATTERI\n';
		mancato_ins = true; 		
	}
	if (mancato_ins == true) {
		alert (''+testo_err+'');
		return false;
	}
	else return true;

}

function valida_cerca_pacchetto() {
	var testo_err = "Per cortesia:\n\n";
	var mancato_ins = false;		

	if (document.forms['cerca_pacchetti']['search_pacch_destinazione'].value == '' || document.forms['cerca_pacchetti']['id_destinazione'].value == '') {
		testo_err = testo_err + '- inserisci la DESTINAZIONE\n\n';
		mancato_ins = true; 
	}
	if (document.forms['cerca_pacchetti']['search_pacch_destinazione'].value != '' && document.forms['cerca_pacchetti']['search_pacch_destinazione'].value.length < 3) {
		testo_err = testo_err + '- devi inserire almeno 3 CARATTERI\n';
		mancato_ins = true; 		
	}
	if (mancato_ins == true) {
		alert (''+testo_err+'');
		return false;
	}
	else return true;

}

function valida_cerca_voli() {
	var testo_err = "Per cortesia:\n\n";
	var mancato_ins = false;		

	if ((document.forms['search_flyers']['B_LOCATION_1'].value == '') || (document.forms['search_flyers']['B_LOCATION_1'].value != '' && document.forms['search_flyers']['B_LOCATION_1'].value.length < 3)) {
		testo_err = testo_err + '- Inserisci l\'aeroporto di partenza\n';
		mancato_ins = true; 		
	}
	if ((document.forms['search_flyers']['E_LOCATION_1'].value == '') || (document.forms['search_flyers']['E_LOCATION_1'].value != '' && document.forms['search_flyers']['E_LOCATION_1'].value.length < 3)) {
		testo_err = testo_err + '- Inserisci l\'aeroporto di arrivo\n';
		mancato_ins = true; 		
	}
	if (mancato_ins == true) {
		alert (''+testo_err+'');
		return false;
	}
	else return true;
}

function show_calendar_act(){
	
	show_calendar('document.forms[search_flyers].checkin', 'document.forms[search_flyers].checkin.value');
}

function active_ar() {
	if (document.forms['search_flyers'].TRIP_TYPE[0].checked==true){
		document.getElementById("li_ritorno_cerca_voli_home").style.color="#aaa";
		document.forms['search_flyers'].checkout.disabled = true;
		document.forms['search_flyers'].checkout.value = "";
		document.forms['search_flyers'].checkout.style.backgroundColor="#efefef";
		document.forms['search_flyers'].checkout.style.borderColor="#aaa";
		document.getElementById('f_trigger_b').style.marginLeft = '50px';
	} else if (document.forms['search_flyers'].TRIP_TYPE[1].checked==true){
		document.getElementById("li_ritorno_cerca_voli_home").style.color="#000";
		document.forms['search_flyers'].checkout.disabled = false;
		document.forms['search_flyers'].checkout.style.backgroundColor="#fff";
		document.forms['search_flyers'].checkout.style.borderColor="#6897c4";
		document.getElementById('f_trigger_b').style.marginLeft = '8px';
	}
}

function validate(id_form){

	var inputs = Array(document.getElementsByTagName("input"), document.getElementsByTagName("select"));
	for(a = 0; a < inputs.length; a++) {
		for(i = 0; i < inputs[a].length; i++) {
			//alert(inputs[a][i].name);
		}
	}
}


var cat_vis="";
var cat_search="";

function class_hotel_form(id_input){
	
	if (id_input=="all_class" && document.getElementsByTagName("input").all_class.checked==true){
		document.getElementsByTagName("input").class_1.checked=true;
		document.getElementsByTagName("input").class_2.checked=true;
		document.getElementsByTagName("input").class_3.checked=true;
		document.getElementsByTagName("input").class_4.checked=true;
		document.getElementsByTagName("input").class_5.checked=true;
		cat_vis="Tutte le categorie";
		cat_search="1&class=2&class=3&class=4&class=5";
	} else if  (id_input=="all_class" && document.getElementsByTagName("input").all_class.checked==false){
		document.getElementsByTagName("input").class_1.checked=false;
		document.getElementsByTagName("input").class_2.checked=false;
		document.getElementsByTagName("input").class_3.checked=false;
		document.getElementsByTagName("input").class_4.checked=false;
		document.getElementsByTagName("input").class_5.checked=false;
		cat_vis="";
		cat_search="1&class=2&class=3&class=4&class=5";
	} else if  (id_input!="all_class" && (document.getElementsByTagName("input").class_1.checked==false || document.getElementsByTagName("input").class_2.checked==false || document.getElementsByTagName("input").class_3.checked==false || document.getElementsByTagName("input").class_4.checked==false || document.getElementsByTagName("input").class_5.checked==false)){
		document.getElementsByTagName("input").all_class.checked=false;
		cat_search="";
		cat_vis="";
		if (document.getElementsByTagName("input").class_1.checked==true){
			cat_search=cat_search+"class=1&";
			cat_vis=cat_vis + " 1";}
		if (document.getElementsByTagName("input").class_2.checked==true){
			cat_search=cat_search+"class=2&";
			cat_vis=cat_vis + " 2";}
		if (document.getElementsByTagName("input").class_3.checked==true){
			cat_search=cat_search+"class=3&";
			cat_vis=cat_vis + " 3";}
		if (document.getElementsByTagName("input").class_4.checked==true){
			cat_search=cat_search+"class=4&";
			cat_vis=cat_vis + " 4";}
		if (document.getElementsByTagName("input").class_5.checked==true){
			cat_search=cat_search+"class=5&";
			cat_vis=cat_vis + " 5";}
		cat_vis=cat_vis + " stelle";
	} else if  (id_input!="all_class" && (document.getElementsByTagName("input").class_1.checked==true && document.getElementsByTagName("input").class_2.checked==true && document.getElementsByTagName("input").class_3.checked==true && document.getElementsByTagName("input").class_4.checked==true && document.getElementsByTagName("input").class_5.checked==true)){
		document.getElementsByTagName("input").all_class.checked=true;
	}
}

function active_class_hotel(stato){
	if (stato=='open'){
		document.getElementById('class_hotel').style.display="block";
	} else if (stato=='close'){
		document.getElementById('class_hotel').style.display="none";
	} else if (stato=='setta'){
		if (cat_vis != ""){
			document.getElementsByTagName("input").class_hotel_sel.value = "Categoria: " + cat_vis;
		} else {
			document.getElementsByTagName("input").class_hotel_sel.value = "";
		}
		document.getElementsByTagName("input").class_set.value = cat_search;
		document.getElementById('class_hotel').style.display = "none";
	}

}

function active(){
	if (document.getElementById("country")){
		if (document.getElementById("country").value=='US'){
			document.getElementById('stateUS').style.display="block";
			document.getElementById('state').style.display="none";
		} else {
			document.getElementById('stateUS').style.display="none";
			document.getElementById('state').style.display="block";
		}
	}
	if (document.getElementById("form_step1")){
		if (document.forms['form_step1'].tipo[0].checked==true){
			document.forms['form_step1'].persone.disabled = true;
			document.forms['form_step1'].persone.style.backgroundColor="#efefef";
			document.forms['form_step1'].persone.style.borderColor="#aaa";
			document.forms['form_step1'].persone.value = "1";
		} else {
			document.forms['form_step1'].persone.disabled = false;
			document.forms['form_step1'].persone.style.backgroundColor="#fff";
			document.forms['form_step1'].persone.style.borderColor="#6897c4";
			document.forms['form_step1'].persone.value = "";
		}
	}
}

function change_filtra_risultati(valore, numero) {
	document.getElementById('search_pacch_destinazione').value = numero;
	document.getElementById('id_destinazione').value = valore;	
	filtra_risultati();
}

function change_filtra_risultati_2(valore, numero) {
	document.getElementById('search_pacch_destinazione').value = numero;
	document.getElementById('id_destinazione').value = valore;	
	filtra_risultati_2();
}

function go_top(topper, value){
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrOfY = document.documentElement.scrollTop;
	}
	if (topper == "null"){
		topper = scrOfY;
	} else {
		topper = topper;
	}
	var new_topper = Math.round(topper/5)*1;
	
	if ((topper-new_topper)>3){
		scrollTo(0, (topper-new_topper));
		//alert(topper-new_topper);
		setTimeout('go_top('+((topper*1)-(new_topper*1))+', '+value+')',20);
	} else {
		scrollTo(0, 0);
		filtra_risultati(value);
	}	
}

function filtra_risultati(page){
	var init_search = true;
	var mia_ricerca = '?';
	var mio_form = document.getElementById('form_principale');
	var selettori_mio_form = mio_form.getElementsByTagName('input');
	for(k = 0; k < selettori_mio_form.length; k++) {
		if ( (selettori_mio_form[k].getAttribute('id') == "search_pacch_destinazione") || (selettori_mio_form[k].getAttribute('id') == "button_send_search_form_pacchetti") ){
			continue;
		} else {
			mia_ricerca = mia_ricerca + selettori_mio_form[k].getAttribute('id') + '=' +selettori_mio_form[k].value + '&';
			if (document.getElementById('id_destinazione')!=1){
				init_search = false;
			}
		}
	}
	var blocco = document.getElementById('lista_pacchetti');
	var selettori = blocco.getElementsByTagName('ul');
	for(a = 0; a < selettori.length; a++) {
		var singolo_selettore = document.getElementById(selettori[a].getAttribute('id'));
		mia_ricerca = mia_ricerca + singolo_selettore.getAttribute('id') + '=';
		var inputs = singolo_selettore.getElementsByTagName('input');
		for(i = 0; i < inputs.length; i++) {
			if (inputs[i].checked==true){
				mia_ricerca = mia_ricerca + inputs[i].value + '*';
				init_search = false;
			}
		}

		mia_ricerca = mia_ricerca +  '&';
	}
	var filtra_per = mia_ricerca.substring(0,mia_ricerca.length-1);
	if (page!=""){
		filtra_per = filtra_per + "&page=" + page;
	}
	include_page('/result_pacchetti.php' + filtra_per, 'colonna_dx_scheda');
}

function show_help_t_left(init_search){
	if (document.getElementById('help_top_left_1')){
		if (init_search){
			document.getElementById('help_top_left_1').style.display="block";
			document.getElementById('help_top_left_2').style.display="none";
		}else{
			document.getElementById('help_top_left_1').style.display="none";
			document.getElementById('help_top_left_2').style.display="block";
		}
	}
}

function keep_back(my_string){
	if (document.getElementById('go_back_history')){
		document.getElementById('go_back_history').setAttribute("href","javascript:include_page('/result_pacchetti.php" + my_string + "&step=back', 'colonna_dx_scheda');");
	}
}

function keep_checked(my_string){
	//alert(my_string);
	var blocco = document.getElementById('lista_pacchetti');
	var selettori = blocco.getElementsByTagName('ul');
	for(a = 0; a < selettori.length; a++) {
		var singolo_selettore = document.getElementById(selettori[a].getAttribute('id'));
		var inputs = singolo_selettore.getElementsByTagName('input');
		for(i = 0; i < inputs.length; i++) {
			inputs[i].checked="";
		}
	}
	
	if (my_string.length > 8){
		var my_single_string = my_string.split("&");
		for (var i=0; i < my_single_string.length; i++){
			
			var my_ul_id=my_single_string[i].split("=");
			var my_checkbox_id=my_ul_id[1].split("*");
			for (var i_checkbox=0; i_checkbox < (my_checkbox_id.length-1); i_checkbox++){
				//alert(my_ul_id[0]+"_"+my_checkbox_id[i_checkbox]);
				var my_checkbox=my_ul_id[0]+"_"+my_checkbox_id[i_checkbox];
				
				if (document.getElementById(my_checkbox)){
					document.getElementById(my_checkbox).checked="checked";
				}
			}
		}
		var mia_destinazione_ar = my_single_string[0].split("=");
		var mia_destinazione = mia_destinazione_ar[1];
		document.getElementById('id_destinazione').value=mia_destinazione;
	}
}

function filtra_risultati_2(){
	var mia_ricerca = '?';
	var mio_form = document.getElementById('form_principale');
	var selettori_mio_form = mio_form.getElementsByTagName('input');
	for(k = 0; k < selettori_mio_form.length; k++) {
		if (document.getElementById('search_pacch_destinazione').value == "") {
			document.getElementById('id_destinazione').value = "2";
		}
		if ( (selettori_mio_form[k].getAttribute('id') == "search_pacch_destinazione") || (selettori_mio_form[k].getAttribute('id') == "button_send_search_form_pacchetti") ){
			continue;
		} else {
			mia_ricerca = mia_ricerca + selettori_mio_form[k].getAttribute('id') + '=' +selettori_mio_form[k].value + '&';			
		}
	}
	var blocco = document.getElementById('lista_pacchetti');
	var selettori = blocco.getElementsByTagName('ul');
	for(a = 0; a < selettori.length; a++) {
		var singolo_selettore = document.getElementById(selettori[a].getAttribute('id'));
		mia_ricerca = mia_ricerca + singolo_selettore.getAttribute('id') + '=';
		var inputs = singolo_selettore.getElementsByTagName('input');
		for(i = 0; i < inputs.length; i++) {
			if (inputs[i].checked==true){
				mia_ricerca = mia_ricerca + inputs[i].value + '*';
			}
		}

		mia_ricerca = mia_ricerca +  '&';
	}
	
	var filtra_per = mia_ricerca.substring(0,mia_ricerca.length-1);
	//alert (filtra_per);
	include_page('/result_pacchetti_int.php' + filtra_per, 'colonna_dx_scheda');
}


function change_option(prod_id){
	//alert("Cambio Aeroporto/Porto");
	if (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT]){
		var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
		if ( valore!= "null"){
			//alert("cambio aeroporto");
			var airport = "?prod_id=" + prod_id + "&airport=" + valore + "&change_airport=1";
			include_page('/option_select.php' + airport, 'sel_field_'+_ROW_N_DATE);
			//alert("  ");
		} else {
			include_page('/option_select.php?prod_id=' + prod_id + '&airport=0', 'sel_field_'+_ROW_N_DATE);
			//alert(" ");
		}
	}
}
function change_option_int(s_type){
	if (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT]){
		var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
		if ( valore!= "null"){
			//alert("cambio aeroporto");
			var airport = "?airport=" + valore + "&change_airport=1&type=" + s_type;
			include_page('/option_select_int.php' + airport, 'sel_field_'+_ROW_N_DATE);
		} else {
			include_page('/option_select_int.php?airport=0&type='+s_type, 'sel_field_'+_ROW_N_DATE);
		}
	}
}
function show_detail(ID_soggiorno){
	if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
		
		var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
		if ((valore_12 == 'null') && (ID_soggiorno != '') && ( (ID_soggiorno) != undefined)) { 
			valore_12 = ID_soggiorno;
			//alert(valore_12);
		}
		var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
		var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
		if ( valore!= "null" && valore_12!= "null"){
			var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id;
			include_page('/details_tour.php' + filtra, 'dett_pacch_container_page');
		}
	}
}
function show_detail_int(ID_soggiorno, type){
	if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
		
		var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
		if ((valore_12 == 'null') && (ID_soggiorno != '') && ( (ID_soggiorno) != undefined)) { 
			valore_12 = ID_soggiorno;
			//alert(valore_12);
		}
		var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
		var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
		if ( valore!= "null" && valore_12!= "null"){
			var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&type=" + type;
			include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
		}
	}
}

function add_bag(nome, datapart, prezzo, sconto, puntatore){
	if (nome != "" && datapart != "" && prezzo != "" && sconto != "" && puntatore != "") {
		var datototale = nome+'|'+datapart+'|'+prezzo+'|'+sconto+'|'+puntatore;
		if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
			var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
			var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
			var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
			if ( valore!= "null" && valore_12!= "null"){
				var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&aggiungi=1&datototale="+datototale+'|'+valore+'|'+valore_12+'|0|1';
				include_page('/details_tour.php' + filtra, 'dett_pacch_container_page');
			}
		}
	}
}
function add_bag_int(type, nome, datapart, prezzo, sconto, puntatore){
	if (nome != "" && datapart != "" && prezzo != "" && sconto != "" && puntatore != "") {
		var datototale = nome+'|'+datapart+'|'+prezzo+'|'+sconto+'|'+puntatore;
		if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
			var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
			var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
			var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
			if ( valore!= "null" && valore_12!= "null"){
				var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&aggiungi=1&type="+type+"&datototale="+datototale+'|'+valore+'|'+valore_12+'|0|1';
				include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
			}
		}
	}
}
function add_bag_int_2(prod_id, type, nome, datapart, prezzo, sconto, puntatore){
	if (nome != "" && datapart != "" && prezzo != "" && sconto != "" && puntatore != "") {
		var datototale = nome+'|'+datapart+'|'+prezzo+'|'+sconto+'|'+puntatore;
		var filtra = "?prod_id=" + prod_id + "&aggiungi=1&type="+type+"&datototale="+datototale+'|0|0|0|1';
		include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
	}
}


function set_value_option(row, name_select){
	var pos_set_now = 0;
	if (name_select.substring(0,6)=="quanti"){
		pos_set_now = 9;
	} else if (name_select.substring(0,6)=="neonat"){
		pos_set_now = 8;
	}
	var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
	var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
	var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
	var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&edit_option=1&row=" + row + "&pos=" + pos_set_now + "&val=" + document.forms['disponibilita_sel'][name_select].value;
	include_page('/details_tour.php' + filtra, 'dett_pacch_container_page');
}

function set_value_option_2(prod_id, type, row, name_select){
	var pos_set_now = 0;
	if (name_select.substring(0,6)=="quanti"){
		pos_set_now = 9;
	} else if (name_select.substring(0,6)=="neonat"){
		pos_set_now = 8;
	}
	var filtra = "?prod_id=" + prod_id + "&type=" + type + "&edit_option=1&row=" + row + "&pos=" + pos_set_now + "&val=" + document.forms['disponibilita_sel'][name_select].value;
	include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
}

function reset_session(nome, datapart, prezzo, sconto, puntatore){
	if (confirm('ATTENZIONE\n\nHai selezionato una data diversa da quelle già scelte.\nProseguendo verranno azzerati tutti i dati già inseriti.\n\nVuoi procedere comunque?')) {
		if (nome != "" && datapart != "" && prezzo != "" && sconto != "" && puntatore != "") {
			var datototale = nome+'|'+datapart+'|'+prezzo+'|'+sconto+'|'+puntatore;
			if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
				var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
				var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
				var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
				if ( valore!= "null" && valore_12!= "null"){
					var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&reset=1&datototale="+datototale+'|'+valore+'|'+valore_12+'|0|1';
					include_page('/details_tour.php' + filtra, 'dett_pacch_container_page');
				}
			}
		}
	}
}

function reset_session_int(type, nome, datapart, prezzo, sconto, puntatore){
	if (confirm('ATTENZIONE\n\nHai selezionato una data diversa da quelle già scelte.\nProseguendo verranno azzerati tutti i dati già inseriti.\n\nVuoi procedere comunque?')) {
		if (nome != "" && datapart != "" && prezzo != "" && sconto != "" && puntatore != "") {
			var datototale = nome+'|'+datapart+'|'+prezzo+'|'+sconto+'|'+puntatore;
			if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
				var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
				var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
				var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
				if ( valore!= "null" && valore_12!= "null"){
					var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&reset=1&type=" + type + "&datototale="+datototale+'|'+valore+'|'+valore_12+'|0|1';
					include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
				}
			}
		}
	}
}
function reset_session_int_2(prod_id, type, nome, datapart, prezzo, sconto, puntatore){
	if (confirm('ATTENZIONE\n\nHai selezionato una data diversa da quelle già scelte.\nProseguendo verranno azzerati tutti i dati già inseriti.\n\nVuoi procedere comunque?')) {
		if (nome != "" && datapart != "" && prezzo != "" && sconto != "" && puntatore != "") {
			var datototale = nome+'|'+datapart+'|'+prezzo+'|'+sconto+'|'+puntatore;
			var filtra = "?&prod_id=" + prod_id + "&reset=1&type=" + type + "&datototale="+datototale+'|0|0|0|1';
			include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
		}
	}
}
function deleteval (id){
	if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
		var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
		var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
		var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
		if ( valore!= "null" && valore_12!= "null"){
			//alert("Cambio durata a:" + valore + " d_s:" +  valore_12);
			var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&delete=1&id="+id;
			include_page('/details_tour.php' + filtra, 'dett_pacch_container_page');
		}
	}
}
function deleteval_int (type, id){
	if ((document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE]) && (document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT])) {
		var valore_12 = document.forms['form_dett_pacchetti']["field_"+_ROW_N_DATE].value;
		var valore = document.forms['form_dett_pacchetti']["field_"+_ROW_N_AIRPORT].value;
		var prod_id = document.forms['form_dett_pacchetti'].id_prodotto.value;
		if ( valore!= "null" && valore_12!= "null"){
			//alert("Cambio durata a:" + valore + " d_s:" +  valore_12);
			var filtra = "?airport=" + valore + "&soggiorno_id=" + valore_12 + "&prod_id=" + prod_id + "&type="+type+"&delete=1&id="+id;
			include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
		}
	}
}
function deleteval_int_2 (prod_id, type, id){
	var filtra = "?prod_id=" + prod_id + "&type="+type+"&delete=1&id="+id;
	include_page('/details_tour_int.php' + filtra, 'dett_pacch_container_page');
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(active);

var cal1, cal2;

function active_calendar(){
	cal1 = new calendar1(document.forms['search_flyers'].elements['checkin']);
	cal1.year_scroll = true;
	cal1.time_comp = false;
	
	cal2 = new calendar1(document.forms['search_flyers'].elements['checkout']);
	cal2.year_scroll = true;
	cal2.time_comp = false;
}