/**
 * @author dvian
 */
$(function(){
    $("#menu ul ul").css('display', 'none').addClass('submenu');
    
    $("#menu li").hover(function(){
        $("ul", this).fadeIn(300);
        $(this).addClass('over');
    }, function(){
        $("ul", this).fadeOut(400);
        $(this).removeClass('over');
    });
    
});

$(document).ready(function() {
    $('#slaid').jcarousel({
        vertical: true,
        scroll: 1,
        auto: 5,
        animation: 400,
        wrap: 'last',
        initCallback: azioni,
        itemVisibleInCallback: {
            onBeforeAnimation: doit,
            onAfterAnimation:  recol
        },
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
    if(jQuery.browser.msie && parseFloat(jQuery.browser.version)<=7){
        messaggio='<div id="stopie6">Il programma che state utilizzando per navigare &egrave; obsoleto. Per aumentare la sicurezza durante la navigazione e le funzionalit&agrave; vi consigliamo di aggiornare il vostro browser. <br />Passate gratuitamente a <a href="http://www.microsoft.com/italy/windows/products/winfamily/ie/default.mspx" target="_blank">Internet Explorer 8</a>, o <a href="http://www.mozilla-europe.org/it/firefox/" target="_blank">Firefox</a>, <a href="http://www.apple.com/it/safari/download/" target="_blank">Safari</a>, <a href="http://www.google.com/chrome/" target="_blank">Chrome</a>, <a href="http://www.opera.com/" target="_blank">Opera</a>.';
        $("body").prepend(messaggio);
        $('#stopie6').css({'background-color':'#ffc','color':'#333','font-family':'Arial,sans-serif','padding':'8px','font-size':'13px','border':'solid 1px #333'})
        $('#stopie6 a').css({'color':'#000'});
        }  
    $("a[rel^='attachment']").colorbox({width:"40%", height:"65%", iframe:true, current:"{current} di {total}"});
    $("a[rel^='mappa']").colorbox({width:"610", height:"520", iframe:true, current:"",scrollbars:"false"});
    $("a[rel^='lightbox']").colorbox({current:"{current} di {total}", maxHeight:"98%"});
    $("img, #cboxContent").bind("contextmenu",function(e){
        alert("Copyright 2011 Huechuraba Salud");
        return false;
    });
    $("#okvai").live('click',function() {
                    $(this).colorbox.close(); 
                });
});
function doit(carousel, item, idx, state){
    $('#menusla :not(span[rel='+idx+'])').removeClass('over');
}
function recol(carousel, item, idx, state){
    $('#menusla span[rel='+idx+']').addClass('over');
}
function azioni(carousel){
    $('#menusla span').mouseenter( function(){
        carousel.scroll(jQuery.jcarousel.intval($(this).attr('rel')));
        setTimeout(function(){ carousel.stopAuto(); },800);
        return false;
    });
    $('#menusla span').mouseleave(function(){
        carousel.startAuto();
    });
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

    $('.jcarousel-scroll select').bind('change', function(){
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
};
Cufon.replace('#emotional h2, #emointerno h2, #emoblog h2', {
    textShadow: '#fff 2px 2px'
});
$().bind('cbox_open', function(){
    $('body').css({overflow:'hidden'});
}).bind('cbox_closed', function(){
    $('body').css({overflow:'auto'});
}); 
$(window).load(function() {
    var hcen = $(".colcent").height();
    var hdx =  $(".coldx").height();
    var hsx =  $(".colsx").height();
    var hdef = Math.max(Math.max(hcen,hdx),Math.max(hsx,hdx));
    $(".colsx, .coldx, .colcent").height(hdef);
})
/*
$().bind('cbox_complete', function(){
        var altil = $("#cboxTitle").height();
        if(altil > 46) {
            $.fn.colorbox({width:"600px"});
            //$().colorbox({width:"600px"});
        }
        //alert(altil);
});*/
