jQuery(document).ready(function() {

    var qualityBrowsers = "jQuery.browser.mozilla || jQuery.browser.webkit || jQuery.browser.safari"

    // carica la mappa degli oratori a piena pagina (o quasi...)
    jQuery('a.iframegooglemap').colorbox({
        href:'http://www.oratorifermani.it/wp-content/themes/of/mappa.php',
        transition:"fade",
        speed: '500',
        width:"980px",
        height:"92%",
        iframe:'true',
        scrolling: 'true',
        close: 'chiudi'
    });

    //    // Slider della home page
    //    jQuery('#blocksliderhomepage').cycle({
    //        fx: 'fade',
    //        delay: 6000,
    //        speed: 1600
    //    });

    // fading delle immagini nella home page

    jQuery(function(){
        jQuery('ul#blocksliderhomepage').fuFade({
            speed: 5000,
            timeout: 500,
            containerheight: '210px'
        });
    });

    // Menu di navigazione in alto con slider
    if (qualityBrowsers)  {
        // Riporta allo stato hidden il submenu, per IE, c'è il solo CSS..
        jQuery('#nav li:hover ul').css('display', 'none');
        // Barra di navigazione in alto, con submenu
        jQuery('#nav li').hover(
            function() {
            jQuery('ul', this).slideDown(50);
        },
        function() {
            jQuery('ul', this).slideUp(100);
        });
    }

    // Effetto slide dell'elemento submenu sulla sidebar
    // simile ad un accordion

    // Fase Show al mouse hover
    jQuery("#sidebarone .menu ul li").mouseover(
        function () {
            jQuery('ul', this).show(150);
        });
    // Fase di Hide al mouse leave
    jQuery("#sidebarone .menu ul li").mouseleave(
        function () {
            jQuery('ul', this).hide(150);
        });
   
    // Il modulo contactable a sx fisso
    jQuery(function(){
        jQuery('#contact').contactable({
            });
    });

    // Effetti rounded abilitati solamente su Firefox e Chrome, Ie sucks!
    if (qualityBrowsers)  {
        jQuery('.rounded').corner('3px');
        jQuery('.rounded10').corner('10px');
        jQuery('.roundedbottom').corner('bottom 3px');
        jQuery('.roundedbottom10').corner('bottom 10px');
        jQuery('.roundedtop').corner('top 3px');
        jQuery('.roundedtop10').corner('top 10px');
    }

    // Per aprire i link esterni in pagine _parent
    jQuery('.external a[href^="http://"]')
    .attr({
        target: "_blank"
    });

    // Piccoli aggiustamenti sulle pagine "colorate" dall'editor di wordpress
    // per uniformare il testo ed avere una migliore leggibilità ed integrazione
    // quindi ricordarsi di questo strumento quando si mette mano ai CSS...
    jQuery('#leftcontentpost .posttext span').css({
        color : '#444444',
        fontWeight : 'normal'
    });
    jQuery('#leftcontentpost .posttext h3').css({
        color : '#444444',
        'font-size': '13px',
        fontWeight : 'normal',
        'text-align' : 'left'
    });
    // Decommentare se si vuole che dopo ogni paragrafo scritto negli articoli o
    // nelle pagine statiche, ci siano un margine di spazio sottostante di 10 px
    // 
    //    jQuery('#leftcontentpost .posttext p').css({
    //        'margin-bottom': '10px'
    //    });

    // qtip generico default
    jQuery('.tooltip').qtip({
        content: {
            text: false // Use each elements title attribute
        },
        position: {
            corner: {
                tooltip: 'bottomLeft',
                target: 'topLeft'
            },
            adjust:
            {
                x: 12,
                y: 3
            }
        },
        style: {
            width: 130,
            padding: 3,
            textAlign: 'center',
            border: {
                radius: 3
            },
            tip: { // Now an object instead of a string
                corner: 'bottomMiddle' // We declare our corner within the object using the corner sub-option
            },
            name: 'cream',
            'font-size' : '14px'
        }
    });

    // qtip per email footer
    if (qualityBrowsers)  {
        jQuery('#rightsidefooteraddress a.maillink[href][title]').qtip({
            content: {
                text: false // Use each elements title attribute
            },
            position: {
                corner: {
                    tooltip: 'bottomMiddle',
                    target: 'topMiddle'
                }
            },
            style: {
                width: 150,
                padding: 6,
                background: '#ffffff',
                color: '#444444',
                textAlign: 'center',
                border: {
                    width: 4,
                    radius: 6,
                    color: '#004c99'
                },
                tip: 'bottomMiddle',
                name: 'dark',
                'font-family': 'Arial, Helvetica, Verdana, sans-serif',
                'font-size' : '14px',
                'font-weight' : 'bold'
            },
            show: {
                effect: {
                    type: 'fade'
                }
            }
        });
    }

    // Aggiunge automaticamente iconcine tipo busta ai mail links..
    jQuery("#leftcontentpost a[href^='mailto:']").addClass("email");
    // Aggiunge automaticamente iconcine pdf ai links
    jQuery("#leftcontentpost a[href$='.pdf']").addClass("pdf");
    jQuery("#leftcontentpost a[href$='.PDF']").addClass("pdf");
    // Aggiunge automaticamente iconcine M$ Shit Word ai links
    jQuery("#leftcontentpost a[href$='.doc']").addClass("word");
    // Aggiunge automaticamente l'icona' M$ Word ai files rtf
    jQuery("#leftcontentpost a[href$='.rtf']").addClass("word");
    // Anche per la nuova monnezzola M$ Shit Word con la x finale.. i links
    jQuery("#leftcontentpost a[href$='.docx']").addClass("word");
    //  Aggiunge automaticamente iconcine MS Excel ai links
    jQuery("#leftcontentpost a[href$='.xls']").addClass("excel");
    // Openoffice :) Links
    jQuery("#leftcontentpost a[href$='.odt']").addClass("openoffice");
    // E i files zippati no???
    jQuery("#leftcontentpost a[href$='.zip']").addClass("zip");
    // mp3 files???
    jQuery("#leftcontentpost a[href$='.mp3']").addClass("mp3");
});


