var _jQueryLoaded = (typeof (jQuery) == "function"); if (_jQueryLoaded) { $(document).ready(function() { InitHoverSwaps(); MainNavHeightInit(); TableCellBorderInit(); //Custom Selectbox var checkDropdownExists = $(".custom-dropdown").size(); if(checkDropdownExists != 0){ $(".custom-dropdown").selectbox(); } // IE 6 PNG fix for elements: // Elements to "fix" are stored in array for readability, converted back to string to feed into fix. var DD_fix = [ ".arrow-right", ".searchcontainer", "#TB_closeWindowButton" ].toString(); (typeof DD_belatedPNG == "object") ? DD_belatedPNG.fix(DD_fix) : ""; // Activate tab sets // $("#tabs_updates").tabs(); // Activate field hints $(".fieldhint").fieldhint(); // Custom font replacements cufonReplacements(); // Clear field default value on focus if nothing entered put default value back on blur ToggleDefaultValue(); }); } var _RolloverNavigationLoaded = false; function InitRolloverNavigation() { if (_jQueryLoaded && !_RolloverNavigationLoaded) { $(".rollover-navigation a").each(function() { $(this).find("img.navitem_prejs").each(function() { $(this).attr("class", "navitem_off"); var newImage = $(this).clone(); var newImageSrc = newImage.attr("src").replace("_0.png", "_1.png"); newImage.attr("src", newImageSrc); newImage.attr("class", "navitem_hover"); newImage.insertAfter(this); }); $(this).focus( function() { $(this).toggleClass("hover"); } ).blur( function() { $(this).toggleClass("hover"); } ); }); _RolloverNavigationLoaded = true; } } function InitHoverSwaps() { $(".hoverswap").each(function() { var imageSrc = $(this).attr("src"); var imageName = imageSrc.substring(imageSrc.lastIndexOf("swap_") + 5, imageSrc.lastIndexOf("_")); for (var preloadLoop=0; preloadLoop < 2; preloadLoop++) { if (eval("typeof(b" + imageName + preloadLoop + ")") != "object") { eval("b" + imageName + preloadLoop + " = new Image()"); if (imageSrc.indexOf(".gif") > -1) { eval("b" + imageName + preloadLoop + ".src = 'Assets/swap_" + imageName + "_" + preloadLoop + ".gif'"); } else if (imageSrc.indexOf(".jpg") > -1) { eval("b" + imageName + preloadLoop + ".src = 'Assets/swap_" + imageName + "_" + preloadLoop + ".jpg'"); } else if (imageSrc.indexOf(".png") > -1) { eval("b" + imageName + preloadLoop + ".src = 'Assets/swap_" + imageName + "_" + preloadLoop + ".png'"); } } } $(this).mouseover(function(){ if ($(this).attr("class").indexOf("btn-disabled")<=-1) { $(this).attr("src", eval("b" + imageName + "1.src")); } }); $(this).mouseout(function() { if ($(this).attr("class").indexOf("btn-disabled")<=-1) { $(this).attr("src", eval("b" + imageName + "0.src")); } }); $(this).click(function() { $(this).attr("src", eval("b" + imageName + "2.src")).addClass("btn-disabled"); }); }); $(".btn, .btn-small").click(function() { $(this).addClass("btn-disabled"); /* THIS NEEDS TO BE CHANGED to add another class that includes what the button says, e.g. "btn-close" becomes "btn-close btn-close-disabled" */ }); } // correct height of subnav container function MainNavHeightInit() { $("#main-nav ul li.sub ul li.sub").addClass("level3"); var mainNavHeight = $("#bodycontainer").height(); $("#main-nav ul li.sub").hover(function () { var mainNavHeight = $("#bodycontainer").height(); var navPos = $(this).position(); var posOffset = navPos.top + $("#bodyscroll").scrollTop(); var findSubClass = $(this).find("li.sub").attr("class"); if(findSubClass == "sub level3"){ $(this).find("li.sub").find("ul:last").addClass("last"); } var findLastSubClass = $(this).find("ul").attr("class"); if(findLastSubClass == "last"){ $(this).find("ul.last").css("margin-top", -posOffset).css("padding-top", posOffset).height(mainNavHeight - navPos.top); } else { $(this).find("ul").css("margin-top", -posOffset).css("padding-top", posOffset).height(mainNavHeight - posOffset); } $(this).find("iframe").css("margin-top", -posOffset).css("padding-top", posOffset).height(mainNavHeight - posOffset); }); $("#main-nav iframe").each(function () { var iframeHeight = $(this).parents("li.sub").find("ul").height(); $(this).height(iframeHeight); }); }; $(function(){ $(window).bind('resize', function() { //Event on resize MainNavHeightInit(); }); //Expandable bar control. var checkExpandableBar = $(".expandable-bar").size(); if(checkExpandableBar != 0){ $(".expandable-bar .hide").css("display", "none"); $(".expandable-bar a.expandtitle").click(function(){ var expandShow = $(this).parents(".expandable-bar").find(".hide").css("display"); if(expandShow == "none"){ $(this).parents(".expandable-bar").find(".hide").css("display", "block"); $(this).addClass("expanded"); } else { $(this).parents(".expandable-bar").find(".hide").css("display", "none"); $(this).removeClass("expanded"); } }); } }); // field Hints jQuery.fn.fieldhint = function () { return this.each(function (){ // get jQuery version of 'this' var t = jQuery(this); // get it once since it won't change var title = t.attr('title'); // only apply logic if the element has the attribute if (title) { // on blur, set value to title attr if text is blank t.blur(function (){ if (t.val() == '') { t.val(title); t.addClass('fieldhint_blur'); } }); // on focus, set value to blank if current value // matches title attr t.focus(function (){ if (t.val() == title) { t.val(''); t.removeClass('fieldhint_blur'); } }); // clear the pre-defined text when form is submitted t.parents('form').submit(function(){ // THIS USED TO SAY form:first() if (t.val() == title) { t.val(''); t.removeClass('fieldhint_blur'); } }); // do the same when the window is unloaded $(window).unload(function(){ // THIS USED TO SAY form:first() if (t.val() == title) { t.val(''); t.removeClass('fieldhint_blur'); } }); // now change all inputs to title t.blur(); } }); } function ToggleDefaultValue() { // For forms to clear values on focus and add values on blur $("input.searchinput[type=text]").focus(function() { currentVal = $(this).attr("title"); ($(this).val() == currentVal) ? $(this).val("") : ""; }).blur(function() { ($(this).val() == "") ? $(this).val(currentVal) : ""; }); } function cufonReplacements() { var checkh1 = $('h1, h2').size(); if(checkh1 != 0){ Cufon.replace('h1', { fontFamily: 'Myriad-Light' }); Cufon.replace('h2, .main-intro01, .price, .promo-container span.title', { fontFamily: 'Myriad Pro' }); Cufon.replace('h3', { fontFamily: 'Myriad Pro Semibold' }); } } function TableCellBorderInit() { // Remove dotted border from first td $(".table01 tr td:first-child").each(function() { $(this).css("border-left","none"); }); $(".table01 tr th:first-child").each(function() { $(this).css("border-left","none"); }); } // Popup window profiles var profiles = { windowCenter: { height:550, width:660, center:1, resizable:1, createnew:0, scrollbars:1 } }; $(function(){ $(".popupwindow").popupwindow(profiles); $("a.close-window").click(function(){ window.close(); return false; }); }); /* Popupwindow plugin for jQuery. by: Tony Petruzzi homepage: http://rip747.wordpress.com */ jQuery.fn.popupwindow = function(p) { var profiles = p || {}; return this.each(function(index){ var settings, parameters, mysettings, b, a; // for overrideing the default settings mysettings = (jQuery(this).attr("rel") || "").split(","); settings = { height:600, // sets the height in pixels of the window. width:600, // sets the width in pixels of the window. toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}. scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}. status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}. resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable. left:0, // left position when the window appears. top:0, // top position when the window appears. center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}. location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}. menubar:0 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}. }; // if mysettings length is 1 and not a value pair then assume it is a profile declaration // and see if the profile settings exists if(mysettings.length == 1 && mysettings[0].split(":").length == 1) { a = mysettings[0]; // see if a profile has been defined if(typeof profiles[a] != "undefined") { settings = jQuery.extend(settings, profiles[a]); } } else { // overrides the settings with parameter passed in using the rel tag. for(var i=0; i < mysettings.length; i++) { b = mysettings[i].split(":"); if(typeof settings[b[0]] != "undefined" && b.length == 2) { settings[b[0]] = b[1]; } } } // center the window if (settings.center == 1) { settings.top = (screen.height-(settings.height + 110))/2; settings.left = (screen.width-settings.width)/2; } parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left + ",screenX=" + settings.left + ",top=" + settings.top + ",screenY=" + settings.top; jQuery(this).bind("click", function(){ var name = settings.createnew ? "PopUpWindow" + index : "PopUpWindow"; window.open(this.href, name, parameters).focus(); return false; }); }); };