//nomensa-1.2.6.js
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
function addPrintLink(){$("#print-link").click(function(){window.print();return false;});}
$(document).ready(function(){addPrintLink();});

function setCorners() {
  var ne="<span class='ne'>&nbsp;</span>";
  var nw="<span class='nw'>&nbsp;</span>";
  var se="<span class='se'>&nbsp;</span>";
  var sw="<span class='sw'>&nbsp;</span>";
  var targetElems=$(".rounded");
  $(targetElems).each(function(i) {
    var targetElement=$(targetElems[i]);
    if(targetElement.children("span.ne, span.nw, span.se, span.sw").length==0) {
      targetElement.prepend(nw).prepend(ne).append(se).append(sw);
    }
  });
  var tr="<span class='tr'>&nbsp;</span>";
  var tl="<span class='tl'>&nbsp;</span>";
  var br="<span class='br'>&nbsp;</span>";
  var bl="<span class='bl'>&nbsp;</span>";
  var targetElems=$(".smooth");
  $(targetElems).each(function(i) {
    var targetElement=$(targetElems[i]);
    if(targetElement.children("span.tr, span.tl, span.br, span.bl").length==0) {
      targetElement.prepend(tl).prepend(tr).append(br).append(bl);
    }
  });
}
function setLinks(){
  var targetContainers=$(".linkified-box, .linkified-heading, .linkified-image, .linkified-multi-box");
  var linkedContainers=new Array();
  $(targetContainers).each(
    function(i){
      var targetContainer=$(targetContainers[i]);
      linkedContainers.push(new linkContainer(targetContainer));
    }
  );
  function linkContainer(targetContainer){
    var sourceLink=$(targetContainer.find("a")[0]);
    if(targetContainer.is(".linkified-box")) {
      var targetElement=targetContainer;
      linkify(targetElement,sourceLink, false);
    }
    if(targetContainer.is(".linkified-multi-box")) {
      var targetElement=targetContainer;
      linkify(targetElement,sourceLink, true);
    }
    if(targetContainer.is(".linkified-heading")){
      var heading=$(targetContainer.find("h1, h2, h3, h4, h5")[0]);
      var targetElement=$("<span></span>").html(heading.html());
      heading.empty();
      heading.append(targetElement);
      linkify(targetElement,sourceLink, false);
    }
    if(targetContainer.is(".linkified-image")){
      var targetElement=$(targetContainer.find("img")[0]);
      linkify(targetElement,sourceLink, false);
    }

function linkify(targetElement,sourceLink, allowMultiple){
  var noChildren=true;
  var allLinks=targetElement.find("a");
  if(allLinks.length>0){
    if(!allowMultiple && (allLinks.length>1 || allLinks[0]!=sourceLink[0])) {
      noChildren=false;
    }
  }
  if(noChildren==true){
    /**
    * Don't re-linkify stuff which is already linkified just in case
    * This may happen after an AJAX callback calls setLinks() again
    **/
    if(targetElement.is('.linkified')) {
      return;
    }
    targetElement.addClass("linkified");
    targetElement.mouseover(function(){targetContainer.addClass("hover");window.status=sourceLink[0];});
    targetElement.mouseout(function(){targetContainer.removeClass("hover");window.status=window.defaultStatus;});
    if(sourceLink[0].onclick) {
      var oldhandler = sourceLink[0].onclick;
      if(sourceLink[0].target+"" != "") {
        targetElement.click(function(){oldhandler(); window.open(sourceLink[0], sourceLink[0].target);});
      } else {
        targetElement.click(function(){oldhandler(); self.location.href=sourceLink[0];});
      }
      sourceLink[0].onclick = function(){return false;};
    } else {
      if(sourceLink[0].target+"" != "") {
        targetElement.click(function(){window.open(sourceLink[0], sourceLink[0].target);});
      } else {
        targetElement.click(function(){self.location.href=sourceLink[0];});
      }
    }
  }
}
}
}

