 var blank = new Image();
 blank.src = '/images/blank.gif';
	menuOpen = false;
function openAnsBox(popup) {
	//alert(menuOpen);
	if (!menuOpen) {
		var num;
		for (var i =0; i < ansboxes.length; i++) {
   			if (menuTimers[i]) clearTimeout(menuTimers[i]);
			//alert ("popup is " + popup);
			//alert (ansboxes[i]);
			if (ansboxes[i] == popup) {
				//alert(ansboxes[i]);
				num = i;
				$(popup).fadeIn('fast');
			} else {
				$(ansboxes[i]).hide();
			}
		} 
	}
	menuOpen = true;
}
function closeAnsBox(popup) {
	//alert (ansboxes.length);
	var num;
	for (var i =0; i < ansboxes.length; i++) {
   		if (menuTimers[i]) clearTimeout(menuTimers[i]);
		if (ansboxes[i] == popup) {
			num = i;
			menuTimers[i] = setTimeout("$('" + popup + "').hide();",500);
		} 
	} 
	menuOpen = false;
}
var ansboxes = new Array("#collections-sub", "#videos-sub", "#stores-sub", "#press-sub", "#bio-sub");

var menuTimers = new Array(ansboxes.length);

$(document).ready(function(){
   var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   $(".button").mouseleave(function(){
      closeAnsBox("#" + $(this).attr('name') + "-sub");
     // $("#" + $(this).attr('name') + "-sub").fadeOut();
      $(this).css("background-color", "transparent");
      $(this).attr('src', "/images/" + $(this).attr('name') + "-off.png");
      if (badBrowser) {
        fixPng(this);
      }
    })
    $(".button").mouseover(function(){
      openAnsBox("#" + $(this).attr('name') + "-sub");
      $(this).css("background-color", "#000");
      $(this).attr('src', "/images/" + $(this).attr('name') + "-on.png");
      if (badBrowser) {
        fixPng(this);
      }
    });
   $(".button-on").mouseleave(function(){
      closeAnsBox("#" + $(this).attr('name') + "-sub");
      $(this).css("background-color", "#000");
      $(this).attr('src', "/images/" + $(this).attr('name') + "-on.png");
      if (badBrowser) {
        fixPng(this);
      }
    })
    $(".button-on").mouseover(function(){
      openAnsBox("#" + $(this).attr('name') + "-sub");
      $(this).css("background-color", "transparent");
      $(this).attr('src', "/images/" + $(this).attr('name') + "-off.png");
      if (badBrowser) {
        fixPng(this);
      }
    });
   if (badBrowser) {
     // get all pngs on page
     $('img[src$=.png]').each(function() {
       if (!this.complete) {
         this.onload = function() { fixPng(this) };
       } else {
         fixPng(this);
       }
     });
   }
  $(".button-sub").mouseover(function(){
      openAnsBox('#' + $(this).parent().attr('id'));
    //$("#testy").text($(this).parent().attr('id'));
  })
  $(".button-sub").mouseleave(function(){
      closeAnsBox('#' + $(this).parent().attr('id'));
    //$("#testy").text($(this).parent().attr('id'));
  })

  // stop buttons with submenus from going to new page when clicked  also turns of hand cursor if there is no link
  $('#collections-link,#videos-link,#press-link,#stores-link').each(function(item) {
    $(this).css('cursor', 'default');
    $(this).bind('click',function(event) {
      event.preventDefault();
    });
  });

});


 function fixPng(png) {
   // get src
   var src = png.src;
   // set width and height
   if (!png.style.width) { png.style.width = $(png).width(); }
   if (!png.style.height) { png.style.height = $(png).height(); }
   // replace by blank image
   png.onload = function() { };
   png.src = blank.src;
   // set filter (display original image)
   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }


b1 = new Image();
b1.src = '/images/collections-on.png';
b2 = new Image();
b2.src = '/images/videos-on.png';
b3 = new Image();
b3.src = '/images/advertising-on.png';
b4 = new Image();
b4.src = '/images/events-on.png';
b5 = new Image();
b5.src = '/images/press-on.png';
b6 = new Image();
b6.src = '/images/bio-on.png';
b7 = new Image();
b7.src = '/images/stores-on.png';
b8 = new Image();
b8.src = '/images/contact-on.png';

