

var total_slides_it = 0;
var current_slide_it = 1;
var is_hover = false;
var t;


jQuery(document).ready(function() {

  //  jQuery(".main_title").dropShadow({left: 2, top: 2, opacity: 1, blur: 2});
    if(jQuery(".image_box").children(".sub_page_popup").length == 1){
        jQuery(".image_box .sub_page_popup:first-child").addClass("single");
    }
    if(jQuery(".image_box").children(".sub_page_popup").length == 2){
        jQuery(".image_box .sub_page_popup:first-child").addClass("double");
    }
    jQuery(".header_right .menu_main").children("li").each(
      function(index,item){
       jQuery(item).hover(
        function(){
         jQuery("ul:first",this).stop(true, true).animate({
                    opacity: 1,
                    height: 'show'
                  }, 100, function() {
                  });
         jQuery(this).siblings().each(
          function(index,item){
           if(jQuery("ul:first",jQuery(item)).is(":visible")){
            jQuery("ul:first",jQuery(item)).fadeOut(100);
           }
          }
         );
        },
        function(){
         jQuery("ul:first",this).fadeOut(100);
        }
       );
      }
     );

    jQuery('.vid_nerea_landa').colorbox({iframe:true, width: '550', height: "450", scrolling: false});
    jQuery('.vid_raquel_lambea').colorbox({iframe:true, width: '550', height: "450", scrolling: false});

    jQuery('.sub_page_popup').addClass("singles");
    jQuery('.slider_it .sub_page_popup').removeClass("singles");
    jQuery('.sub_page_popup.singles:last-child').parent().append("<div style='clear:both;'></div><label class=\"single_non_slider\">Haga click en las fotos para agrandar la imagen</label>");
    jQuery('.sub_page_popup.singles:last-child').parent().attr("style", "margin-bottom: -49px;");
    jQuery(".slider_it").append("<label style=\"font-style: italic; font-size: 12px; float: left; width: 399px; line-height: 12px; text-align: center; margin-top: 7px;\">Haga click en las fotos para agrandar la imagen</label>");
    total_slides_it = Math.ceil( jQuery(".slider_it .slider_wrapper .slider_span > a").size() / 3 );
    jQuery(".slider_it .slider_it_btn_prev").click(function(){
        if(current_slide_it > 1){
            current_slide_it--;
            jQuery(".slider_it .slider_wrapper .slider_span").animate({
                'margin-left': '+=330'
              }, 1000, function() {
                // Animation complete.
              });
        }
    });
    jQuery(".slider_it .slider_it_btn_next").click(function(){
        if(current_slide_it < total_slides_it){
            current_slide_it++;
            jQuery(".slider_it .slider_wrapper .slider_span").animate({
                'margin-left': '-=330'
              }, 1000, function() {
                // Animation complete.
              });
        }
    });
    jQuery(".cb_flvplr").colorbox({iframe:true, width: '550', height: "450", scrolling: false});
   // jQuery(".gallery_link").colorbox({iframe:true, width: '550', height: "450", scrolling: false});
    jQuery(".newsletter_popup").colorbox({iframe:true, width: '250', height: "220", scrolling: false});

    jQuery(".sub_page_popup").colorbox();

    var total_slides = jQuery(".slides .slide_wrapper .slide").length;
    var current_slide = 1;

    jQuery(".slides .slide_wrapper").width(total_slides * 264);

    jQuery(".photos_btn_nav_lft").click(function(){

        if(current_slide > 1){
            current_slide--;
            jQuery(".slide_wrapper").animate({
                'margin-left': '+=264'
              }, 1000, function() {
                // Animation complete.
              });
        }


    });
    jQuery(".photos_btn_nav_ryt").click(function(){

        if(current_slide < total_slides){
            current_slide++;
            jQuery(".slide_wrapper").animate({
                'margin-left': '-=264'
              }, 1000, function() {
                // Animation complete.
              });
        }
    });



     jQuery("#btn_sidebar_inquietudes").click(function(){
         jQuery(".sidebar").removeClass("sibar_bg_2");
         jQuery(".sidebar").addClass("sibar_bg_1");
         jQuery(".widget-area .xoxo li#nav_menu-3").fadeOut("slow", function(){
             jQuery(".widget-area .xoxo li#nav_menu-4").fadeIn("slow");
                 jQuery("#btn_sidebar_inquietudes").removeClass("black");
                 jQuery("#btn_sidebar_tratamientos").addClass("black");
         })
     })
     jQuery("#btn_sidebar_tratamientos").click(function(){
         jQuery(".sidebar").removeClass("sibar_bg_1");
         jQuery(".sidebar").addClass("sibar_bg_2");
         jQuery(".widget-area .xoxo li#nav_menu-4").fadeOut("slow", function(){
             jQuery(".widget-area .xoxo li#nav_menu-3").fadeIn("slow");
                 jQuery("#btn_sidebar_inquietudes").addClass("black");
                 jQuery("#btn_sidebar_tratamientos").removeClass("black");
         })
     })
    jQuery(".btn_read_more").click(function(){
        if(jQuery(".content_details").is(":visible") == true){
            jQuery(".content_details").slideUp("slow");

        }
        else{
            jQuery(".content_details").slideDown("slow");

        }

    });



    jQuery(".sub_content .btn_read_more_sub").click(function(){
        var divToSlide = jQuery(this).parent().parent().find(".content_details_sub");
           if (divToSlide.is(":hidden")) {
              divToSlide.slideDown("slow");
           } else {
              divToSlide.slideUp();
           }


    });

 })
