/* INTERFACCIA JS PER GESTIRE LA FASE DI RICERCA DISPONIBILITA' */

// Variabili Globali
var url_xml_rpc;	        // indirizzo per chiamare la call.php
var form_obj;				        // form principale
var struct_param = new Array();		// array standard per contenere la struttura/xml
var iso_encoding;			        // variabile che conterrà la codifica della struttura/xml
var global_duration = 1;            // variabile globale che conterrà la durata del soggiorno
var jsProductId = 0;
var applicationProduct = new Array();


// Trova tutti i prodotti di una determinata tipologia
function products_of_typology(typology) {
	struct_param['query'] = new Array();
	struct_param['header']['product'] = 'availability';
	struct_param['header']['type'] = 'products_of_typology';
	struct_param['query']['typology'] = typology;
	
	document.getElementById('typology').value = typology;
	document.getElementById('products').innerHTML = js_dic_LOADING+'...';
	
	xml_request(struct_param, url_xml_rpc, iso_encoding, print_products_of_typology);
}

//Crea la select con tutti i prodotti di una determinata tipologia
function print_products_of_typology(response, type) {
	var html_label = js_dic_PACKAGE ;
	//var html = '<select class="font_9" name="product" id="product" onChange="set_product(this.value);description_of_product(this.value);search_products(this.value,null);">';
	var html = '&nbsp;<select class="font_9" name="product" id="product" onChange="set_product(this.value);description_of_product(this.value);">';
	
	html += '<option value="***">--- '+js_dic_SELECT_PRODUCT+' ---</option>';
	
	var count = 0;
	for(var i in response) {
		html+= '<option value="'+response[i]['id']+'">'+response[i]['name']+'</option>';
		count++;
	}
	html += '</select>';
	
	// se ho trovato almeno un prodotto mostro il bottone per fare la ricerca e la select coi prodotti
	if(count > 0) {
		// document.getElementById('label_products').innerHTML = html_label;
		document.getElementById('products').innerHTML = html;
		document.getElementById('products').style.display = 'inline';
		//document.getElementById('button').style.display = 'inline';
	}
	// ...altrimenti nascondo il bottone e mostro un avviso
	else {
		html = '<td>'+js_dic_NOPRODUCTS +'</td>';
		document.getElementById('products').innerHTML = js_dic_NOPRODUCTS;
		document.getElementById('products').style.display = 'inline';
		// document.getElementById('button').style.display = 'none';
	}

	display_default();
	
	refresh_box();
}


function description_of_product(idProduct){
	/*
	document.getElementById('rigth_panel_image').style.display = 'none';
	var language = document.getElementById('language').value;
	var html = '<iframe src ="'+js_global_contracts_url+idProduct+'/'+ idProduct +'_Description_' + language +'.html" width="575" height="250">';		
	document.getElementById('products_description').innerHTML = html;
	document.getElementById('products_description').style.display = 'inline';
	refresh_box();		
	*/
	
	if(idProduct != "***"){		
		struct_param['query'] = new Array();
		struct_param['header']['product'] = 'availability';
		struct_param['header']['type'] = 'description_of_product';
		struct_param['query']['id'] = idProduct;
	
		xml_request(struct_param, url_xml_rpc, iso_encoding, print_description_of_product);
	} else {
		print_error(js_dic_ERRORTECHNICAL);
	}	
}


function print_description_of_product(response, type) {
	var html = ' &nbsp;' + response + ' &nbsp;';
		
	if(response != "") {
		document.getElementById('rigth_panel_image').style.display = 'none';
		document.getElementById('products_description').innerHTML = html;
	 if(document.getElementById('products_list')){
		 document.getElementById('products_list').innerHTML = "";
		document.getElementById('products_list').style.display = 'none';		 
	 }
	if(document.getElementById("products_cost")){
		document.getElementById("products_cost").innerHTML = "";
		document.getElementById("products_cost").style.display =  'none';		 
	}
		document.getElementById('rigth_panel_products').style.display = 'inline';		
		document.getElementById('products_description').style.display = 'inline';
	}
	refresh_box();
}





function set_product(idProduct){	
	document.getElementById('product').value = idProduct;
	document.getElementById('product_id').value = idProduct;
	if(document.getElementById('destination').value != "***"){
		document.getElementById('destination').value = "***";
	}
	if(document.getElementById('nationality').value != "***"){
		document.getElementById('nationality').value = "***";
	}
	
	
	jsProductId = idProduct;
	
	refresh_box();
}


