/* Copyright DTDigital :: www.dtdigital.com.au :: Unauthorised modification / use is a criminal offence, and will be prosecuted to the fullest extent permitted by law. All Rights Reserved */ // jQuery functions that run on "dom ready" var _jQueryLoaded = (typeof(jQuery) == "function"); if (_jQueryLoaded) { $(document).ready(function() { InitRolloverNavigation(); $(".sub-container").bgiframe({opacity:false}); }); } var _RolloverNavigationLoaded = false; function InitRolloverNavigation() { if (_jQueryLoaded && !_RolloverNavigationLoaded) { $("#nav a, #main-nav li").each(function() { $(this).focus( function() { $(this).toggleClass("hover"); } ).blur( function() { $(this).toggleClass("hover"); } ); }); _RolloverNavigationLoaded = true; } } /** * Toggle the cart and wishlist. * These lists start collapsed and then remember their state (collapsed / expanded) * using cookies. * * @param target * @param link * @param expand * @return */ function toggleItems(target, link, expand) { // prepare expand var display = "block"; var text = "Collapse all items"; link.addClass("minus") if (expand == "false") { // prepare collapse display = "none"; text = "Click to see all items"; link.removeClass("minus") } // hide/ show items $("a." + target + "-link").css("display", display) // change text link.text(text); // set cookie (so the basket remains expanded or colapsed) $.cookies.set(target + "Expanded", expand); } function showHideWishListItemsOW(show) { $('#wishlist_items').css('display', show == "true" ? 'block' : 'none'); $('#wishlist_expand').css('display', show == "true" ? 'none' : 'block'); $('#wishlist_collapse').css('display', show == "true" ? 'block' : 'none'); // Store the cookie for next time $.cookies.set("wishExpanded", show); } //Show/Hide Wish List. $(function() { // on page load var expand = $.cookies.get("wishExpanded"); if (expand != "true" && expand != "false") { // default to collapsed if no cookie is found expand = "false"; } showHideWishListItemsOW(expand); // Just going with a string representation of boolean to // keep consistent with stored value in cookie $('#wishlist_expand').click(function() { showHideWishListItemsOW("true"); return false; }); $('#wishlist_collapse').click(function() { showHideWishListItemsOW("false"); return false; }); }); //Show/Hide Shopping cart. $(function() { $("a.showall-cart").css("display", "block"); var link = $("a.showall-cart"); // on page load var expand = $.cookies.get("cartExpanded"); if (expand != "true" && expand != "false") { // default to collapsed expand = "false"; } toggleItems("cart", link, expand) link.bind("click", function (event) { // toggle display and cookie at user's request var toggleExpand = "false"; if ($.cookies.get("cartExpanded") == "false") { toggleExpand = "true"; } toggleItems("cart", link, toggleExpand); return false; }); }); /** * Enable the wait cursor during a ajax event. * @return */ function globalAjaxCursorChange() { $("html").bind("ajaxSend", function(){ $(this).addClass('busy'); }) .bind("ajaxComplete", function(){ $(this).removeClass('busy'); }); } $(function() {globalAjaxCursorChange();}); /** * Submit forms when adding items to cart. */ $(document).ready(function() { bindAddToCartSubmissions('WN'); bindAddToCartSubmissions('bsc'); bindAddToCartSubmissions('rfy'); $('#BRANDS').change(function(e) { $('#MODELS').val(""); $('#filterForm').submit(); }); $('#MODELS').change(function(e) { $('#filterForm').submit(); }); }); /** * Force all passwords to uppercase to work around a bug in the SAP kernel. */ $(function() { $(":password").bind("blur keypress", function(e){ var oldVal = $(this).val(); $(this).val(oldVal.toUpperCase()); }); }); /** * Bind site intelligence to all form submissions. * Fields of type "password" or names matching "nolog_.*" are excluded * as they may contain sensitive information. * (See site-tracker.js.jsp) * */ $(function() { $("form.siTag").submit( function () { // protect application agaist site-intelligence errors try { SiTrackFormData(this); } catch(err) { // fail without notification } return true; }); }); // ============================================================================= // Common Javascript Library // ============================================================================= //------------------------------------------------------------------------------ function traceForm(form) { var debug = form.id + "["; if (form.elements && (form.elements.length > 0)) { for (var i=0; i