function setLayoutSwitcher(switchArray){
  var switchers = new Array();
  var Switcher = function(switchParams) {
    var jqTarget=$(switchParams.selector);
    var ranges=switchParams.ranges;
    var lastClass="";
    var checkThreshold=function(point) {
      var rangeToApply=null;
      for(var i=0;i<ranges.length;i++){
        var thBegin=0;
        var thEnd=9999999999;
        if(i==0&&ranges[i].th!=0){
          thBegin=ranges[i].th;
        } else if(i+1<ranges.length) {
          thBegin=ranges[i].th;
          thEnd=ranges[i+1].th;
        } else {
          thBegin=ranges[i].th;
        }
        if(point>=thBegin&&point<thEnd) {
          rangeToApply=i;
        }
      }
      if(rangeToApply==null) {
        applyClass("");
      } else {
        if(ranges[rangeToApply].className) {
          applyClass(ranges[rangeToApply].className);
        } else {
          applyClass("");
        }
      }
    }
    var applyClass = function(className) {
      if(lastClass!=className) {
        if(lastClass!="") {
          jqTarget.removeClass(lastClass);
        }
        if(className!="") {
          jqTarget.addClass(className);
        }
        lastClass=className;
      }
    }
    return({checkThreshold:checkThreshold});
  }
  for(var i=0;i<switchArray.length;i++) {
    switchers.push(new Switcher(switchArray[i]));
  }
  $(window).bind('resize',function(){checkWidth(); checkBreadcrumbHeight();});
  checkWidth(); 
  checkBreadcrumbHeight();
  function checkWidth() {
    var bodyWidth=$("body").width();
    for(var i=0;i<switchers.length;i++) {
      switchers[i].checkThreshold(bodyWidth);
    }
  }
}

function setScriptPrefrence(){var linkLocation;containerId=setScriptPrefrence.containerId?setScriptPrefrence.containerId:"site-services";enableText=setScriptPrefrence.enableText?setScriptPrefrence.enableText:"Enable Scripts";disableText=setScriptPrefrence.disableText?setScriptPrefrence.disableText:"Enable Scripts";if($("#"+containerId).length!=0){linkLocation="#"+containerId
var allowScripts;if(readCookie('allowScripts')=='false'){allowScripts=false;}else if(readCookie('allowScripts')=='true'){allowScripts=true;}else{allowScripts=true;createCookie('allowScripts','true',30);}
if($("#scripts-setting").length==0){;var location=window.location.href;var hash=location.indexOf("#");if(hash!=-1){location=location.substring(0,hash);}
if(allowScripts==true){link="<a href='"+location+"' id='scripts-setting'>"+disableText+"</a>";}else{link="<a href='"+location+"' id='scripts-setting'>"+enableText+"</a>";}
if($(linkLocation+" ul").length!=0){$(linkLocation+" ul").slice(0,1).prepend("<li>"+link+"</li>");}else if($(linkLocation+":not(ul)").length==0){$(linkLocation).prepend("<li>"+link+"</li>");}else{$(linkLocation).prepend(link);}
$("#scripts-setting").click(function(){if(readCookie('allowScripts')=='true'){createCookie('allowScripts','false',30);}else if(readCookie('allowScripts')=='false'){createCookie('allowScripts','true',30);}});}
return(allowScripts);}}

// show and hide toggle
$( function showToggle() { 
    var aListOfSubItems = $("div.show-hide ul>li>ul");
    $("div.show-hide ul>li>ul").hide();
    $("div.show-hide>ul>li").each( function () { 
        if ( $(this).find('ul li').length > 0 ) {
        $(this).prepend("<a class='icon expand' href='#'>Expand Category</a>");
        }
    });
    $(".icon").click( function() {
        $(this).toggleClass('collapse')
                .toggleClass('expand')
                .parent().find("ul")
                .slideToggle();
        return false;
	});
});




$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#inner-related-products').hide();

 // toggles the slickbox on clicking the noted link
  $('a#slick-toggle').click(function() {
	$('#inner-related-products').slideToggle();
    $(this).text($(this).text() == 'Hide more related products' ? 'View more related products ' : 'Hide more related products');
	return false;
  });
});


$(document).ready(function() {
  // hides the sign up and login forms as soon as the DOM is ready
  $('#login-form').hide();
  $('#sign-up-form').hide();

  // toggles the slickbox on clicking the noted link
  $('a#toggle-signup').click(function() {
    $('#login-form1').slideUp();
    $('#sign-up-form1').slideToggle();
    $('#login-form').slideUp();
    $('#sign-up-form').slideToggle();
    $(window).scrollTop($('a#toggle-signup').offset().top - 200);
    return false;
  });

  // toggles the slickbox on clicking the noted link
  $('a#toggle-login').click(function() {
    $('#sign-up-form1').slideUp();
    $('#login-form1').slideToggle();
    $('#sign-up-form').slideUp();
    $('#login-form').slideToggle();
    $(window).scrollTop($('a#toggle-login').offset().top - 200);
    return false;
  });
  
  // Put the text in the search input and bind some events {
	  var sSearchText = 'Search for a review...';
	  $('#find').val(sSearchText);
	  $('#find').bind('focus', function() { $(this).val(''); });
	  $('#find').bind('blur', function() {
		  if ($(this).val() == '') {
			  $(this).val(sSearchText);
		  }
	  });
	  
	  $('#inner-search-area .submit-button .submit').bind('click', function() {
		  if ($('#find').val() == sSearchText) {
			  $('#find').val('');
		  }
	  });
  //}
});