function show_product_description(){
	var result = "";
	if(document.getElementById('products_description') != null){
		result = document.getElementById('products_description').value; 
	}
	return result;
}



// setta la data di fine soggiorno al giorno sucessivo a quella di inizio
function set_to_date() {
	var new_to = new Date(document.getElementById('syear').value, document.getElementById('smonth').value-1, parseInt(document.getElementById('sday').value)+1);
	
	document.getElementById('eyear').value = new_to.getFullYear();
	document.getElementById('emonth').value = format_two_digits(new_to.getMonth()+1);
	document.getElementById('eday').value = format_two_digits(new_to.getDate());
}

// Gestisce le date di inizio e fine soggiorno e la durata che intercorre
function dates_manager(param) {
	if(!param)
		param='';
	reset_errors();
	
	var from = document.getElementById(param+'syear').value+'-'+document.getElementById(param+'smonth').value+'-'+document.getElementById(param+'sday').value;
	var to = document.getElementById(param+'eyear').value+'-'+document.getElementById(param+'emonth').value+'-'+document.getElementById(param+'eday').value;
	
	// controlla se le date inserite sono valide
	if(!check_date(document.getElementById(param+'syear').value, document.getElementById(param+'smonth').value, document.getElementById(param+'sday').value) || !check_date(document.getElementById(param+'eyear').value, document.getElementById(param+'emonth').value, document.getElementById(param+'eday').value)) {
		document.getElementById(param+'duration').className = 'red';
		document.getElementById(param+'duration').innerHTML = js_dic_ERRORWORNGDATES;
		return false;
	}
	
	// controlla se tra le due date intercorrono più di 45 giorni e li stampa
	global_duration = compute_days(from, to);
	if(global_duration > 45 || global_duration <= 0)
		document.getElementById(param+'duration').className = 'red';
	else
		document.getElementById(param+'duration').className = 'green';
	document.getElementById(param+'duration').innerHTML ='<span id="duration" class="font_9">' + js_dic_DAYS + ':' + global_duration+'</span>'; 
		// js_dic_DURATION+': '+global_duration+' '+js_dic_DAYS;
	document.getElementById('duration_inp').value = global_duration;
}

function get_products(){
	if(document.getElementById('typology').value == '***') {
		print_error(js_dic_ERRORNOTYPOLOGY);
		return false;
	}
	// controlla che le date selezionate siano valide
	if(document.getElementById('duration').className == 'red') {
		print_error(js_dic_ERRORWORNGDATES);
		return false;
	}

	struct_param['query'] = new Array();
	struct_param['header']['product'] = 'availability';
	struct_param['header']['type'] = 'get_product';
	struct_param['query']['startdate'] = document.getElementById('syear').value+'-'+document.getElementById('smonth').value+'-'+document.getElementById('sday').value;
	struct_param['query']['enddate'] = document.getElementById('eyear').value+'-'+document.getElementById('emonth').value+'-'+document.getElementById('eday').value;
	struct_param['query']['duration'] = global_duration;
	struct_param['query']['typology'] = document.getElementById('typology').value;
	struct_param['query']['product'] = document.getElementById('product').value;
	struct_param['query']['nationality'] = document.getElementById('nationality').value;
	struct_param['query']['destination'] = document.getElementById('destination').value;
	struct_param['query']['pax_number'] = document.getElementById('number').value;
	
	xml_request(struct_param, url_xml_rpc, iso_encoding, callbacks_xml_request);
	
}
function default_product(){
	document.getElementById('product').value = '***';
}

function default_search(){
	
}

