// JavaScript Document
function verificaContatti()	{

var n = document.contattiForm.nome.value
var co = document.contattiForm.cognome.value
var e = document.contattiForm.email.value
var rs = document.contattiForm.ragioneSociale.value
var ruolo = document.contattiForm.ruolo.value
var mess = document.contattiForm.msg.value

if ((n=="")){
	alert("Attenzione: devi inserire il tuo nome!");
	return false
	}
if ((co=="")){
	alert("Attenzione: devi inserire il tuo cognome!");
	return false
	}
if ((rs=="")){
	alert("Attenzione: devi inserire la ragione sociale!");
	return false
	}
	
if ((e=="")){
	alert("Attenzione: devi inserire la tua email!");
	return false
	}
	
if ((e!="")&&(e.indexOf("@") == -1)) {
	alert("E-mail non valida!");
	return false;
	}
	
if ((ruolo=="")){
	alert("Attenzione: devi inserire il tuo ruolo aziendale!");
	return false
	}
	
if ((mess=="")){
	alert("Attenzione: devi inserire il messaggio!");
	return false
	}

SubCarSpeciali(document.contattiForm.nome)
SubCarSpeciali(document.contattiForm.cognome)
SubCarSpeciali(document.contattiForm.email)
SubCarSpeciali(document.contattiForm.ragioneSociale)
SubCarSpeciali(document.contattiForm.ruolo)
SubCarSpeciali(document.contattiForm.msg)
	
return true;	
}

function verificaLoginHome()	{

var usr = document.loginHome.user.value
var pwd = document.loginHome.password.value



if ((usr=="")){
	alert("Attenzione: devi inserire il nome utente!");
	return false
	}
if ((pwd=="")){
	alert("Attenzione: devi inserire la password!");
	return false
	}
	
SubCarSpeciali(document.loginHome.user)
SubCarSpeciali(document.loginHome.password)

return true;	
} 

function verificaRecPwd()	{

var e = document.rec_pwdForm.usern.value;
	
if ((e=="")){
	alert("Attenzione: devi inserire il tuo username!");
	return false
	}	
	
SubCarSpeciali(document.rec_pwdForm.usern);
	
return true;	
}

function SubCarSpeciali(elemento){
	var outstr="";
	for (x=0;x<elemento.value.length;x++){

		//alert("carattere: " + x + " - " + elemento.value.charAt(x));
		
		var caratt = elemento.value.charAt(x);
		
		if (caratt == "\u00E0")  {  // à 
			outstr += "&agrave;"; 
		} else if (caratt == "\u00E1")  {  // á
			outstr += "&aacute;"; 
		} else if (caratt == "\u00C0")  {  // À
			outstr += "&Agrave;"; 
		} else if (caratt == "\u00C1")  {  // Á
			outstr += "&Aacute;"; 
		} else if (caratt == "\u00E8")  {  // è
			outstr += "&egrave;"; 
		} else if (caratt == "\u00E9")  {  // é
			outstr += "&eacute;"; 
		} else if (caratt == "\u00C8")  {  // È
			outstr += "&Egrave;"; 
		} else if (caratt == "\u00C9")  {  // É
			outstr += "&Eacute;"; 
		} else if (caratt == "\u00EC")  {  // ì
			outstr += "&igrave;"; 
		} else if (caratt == "\u00ED")  {  // í
			outstr += "&iacute;"; 
		} else if (caratt == "\u00CC")  {  // Ì
			outstr += "&Igrave;"; 
		} else if (caratt == "\u00CD")  {  // Í
			outstr += "&Iacute;"; 
		} else if (caratt == "\u00F2")  {  // ò
			outstr += "&ograve;"; 
		} else if (caratt == "\u00F3")  {  // ó
			outstr += "&oacute;"; 
		} else if (caratt == "\u00D2")  {  // Ò
			outstr += "&Ograve;"; 
		} else if (caratt == "\u00D3")  {  // Ó
			outstr += "&Oacute;"; 
		} else if (caratt == "\u00F9")  {  // ù
			outstr += "&ugrave;"; 
		} else if (caratt == "\u00FA")  {  // ú
			outstr += "&uacute;"; 
		} else if (caratt == "\u00D9")  {  // Ò
			outstr += "&Ugrave;"; 
		} else if (caratt == "\u00DA")  {  // Ó
			outstr += "&Uacute;"; 
		} else if (caratt == "\u00A9")  {  // ©
			outstr += "&copy;"; 
		} else if (caratt == "\u00B0")  {  // °
			outstr += "&deg;"; 
		} else if (caratt == "\u00A2")  {  // ¢
			outstr += "&cent;"; 
		} else if (caratt == "\u20AC")  {  // €
			outstr += "&euro;"; 
		} else if (caratt == "'")  {  // '
			outstr += "&#39;"; 
		} else if (caratt == "\"")  {  // "
			outstr += "&#34;"; 
		} else outstr +=caratt;
	}
	elemento.value = outstr;
}