// layout Switcher
$(function(){
	// Add corner spans to elements with class .rounded
    setCorners();

    // Linkify boxes with classes .linkified-box, .linkified-heading, .linkified-image"
    setLinks();
    /*
    if($('#switch-off').size() < 1) {
      setLayoutSwitcher([{
      selector:"#main-wrap", ranges:new Array(
         // The default will be no class at 0-500
        {th:0},
        {th:950, className:"switch-one"}
      )},{
        selector:"#outer-wrap", ranges:new Array(
          {th:0}, // Default, although not required (0-300)
          {th:650, className:"switch-two"},
          {th:750, className:"switch-three"},
          {th:900, className:"switch-four"},
          {th:1024, className:"switch-five"}
      )},{
        selector:"#switch-three", ranges:new Array(
          {th:0, className:"layout1"},
          {th:300}, // Default
          {th:500, className:"layout3"}
      )},{
        selector:"#switch-four", ranges:new Array(
          {th:0, className:"layout1"},
          {th:300, className:"layout2"},
          {th:500, className:"layout3"},
          {th:700, className:"layout4"},
          {th:900} // Default
      )}]);
    }*/

	// Add "Disable Scripts" to this UL (or UL container)
    setScriptPrefrence.containerId = "top-nav";
	// Change script preference link text
	//setScriptPrefrence.enableText = "Turn on slide show animation";
	//setScriptPrefrence.disableText = "Turn off slide show animation";
});


$(function(){
	$("#compare-prices .linkified-box").hover(
		  function () {
			$(this).addClass('hover');
			$(".tab-prices").addClass('hover');
		  }, 
		  function () {
			$(this).removeClass('hover');
			$(".tab-prices").removeClass('hover');
		  }
	); 
});


$(function(){
$("#product-rating .submit-button").hover(
  function () {
	$(this).addClass('hover');
	$(".tab-reviews").addClass('hover');
  }, 
  function () {
	$(this).removeClass('hover');
	$(".tab-reviews").removeClass('hover');
  }
); 
});