function validate_search(type){
    
	if(document.getElementById('typology').value != '***' &&
		document.getElementById('product_id').value != '' && 		
		document.getElementById('product_id').value != '***' &&
		document.getElementById('destination').value != '***' &&
		document.getElementById('nationality').value != '***' &&
		document.getElementById('number').value > 0 &&
		document.getElementById('duration').className != 'red') {
		//document.getElementById('b_choose').disabled = false;
		jsProductId = document.getElementById('product_id').value;
		search_products(null,null);
	} else {
		jsProductId = 0;
	}
	
}
// Controlla i parametri richiesti e cerca tutti i prodotti che li rispettano
function search_products(productId,premiumId) {	

	if(productId == ""){
		productId = null;
	}
	if(premiumId == ""){
		premiumId = null;
	}
	
	var where = document.getElementById('products_list');
	var startdate = "";
	var enddate = "";
	var pax_number = "";
	var valueTravelCost = 0;

	// controlla che sia stata selezionata almeno una tipologia
	if(document.getElementById('typology').value == '***') {
		print_error(js_dic_ERRORNOTYPOLOGY);
		return false;
	}

	if(document.getElementById('product').value == '') {
		print_error(js_dic_ERRORNOPRODUCT);
		return false;
	} 
	
	if(document.getElementById('destination').value == '***') {
		document.getElementById('products').style.display = 'none';	
		document.getElementById('typology').value = '***';

		print_error(js_dic_ERROR_NO_DESTINATION);
		refresh_box();		
		return false;		
	}

	if(document.getElementById('nationality').value == '***') {
		document.getElementById('products').style.display = 'none';
		document.getElementById('typology').value = '***';

		print_error(js_dic_ERROR_NO_NATIONALITY);
		refresh_box();		
		return false;
	}
	
	if(document.getElementById('number').value <= 0) {
		document.getElementById('products').style.display = 'none';
		document.getElementById('typology').value = '***';
		refresh_box();
		print_error(js_dic_ERROR_PAX_NUMBER);
		return false;
	}
	// controlla che le date selezionate siano valide
	if(document.getElementById('duration').className == 'red') {
		print_error(js_dic_ERRORWORNGDATES);
		return false;
	}
	if(document.getElementById('select_application') != null && document.getElementById('select_application').value == '***'){
		print_error(js_dic_ERROR_NO_APPLICATION);
		return false;		
	}
	
	
	//non mostro il form per la ricerca e invece mostro il loading
	if(document.getElementById('search') && document.getElementById('loading')){
		document.getElementById('search').style.display = 'none';
		document.getElementById('loading').style.display = 'block';
		refresh_box();		
	}
	//mi costruisco i parametri da passare all'html
	struct_param['query'] = new Array();
	struct_param['header']['product'] = 'availability';
	struct_param['header']['type'] = 'search_products';
	//struct_param['query']['filter_function'] = 'show_products_list';
	
	if(document.getElementById('syear')){
		startdate = document.getElementById('syear').value+'-'+document.getElementById('smonth').value+'-'+document.getElementById('sday').value;		
	} else {
		startdate = document.getElementById('startdate').value;
	}
	struct_param['query']['startdate'] = startdate;
	if(document.getElementById('eyear')){
		enddate = document.getElementById('eyear').value+'-'+document.getElementById('emonth').value+'-'+document.getElementById('eday').value; 
	}else {
		enddate = document.getElementById('enddate').value;
	}
	
	struct_param['query']['enddate'] = enddate;
	struct_param['query']['duration'] = global_duration;
	struct_param['query']['typology'] = document.getElementById('typology').value;
	struct_param['query']['product'] = document.getElementById('product').value;	
	struct_param['query']['nationality'] = document.getElementById('nationality').value;
	struct_param['query']['destination'] = document.getElementById('destination').value;
	
	if(document.getElementById('number')){
		pax_number = document.getElementById('number').value;
	}else {
		pax_number = document.getElementById('pax_number').value;
	}
	struct_param['query']['pax_number'] = pax_number;
	if(productId != null && premiumId != null){
		// valueTravelCost = document.getElementById('travel_cost_'+productId).value;
		if(document.getElementById('travel_cost')){
			valueTravelCost = document.getElementById('travel_cost').value;
			if(isNaN(valueTravelCost)){
				print_error(js_dic_MSG_INSERT_TRAVEL_COST);
				return false;
			} else {
				if(valueTravelCost != null && valueTravelCost > 0){
					struct_param['query']['product_id'] = productId;
					struct_param['query']['premium_id'] = premiumId;
					struct_param['query']['travel_cost'] = valueTravelCost;
				}
			}
		} else if (document.getElementById('select_application')){
			valueApplication = document.getElementById('select_application').value;
			if(isNaN(valueApplication)){
				print_error(js_dic_ERROR_NO_APPLICATION);
				return false;
			} else {
				if(valueApplication != null && valueApplication > 0){
					premiumId = applicationProduct[valueApplication];
					struct_param['query']['product_id'] = productId;
					struct_param['query']['premium_id'] = premiumId;
					document.getElementById('premium_id').value = premiumId;
					document.getElementById('product_id').value = productId;					
				}
			}
		}
	}

	//la callback_html_response non fa altro che risputare fuori l'html
	//html_request(struct_param, url_xml_rpc, iso_encoding, callback_html_response, where);
	xml_request(struct_param, url_xml_rpc, iso_encoding, show_product_list);
    
}

