jQuery(function(){
	
		
	//call all cufons
	setCufon();
	
	//init jqTransform
	$('.frm2').jqTransform({});
	$('.select2').jqTransform({});
	
	//Navigation DOM
	$("#nav_cnr .t1").find("a").wrapInner('<span class="txt"></span>')
					.append('<span class="nlft"></span><span class="nrgt"></span><span class="narw"></span>');
	if($.browser.msie && $.browser.version == "6.0"){
		$("#nav_cnr .t1 .active").width($("#nav_cnr .t1 .active").width());
	}
	
	$("#nav_cnr .t1 a:not(.active)").hover(
		function(){
			$(this).addClass("active");
		},function(){
			$(this).removeClass("active");
    });
	
	
	//set alt
	$(".nk_list a:odd").addClass("alt");
	
	//center elem
	$(".pgnation ul").centerAlign();
	
	//block4 alignment
	$(".block4 .blk_in").each(function(){
		var b4h = $(this).height();
		var eh = $(this).find(".col2").height();
		eh = b4h - eh;
		$(this).find(".col2").css("padding-top", eh)
    });
	
	//hiding hit in slider panels

	$("#slider .panel").append('<div class="nohit"></div>')
						.find(".nohit")
						.each(function(){
							$(this).height($(this).parent().height())			   
						});

	//Dropdown DOM
	$(".dropdown").wrapInner("<div class='drop_wrap'><div class='drop_in'></div></div>");
	$(".t2 li").hover(
		function(){
		  $(this).addClass("hover");
		},
		function(){
			$(this).removeClass("hover");
		}
	);
	
	
	//Dropdown
	jQuery.fn.dropMenu("#dropanchor1", "#dropmenu1");
	jQuery.fn.dropMenu("#dropanchor2", "#dropmenu2");
	jQuery.fn.dropMenu("#dropanchor3", "#dropmenu3");
	
	// Map link DOM
	$("a.map_link").wrapInner('<span class="mid"></span>')
					.prepend('<span class="lft"></span>')
					.append('<span class="rgt"></span><span class="arw"></span>');
	
	// fixes png's in IE6	  
	fixpng();
	
	//RCor sol
	DD_roundies.addRule('.box1 .bx_wrap, .block1 .blk_wrap, .block3 .blk_wrap, .box2 .bx_wrap, .dropdown .drop_wrap, .rc', '5px', true);
	DD_roundies.addRule('.rtcr', '5px 5px 0 0', true);
	DD_roundies.addRule('.rbcr', '0 0 5px 5px', true);
	DD_roundies.addRule('.btn2', '5px', true);

        //  Modal window privacy
        $("#privacy_link").colorbox({width:"90%", height:"90%", inline:true, href:"#privacy_content"});
        $("#privacy_link_2").colorbox({width:"90%", height:"90%", inline:true, href:"#privacy_content"});
	
});


function setCufon(){
	Cufon.set("fontFamily", "Coupe-Medium");
	Cufon.replace("#slog",{"fontSize":"20px"});
	Cufon.replace("#slog2",{"fontSize":"16px"});
	Cufon.replace(".quote p, .quote .auth, .frm2 .field label",{"fontSize":"18px"});
	Cufon.replace("#nav_cnr .t1 a",{"fontSize":"18px", "hover":true});
	Cufon.replace("h1, .block1 .lnk2");
	Cufon.replace("h2");
}

function fixpng(){
	if($.browser.msie && $.browser.version == "6.0"){
		DD_belatedPNG.fix('div');
		DD_belatedPNG.fix('span');
		DD_belatedPNG.fix('img');
		DD_belatedPNG.fix('.zoom');
	}
}

jQuery.fn.centerAlign = function(){
	return $(this).each(function(){
		var $elem = $(this);
		$elem.css("float", "left");
		var wdh = $elem.width();
		$elem.css("float", "none");
		$elem.width(wdh);
    });
	
}


//DD_roundies.addRule('#doc .container', '10px 5px');



function check_form_email_contatto(){
    if(document.getElementById('form_centro').selectedIndex==0){
        alert("Selezionare una SEDE a cui inviare il messaggio");
        return false;
    }
    if(document.getElementById('form_email_contatto').nome.value.length==0){
        alert("Inserire un valore per il campo NOME");
        return false;
    }
    if(document.getElementById('form_email_contatto').email.value.length==0){
        alert("Inserire un valore per il campo EMAIL");
        return false;
    }
    var validRegExpEmail = /^([a-zA-Z0-9\_\.\-])+\@([a-zA-Z0-9\_\.\-]{2,})+\.([a-zA-Z0-9]{2,})+$/;
    if(validRegExpEmail.test(document.getElementById('form_email_contatto').email.value)==false){
        alert("L'indirizzo EMAIL inserito non è valido");
        return false;
    }
    if(document.getElementById('form_email_contatto').messaggio.value.length==0){
        alert("Inserire un valore per il campo MESSAGGIO");
        return false;
    }
    if(document.getElementById('form_email_contatto').privacy.checked==false){
        alert("Devono essere accettate le condizioni riguardo al trattamento dei dati personali");
        return false;
    }
    //  Tutto ok, invio
    document.getElementById('form_email_contatto').submit();
    return true;
}

function check_form_riabilitazione_info(){
    if(document.getElementById('form_centro').selectedIndex==0){
        alert("Selezionare un CENTRO a cui inviare il messaggio");
        return false;
    }
    if(document.getElementById('form_riabilitazione_info').nome.value.length==0){
        alert("Inserire un valore per il campo NOME");
        return false;
    }
    if(document.getElementById('form_riabilitazione_info').email.value.length==0){
        alert("Inserire un valore per il campo EMAIL");
        return false;
    }
    var validRegExpEmail = /^([a-zA-Z0-9\_\.\-])+\@([a-zA-Z0-9\_\.\-]{2,})+\.([a-zA-Z0-9]{2,})+$/;
    if(validRegExpEmail.test(document.getElementById('form_riabilitazione_info').email.value)==false){
        alert("L'indirizzo EMAIL inserito non è valido");
        return false;
    }
    if(document.getElementById('form_riabilitazione_info').messaggio.value.length==0){
        alert("Inserire un valore per il campo MESSAGGIO");
        return false;
    }
    if(document.getElementById('form_riabilitazione_info').privacy.checked==false){
        alert("Devono essere accettate le condizioni riguardo al trattamento dei dati personali");
        return false;
    }
    //  Tutto ok, invio
    document.getElementById('form_riabilitazione_info').submit();
    return true;
}

