if(typeof(window.jQuery) != "undefined"){  //check that jQ is installed
	$(document).ready(function(){
		var activeImage;
		
		//Zebra stripe tables
		//$(".ZebraStripe tr:odd td").not(".ChromeHeader").each(function(){
		//	alert($(this).attr("class"));
		//}); //.css("background-color", "#eeeeee");
		
		$(".ZebraStripe tr:nth-child(even) td").each(function(){
			if(!$(this).parent().hasClass("NoZebraStripe") && !$(this).parents().hasClass("ChromeHeader") && !$(this).hasClass("RowTitle")){
				$(this).css("background-color", "#fafafa");
			}
		});
	
		//Load language
		lExt = (GetLanguage() == "en") ? "" : "-" + GetLanguage();

		$("td[class^='mTop']").click(function(){
			theurl = $(this).children("a").attr("href");
			location.href = theurl;
		}).hover(
			function(){
				currImg = $(this).css("background-image");
				if(currImg.indexOf("_" + lExt + ".jpg") < 0){
					newImg = currImg.replace(lExt + ".jpg", "_" + lExt + ".jpg");
					$(this).css("background-image", newImg);
				}else{
					activeImage = $(this).css("background-image");
				}
				$(this).css("cursor", "hand");
			},
			function(){
				currImg = $(this).css("background-image");
				if($(this).css("background-image") !== activeImage){
					newImg = currImg.replace("_" + lExt + ".jpg", lExt + ".jpg");
					$(this).css("background-image", newImg);
				}
				$(this).css("cursor", "arrow");
			}			
		);
		
		//Left nav links
		$("td[class^='MenuLeft']").click(function(){
			theurl = $(this).children("a").attr("href");
			location.href = theurl;
		}).hover(
			function(){
				$(this).css("cursor", "hand");
			},
			function(){
				$(this).css("cursor", "arrow");
			}			
		);
	
		//Textbox styles & behaviors
		$("input:not(:button),textarea").focus(function(){
			$(this).addClass("activeInput");
		});
		$("input:not(:button),textarea").blur(function(){
			$(this).removeClass("activeInput");
		});
		
		//Select menu styles & behaviors
		/*$("select:not('.noHighlight')").wrap("<span></span>");
		//$("select:not('.noHighlight')").parent('span').addClass("inactiveSelectParent");
		$("select:not('.noHighlight')").focus(function(){
			$(this).parent('span').toggleClass("activeSelectParent");
			//$(this).parent('span').addClass("activeSelectParent");
			//$(this).addClass("activeSelect");
			//$(this).click();
		});
		$("select:not('.noHighlight')").blur(function(){
			$(this).parent('span').removeClass("activeSelectParent");
			$(this).removeClass("activeSelect");
		});*/
		
		//Button styles & behaviors
		$(":button, :submit, :reset").each(function(i){
			if(!$(this).hasClass("inputButton")){
				$(this).removeClass("StandardButton");
				$(this).addClass("inputButton inputButtonT");
				$(this).hover(
					function(){
						$(this).removeClass("inputButton inputButtonT");
						$(this).addClass("inputButton1 inputButtonT1");
					},
					function(){
						$(this).removeClass("inputButton1 inputButtonT1");
						$(this).addClass("inputButton inputButtonT");
					}
				);
			}
		});
		
		//Did you know box
		$(".DYKbox").corner();
		
		//$(".headerLang").corner("sc:#CC8822 bottom 4px");
		
		//Language action
		$("#iptSetLanguage").change(function(i){
			seturl = "/setlanguage.asp?lang=" + $(this).val() + "&ref=" + location.href;
			location.href = seturl;
		});
		
		//Debug messages
		var wasClk;
		var numDebug = $(".debugMessage").length;
		if(numDebug > 0){
			$("#debugTab").css("display", "inline").append("Debug (" + numDebug + ")");
			$("#debugTab").click(function(){
				if(wasClk != true){
					$(".debugMessage").each(function(i){
						$(this).appendTo("#debugContainer").prepend(i+1 + ". ");
						$(this).css("display", "block");
					});
				}
				wasClk = true;
				
				if($("#debugContainer").is(":hidden")){
					$("#debugContainer").slideDown("fast", function(){
						var scrTop = $("#debugContainer").offset();
						$("body").animate({ scrollTop: scrTop.top + "px" }, 1500);
					});
				}
				else{
					$("#debugContainer").slideUp("slow");
				}
			});
		}
				
	});
}