﻿// JScript File
$(function() {
    if ($.browser.msie && ($.browser.version < 7.0))
    {
        initIE6();
    }
    else
    {
        initFull();
    }
});

function initFull()
{
    /* 
		hide everything 
		TB: Disabled due to client request
    $("#wrapper").css("display", "none");
    $("#wrapper").css("visibility", "hidden");
    */
    
    /*
    $("#background").css("display", "none");
    $("#main-header").css("display", "none");
    $("#main-menu").css("display", "none");
    $("#main-content-bg").css("display", "none");
    */
    
    /*
        Display splash screen (but don't enable click yet)
        TB: Disabled due to client request
    
    displaySplash();
    */
    
    /*
        AJAX listeners on ASP forms
    */
    addFormListeners()
    
    /*
        PNG Fix
        Makes transparent PNGs work in IE6 (both inline and css)
    */
    $(document).pngFix();
    
    /*
        Scrollbars 
        Initialises the scrollbars on all tabs of the current page
    */
    initScrollBars();
    
    /*
        Easing
        Makes all animations use 'easing' by default
    */
    
    jQuery.easing.def = "easeInOutQuad";
    
    /* 
        Tabs
        Turns specific sets of list items/anchored divs into tabs/sections  
    */
    initTabs();
    
    /*
        Main Menu
        Changes the main menu links so that they use AJAX/animation
    */
    initMainMenu();
    
    /*
        Preload
        Preloads images that are used throughout the site, to speed up animation
    */
    preload();
    
    /*
        remove splash
    */
    $("#main-header").click(displaySplash);
    $("#main-header").css("cursor", "pointer");
}

function initIE6()
{
    $(document).pngFix();
    addFormListeners()
    initScrollBars();
    jQuery.easing.def = "easeInOutQuad";
    initTabs();
    //displaySplashIE6();
    $("#wrapper").css("display", "block");
}

/*Preloads important images (mainly for animation) on the Jamie Baird site*/
function preload()
{
    $.preloadImages(
    "Images/Backgrounds/arm.jpg",
    "Images/Backgrounds/bum.jpg",
    "Images/Backgrounds/legs.jpg",
    "Images/Backgrounds/pecs.jpg",
    "Images/Backgrounds/tummy.jpg",
    "Images/Navigation/press.png",
    "Images/Navigation/products.png",
    "Images/Navigation/quick_fix_programme.png",
    "Images/Navigation/resigym.png",
    "Images/Navigation/training.png",
    "Images/Navigation/press_o.png",
    "Images/Navigation/products_o.png",
    "Images/Navigation/quick_fix_programme_o.png",
    "Images/Navigation/resigym_o.png",
    "Images/Navigation/training_o.png",
    "Images/Navigation/press_h.png",
    "Images/Navigation/products_h.png",
    "Images/Navigation/quick_fix_programme_h.png",
    "Images/Navigation/resigym_h.png",
    "Images/Navigation/training_h.png"
    );
}
  
/* Takes an array of paths to images and preloads them by creating <img> objects*/
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

