    //Cufon
    Cufon.replace('h1, h2, h3, h4, h5, h6', { fontFamily: 'TitilliumText22L-Regular', hover: true });
    Cufon.replace('.medCufon', { fontFamily: 'TitilliumText22L-Medium', hover: true });
    Cufon.replace('.boldCufon', { fontFamily: 'TitilliumText22L-Bold', hover: true });
    Cufon.replace('.mainMenu li', { fontFamily: 'TitilliumText22L-Medium', hover: true });
    Cufon.replace('.tab-menu li a', { fontFamily: 'TitilliumText22L-Regular', hover: true });

    //Slide
    $(function () {
        $('#slides').slides({
            preload: true,
            preloadImage: '/res/ftpgaposa/layout/css/preload.gif',
            play: 5000,
            pause: 2500,
            hoverPause: true,
            animationStart: function (current) {
                $('.caption').animate({
                    bottom: -45
                }, 100);
                if (window.console && console.log) {
                    // example return of current slide number
                    console.log('animationStart on slide: ', current);
                };
            },
            animationComplete: function (current) {
                $('.caption').animate({
                    bottom: 0
                }, 200);
                if (window.console && console.log) {
                    // example return of current slide number
                    console.log('animationComplete on slide: ', current);
                };
            },
            slidesLoaded: function () {
                $('.caption').animate({
                    bottom: 0
                }, 200);
            }
        });
    });