function change_value(txtObj){
	txtObj.value="";
}
function show_product_list(response, type){	
	

	var products = response;
	if(products.length <= 0){
		alert(js_dic_NOPRODUCTS);
		window.location=js_global_root_url+'index.php';
		return;
	}
	var html_cost = "";
	// var html_premium = "<fieldset>";
	var html_premium = "";
	var html_premium_import = "";
	var html_premium_application = "";
	var names = "";
	var typology_name = "";
	var final_premium = 0;
	var description_premium = "";
	var final_premium_pp = 0;
	var description_final_premium = "";
	var description_application = "";
	var description_taxes = "";
	var startdate = "";
	var enddate = "";
	var premium_id = "";
	var product_id = "";
	var destination = "";
	var nationality = "";
	var sday = "";
	var smonth = "";
	var syear = "";
	var eday = "";
	var emonth  = "";
	var eyear  = "";	
	var typeApplication = new Array();
	
	////////////////////////////////////////////////
	destination = get_text_selection(document.getElementById("destination"),document.getElementById("destination").value);
	nationality = get_text_selection(document.getElementById("nationality"),document.getElementById("nationality").value);
	/////////////////////////////////////
	sday = document.getElementById("sday").value;
	smonth = document.getElementById("smonth").value;
	syear = document.getElementById("syear").value;
	////////////////////////////////////
	eday = document.getElementById("eday").value;
	emonth = document.getElementById("emonth").value;
	eyear = document.getElementById("eyear").value;
	///////////////////////////////////////////////////
	
	for(var i in products) {
		// names = products[i]['names'];				
		// html_premium += "<legend>"+names[document.getElementById("language").value]+"</legend>";		
		typology_name = products[i]['typology_name'];
		
		html_premium += "<table>";
		html_premium += "<tr>";
		html_premium += '<td><img alt="" src="' + js_global_images_url + 'contracts/logo_' + jsProductId + '.jpg"></img></td>';
		html_premium += '<td class="font_9">';
	
		 
		html_premium += '<b>'+js_dic_TYPOLOGY +":</b>"+typology_name+"<br />";
		html_premium += '<b>'+js_dic_DESTINATION+":</b>"+destination+"<br />";
		html_premium += '<b>'+js_dic_NATIONALITY+":</b>"+nationality+"<br />";
		html_premium += '<b>'+js_dic_START+":</b>"+sday+"-"+smonth+"-"+syear+"<br />";
		html_premium += '<b>'+js_dic_END+":</b>"+eday+"-"+emonth+"-"+eyear+"<br />";
		
		for (var k in products[i]['premium']){
			final_premium = products[i]['premium'][k]['final_premium'];
			description_premium = products[i]['premium'][k]['description_premium'];
			final_premium_pp = products[i]['premium'][k]['final_premium_pp'];
			description_final_premium = products[i]['premium'][k]['description_final_premium'];
			description_application = products[i]['premium'][k]['description_application'];
			description_taxes =  products[i]['premium'][k]['description_taxes'];
			startdate =  products[i]['premium'][k]['startdate'];
			enddate =  products[i]['premium'][k]['enddate'];
			premium_id = products[i]['premium'][k]['id'];
			product_id = products[i]['premium'][k]['product'];
			
			if(products[i]['premium'][k]['type_application']  > -1){
				typeApplication[products[i]['premium'][k]['application']] = products[i]['premium'][k]['type_application']; 
				applicationProduct[products[i]['premium'][k]['application']] = premium_id;
			}
			
			if(products[i]['premium'][k]['premium_class_name'] == js_dic_CLASS_NAME_TYPE_PREMIUM_PERC && html_cost == ""){				
				html_cost += '<input class="cell_isert" id="travel_cost" name="travel_cost" type="text" value="" size="25" onClick="change_value(this)" maxlength="10"></input>';				
			} else {
				
			}
			
			if (final_premium >0 && document.getElementById("premium_import") != null){
				html_premium += '<b>'+js_dic_PREMIUM +":</b>" +final_premium + "-" + description_premium+"</br>";
				html_premium_import+= '<b>'+js_dic_PREMIUM +":</b>" +format_price(final_premium,"it") + " " + js_dic_CURRENCY_SIGN + "</br>";
				document.getElementById("premium_import").innerHTML = html_premium_import;
				document.getElementById("premium_import").style.display = display_for_browser();
				document.getElementById("button_buy").style.display = display_for_browser();
			} else {
				// document.getElementById("button_buy").style.display = 'none';
				// document.getElementById("premium_import").innerHTML = "";
			}			
			html_premium += '<b>'+js_dic_PREMIUM +":</b>"+ final_premium_pp + " " + description_premium + "-" + description_final_premium +"</br>";

			if(description_application  != ""){
				html_premium += description_application + " " ;
			}
			html_premium += description_taxes + "</br>";			
		}
	}

	if(typeApplication.length > 0){
		html_premium_application = '<select class="font_9" id="select_application"><option value="***">Seleziona tratta</option><option value="1">Andata o Ritorno</option><option value="2">Andata e Ritorno</option></select>';
	}

	html_premium += "</td>";
	
	//html_premium += '<td><table><tr><td class="font_18_green"><div  id="premium_import" name="premium_import" style="display: none;"></div></td>';
	//html_premium += '<td><input id="button_buy" type="button" class="button_red_100"  value="' + js_dic_BUY + '" style="display: none;" onClick="go_to_buy(document.getElementById(\'product_id\').value,document.getElementById(\'premium_id\').value)"></td>';
	html_premium += '<td colspan=2">&nbsp;</td><td class="align_right"><div  id="premium_import" class="home_import" name="premium_import" style="display: none;"></div></br>';
	html_premium += '<input id="button_buy" type="button" class="button_red_100"  value="' + js_dic_BUY + '" style="display: none;" onClick="go_to_buy(document.getElementById(\'product_id\').value,document.getElementById(\'premium_id\').value)"></td>';
	
	// html_premium += '</tr><tr><td><input id="button_buy" type="button" class="button_red_100"  value="' + js_dic_BUY + '" style="display: none;" onClick="go_to_buy(document.getElementById(\'product_id\').value,document.getElementById(\'premium_id\').value)"></td>';
	html_premium += '</td>';
	//if(html_premium_import != ""){
		
		//html_premium += '<td>' + html_premium +'<input id="button_buy" type="button" class="button_red_100"  value="'+ js_dic_BUY + '" style="display: none;" onClick="go_to_buy(document.getElementById(\'product_id\').value,document.getElementById(\'premium_id\').value)">';
		//html_premium += "<\td>";
	//}
	html_premium += "</tr></table>";
	
	
	
	if(html_cost != ""){		
		document.getElementById("products_cost").innerHTML = html_cost;
		document.getElementById("products_cost").style.display = display_for_browser();
		//document.getElementById("button_choose").style.display = 'none';
		//document.getElementById("button_calculate").style.display = display_for_browser();		
		document.getElementById("travel_cost").value = js_dic_MSG_INSERT_TRAVEL_COST;				
	} else {
		
		document.getElementById("products_cost").style.display = "none";
	}
	
	if(html_premium_application != ""){
		document.getElementById("products_application").innerHTML = html_premium_application;
		document.getElementById("products_application").style.display = display_for_browser();		
	} else {
		document.getElementById("products_application").style.display = 'none';
	}
	
	
	if(html_premium != "" && html_premium_import == ""){		
		document.getElementById('premium_id').value = premium_id;
		document.getElementById('product_id').value = product_id;
		document.getElementById('products_list').innerHTML = build_box(html_premium,570);
		document.getElementById("products_list").style.display = display_for_browser();
	} else {
		
	}
	
	// document.getElementById('button').style.display = 'inline';
	refresh_box();
	
}


