var agente = navigator.userAgent;
//console.log("el navegador actual es: "+ agente);

$(function(){

    $("ul.dropdown li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

});


$(function(){ 
    // carousel promos brands
    $("li.li-logo").click( function(){
        var id = $(this).attr("id").split("_")[1];
        $.cookie('carousel_position', id, {path: "/"});
    });
    
    if ($("#banners-brands div.brands-rotator").length > 0) {
        var startPosition = $.cookie('carousel_position') > 0 ?  $.cookie('carousel_position') : 1;  
        $("#banners-brands div.brands-rotator").jcarousel({ vertical: true, scroll: 3, start: startPosition, animation: "fast"});
        $.cookie('carousel_position', null, {path: "/"});
    }    
    
    // carusel sidebar
    if ($("#banners div.logo-rotator").length > 0) $("#banners div.logo-rotator").carousel({ autoSlide: true, loop: true });
        
    // target _blank
    $(".external").attr("target","_blank");
    
    // Equal heights
    equalHeight($(".columns"));
    
   //Opacidad para informacion promos
    $('.opacity').fadeTo('0','0.95'); 
    
    // help mobile
    $('#promomobile-help').hide();
    
    $('#mobile-how, #mobile-help-back').click( function () {
        if ($('#promomobile-help').css('display') == 'none') {
            $('#promomobile-help').show();
            $('#promomobile-promos').hide();
            $('#mobile-how').hide();
        } else {
            $('#promomobile-help').hide();
            $('#promomobile-promos').show();            
            $('#mobile-how').show();
        }
    });
    
    // send coupon mobile
    $('#promomobile-opensend').click( function () {
        $("#showme-mobile").slideToggle('slow');
        $("#showme").hide();
    });
    
    // capa más información
    $(".show-details-btn").click(function() {
        $("#showme").slideToggle('slow'); 
        $("#showme-mobile").hide();
    });

    // capa más información mobile
    $(".show-details-mobile-btn").click(function() {
        $("#showme-mobile").slideToggle('slow'); 
    });
                                                                                              
    // login campos
    var input_user =  $("#usuario").val();
    var input_pass =  $("#psw").val();    
    $("#usuario").focus(function() {if ($(this).val() == input_user) { $(this).val(''); }});
    $("#usuario").blur(function() {if (! $(this).val().length) { $(this).val(input_user); }});     
    $("#psw").focus(function() { if ( $(this).val() == input_pass) { $(this).val(''); }});
    $("#psw").blur(function() {if (! $(this).val().length) { $(this).val(input_pass); }});  
    
    // submenu otros paises
    var url;
    var inited = false;
    $("li#otros-paises").hover( function(){
        if (!inited) {
            url = $(this).children("div").html();
        }
        inited = true;
        $(this).children("div").remove();
        $(this).find("a").after("<div class='country_options'>" + url + "</div>");
        $(this).children("div").show();
    },function(){
        $(this).children("div").hide();
    });                                                                                                                             
    
    // Cufon
    Cufon.replace('h2.title', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' });
    Cufon.replace('#pags h3', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' });
    //Cufon.replace('#pags div', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' });
    Cufon.replace('.ico-f1', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' });
	Cufon.replace('.subtitle', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' });
    Cufon.replace('.box-contact dd', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' });
    Cufon.replace('.box-title-pags ul li a', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' }); 
    Cufon.replace('.precio_outlet p', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' }); 
    Cufon.replace('.descuento p', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' }); 
    Cufon.replace('.generica p', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' }); 
    Cufon.replace('.prize-box', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' }); 
	Cufon.replace('.flotante h4', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' }); 
	Cufon.replace('.select-centre', { hover: true, hoverables: {a:true, li:true, strong:true }, fontFamily: 'chalet' }); 
	
    $(".detailInfo").click(function(event){
        event.preventDefault();
        //var id = $(this).attr("id").split("_")[1];
        $("#detail").load($(this).attr("href"));
    });
    
});
//mostrar/ocultar informaciÃ³n de promos
function toggleSlow(divId) {
       $(divId).slideToggle('slow');
};





