// This helps the top menu to function properly in IE

navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);

// jquery image preload plugin...

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

// ... and the actual preloading

$.preloadImages("http://www.syntaxis.com/images/syn-gui/btn-submit_over.gif", "http://www.syntaxis.com/images/syn-gui/btn-quiz_over.gif");

// jquery for books pop-up elements

$(document).ready(function(){
$("a.reveal").click(function () {	// to show-hide the book details
	$(this).parent("span.more").parent("span.pipeLeft").prev("span").parent("p.subinfo").next("div.popDetails").toggle();	// traversing to find the hidden span    
	return false;	// to keep the page from bouncing to top on click
	});
$("body").click(function () {	// to hide details when clicking anywhere on page
	$(".popDetails").hide();        
	});
	
$("a.discount").click(function () {	// to show-hide the volume discount info
	$(this).parent("p.price").next("div.popDiscounts").toggle();	 
	return false;
	});
$("body").click(function () {$(".popDiscounts").hide();});

$("a.help").click(function () {	// to show-hide the account question box
	$(this).parent(".loginBlock").next("div.popAccounts").toggle();	    
	return false;	
	});
$("body").click(function () {$(".popAccounts").hide();});
});

// rollover effect on submit buttons

$(document).ready(function(){
	$("input.btnSubmit").hover(
		function() {$(this).attr("src","http://www.syntaxis.com/images/syn-gui/btn-submit_over.gif");}, 
		function() {$(this).attr("src","http://www.syntaxis.com/images/syn-gui/btn-submit.gif");}
	);
});

// rollover effect for quiz button

$(document).ready(function(){
	$("input.btnQuiz").hover(
		function() {$(this).attr("src","http://www.syntaxis.com/images/syn-gui/btn-quiz_over.gif");}, 
		function() {$(this).attr("src","http://www.syntaxis.com/images/syn-gui/btn-quiz.gif");}
	);
});

// image swap for Bean's native elements

function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  /*
    WM_imageSwap()
	Changes the source of an image. Source: Webmonkey Code Library
    Usage: WM_imageSwap(originalImage, 'newSourceUrl');
    Requires: WM_preloadImages() (optional, but recommended)
  */

  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}