/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-02-18 22:09:54 -0600 (Sun, 18 Feb 2007) $
 * $Rev: 1379 $
 */
jQuery.fn.bgIframe = jQuery.fn.bgiframe = function() {
	// This is only for IE6
	if ( !(jQuery.browser.msie && typeof XMLHttpRequest == 'function') ) return this;
	var html = '<iframe class="bgiframe" src="javascript:false;document.write(\'\');" tabindex="-1" '
	 					+'style="display:block; position:absolute; '
						+'top: expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)  || 0) * -1) + \'px\'); '
						+'left:expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth) || 0) * -1) + \'px\'); ' 
						+'z-index:-1; filter:Alpha(Opacity=\'0\'); '
						+'width:expression(this.parentNode.offsetWidth + \'px\'); '
						+'height:expression(this.parentNode.offsetHeight + \'px\')"/>';
	return this.each(function() {
		if ( !jQuery('iframe.bgiframe', this)[0] )
			this.insertBefore( document.createElement(html), this.firstChild );
	});
};

$(function(){if(typeof $.fn.tabs=="function"){$(".tabs").tabs()}if(typeof $.ajaxHistory=="object"){$.ajaxHistory.initialize()}if(typeof $.fn.accessNews=="function"){$(".featured_slider").accessNews({newsHeadline:"Featured",newsSpeed:"normal",newsColumns:"2"});$(".guest_blogger_promo_slider").accessNews({newsHeadline:"Guest Blogger Articles",newsSpeed:"normal",newsColumns:"1"})}$(".collapsable, .sb_collapsable, .bulletin_board, .subproduct_order_form").each(function(){var I=$(this);var C=I.children();var E=$(C[0]).addClass("collapsable_toggler");var F=$(C[1]).addClass("collapsable_content");var B=I.is(".persistent")&&!!I.attr("id");var D=(B&&$.cookie(I.attr("id")))?$.cookie(I.attr("id"))=="true":null;var G=(B&&D)||((D==null||!B)&&I.is(".showing"));I.removeClass("showing").removeClass("hidden");var H=$.DIV({Class:"collapsable_toggler_icon"});if(G){I.addClass("showing");F.show()}else{I.addClass("hidden");F.hide()}E.prepend(H);E.click(function(){I.toggleClass("showing").toggleClass("hidden");F.slideToggle("fast",function(){$.cookie(I.attr("id"),F.is(":visible"),{expires:3653,path:"/"})})}).hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});$("a, input, button",E).bind("click",function(J){J.stopPropagation();return true})});$(".form_tips").livequery(function(){$(this).cluetip({splitTitle:"|",positionBy:"bottomTop",topOffset:"20",dropShadow:false})});$(".guest_blogger_summary_tips").cluetip({local:true,topOffset:"0",leftOffset:"0",dropShadow:false});$(".product_summary_tips").cluetip({local:true,positionBy:"mouse",topOffset:70,leftOffset:50,dropShadow:false});$(".post_summary_tips").cluetip({local:true,positionBy:"mouse",topOffset:70,leftOffset:50,dropShadow:false});if(typeof $.fn.markItUp=="function"){$(".markitup_editable_field").markItUp(markItUpTextile)}$(".select_all_checkbox").each(function(){$checkbox=$(this);$container=$(this).parent().parent();$siblings=$("> * > input",$container).not($checkbox);$checkbox.click(function(){$siblings.attr("checked",$checkbox.attr("checked"))});$siblings.click(function(){var B=true;$siblings.each(function(){if(!this.checked){B=false}});$checkbox.attr("checked",B)})});var A=function(B,C){$input=$(B);if($.trim($input.val())==""||$input.val()==C){$input.addClass("quiet_input_prompt").val(C)}$(B).focus(function(){if($input.val()==C){$input.removeClass("quiet_input_prompt").val("")}});$(B).blur(function(){if($.trim($input.val())==""){$input.addClass("quiet_input_prompt").val(C)}})};A("#hd_masthead_search_field","Search...");$("a.method_delete,area.method_delete").click(function(){if(confirm("Are you sure?")){var C=document.createElement("form");C.style.display="none";this.parentNode.appendChild(C);C.method="POST";C.action=this.href;var B=document.createElement("input");B.setAttribute("type","hidden");B.setAttribute("name","_method");B.setAttribute("value","delete");C.appendChild(B);C.submit()}return false});$(".first_header_fix").each(function(B){$("h2:first",this).addClass("first")});superDuperRollover.init();$("input.multiple_file_upload").multipleFileUpload();$("input, button, select, textarea").not("#hd_masthead_search_field, #hd_masthead_search_button").each(function(B){if(!this.getAttribute("tabindex")){this.setAttribute("tabindex","1")}});$("div.product_in_list_product,div.product_in_list_related_product").hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});$("a.search_result_image").each(function(C){var B=$(this);var D=$.IMG({src:"/images/blank.gif",alt:"",Class:"search_label"});B.append(D)})});jQuery.fn.extend({multipleFileUpload:function(){return $(this).each(function(){var C=$(this);var B=$.DIV().css("float","left");var A=$.DIV().css("clear","both").text(" ");C.parent().append(B).append(A);C.appendTo(B);C.css("display","block");var D=function(){current=$(this);if(current.attr("multiple_file_appended")!="true"&&this.value!=""){var E=current.clone();E[0].value="";E.change(D).appendTo(current.parent())}current.attr("multiple_file_appended",true)};C.change(D)})}});$.numberToCurrency=function(A){var B=parseFloat(A);if(isNaN(B)){B=0}var C="";if(B<0){C="-"}B=Math.abs(B);B=parseInt((B+0.005)*100);B=B/100;s=new String(B);if(s.indexOf(".")<0){s+=".00"}if(s.indexOf(".")==(s.length-2)){s+="0"}s=C+s;return"$"+s};var superDuperRollover={init:function(){this.preload();$(".ro").hover(function(){$(this).attr("src",superDuperRollover.newimage($(this).attr("src")))},function(){$(this).attr("src",superDuperRollover.oldimage($(this).attr("src")))})},preload:function(){$(window).bind("load",function(){$(".ro").each(function(A,B){$("<img>").attr("src",superDuperRollover.newimage($(this).attr("src")))})})},newimage:function(A){return A.substring(0,A.search(/(\.[a-z]+)/))+"_o"+A.match(/(\.[a-z]+)/)[0]},oldimage:function(A){return A.replace(/(_o)+/,"")}};jQuery.ajaxSetup({beforeSend:function(A){A.setRequestHeader("Accept","text/javascript")}});
$(function(){$("ul.jd_menu").jdMenu({activateDelay:50,showDelay:10,hideDelay:100,disableLinks:false});if(typeof $.fn.tabs=="function"){$(".tabs > ul").tabs()}if(typeof $.ajaxHistory=="object"){$.ajaxHistory.initialize()}$socialize=$(".socialize_this_list");if($socialize.length){$socialize.clickMenu({onClick:false})}});
(function(D){function C(E){var F=D.data(D(E).parents().andSelf().filter("ul.jd_menu")[0],"jdMenuSettings");D("> li",E).bind("mouseenter.jdmenu mouseleave.jdmenu",function(G){D(this).toggleClass("jdm_hover");var H=D("> ul",this);if(H.length==1){clearTimeout(this.$jdTimer);var J=(G.type=="mouseenter");var I=(J?B:A);this.$jdTimer=setTimeout(function(){I(H[0],F.onAnimate,F.isVertical)},J?F.showDelay:F.hideDelay)}}).bind("click.jdmenu",function(H){var I=D("> ul",this);if(I.length==1&&(F.disableLinks==true||D(this).hasClass("accessible"))){B(I,F.onAnimate,F.isVertical);return false}if(H.target==this){var J=D("> a",H.target).not(".accessible");if(J.length>0){var G=J[0];if(!G.onclick){window.open(G.href,G.target||"_self")}else{D(G).trigger("click")}}}if(F.disableLinks||(!F.disableLinks&&!D(this).parent().hasClass("jd_menu"))){D(this).parent().jdMenuHide();H.stopPropagation()}}).find("> a").bind("focus.jdmenu blur.jdmenu",function(G){var H=D(this).parents("li:eq(0)");if(G.type=="focus"){H.addClass("jdm_hover")}else{H.removeClass("jdm_hover")}}).filter(".accessible").bind("click.jdmenu",function(G){G.preventDefault()})}function B(H,G,F){var H=D(H);if(H.is(":visible")){return }H.bgiframe();var E=H.parent();H.trigger("jdMenuShow").positionBy({target:E[0],targetPos:(F===true||!E.parent().hasClass("jd_menu")?1:3),elementPos:0,hideAfterPosition:true});if(!H.hasClass("jdm_events")){H.addClass("jdm_events");C(H)}E.addClass("jdm_active").siblings("li").find("> ul:eq(0):visible").each(function(){A(this)});if(G===undefined){H.show()}else{G.apply(H[0],[true])}}function A(F,E){var F=D(F);D(".bgiframe",F).remove();F.filter(":not(.jd_menu)").find("> li > ul:eq(0):visible").each(function(){A(this)}).end();if(E===undefined){F.hide()}else{E.apply(F[0],[false])}F.trigger("jdMenuHide").parents("li:eq(0)").removeClass("jdm_active jdm_hover").end().find("> li").removeClass("jdm_active jdm_hover")}D.fn.jdMenu=function(E){var E=D.extend({showDelay:200,hideDelay:500,disableLinks:true},E);if(!D.isFunction(E.onAnimate)){E.onAnimate=undefined}return this.filter("ul.jd_menu").each(function(){D.data(this,"jdMenuSettings",D.extend({isVertical:D(this).hasClass("jd_menu_vertical")},E));C(this)})};D.fn.jdMenuUnbind=function(){D("ul.jdm_events",this).unbind(".jdmenu").find("> a").unbind(".jdmenu")};D.fn.jdMenuHide=function(){return this.filter("ul").each(function(){A(this)})};D(window).bind("click.jdmenu",function(){D("ul.jd_menu ul:visible").jdMenuHide()})})(jQuery);
var jqmOnShow=function(A,B){A.w.fadeIn("fast",function(){A.o.fadeTo("slow",0.5,function(){if(B){B()}})})};var jqmOnHide=function(A,B){A.o.fadeOut("slow",function(){A.w.fadeOut("fast",function(){if(B){B()}})})};jQuery.fn.extend({ajaxPopupDefaultLoading:function(){return this.append($(document.createElement("div")).css("textAlign","center").append($(document.createElement("img")).attr("src","/images/loading.gif").css("textAlign","center")))},ajaxPopup:function(C){link=this;var A={accept:"html",url:"",popupId:"",inputIdPrefix:"",windowClass:"jqmWindowMedium"};C=$.extend(A,C);if(C.inputIdPrefix.length){C.inputIdPrefix+="_"}var B=$(document.createElement("div")).attr("id",C.popupId).addClass(C.windowClass).addClass("jqmWindow").append($(document.createElement("div")).addClass("jqmWindowContainer").append($(document.createElement("div")).addClass("jqmWindowTitle  clearfix").append($(document.createElement("h2")).append("Loading")).append($(document.createElement("a")).addClass("jqmClose").attr("href","#").append($(document.createElement("span")).append("close")))).append($(document.createElement("div")).addClass("jqmWindowContent jqmTarget").ajaxPopupDefaultLoading())).appendTo("body").jqm({modal:true,trigger:false,overlay:1,ajax:C.url,target:".jqmTarget",onLoad:function(D){$(".jqmWindowTitle h2",B).empty().append($("h1",this).html());$("h1",this).remove();$("input[@name=cancel]",this).click(function(){B.jqmHide()});$(".jqmClose",this).click(function(){B.jqmHide()})},onShow:function(D){jqmOnShow(D)},onHide:function(D){jqmOnHide(D,function(){$(".jqmTarget",B).empty().ajaxPopupDefaultLoading()})}});link.click(function(){window.scrollTo(0,0);B.jqmShow();return false});return $(this)},navPopup:function(B,I){var H={windowClass:"jqmWindowMedium",top:false,left:false,closeLeft:0,closeTop:0,closeRight:0,closeBottom:0};I=$.extend(H,I);var D=null;var A=$(this).addClass("jqmWindow").addClass(I.windowClass);var F=$("h2:first",A).remove().html();var C=A.children().remove();A.append($(document.createElement("div")).addClass("jqmWindowContainer").append($(document.createElement("div")).addClass("jqmWindowContent").append(C).append($(document.createElement("a")).css({position:"absolute",left:I.closeLeft,top:I.closeTop,width:I.closeRight-I.closeLeft,height:I.closeBottom-I.closeTop}).click(function(){E()})))).jqm({trigger:false,overlay:0.8,onShow:function(J){J.o.css("opacity",0.8).show();J.w.show()},onHide:function(J){J.w.fadeOut("fast",function(){if(J.o){J.o.remove()}})}});if(I.top&&I.left){A.addClass("jqmWindowAbsolute").css({position:"absolute",top:I.top,left:I.left})}var G=function(){A.jqmShow()};var E=function(){A.jqmHide()};$(B).click(function(){G();return false});return A}});