function verificaNewsletter()	{

var e = document.newsletterForm.email.value

SubCarSpeciali(document.newsletterForm.nome)
SubCarSpeciali(document.newsletterForm.cognome)
SubCarSpeciali(document.newsletterForm.email)
SubCarSpeciali(document.newsletterForm.ind)
	
if ((e=="")){
	alert("Attenzione: devi inserire la tua email!");
	return false
	}
	
if ((e!="")&&(e.indexOf("@") == -1)) {
	alert("E-mail non valida!");
	return false;
	}
	
return true;	
}

function screen_res() {
	alert("H. "+screen.width+" W. "+screen.height);
}

function setMaxHeight() {
		
		var maxPageHeight=0;
		//alert("colonna SX: " +$('#colonna_SX').height() + " centro: " +$('#centro').height() + " Colonna DX: "+ $('#colonna_DX').height());
		
		if ($('#colonna_SX').height() > maxPageHeight) maxPageHeight=$('#colonna_SX').height();
		if ($('#centro').height() > maxPageHeight) maxPageHeight=$('#centro').height();
		if ($('#colonna_DX').height() > maxPageHeight) maxPageHeight=$('#colonna_DX').height();
		
		$('#contenuti').height(maxPageHeight);
	}

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	
	$.fn.ClickMenuItem = function(cosa, submenu_da_attivare, altezza) {
		
		var chiamante = $(this).selector;
		var num_menu= chiamante.charAt(chiamante.indexOf('SX_') + 3);
		
		$('div[id*="submenu_"]').slideUp("slow");
		
		//console.log($(this)); 
		//alert("caller: " + chiamante + " - " + num_menu + " " + submenu_da_attivare);
		if (chiamante=="#voce_menu_SX_5") {
			$("#menu_DX").load("inc_menu_dx_news.asp");
		} else if (chiamante=="#voce_menu_SX_6") {
			$("#menu_DX").load("inc_menu_dx_att.asp");
		} else {
			$("#menu_DX").load("inc_menu_dx.asp");
		}
		
		if (!submenu_da_attivare) {
			$("#corpo").load(cosa); 
			if (altezza) {
				//$("#destra").css("height", altezza );
				$("#destra").animate({
					height: altezza
				  }, 1000, function() {
					// Animation complete.
				  });
			} else {
				$("#destra").animate({
					height: 450
				  }, 1000, function() {
					// Animation complete.
				  });
			}
			//$("#destra").css("height", $("#corpo_pagine").height() );
			
			$('a[id*="voce_menu_SX_"]').removeClass("voce_menu_SX_hover");
			$('a[id*="voce_submenu_SX_"]').removeClass("voce_submenu_SX_hover");
			$(chiamante).addClass("voce_menu_SX_hover");
		} else {
			if ($("#submenu_"+num_menu+":first").is(":hidden")) {
				$("#submenu_"+num_menu).slideDown("slow", function() {
						 // Animation complete.
						  $("#corpo").load(cosa); 
						  if (altezza) {
								//$("#destra").css("height", altezza );
								$("#destra").animate({
									height: altezza
								  }, 1000, function() {
									// Animation complete.
								  });
							} else {
								$("#destra").animate({
									height: 450
								  }, 1000, function() {
									// Animation complete.
								  });
							}
						  //$("#destra").css("height", $("#corpo_pagine").height() );
						  $('a[id*="voce_menu_SX_"]').removeClass("voce_menu_SX_hover");
						  $('a[id*="voce_submenu_SX_"]').removeClass("voce_submenu_SX_hover");
						  $(chiamante).addClass("voce_menu_SX_hover");
						  $("#voce_submenu_SX_"+num_menu+"_"+submenu_da_attivare).addClass("voce_submenu_SX_hover");
					});
			} 			
		}
	};
	
	$.fn.ClickSubMenuItem = function(cosa, altezza) {
		
		var chiamante = $(this).selector;
		var num_menu= chiamante.charAt(chiamante.indexOf('SX_') + 3);
		var num_submenu= chiamante.charAt(chiamante.indexOf('SX_') + 5);
		
		var deseleziona = 'a[id*="voce_submenu_SX_' + num_menu + '_"]';
		var seleziona = "#voce_submenu_SX_"+ num_menu + "_" + num_submenu;
		
		//console.log($(this)); 
		//alert(deseleziona + " " + seleziona);
		//alert("caller: " + chiamante + " - " + num_menu + " " + num_submenu);
		
		$("#corpo").load(cosa);
		
		if (chiamante=="#voce_submenu_SX_5_1" || chiamante=="#voce_submenu_SX_5_2") {
			$("#menu_DX").load("inc_menu_dx_news.asp");
		} else if (chiamante=="#voce_submenu_SX_6_1" || chiamante=="#voce_submenu_SX_6_2") {
			$("#menu_DX").load("inc_menu_dx_att.asp");
		} else {
			$("#menu_DX").load("inc_menu_dx.asp");
		}
		//$("#corpo").css("height", 800 );
		if (altezza) {
			//$("#destra").css("height", altezza );
			$("#destra").animate({
				height: altezza
			  }, 1000, function() {
				// Animation complete.
			  });
		} else {
			$("#destra").animate({
				height: 450
			  }, 1000, function() {
				// Animation complete.
			  });
		}
		$(deseleziona).removeClass("voce_submenu_SX_hover"); 
		$(seleziona).addClass("voce_submenu_SX_hover"); 
	};
		
	
})(jQuery);
