/*******************************************************
****    Overrides js for changes on 23/11/2010      ****
*******************************************************/
$(document).ready(function() {
    createDropdowns();
    createTabs();
    smoothScroll();
    home_scroller.init();
});
/**** JQuery for the dropdown menus on the brands page ****/
function createDropdowns() {
    $('img.menu_head').css('display', 'block');
    $('ul.menu_body').css('display', 'none').css('position', 'absolute');
    $("ul.menu_body li:even").addClass("alt");

    if (is_ie7()) {
        $('ul.menu_body').css('position', 'relative');
    }

    $('img.menu_head').click(function() {
        $('ul.menu_body').slideUp('medium');
        if ($(this).next('ul.menu_body').css('display') == "none") {
            $(this).next('ul.menu_body').slideDown('medium');
        }
        else {
            $(this).next('ul.menu_body').slideUp('medium');
        }
    });
}
/**** Create Tabs ****/
function createTabs() {
    if ($("#tabs").length > 0) {
        $("#tabs").tabs();
    }
}
function smoothScroll() {
    $('a.back-top-link').click(function(event) {
        event.preventDefault();
        //Get the target
        var target = $(this).attr("href");
        //perform animated scrolling
        $('html,body').animate(
        {
            //get top-position of target-element and set it as scroll target
            scrollTop: $(target).offset().top
            //scrolldelay: 2 seconds
        }, 1000, function() {
            //attach the hash (#jumptarget) to the pageurl
            location.hash = target;
        });
    });
}
// Test for IE7
function is_ie7() {
    if ($.browser.msie && parseInt($.browser.version) <= 7) {
        return true;
    }
    else {
        return false;
    }
}

var home_scroller = {
    init: function() {
        var homeScrollerItem = $('#hero .scrollable');
        if (homeScrollerItem.length > 0) {
			if($('.items div',homeScrollerItem).length > 1){
            	homeScrollerItem.scrollable({ circular: true }).autoscroll(6000).navigator({ idPrefix: 'navi' });
			}
        }
    }
}
