var navCollection = "nav > ul > li"; var touchbound = false; jQuery(document).ready(function(){ jQuery(window).bind('touchstart', function(e){ isTouch() }); if (navigator.msMaxTouchPoints) jQuery(window).bind('MSPointerDown', function(e){ isTouch() }); jQuery(navCollection).each(function() { jQuery(this).hover(function() { if (!touchbound) showNav(jQuery(this)); }, function() { if (!touchbound) hideNav(jQuery(this)); }); // side-by-side dropdowns if (jQuery(this).children(".dropdown").length) { var num_dropdown_items = jQuery(this).children(".dropdown").children("ul").children("li").length; if (num_dropdown_items > 15) jQuery(this).children(".dropdown").children("ul").addClass("side-by-side"); } }); }); function showNav(navItem) { navItem.children('.dropdown').stop().each(function(){ var w = parseInt(jQuery(this).width()); var x = parseInt(jQuery(this).parent().position().left); var y = parseInt(jQuery(this).parent().parent().width()); // console.log("w: "+w); // console.log("x: "+x); // console.log("y: "+y); if (w > y) { jQuery(this).width(y); w = parseInt(jQuery(this).width()); } if ((x + w) > y) { var q = (x - (y - w) - parseInt(jQuery(this).parent().parent().position().left)); jQuery(this).css("margin-left", "-"+q+"px"); } else { jQuery(this).css("margin-left", "0px"); } jQuery(this).css("width", "auto"); jQuery(this).children("ul").css("width", "auto"); jQuery(this).show(0, function(){ jQuery(this).children("ul").each(function(){ var new_width = jQuery(this).width(); if (jQuery(this).hasClass("side-by-side")) { new_width = 0; jQuery(this).children("li").each(function(){ if (jQuery(this).outerWidth() > new_width) new_width = jQuery(this).outerWidth(); }); jQuery(this).children("li").outerWidth(new_width); jQuery(this).width((new_width * 3)+1); // Re-do margins.... =P var drop_parent = jQuery(this).parent(); drop_parent.css("margin-left", "0px"); var w = parseInt(drop_parent.width()); var x = parseInt(drop_parent.parent().position().left); var y = parseInt(drop_parent.parent().parent().width()); if (w > y) { drop_parent.width(y); w = parseInt(drop_parent.width()); } if ((x + w) > y) { var q = (x - (y - w) - parseInt(drop_parent.parent().parent().position().left)); drop_parent.css("margin-left", "-"+q+"px"); } else drop_parent.css("margin-left", "0px"); } else { new_width = new_width - (parseInt(jQuery(this).children("li").css("padding-left")) + parseInt(jQuery(this).children("li").css("padding-right"))); jQuery(this).children("li").width(new_width); } }); }); }); } function hideNav(navItem) { navItem.children('.dropdown').stop().fadeOut(100); } function isTouch() { if (!touchbound) { jQuery(navCollection).each(function(){ jQuery(this).unbind("hover"); jQuery(this).unbind("mouseover"); jQuery(this).unbind("mouseout"); if (jQuery(this).children("div").length > 0) { jQuery(this).unbind('mouseout'); jQuery(this).unbind('mouseover'); jQuery(this).children("div").children("ul").prepend("
  • "+jQuery(this).children("a").html()+"
  • "); jQuery(this).children("a").bind('click', function(e){ e.preventDefault(); if (jQuery(this).attr("rel") == "open") { jQuery(this).attr("rel", "closed"); hideNav(jQuery(this).parent()); } else { jQuery('.dropdown').hide(); jQuery("a[rel=open]").attr("rel", "closed"); jQuery(this).attr("rel", "open"); showNav(jQuery(this).parent()); } return false; }); } }); jQuery("#phone").children("a").attr("href", "tel:18007073223"); touchbound = true; } } // Custom code for this site: