﻿//jQuery
jQuery('document').ready(function() {

    $(function(){     
        $("ul#ticker01").liScroll(); 
    });
    jQuery('.hiddenRow').css('display', 'none');
    jQuery('#subnavArea').css('display', 'none');
    jQuery('#subnavArea dd').css('display', 'none');
    //jQuery('head').append('<link rel="stylesheet" href="/Styles/jsStyles.css" type="text/css" rev="Stylesheet" media="screen" />');
    
    //Shopping Basket total styling
    /*jQuery('.ShoppingDetails ul li:last').css('font-weight', 'bold');
    jQuery('.ShoppingDetails ul li:last').css('border-top', 'solid 1px #dbdbdb');
    jQuery('.ShoppingDetails ul li:last').css('border-bottom', 'solid 1px #dbdbdb');*/
    
    //homepage feature sections
    jQuery('div.homeFeature').click(function() {
        var link = jQuery(this).children('div').children('div').children('a').attr('href');
        document.location = link;
    });
    
    //Hotkey
    jQuery('input.HotKeyActive').keydown(function(event) {
        if (event.keyCode == 13)
        {
            event.cancel = true;
            event.returnValue = false;
            
            jQuery('input.btn_login').click ();
            
            return false;
        }
    });
    jQuery('input.searchfield').keydown(function(event) {
		// process only the Enter key
        if (event.keyCode == 13)
        {
            // cancel the default submit
            event.returnValue = false;
            event.cancel = true;
            
            jQuery('input.btn_search').click ();            
        
            return false;
        }
    });
     
    //Tabbed panels & right height fix
    jQuery('.AboutContentBar h2.openpanel').toggle(function() {
        jQuery(this).css('background', 'url(/images/ContentBarBG_2.gif)');
        jQuery(this).siblings('div.AboutContent').slideDown('slow');
    }, function() {
        jQuery(this).siblings('div.AboutContent').slideUp('slow');
        jQuery(this).css('background', 'url(/images/ContentBarBG.gif)');
    });
    
    jQuery('.tabPanel h2').click(function() {
        jQuery(this).siblings('div.tabPanelContent').attr('id', 'UnselectedTab');
        jQuery(this).next('div.tabPanelContent').attr('id', 'SelectedTab');
        jQuery(this).siblings('h2').attr('id', 'UnselectedHead');
        jQuery(this).attr('id', 'SelectedHead');
        var rightHeight = jQuery('div#SelectedTab').height();
        jQuery('div#rightHeightFix').css('height', rightHeight + 'px');
        jQuery(this).siblings('div.tabPanelContent').css('display', 'none');
        jQuery(this).next('div').css('display', 'block');
    });
    
    //Browse Catalogue button
    if(jQuery('h1#catalogue').text() == "Catalogue")
    {
        jQuery('.BrowseCatagoryButton img').attr('src', '/images/lhsitems/browse_catalogue_dn.gif');
        jQuery('#subnavArea').css('display', 'block');
        jQuery('#subnavArea dd').css('display', 'block');
        jQuery('div.lhsItem a.BrowseCatagoryButton').toggle(function() {
            jQuery(this).siblings('div#subnavArea').slideUp('slow');
            jQuery(this).children('img').attr('src','/images/lhsitems/browse_catalogue.gif');
        }, function() {
            jQuery(this).children('img').attr('src','/images/lhsitems/browse_catalogue_dn.gif');
            jQuery(this).siblings('div#subnavArea').slideDown('slow');
        });
        jQuery('div.lhsItem dt').toggle(function() {
            jQuery(this).siblings('dd').slideUp('slow');
        }, function() {
            jQuery(this).siblings('dd').slideDown('slow');
        });
    } else {
        jQuery('div.lhsItem a.BrowseCatagoryButton').toggle(function() {
            jQuery(this).children('img').attr('src','/images/lhsitems/browse_catalogue_dn.gif');
            jQuery(this).siblings('div#subnavArea').slideDown('slow');
        }, function() {
            jQuery(this).siblings('div#subnavArea').slideUp('slow');
            jQuery(this).children('img').attr('src','/images/lhsitems/browse_catalogue.gif');
        });
        jQuery('div.lhsItem dt').toggle(function() {
            //jQuery(this).parents('dl').siblings('dl').children('dd').slideUp('slow');
            jQuery(this).siblings('dd').slideDown('slow');
        }, function() {
            jQuery(this).siblings('dd').slideUp('slow');
        });
    }
    
    //News user comments style
    jQuery('div.newsUserComments h3').parent('div').css('border', 'solid 1px #dbdbdb');
    
    //Learning Aids hide & show
    jQuery('tr.clickableRow td a.btn_plusminus').toggle(function() {
        jQuery(this).parent('td').parent('tr').next('tr').children('td').children('.hiddenRow').css('display', 'block');
        jQuery(this).children('img').attr('src', '/images/buttons/btn_minus.gif');
        var rightHeight = jQuery('div#SelectedTab').height();
        jQuery('div#rightHeightFix').css('height', rightHeight + 'px');
    }, function() {
        jQuery(this).children('img').attr('src', '/images/buttons/btn_plus.gif');
        jQuery(this).parent('td').parent('tr').next('tr').children('td').children('.hiddenRow').css('display', 'none');
        var rightHeight = jQuery('div#SelectedTab').height();
        jQuery('div#rightHeightFix').css('height', rightHeight + 'px');
    });
});