// this is a placeholder to replace the stuff that comes from the mola_jq command, which is deprecated!
// from here... standards/mola_0.9.7/mola_jquery_base.js?v=3 to this

var ie6=($.browser.msie && !window.XMLHttpRequest);	//a global hack test for IE...
var hConstraints=[];
minHeightFix=function(target,constraints,padding) {
	//alert("enacting minHeightFix"); // this prevents the existing fix from causing us problems...
	//alert("passed in "+constraints.length);
	if (ie6) {
		if(!$("#minheightfix").length){
			target.append("<div id='minheightfix'></div>");	
		}
		$("#minheightfix").height(0);
	} 	
	var targetH=target.height();
	var tallest=0;
	for(i=0;i<constraints.length;i++) {
		if (constraints[i]>tallest) {
			tallest=constraints[i];
		}
	}
	tallest+=padding;
	//alert("content ="+targetH+"; "+"tallest = "+tallest+ " differential="+(tallest-targetH>0?tallest-targetH:0));
	target.css("min-height",(tallest)).css("height","auto"); // go ahead and set it just in case
	//alert("after set min-height: "+target.css("min-height"));
	if (ie6) {  // need min-height detection!
		$("#minheightfix").height(tallest-targetH>0?tallest-targetH:0);
	} 	
}



$(function() {
	if($.browser.msie && ($.browser.version == 6 || $.browser.version==7)) {
		$("#sidebarBox").css("z-index","-1");
		if($.browser.version == 6) {
			$("#disclaimer").css("top","-100px").css("right","-50px").css("border-right","4px solid black");
		}
	}	
	
	$("#areaMenu:visible a[href='"+molajsURL+"']").each(function() {
		var c=$(this).prepend($.browser.msie?"&gt;":"&#x25B6;").removeAttr("href").html();
		$(this).replaceWith("<span class='thisPage'>"+c+"</span>");
	});	
	
    $(".jqZebra tr:nth-child(odd)").addClass("jqOdd");
    $(".jqZebra tr:nth-child(even)").addClass("jqEven");
	$("#jqSupport").hide();
    $("#formLoading").hide();	
	
	$("#search").submit(function(){
		if($.trim($("#q").val())=="catalog") {
		 	$("#q").val("catalogue");
		}
	});		
	
	$(".alertBox").wrapInner("<div></div>").prepend("<div></div>").append("<div></div>");
	$(".alertBox div").eq(0).addClass("alertPre");
	$(".alertBox div").eq(1).addClass("alertBody");
	$(".alertBox div").eq(2).addClass("alertPost");	
	
	$("#content").children().slice(0,1).css("margin-top","0"); // only works on sigletons, not compounds...
	// 36 is the current height of "#exploreBox" ... hardcoded here; only changes if template changes
	hConstraints=[$("#areaMenu").height()+36, $("#siteMenu").height()+36, $("#sidebarBox").height()];
	minHeightFix($("#content"),hConstraints,30);
	$("#sidebarBox form").css("margin-top","0"); //IE fix.
	$("#exploreBox a").click(function() {

		if($(this).attr("rel")=="closed") {
			$("#areaMenu").hide(100,function() {
				$("#siteMenu").show(200);
			});  // should work, but throws error!
			//$("#areaMenu").hide();$("#siteMenu").show();
			//console.log('clicked');
			$(this).parent().css("background-image","url(/d/img/exploreOpen.gif)");
			$(this).attr("rel","open");
			$(this).attr("title","click to hide Centenary site menu");
		} else {
			$("#siteMenu").hide(100, function() {
				$("#areaMenu").show(200);
			});
			//$("#siteMenu").hide();$("#areaMenu").show();
			$(this).parent().css("background-image","url(/d/img/exploreClosed.gif)");
			$(this).attr("title","click to show Centenary site menu");
			$(this).attr("rel","closed");
		}
		return false; // this should prevent anchor load in firefox ...// 
	});
});
	
