﻿// Check that the page has loaded
$(document).ready(function() {
    
    // About us dropdown   
    $('.mainNav LI:eq(1)').hover(
        function(){
        // Show dropdown
        $('#mainNav .aboutUs').show();
        },
        
        function(){
        // Hide dropdown
        $('#mainNav .aboutUs').hide();
    });
    
    $('.mainNav LI:eq(4)').hover(
        function(){
        // Show dropdown
        $('#mainNav .instructors').show();
        },
        
        function(){
        // Hide dropdown
        $('#mainNav .instructors').hide();
    });
    
    $('#mainNav .aboutUs').hover(
        function(){
        // Show dropdown
        $(this).show();
        },
        
        function(){
        // Hide dropdown
        $(this).hide();
    });
    $('#mainNav .instructors').hover(
        function(){
        // Show dropdown
        $(this).show();
        },
        
        function(){
        // Hide dropdown
        $(this).hide();
    });
    
    // Remove border for last dropdown
    $('.dropdown LI:last A').css({border: 'none'});
    

    // Homepage quick links rollover
    $('#homeQuicklinks .quicklink').hover(
    
        // Mouseover
        function() {
            $(this).find('.tooltip').dequeue().css("bottom",110).css("opacity",null).css("display","none");
            $(this).find('.quicklinkTitle').css({backgroundPosition: '0 -30px' });
            $(this).find('.tooltip').animate({bottom:110},0).animate({bottom: 120, opacity: 'show'}, 300);
        },

        // Mouseout
        function() {
            $(this).find('.quicklinkTitle').css({backgroundPosition: '0 0' });
            $(this).find('.tooltip').animate({bottom: 140, opacity: 'hide'}, 300).animate({bottom: 110},0);
            
        }
    );
    
    // Product page gallery
    $('.productDetailsGallery .thumbnail A').click(function(){
    
        // Find out which image to load
        var img = $(this).attr('href');
        
        // Change image
        $('.productDetailsGallery .mainImg IMG').attr('src', img);
        
        // Remove 'selected' from all thumbnails
        $('.productDetailsGallery .thumbnail').removeClass('selected');
        
        // Add 'selected' to correct thumbnail
        $(this).parent('.thumbnail').addClass('selected');
        
        return false;
    });
    
    // Bottom alignment for product description
    var heightLeft = '340';
    var heightRight = $('.productDetailsDesc').height();
    var marginBottom = heightLeft - heightRight;
    
    //$('#bottomArea').css({marginTop: marginBottom });

    for (var count = 0; count < 20; count++)
    {
        setTimeout("resetInputs()", 50 * count);
    }
    timer = setInterval("resetInputs()", 250);

});

function resetInputs(){
    $('input').css("background-color", "white");
    $('.form').find('input').css("background-color", "#f5fafb");
    $('.TVI-form').find('input').css("background-color", "transparent");
}

function clear_checkboxes(myID) {
    var frm = document.forms[0];
    for (i = 0; i < frm.length; i++) {
        if (frm.elements[i].id != myID) {
            if (frm.elements[i].id.indexOf('cb') != -1) {
                frm.elements[i].checked = false;
            }
        }
    }
}