function angoli() {
	Nifty("div#gruppi","big");
	Nifty("div#sub_nav","bottom normal");
	Nifty("ul#sub_ban","normal");
	Nifty("div.download","normal tr tl br");
	Nifty("form#lettere","normal tr tl br");
	Nifty("div.sconto","normal tr tl br");
	Nifty("div.sponsor","normal tr tl br");
	Nifty("form#ricerca_evento","normal tr tl br");
}



function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function popup(url,attr) {
	newwindow=window.open(url,'name',attr);
	if (window.focus) {newwindow.focus()}
		return false;
}

function CheckPwd()
	{
		var errmsg="";
		var c4=document.pw_persa.recuperapwd.value;
		

		if (Trim(c4) == '')
		{
			errmsg = errmsg + "Attenzione, inserire una Email\n";
		}else{
		//controllo EMAIL
if ((c4.length<6) || (c4.indexOf(",")>=0) || (c4.indexOf(";")>=0) || (c4.indexOf(":")>=0) || (c4.indexOf("/")>=0) || (c4.indexOf(" ")>=0) || (c4.indexOf("@")<=0) || (c4.indexOf("@") != c4.lastIndexOf("@")) || (c4.lastIndexOf(".")<c4.indexOf("@")) || ((c4.lastIndexOf(".")+3)>c4.length)) errmsg = errmsg + "\nAttenzione, formato Email non corretto";
		}
	
		if (errmsg != '')
		{
			alert(errmsg);
		} else {
			document.pw_persa.submit();
		}		
}


function CheckLogin()
	{
		var errmsg="";
		var c1=document.login.au_user.value;
		var c2=document.login.au_pwd.value;

		if ( (Trim(c1) == '')||(Trim(c2) == '') )
		{
			errmsg = errmsg + "Inserisci i seguenti campi:\n";
			if (Trim(c1) == '')	errmsg = errmsg + "\nUsername"
			if (Trim(c2) == '')	errmsg = errmsg + "\nPassword"
		}
		
		
	
		if (errmsg != ''){
			alert(errmsg);
		} else {
			document.login.submit();
		}		
}

function LTrim(str)
{
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...
            var j=0, i = s.length;
            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }
        return s;
}
// Trims all spaces to the right of a specific string
function RTrim(str)
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in whitespace
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...
            var i = s.length - 1;       // Get length of string
            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }
        return s;
}
                                                                                                                        
// Trims all spaces to the left and right of a specific string by calling RTim
// and LTrim
function Trim(str)
{
        return RTrim(LTrim(str));
}
/*link che aprono in una nuova finestra
function externalLinks() {
	$("a[href]").each(function(){
		if ($(this).hasClass("ppt") || $(this).hasClass("pdf") || $(this).hasClass("allegato") || $(this).hasClass("doc") || $(this).hasClass("jpg") || $(this).hasClass("xls") || $(this).hasClass("external") || $(this).hasClass("zip")){
		  $(this).attr("target","_blank");}
	});
}*/

/*link che aprono in una nuova finestra*/
function externalLinks() {
	$("a[href]").each(function(){
		$("a.ppt,a.pdf,a.allegato,a.doc,a.jpg,a.xls,a.external,a.zip2").attr("target","_blank");
	});
}