function accessible_menus(listId) {
	
	function init() {	
		/*
		based on http://www.htmldog.com/articles/suckerfish/dropdowns/
		see also http://www.htmldog.com/ptg/archives/000050.php#comment131
		lines added to workaround for IE not correctly interpreting multiple css classes.
		Conditional comments added to prevent IE<7 showing the select through the menu.
		*/

		/*@cc_on
		/*@if (@ie7 != true)
			var shim = document.createElement('iframe');
			shim.setAttribute('id', 'shim');
			shim.setAttribute('frameBorder','0');
			shim.setAttribute('scrolling','no');
			shim.setAttribute('src','javascript:;');
			//shim.style.display = 'none'; 
			//shim.style.border = '3px solid #f00';
			shim.style.width = '0';
			shim.style.height = '0';
			shim.style.left = '0';
			shim.style.top = '0'; 
			shim.style.zIndex = '90'; 
			shim.style.position = 'absolute'; 
			shim.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
			document.getElementById(listId).appendChild(shim);

			function positionShim(element) {
				var targetElement = null;

				if (element.tagName == "LI" && element.lastChild.tagName == "UL") {
					// LI with nested list, for hover condition
					targetElement = element.lastChild;
				} else if (element.tagName == "A") {
					if (element.parentNode.lastChild.tagName == "UL") {
						// A of a LI with nested list, i.e. keyboard to a top-level link.
						targetElement = element.parentNode.lastChild;
					} else {
						// Sub-nav A, keyboard to a sub-link
						if (element.parentNode.parentNode.getAttribute("id") != listId ) {
							targetElement = element.parentNode.parentNode.parentNode.lastChild;
						}

					}
				}

				if (targetElement) {
					shim.style.width	= targetElement.offsetWidth+"px";
					shim.style.height	= targetElement.offsetHeight+"px";
					shim.style.left		= targetElement.offsetLeft + "px";
					shim.style.top		= targetElement.offsetTop + "px";
					shim.style.display 	= 'block';
				}
			}

			function hideShim(element) {			
				var hideShim = false;

				if (element.tagName == "LI" && element.lastChild.tagName == "UL") {
					// LI with nested list
					hideShim = true;
				} else if (element.tagName == "A") {
					if (element.parentNode.lastChild.tagName == "UL") {
						// A of a LI with nested list
						hideShim = true;
					} else {
						// Sub-nav A
						hideShim = true;
					}
				}

				if (hideShim) {
					shim.style.display='none';
				}
			}
		
		/*@end			
		@*/

		var mcEls = document.getElementById(listId).getElementsByTagName("A");
		for (var i=0; i<mcEls.length; i++) {
			mcEls[i].onfocus = focus;
			mcEls[i].onblur = blur;
		}
		var mcEls = document.getElementById(listId).getElementsByTagName("LI");
		for (var i=0; i<mcEls.length; i++) {
			mcEls[i].onmouseover = function(e) {
				if(!e){if(window.event){e = window.event}}
				this.getElementsByTagName("A")[0].onfocus(e);
			}
			mcEls[i].onmouseout = function(e) {
				if(!e){if(window.event){e = window.event}}
				this.getElementsByTagName("A")[0].onblur(e);
			}
		}

		function focus(e) {			
			if(!e){if(window.event){e = window.event}}

			// Ensure menu displays
			if (e.type == "focus") {this.className += (this.className.length>0? " ": "") + "sffocus";} //a:focus
			function showParents(target) {
				target.parentNode.className += (target.parentNode.className.length>0? " ": "") + "sffocusparent"; //li < a:focus
				if (e.type == "focus") {target.parentNode.parentNode.className += (target.parentNode.parentNode.className.length>0? " ": "") + "sffocusparent";} //ul < li < a:focus

				if(target.parentNode.parentNode.parentNode.nodeName == "LI") { //li < ul < li < a:focus
					showParents(target.parentNode.parentNode)
				}
			}
			showParents(this);		

			fixOverhang(this);

			/*@cc_on
			/*@if (@ie7 != true)
				this.parentNode.className+=(this.parentNode.className.length>0? " ": "") + "sfhover";
				positionShim(this); // add iframe if needed.	
			/*@end			
			@*/
		}		

		function blur(e) {	
			if(!e){if(window.event){e = window.event}}		

			// Ensure menu hides		
			if (e.type == "blur") {this.className = this.className.replace(new RegExp("( ?|^)sffocus\\b"), "");}
			function hideParents(target) {
				target.parentNode.className = target.parentNode.className.replace(new RegExp("( ?|^)sffocusparent\\b"), "");
				if (e.type == "blur") {target.parentNode.parentNode.className = target.parentNode.parentNode.className.replace(new RegExp("( ?|^)sffocusparent\\b"), "");}

				if(target.parentNode.parentNode.parentNode.nodeName == "LI") { //li < ul < li < a:focus
					hideParents(target.parentNode.parentNode)
				}
			}				
			hideParents(this);

			/*@cc_on
			/*@if (@ie7 != true)
				this.parentNode.className=this.parentNode.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
				hideShim(this); // hide iframe if needed.
			/*@end			
			@*/				
		}	

		function fixOverhang(target) {
			var ulContainer = null;

			//Find container
			var mcEls = target.parentNode.childNodes;

			for (var i=0; i<mcEls.length; i++) {
				if (mcEls[i].tagName == "UL") {
					ulContainer = mcEls[i];
				}
			}
			if (!ulContainer && target.parentNode.parentNode.tagName == "UL") {
				ulContainer = target.parentNode.parentNode;
			}

			if (ulContainer) {
				// Incase of text size adjustment
				if(ulContainer.cachedPosition) {
					if (ulContainer.cachedPosition != ulContainer.parentNode.offsetLeft) {
						ulContainer.style.left = "";
					}
				}
				ulContainer.cachedPosition = ulContainer.parentNode.offsetLeft;	
				
				var ulContainerEdge = ulContainer.offsetLeft + ulContainer.offsetWidth;
				var navWidth = document.getElementById(listId).offsetWidth;

				if (ulContainerEdge >= navWidth) {
					ulContainer.style.left = navWidth - ulContainer.offsetWidth + "px";
				} else {
					ulContainer.style.left = "";
				}
			
			}
		}
	}



	// thanks http://www.brothercake.com/site/resources/scripts/onload/
	if(window.addEventListener) {
		 // gecko, safari, konqueror and standard
		 window.addEventListener('load', init, false);
	} else if(document.addEventListener) {
		 // opera 7
		document.addEventListener('load', init, false);
	} else if(window.attachEvent) {
		 // win/ie
		window.attachEvent('onload', init);
	} else {
		// mac/ie5
		if(typeof window.onload == 'function') {
			var existing = onload;
			window.onload = function() {
				existing();
				init();
			}
		} else {
			window.onload = init;
		}
	}	
	
}
accessible_menus("top-nav");
function checkBreadcrumbHeight() {
  var oHeader = document.getElementById('header');
  var oMainWrap = document.getElementById('main-wrap');
  oMainWrap.style.marginTop = oHeader.offsetHeight+(-1)+'px';
}

$(document).ready(function() {
	$(window).bind('resize',function(){checkBreadcrumbHeight();});
	setTimeout(function() {$(window).trigger('resize');}, 10);
});