/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function ($) { $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function (e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);





    $(document).ready(function () {
    
    
    // MAIN MENU
    //--------------------------------------------------------------

    // Inizio drop Down Menu
    //On Hover Over x il Main Menu
    function megaHoverOver() {
        $(this).find(".showSub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
        //(function($) {
        //Function to calculate total width of all ul's
        //jQuery.fn.calcSubWidth = function() {
        //rowWidth = 0;
        //Calculate row
        //$(this).find("ul.topMenu").each(function() { //for each ul...
        //rowWidth += $(this).width(); //Add each ul's width together
        //});
        //};
        //})(jQuery); 

        //if ( $(this).find(".row").length > 0 ) { //If row exists...

        //var biggestRow = 0;	

        //$(this).find(".row").each(function() {	//for each row...
        //$(this).calcSubWidth(); //Call function to calculate width of all ul's
        //Find biggest row
        //if(rowWidth > biggestRow) {
        //biggestRow = rowWidth;
        //}
        //});

        //$(this).find(".showSub").css({'width' :biggestRow}); //Set width
        //$(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin

        //} else { //If row does not exist...

        //$(this).calcSubWidth();  //Call function to calculate width of all ul's
        //$(this).find(".showSub").css({'width' : rowWidth}); //Set Width

        //}
    }
    //On Hover Out x il Main Menu
    function megaHoverOut() {
        $(this).find(".showSub").stop().fadeTo('fast', 0, function () { //Fade to 0 opactiy
            $(this).hide();  //after fading, hide it
        });
    }
    //Set custom configurations
    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
        interval: 10, // number = milliseconds for onMouseOver polling interval
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
        timeout: 100, // number = milliseconds delay before onMouseOut
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)
    };

    $(".mainMenu ul li .showSub").css({ 'opacity': '0' }); //Fade sub nav to 0 opacity on default
    $(".mainMenu ul li").hoverIntent(config); //Trigger Hover intent with custom configurations

	// Fine drop Down Menu
    
    

        //effetto mouse hover categorie prodotto homepage
        $('.gridBox-unterzo').hover(function () {
            $(".gridBox-caption", this).stop().animate({ top: '-95px' }, { queue: false, duration: 500 });
        }, function () {
            $(".gridBox-caption", this).stop().animate({ top: '0px' }, { queue: false, duration: 500 });
        });
        //effetto mouse hover accessori homepage
        $('.xplus').hover(function () {
            $(".gridBox-caption2", this).fadeIn("slow");
        }, function () {
            $(".gridBox-caption2", this).fadeOut("slow");
        });
      

		
        //visualizzazione tab
        $('.tab-menu').tabify();
        $('.tab-menu-table').tabify();
        $('.tab-story').tabstory();


        /*link overlay CREDITS*/
			$("#modalCredit").fancybox();


        /*link overlay*/
        $(".classLogin").fancybox({  
          'width' : 650,  
          'height' : 500,  
          'autoScale' : false,
          'transitionIn': 'fade',
          'transitionOut': 'fade',
          'speedIn': 600,
          'speedOut': 400,
          'type' : 'iframe',  
          'hideOnOverlayClick' : true //attivo il click di chiusura fuori dal riquadro  
        });  

        /*link overlay*/
        $(".extLink").fancybox({  
          'width' : 700,  
          'height' : 300,  
          'autoScale' : false,
          'transitionIn': 'fade',
          'transitionOut': 'fade',
          'speedIn': 600,
          'speedOut': 400,
          'type' : 'iframe',  
          'hideOnOverlayClick' : true //attivo il click di chiusura fuori dal riquadro  
        });  
      
        /*link overlay LEGENDA*/
        $(".extLegenda").fancybox({  
          'width' : 500,  
          'height' : 450,  
          'autoScale' : false,
          'transitionIn': 'fade',
          'transitionOut': 'fade',
          'speedIn': 600,
          'speedOut': 400,
          'type' : 'iframe',  
          'hideOnOverlayClick' : true //attivo il click di chiusura fuori dal riquadro  
        });  

        /*link overlay VIRTUAL TOUR*/
	    $(".vt-uffici").click(function() {
			$.fancybox([
				{'href':'/res/ftpgaposa/resources/vt01-uffici.jpg', 'title':'Uffici'},
				{'href':'/res/ftpgaposa/resources/vt02-uffici.jpg', 'title':'Uffici'},
				{'href':'/res/ftpgaposa/resources/vt03-uffici.jpg', 'title':'Uffici'}
			], {
				'padding'			: 0,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'changeFade'        : 0,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '<strong>' + (title.length ? ' &nbsp; ' + title : '') + '</strong></span>';
			}
				
			});
		});

        /*link overlay VIRTUAL TOUR*/
	    $(".vt-lab").click(function() {
			$.fancybox([
				{'href':'/res/ftpgaposa/resources/vt04-laboratorio.jpg', 'title':'Laboratori'},
				{'href':'/res/ftpgaposa/resources/vt05-laboratorio.jpg', 'title':'Laboratori'},
				{'href':'/res/ftpgaposa/resources/vt06-laboratorio.jpg', 'title':'Laboratori'}
			], {
				'padding'			: 0,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'changeFade'        : 0,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '<strong>' + (title.length ? ' &nbsp; ' + title : '') + '</strong></span>';
			}
				
			});
		});

        /*link overlay VIRTUAL TOUR*/
	    $(".vt-prod").click(function() {
			$.fancybox([
				{'href':'/res/ftpgaposa/resources/vt07-produzione.jpg', 'title':'Produzione'},
				{'href':'/res/ftpgaposa/resources/vt08-produzione.jpg', 'title':'Produzione'},
				{'href':'/res/ftpgaposa/resources/vt09-produzione.jpg', 'title':'Produzione'}
			], {
				'padding'			: 0,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'changeFade'        : 0,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '<strong>' + (title.length ? ' &nbsp; ' + title : '') + '</strong></span>';
			}
				
			});
		});

        /*link overlay VIRTUAL TOUR*/
	    $(".vt-mag").click(function() {
			$.fancybox([
				{'href':'/res/ftpgaposa/resources/vt10-magazzino.jpg', 'title':'Magazzino'},
				{'href':'/res/ftpgaposa/resources/vt11-magazzino.jpg', 'title':'Magazzino'},
				{'href':'/res/ftpgaposa/resources/vt12-magazzino.jpg', 'title':'Magazzino'}
			], {
				'padding'			: 0,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'changeFade'        : 0,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '<strong>' + (title.length ? ' &nbsp; ' + title : '') + '</strong></span>';
			}
				
			});
		});


    });
  

    //Top image
    $(function () {
        // Opzioni SuperBGImage
        $.fn.superbgimage.options = {
            inlineMode: 1, // 0-resize to browser size, 1-do not resize to browser-size
            z_index: 0, // z-index for the container
            transition: 7, //  0-none,  1-fade, 2-slide down, 3-slide left, 4-slide top, 5-slide  right,  6-blind horizontal, 7-blind vertical, 90-slide right/left,  91-slide  top/down
            transitionout: 0, // 0-no transition for previous image, 1-transition for previous image
            slideshow: 1, // 0-none, 1-autostart slideshow
            slide_interval: 4000, // interval for the slideshow
            randomimage: 0, // 0-none, 1-random image
            speed: 1000 // animation speed
        };
        // initialize SuperBGImage
        $('#thumbs').superbgimage().hide();
    });  




  function ChkMail() {
       
    var oggetto= $('select[name="Oggetto"]').val();
    var nome= $('input[name="Nome"]').val();
    var cognome= $('input[name="Cognome"]').val();
    var professione= $('select[name="Professione"]').val();
    var azienda= $('input[name="Azienda"]').val();
    var citta= $('input[name="Citta"]').val();
    var stato= $('input[name="Stato"]').val();
    var telefono= $('input[name="Telefono"]').val();
    var email= $('input[name="Email"]').val();
    var confemail= $('input[name="ConfEmail"]').val();    
    var richiesta= $('textarea[name="Richiesta"]').val();    
    
    var reg_exp = /^([a-zA-Z0-9_.,àòè éùì])+$/;
    var reg_num = /^([0-9_ -])+$/;
    var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
    var IsToSend = 1;

    $('select[name="Oggetto"]').removeClass('nocompiled');
    $('input[name="Nome"]').removeClass('nocompiled');
    $('input[name="Cognome"]').removeClass('nocompiled');
    $('select[name="Professione"]').removeClass('nocompiled');
    $('input[name="Azienda"]').removeClass('nocompiled');
    $('input[name="Citta"]').removeClass('nocompiled');
    $('input[name="Stato"]').removeClass('nocompiled');
    $('input[name="Email"]').removeClass('nocompiled');     
    $('input[name="ConfEmail"]').removeClass('nocompiled');   
    $('input[name="Richiesta"]').removeClass('nocompiled');   
    $('.privacy').removeClass('nocompiled2');

    //Effettua il controllo sul campi            
    
    if ((oggetto == "")) { IsToSend = 0; $('select[name="Oggetto"]').addClass('nocompiled'); }
    
    if ((nome == "") || (nome == "undefined")) { IsToSend = 0; $('input[name="Nome"]').addClass('nocompiled'); }
    else if (!reg_exp.test(nome)) { IsToSend = 0; $('input[name="Nome"]').addClass('nocompiled'); }
    
    if ((cognome == "") || (cognome == "undefined")) { IsToSend = 0; $('input[name="Cognome"]').addClass('nocompiled'); }
    else if (!reg_exp.test(cognome)) { IsToSend = 0; $('input[name="Cognome"]').addClass('nocompiled'); }

    if ((professione == "")) { IsToSend = 0; $('select[name="Professione"]').addClass('nocompiled'); }
    
    if ((azienda == "") || (azienda == "undefined")) { IsToSend = 0; $('input[name="Azienda"]').addClass('nocompiled'); }
    else if (!reg_exp.test(azienda)) { IsToSend = 0; $('input[name="Azienda"]').addClass('nocompiled'); }

    if ((citta == "") || (citta == "undefined")) { IsToSend = 0; $('input[name="Citta"]').addClass('nocompiled'); }
    else if (!reg_exp.test(citta)) { IsToSend = 0; $('input[name="Citta"]').addClass('nocompiled'); }

    if ((stato == "") || (stato == "undefined")) { IsToSend = 0; $('input[name="Stato"]').addClass('nocompiled'); }
    else if (!reg_exp.test(stato)) { IsToSend = 0; $('input[name="Stato"]').addClass('nocompiled'); }

    if ((email == "") || (email == "undefined")) { IsToSend = 0; $('input[name="Email"]').addClass('nocompiled'); }
    else if (!email_reg_exp.test(email)) { IsToSend = 0; $('input[name="Email"]').addClass('nocompiled'); }    
    
    if ((confemail == "") || (confemail== "undefined")) { IsToSend = 0; $('input[name="ConfEmail"]').addClass('nocompiled'); }
    else if ((confemail != email)) { IsToSend = 0; $('input[name="ConfEmail"]').addClass('nocompiled'); }   

    if ((richiesta == "") || (richiesta == "undefined")) { IsToSend = 0; $('textarea[name="Richiesta"]').addClass('nocompiled'); }
    
    if (document.FormRichiesta.Privacy.checked == false) { IsToSend = 0; $('.privacy').addClass('nocompiled2'); }
    
    if (IsToSend == 1) $('#cmdInviaForm').click();
    else return false;    
}
      