$(document).ready(function() {
	/*$("#ysearchinput_n").keydown(function(e){
		if(e.keyCode==13)
			taglia('n');
	});
	
	$("#ysearchinput_r").keydown(function(e){
		if(e.keyCode==13)
			taglia('r');
	});
	
	$("#ysearchinput_s").keydown(function(e){
		if(e.keyCode==13)
			taglia('s');
	});*/
	/*$("a[href]").each(function(){
		if ($(this).hasClass("ppt") || $(this).hasClass("pdf") || $(this).hasClass("allegato") || $(this).hasClass("doc") || $(this).hasClass("jpg") || $(this).hasClass("xls") || $(this).hasClass("external") || $(this).hasClass("zip"))
		   $(this).attr("target","_blank");
	});*/
	
	
	//colore alternato del menu di terzo livello e del menu gruppi in homepage
	$("#sub_ban li:odd a").addClass("odd");
	$("#gruppi li:odd").addClass("pari");
	
	//informativa in coda ai form
	$(".info a").click(function(){
		$("#normativa").slideToggle('slow');
		return false;
	});
	
	$("dl").each(function(){
		var t = $(this).children("dd").text();
		if (t != ''){
			$(this).after('<a class="open" href="javascript(void);">leggi tutto</a>');
			$("dd").hide();}
	});
	$("a.open").toggle(function(){
									$(this).prev().children("dd").slideDown();
									$(this).text('chiudi');
									},
						   function(){
									$(this).prev().children("dd").slideUp();
									$(this).text('leggi tutto');
							});	
			
		
});

//funzioni per raccolta valore dall'autocomplete
var val;
var loc;
var pro;
var reg;
var cap;
var canc;

function set(t){
	val = $("#ysearchinput_" + t).val();
	loc = "#localita_" + t + "_ita";
	pro = "#provincia_" + t + "_ita";
	reg = "#regione_" + t + "_ita";
	cap = "#cap_" + t + "_ita";
}

function taglia(t){
	set(t);
	if((val != "")&&(val.indexOf("-")!=-1)){
		var valoreSel = new Array();
		valoreSel = val.split('-');
		valoreSel2 = valoreSel[0].split(',');
		$(loc).attr("value",Trim(valoreSel2[0])).attr("readonly","true"); //localita
		$(pro).attr("value",Trim(valoreSel2[1])).attr("disabled","true"); //provincia
		p = (Trim(valoreSel2[1]) + "-" + Trim(valoreSel[2]).toLowerCase());
		$(pro).selectOptions(p);
		$(reg).attr("value",Trim(valoreSel[2])).attr("readonly","true");
		$("#provincia_h").attr("value",Trim(valoreSel2[1]));
		$("#regione_h").attr("value",Trim(valoreSel2[1]));
		if (t == "n") $("#gruppo").focus();
		if (t == "r") $("#tel").focus();
		if (t == "s") $("#societa").focus();
		v = Trim(valoreSel[1]);
		if(v.indexOf('*')!=-1){
			$(cap).attr("value",v).removeAttr("readonly").addClass("cap_mod");
			$(cap).focus();
		}else{
			$(cap).attr("value",v).attr("readonly","true").removeClass("cap_mod");
		}
	} else {
		$(pro).selectOptions("").removeAttr("disabled");
		$(loc).attr("value",$("#ysearchinput").val());
		$(cap).removeClass("cap_mod").removeAttr("readonly").attr("value","");
	}
	$("#ysearchinput_" + t).attr("value",$(loc).val());
}
function nuova(t){
	set(t);
	$(reg).removeAttr("readonly").attr("value","");
	$(loc).attr("value",$("#ysearchinput_" + t).val()).removeAttr("readonly").attr("value","");
	$(loc).attr("value",val);
	$(pro).removeAttr("disabled").attr("value","");
	$(cap).removeClass("cap_mod").removeAttr("readonly").attr("value","");
	$(loc).focus();
	$(canc).attr("value","#");
}
function nazione(naz,t){
	set(t);
	$(loc).attr("readonly","true");
	$(pro).attr("disabled","true");
	$(cap).attr("readonly","true");
	$(reg).attr("readonly","true");
	if(naz=="ita"){
		$("#paese_" + t).fadeIn("slow");	
		$("#bottoni_" + t).fadeIn("slow");
		$("#estero_" + t).hide();				
		$("#italia_" + t).fadeIn("slow");
	} else {
		$("#paese_" + t).hide();
		$("#bottoni_" + t).hide();
		$("#italia_" + t).hide();
		$("#estero_" + t).fadeIn("slow");	
		$("#localita_" + t).removeAttr("readonly");
		$("#provincia_" + t).removeAttr("disabled");
	}
	$("#indirizzo_" + t).focus();
}