/*
function calculatePremiumForPercPremium(productId,premiumId){
	product_id = productId;
	premium_id = premiumId;

	
	valueTravelCost = 0;
	valueTravelCost = document.getElementById('travel_cost_'+productId).value;
	if(valueTravelCost == null){
		print_error(js_dic_ERRORCOMPULSORYFIELD);
	} else if (valueTravelCost <= 0){
		print_error(js_dic_ERRORCOMPULSORYFIELD);
	} else {
		struct_param['query'] = new Array();
		struct_param['header']['product'] = 'availability';
		struct_param['header']['type'] = 'set_premium_for_perc';
		struct_param['query']['product_id'] = productId;
		struct_param['query']['premium_id'] = premiumId;
		struct_param['query']['travel_cost'] = valueTravelCost;
		
		xml_request(struct_param, url_xml_rpc, iso_encoding, callbacks_xml_request);
		
	}

}
*/
// Torna indietro dalla lista dei prodotti trovati al form di ricerca disponibilità
function new_search(response, where) {
	document.getElementById('search').style.display = 'block';
	document.getElementById('products_list').style.display = 'none';
	document.getElementById('products_description').style.display = 'none';
	document.getElementById('products_cost').style.display = 'none';
}

// Evidenzia la riga selezionata
function product_highlight(row) {
	document.getElementById('name_col_'+row).className = 'highlight cell_dark';
	document.getElementById('typology_col_'+row).className = 'highlight cell_white';
	document.getElementById('premium_col_'+row).className = 'highlight cell_dark align_right';
	document.getElementById('buy_col_'+row).className = 'highlight cell_options';
}

