/**
 * Javascript for Hausland Theme
 */
 

$(document).ready(function(){
    $("ul.sf-menu").supersubs({
        minWidth:    12,                                // minimum width of sub-menus in em units
        maxWidth:    27,                                // maximum width of sub-menus in em units
        extraWidth:  1                                  // extra width can ensure lines don't sometimes turn over
    }).superfish({
        delay:       400,                               // delay on mouseout
        animation:   {opacity:'show',height:'show'},    // fade-in and slide-down animation
        speed:       'fast',                            // faster animation speed
        autoArrows:  false,                             // disable generation of arrow mark-up
        dropShadows: false                              // disable drop shadows
    });
});

 

$(document).ready(function(){    
    $("#slider").nivoSlider();

    $("#recent_articles_slider").jCarouselLite({
        btnNext: "#slider1next",
        btnPrev: "#slider1prev"
    });

});


$(document).ready(function () {
  
    var id= document.body.id;
    var sidebar = $('#faq_sidebar_content');
    
    if(id == 'page-16') {     
    
    var top = sidebar.offset().top - parseFloat(sidebar.css('marginTop'));         
    $(window).scroll(function (event) {
        var ypos = $(this).scrollTop();
        if (ypos >= top) {
            sidebar.addClass('fixed');
        }
        else {
            sidebar.removeClass('fixed');
        }
    });

    $.localScroll();    

    }

    
});


$(document).ready(function(){
    /* This code is executed after the DOM has been completely loaded */
    
    var totWidth=0;
    var positions = new Array();
    
    $('#model_houses_slides .model_houses_slide').each(function(i){
        
        /* Traverse through all the slides and store their accumulative widths in totWidth */
        
        positions[i]= totWidth;
        totWidth += $(this).width();
        
        /* The positions array contains each slide's commulutative offset from the left part of the container */
        
        if(!$(this).width())
        {
            alert("Please, fill in width & height for all your images!");
            return false;
        }
        
    });
    
    $('#model_houses_slides').width(totWidth);

    /* Change the cotnainer div's width to the exact width of all the slides combined */

    $('#model_houses_menu ul li a').click(function(e,keepScroll){

            /* On a thumbnail click */

            $('li.menuItem').removeClass('act').addClass('inact');
            $(this).parent().addClass('act');
            
            var pos = $(this).parent().prevAll('.menuItem').length;
            
            $('#model_houses_slides').stop().animate({marginLeft:-positions[pos]+'px'},450);
            /* Start the sliding animation */
            
            e.preventDefault();
            /* Prevent the default action of the link */
            
            
            // Stopping the auto-advance if an icon has been clicked:
            if(!keepScroll) clearInterval(itvl);
    });
    
    $('#model_houses_menu ul li.menuItem:first').addClass('act').siblings().addClass('inact');
    /* On page load, mark the first thumbnail as active */
    
    
    
    /*****
     *
     *    Enabling auto-advance.
     *
     ****/
     
    var current=1;
    function autoAdvance()
    {
        if(current==-1) return false;
        
        $('#model_houses_menu ul li a').eq(current%$('#model_houses_menu ul li a').length).trigger('click',[true]);    // [true] will be passed as the keepScroll parameter of the click function on line 28
        current++;
    }

    // The number of seconds that the slider will auto-advance in:
    
    var changeEvery = 10;

    var itvl = setInterval(function(){autoAdvance()},changeEvery*1000);

    /* End of customizations */
});

$(document).ready(function(){

$(".view_step").colorbox({width:"620px",height:"220px", inline:true, href:"#inline_step"});

});


$(document).ready(function(){
    $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
});

$(document).ready(function(){    
     $(".amenities_gallery").colorbox({rel:'amenities_gallery', transition:"fade", width:"700px", height:"500px"});           
});     


     $(document).ready(function(){    
     $(".article_gallery").colorbox({rel:'amenities_gallery', transition:"fade", width:"700px", height:"500px"});           
     });

     
