var isIE = /*@cc_on!@*/false;
//---------------------------------------------
$(document).ready(function () {

    //AUTOBOX
    $('.jsautobox').autobox();

    //PryIMG
    var animTimep = 300;
    if (isIE) animTimep = 0;
    $(".JSimageBox").livequery(function(){
        $(this).pryImageBox({
            typeOut : true,
            animTime:animTimep,
            delayInit4Each:10
        });
    });
    $(".JSimageBoxLogo").livequery(function(){
        $(this).pryImageBox({
            typeOut : false,
            animTime:animTimep,
            horizontalAling: "CENTER",
            delayInit4Each:0
        });
    });
    $(".basic-combo").sexyCombo({
        checkWidth: false
    });



    ////-------------------------------------------------------
    //El primer intBg va sin fondo
    ////-------------------------------------------------------
    $(".intBg").eq(0).addClass('noBg')
    ////-------------------------------------------------------

    
    ///--------------------------------------------------------
    //BLUR FOCUS & SELECTABLE
    ///--------------------------------------------------------
    $('a').click(function () {
        $(this).blur();
        $(this).disableTextSelect();
    });
    $('img').each(function(){
        $(this).blur();
        $(this).disableTextSelect();
    });
    //-----------------------------------------------

    
    ///--------------------------------------------------------
    ///SLIDER1
    ///--------------------------------------------------------
    $('#slider1 li').each(function(){
        $('.carr .carrStatus').html($('.carr .carrStatus').html() + "<a href ='#'></a>")
    })
    var updateCaption = function(slider){
        var cap = ''
        var caplink =   ''
        if (slider.$currentPage != null){
            cap =     slider.$currentPage.find('.caption').html();
            caplink = slider.$currentPage.find('a').attr('href')
        }
        $('.carr .caption .label').html("<a href ='"+caplink+"'>"+cap+"</a>")
        $('.carr .carrStatus a').removeClass('current')
        $('.carr .carrStatus a').eq(slider.currentPage-1).addClass('current')
    };
    $('#slider1').anythingSlider({
        startStopped    : false,  // If autoPlay is on, this can force it to start stopped
        width           : 1000,   // Override the default CSS width
        height          : 337,
        easing          : 'easeOutExpo',
        buildArrows     : false,
        buildNavigation : false,
        delay           : 12000,
        animationTime   : 1200,
        onSlideComplete: function(slider) {
            updateCaption(slider);
            $('.carr .caption > div').fadeIn(25)
        },
        onInitialized: function(e, slider) {
            updateCaption(slider);
        },
        onSlideBegin: function(e, slider) {
            updateCaption(slider);
            $('.carr .caption > div').fadeOut(600)
        }
    });
    $('.carr .carrStatus a').click(function(){
        var num = $('.carr .carrStatus a').index($(this));
        $('#slider1').anythingSlider(num+1);
    })
    ///--------------------------------------------------------


    ///--------------------------------------------------------
    ///SLIDER2
    ///--------------------------------------------------------
    $('#slider2').anythingSlider({
        startStopped    : true,  // If autoPlay is on, this can force it to start stopped
        width           : 940,   // Override the default CSS width
        height          : 463,
        easing          : 'easeOutExpo',
        buildArrows     : false,
        buildNavigation : false,
        animationTime   : 1200
    });
    $('.homeDest .flecha.fl').click(function(){
        $('#slider2').data('AnythingSlider').goBack();
    })
    $('.homeDest .flecha.ri').click(function(){
        $('#slider2').data('AnythingSlider').goForward();
    })
    ///--------------------------------------------------------



    ///--------------------------------------------------------
    ///SLIDERFicha
    ///--------------------------------------------------------
    $('#slider_ficha').anythingSlider({
        startStopped    : true,  // If autoPlay is on, this can force it to start stopped
        width           : 582,   // Override the default CSS width
        height          : 361,
        buildArrows     : false,
        buildNavigation : false,
        animationTime   : 160
    });
    $('#slider_ficha_th').anythingSlider({
        startStopped    : true,  // If autoPlay is on, this can force it to start stopped
        width           : 532,
        buildArrows     : false,
        buildNavigation : false,
        animationTime   : 300
    });
    $('.ficha_foto_box .flecha.fl').click(function(){
        $('#slider_ficha_th').data('AnythingSlider').goBack();
    })
    $('.ficha_foto_box .flecha.ri').click(function(){
        $('#slider_ficha_th').data('AnythingSlider').goForward();
    })
    $('#slider_ficha_th a').click(function(){
        var num = $('#slider_ficha_th .JSimageBox a').index($(this))
        //LE RESRTO EL CLONADO
        num = num - $("#slider_ficha_th li.cloned:eq(0) .listThumbFicha li").size()
        num = num +1
        $('#slider_ficha').anythingSlider(num);
    })
    if ($('#slider_ficha_th .JSimageBox a').size() < 8){
        $('.ficha_foto_box .flecha').hide();
        $('#contentThumbFicha').css('margin-left','6px');
    }

///--------------------------------------------------------
    
});

function putVideo(strYouTube, Width_, Height_, Autoplay_){
    var viseoShareString = strYouTube.replace("http://youtu.be/", "");
    viseoShareString = viseoShareString.replace("http://www.youtube.com/watch?v=", "");
    viseoShareString = viseoShareString.replace("&feature=related", "");
    viseoShareString = viseoShareString.replace("&feature=player_embedded", "");
   
    if (Width_ == -1) Width_ = null;
    var _width = Width_;
    if (_width ==null)_width=600;

    if (Height_ == -1)Height_ = null;
    var _height = Height_;
    if (_height ==null) _height=370;

    if (Autoplay_ == -1) Autoplay_ = null;
    var autoplay = Autoplay_;
    if (autoplay ==null)autoplay=0;

    //alert (autoplay)
    var jsMovoOpt 	= '&autoplay='+autoplay+'&rel=0&showinfo=0';
    var jsMovie 	= viseoShareString + '?version=3&amp;hl=es' + jsMovoOpt;
    var jsVideoIns = '<object data="http://www.youtube.com/v/'+jsMovie+'" type="application/x-shockwave-flash" height="'+_height+'" width="'+_width+'">';
    jsVideoIns +=		'<param name="movie" value="http://www.youtube.com/v/'+jsMovie+'"></param>';
    jsVideoIns +=		'<param name="quality" value="high"/>';
    jsVideoIns +=		'<param name="menu" value="false"/>';
    jsVideoIns +=		'<param name="wmode" value="transparent"/>';
    jsVideoIns +=		'<param name="allowFullScreen" value="true">';
    jsVideoIns +=		'<embed src="http://www.youtube.com/v/'+jsMovie+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+_width+'" height="'+_height+'"></embed>';
    jsVideoIns +=	'</object>';
    document.write(jsVideoIns)
}