// Toglie l'evidenziazione alla liena deselezionata
function product_no_highlight(row) {
	document.getElementById('name_col_'+row).className = 'cell_dark';
	document.getElementById('typology_col_'+row).className = 'cell_white';
	document.getElementById('premium_col_'+row).className = 'cell_dark align_right';
	document.getElementById('buy_col_'+row).className = 'cell_options';
}

// Nasconde tutti i div coi dettagli aperti. Trova la posizione della riga cliccata e ne mostra i dettagli
function product_details(row) {
	var rows = document.getElementsByTagName('div');
	for (i = 0; i < rows.length; i++) {
		if(rows[i].getAttribute('id') && rows[i].getAttribute('id').match('details_'))
			rows[i].style.display = 'none';
	}
	
	var pos = findPos(document.getElementById('name_col_'+row));
	document.getElementById('details_'+row).style.top = pos[1]+40;
	document.getElementById('details_'+row).style.left = pos[0]+11;
	document.getElementById('details_'+row).style.display = 'block';
}

// Nasconde il box con i dettagli del prodotto
function hide_product_details(row) {
	document.getElementById('details_'+row).style.display = 'none';
}

// Funzione per la gestione dei valori ritornati dalla Filter
function callback_html_response(response, where) {
	if(document.getElementById('loading')){
		document.getElementById('loading').style.display = 'none';		
	}
	if(document.getElementById('products_list_home')){
		//document.getElementById('products_list_home').style.display = 'none';
		document.getElementById('products_list_home').innerHTML = "";
	}	
	where.style.display = 'block';
	where.innerHTML = response;
	refresh_box();
}
 function go_to_buy(product_id,premium_id){
	 window.location=js_global_root_url+'products/cart.php?id='+ product_id +'&idp='+premium_id;
 }
 
 function dislay_message_duration(){
	 print_error(js_dic_WARNING_DURATION_TRAVEL);
 }
 
 function display_message_destination(){
	 print_error(js_dic_WARNING_DOCK_MEDITERRANEAN);
 }
 
 function display_message_passengers(){
	 print_error(js_dic_WARNING_ITALIANS_PASSENGERS);
 }
 
 function display_default(){

	 if(document.getElementById('products_list')){
		 document.getElementById('products_list').innerHTML = "";
		document.getElementById('products_list').style.display = 'none';		 
	 }
	 if(document.getElementById('products_description')){
		document.getElementById('products_description').innerHTML = "";
		document.getElementById('products_description').style.display = 'none';				 
	 }

	if(document.getElementById("rigth_panel_products")){
		 document.getElementById("rigth_panel_products").style.display =  'none';
	}
	
	if(document.getElementById("travel_cost")){
		document.getElementById("products_cost").innerHTML = "";
		document.getElementById("products_cost").style.display =  'none';		 
	}
	if(document.getElementById("select_application")){
		document.getElementById("products_application").innerHTML = "";
		document.getElementById("products_application").style.display =  'none';		 
	}

	
	document.getElementById('rigth_panel_image').style.display = 'inline';
	
	document.getElementById('destination').value = "***";
	document.getElementById('nationality').value = "***";
	 applicationProduct = new Array();
	
	 // window.location=js_global_root_url+'index.php';	
 }
 function redirectSearch(idTypologie,idProduct){
	 window.location=js_global_root_url+'index.php?typologie_id='+idTypologie+'&product_id='+idProduct;
 } 
 
/*
function callbacks_xml_request(response, type) {
	var arrayPremium = null;
	switch(type){
  		case 'set_premium_for_perc':
  			for(var i in response) {  				
  				if(response[i]['id'] == product_id){
  					arrayPremium = response[i]['premium']; 
  					var_dump(arrayPremium);
  					for(var k in arrayPremium){
  						if(arrayPremium[k]['id'] == premium_id){
  							
  						} 
  					}
  				}  				
  				break;
  			}
	}
}
*/
