//var img = new Image();
//img.src = "/path/to/img";

//var img = new Array();
//img[0] = new Image();

var menuSpeed = "slow";
var selectedMenu = "";
function SetSelectedMenu(menu)
{
    MenuOn(menu);
    selectedMenu = menu;
}

function MenuOn(menu)
{
    if(selectedMenu != menu)
    {
        var menuId = "#" + menu + "OnImage";
        $(menuId).fadeTo(menuSpeed, 1);
    }
}

function MenuOff(menu)
{
    if(selectedMenu != menu)
    {
        var menuId = "#" + menu + "OnImage";
        $(menuId).fadeTo(menuSpeed, 0);
    }
}

function init()
{
}

function mastetersInit()
{
}

function ShowThankYou()
{
    HideThrobber();
    $("#formHolder").fadeOut("fast", function(){
        $("#thankYouHolder").fadeIn("fast");
    });
}


function HideItems()
{
    $('#itemsContainer').hide();
    ShowThrobber();
}

function ShowItems()
{
    $('#itemsContainer').fadeIn('slow', function(){
        HideThrobber();
    });
}

function ShowDetail()
{
    SetPositionToCenter("detailsContainer", 250, 200);  
    if(!$.browser.msie)
    {
        $("#innerHolder").fadeTo('fast', 0.25, function(){
            $('#detailsContainer').fadeIn('fast', function(){
                HideThrobber();
            });
        });
    }
    else
    {
        $('#detailsContainer').css("border", "4px solid #340305");
        if($.browser.version < 7.0)
        {
            $('#detailsContainer').fadeIn('slow', function(){
                $('#itemsContainer').fadeTo('fast', 0.25, function(){});            
                    $('#productCategoryHolder').fadeTo('fast', 0.25, function(){
                        HideThrobber();
                    });         
            });
        }
        else
        {
            $('#productCategoryHolder').fadeTo('fast', 0.25);
            $('#itemsContainer').fadeTo('fast', 0.25, function(){
                $('#detailsContainer').fadeIn('slow', function(){
                    HideThrobber();
                });
            });
        }
    }
}

function HideDetail()
{
    if(!$.browser.msie)
    {
        $('#detailsContainer').fadeOut('fast', function(){
            $("#innerHolder").fadeTo('fast', 1);
        });
    }
    else
    {
        $('#detailsContainer').fadeOut('slow');
        $('#itemsContainer').fadeTo('fast', 1, function(){});
        $('#productCategoryHolder').fadeTo('fast', 1);
    }
}

function ShowThrobber()
{
    SetPositionToCenter('throbber', 16, 16);
    $('#throbber').show();
}

function HideThrobber()
{
    $('#throbber').hide();
}

function SetPositionToCenter(objectId, objectWidth, objectHeight)
{
    var topPosition = ($(window).scrollTop() + ($(window).height()/2) | 0) - objectHeight;
    var leftPosition = ($(window).scrollLeft() + ($(window).width()/2) | 0) - objectWidth;
    document.getElementById(objectId).style.top = topPosition + "px";
    document.getElementById(objectId).style.left = leftPosition + "px";
}

function SmoothLoad()
{
    SmoothLoadCustom('.smoothLoad');
}

function SmoothLoadCustom(filter)
{
    var images = $(filter);
    for (i = 0; i < images.length; i++)
    {
        if(!images[i].complete)
            LoadAndFadeIn(images[i].id);
        else
        {   
            $('#' + images[i].id).fadeIn('normal');
        }
    }
}

function LoadAndFadeIn(imageId)
{
    ShowThrobber();
    var img = document.getElementById(imageId);
    var src = img.src;
    var imgToLoad = new Image();
    imgToLoad.src = src;
    var jqueryImageId = '#' + imageId;
    $(imgToLoad).load(function() {
        $(jqueryImageId).fadeIn('normal');
        HideThrobber();
    });
}

var currentFeatureId = "#productFeatures";
function SwapFeature(featureId)
{
    if (!$(featureId).is(":visible"))
    {
        $(currentFeatureId).fadeOut('fast', function(){
            $(featureId).fadeIn('fast');
            currentFeatureId = featureId;
        });
    }
}

$(document).ready (function() {

});