/* Javascript Document */
$(document).ready(function(){
	// attivazione favicon
	$('#favicon').jFav();

	$(".fancybox").fancybox({
		imageScale: true
		//frameWidth: 800,
		//frameHeight: 600
	});
	
	$(".lightbox").lightbox({
		fitToScreen: true
	});
	
	// per le schede prodotto
	$(".schedeprodotto_fb").fancybox({
		imageScale: true,
		frameWidth: 640,
		frameHeight: 480
	});
	// per la preview delle ecard
	$(".ecard_preview").fancybox({
		imageScale: true,
		frameWidth: 600,
		frameHeight: 500
	});
	// per stampa elenchi da catalogo online
	$(".stampa_elenco").fancybox({
		imageScale: true,
		frameWidth: 600,
		frameHeight: 500
	});
	// per numeri2008
	$(".s_numeri").fancybox({
		imageScale: true,
		frameWidth: 600,
		frameHeight: 600
	});
	// per dettaglio ricerca_pcomm
	$(".ricerca_pcomm").fancybox({
		imageScale: true,
		frameWidth: 640,
		frameHeight: 480
	});
	$(".turismo").fancybox({
				imageScale: false,
				frameWidth: 320,
				frameHeight: 270
			});


	// baco IE6 (Internet explorer 6 sui bottoni delle form)
	// se c'è il bottone di reset e siamo in ie6 lo cancella
    mainVersion = jQuery.browser.version.substr(0,1);
	ie6 = jQuery.browser.msie && (mainVersion == 6);
	//alert('ie6 '+ie6+' '+mainVersion);
	if (ie6) {
	    //alert('cancello');
	    $('#reset_FormFORM').remove();
	}

});



/* per semplificare le popup */
function xxx_imgPopup(url,w,h) {
    w = w+15;
    h = h+15;
	var win = window.open (url, "IMAGES", "width="+w+",height="+h+",scrollbars=no");
	win.focus();
	return false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function xxx_my_openBrWindow(theURL,winName,features) { //v2.0
  var win = window.open(theURL,winName,features);
  win.focus();
}


// Apre la scheda novità
function xxx_schedaNovitaEsp(codice, sortid, curLang, w, h, prova) {
	var href = '/'+curLang+'/pop_scheda.php?CODICE='+codice+'&SORTID='+sortid;
	if (prova) { href += '&P=1';}
	var minH = 400;
	var minW = 400;
	h += 170;
	w += 50;
	if (h < minH) {h=minH;}
	if (w < minW) {w=minW;}
	var features = 'width='+w+',height='+h+',scrollbars=0,status=0';
	//alert(features);
	//alert(href);
	my_openBrWindow(href,'_blank',features);
	return(false);		// non fa l'href
} // schedaNovitaEsp

// Apre la popup con la mappa
function xxx_mappaEsp(cod_sta, curLang) {
	var href = '/php/e_pop_mappa.php?COD_STA='+cod_sta+'&langCode='+curLang;
	var minH = 450;
	var minW = 650;
	h = 170;
	w = 50;
	if (h < minH) {h=minH;}
	if (w < minW) {w=minW;}
	var features = 'width='+w+',height='+h+',scrollbars=1,status=0';
	//alert(features);
	//alert(href);
	my_openBrWindow(href,'_blank',features);
	return(false);		// non fa l'href
} // mappaEsp

// apre le popup di info e privacy
function xxx_footer(href) {
	var h = 600;
	var w = 650;
	var features = 'width='+w+',height='+h+',scrollbars=yes,status=0';
	//alert(features);
	//alert(href);
	my_openBrWindow(href,'_blank',features);
	return(false);		// non fa l'href
} // footer

// Apre la popup del dettaglio della ricerca sul modulo_a
function xxx_dettModuloAEsp(codice, curLang) {
	var href = '/'+curLang+'/v_ricerca_modulo_a_dett.php?CODICE_EXPO='+codice;
	var h = 400;
	var w = 650;
	var features = 'width='+w+',height='+h+',scrollbars=yes,status=0';
	//alert(features);
	//alert(href);
	my_openBrWindow(href,'_blank',features);
	return(false);		// non fa l'href
} // dettModuloAEsp

// Apre la popup del dettaglio della ricerca sul modulo_a
function xxx_dettPCommEsp(codice, curLang) {
	var href = '/'+curLang+'/r_ricerca_pcomm_dett.php?CODICE='+codice;
	var h = 400;
	var w = 650;
	var features = 'width='+w+',height='+h+',scrollbars=yes,status=0';
	//alert(features);
	//alert(href);
	my_openBrWindow(href,'_blank',features);
	return(false);		// non fa l'href
} // dettPCommEsp

function checkPrivacy(f,m){
	if(f.elements['Privacy'].checked){
	    return true;
	}
	alert(m);
	return false;
}//checkPrivacy


function privacyTest() {
  f = document.getElementById('PersonalCard');
  if (f.elements["privacy[]"].checked) {
	   return true;
	   alert("Please, check for privacy");
	   return false;
  }
   alert("Please, check for privacy");
   return false;
}
/* prova modifica heigh col javascripa
function testa() {
	p = document.getElementById('page').clientHeight;
	c = document.getElementById("center_tab").clientHeight;
	alert('page height: '+p+' center_tab height: '+c);
	document.getElementById("center_tab").clientHeight = p-2;
}
*/

// indice del processo di setTimeOut, utile per cancellarlo dalla coda
var setTo = new Array();

//LoP: funzione per lo show/hide layer del menu a tendina (migliorabile, forse..)
function xxx_toggle(ul,on){
	
    ulElement = document.getElementById(ul);
    if (ulElement){
        ulElement.style.display = (on)?'block':'none';
    }
}//toggle

//Aggiungo un delay all'esecuzione del toggle() per evitare il flicker di IE6
// ul: id del menu da nascondere/visualizzare
// sty: stile da applicare (on o off)
// on: flag true o false
function xxx_menuShow(ul,on){
	if(on) {
	    window.clearTimeout(setTo[ul]);
	    toggle(ul,on);
	} else {
	    setTo[ul] = window.setTimeout("toggle('" + ul + "'," + on + ");",100);
	}
}//menuShow

	$(document).ready(function() {
		$(".fb").fancybox({
				 imageScale: false,
				frameWidth: 640,
				frameHeight: 300
		});
	});

	
	//funzione che fa il click quando passo l'id dal flash
	function oFB(id){
	    $('#'+id).click();
	}

