// JavaScript Document

$(function(){ 
	//Get the root url to be used in javascript
	setSiteInfo();

	/******************
	* Global actions for html tags
	******************/
	//links the don't want to be redirected because it will execute a script instead.
	$("a[stopLink]").click(function(e){
		stopDefault(e);
	});
	
	//Initialize the homepage style accordion.
	//If not using that style then nothing will happen.;
	$("#accordion-options").accordion(); 
	
	//Adjust the body content and footer image so that the fadding effects of the footer matches the location of 
	//Where the body of the content ends.
	var staticPages = new Array("index.jsp"); //Pages that are static and doesn't need footer to be adjusted.
	var curPage = location.href;
	var matchPage = false;
	//Loop through the static pages to see if the currpage page match.
	for(x=0; x<staticPages.length; x++) {
		if (curPage.indexOf(staticPages[x])>=0) {
			$("#contentBtm").attr("src", "/images/global/content_box_btm_5.jpg");
			matchPage = true;
			break;				
		} 
	}//for(x=0; x<statpages.length; x++) {
	//If there are no match page, then auto adjust the body for dynamic content.
	if (!matchPage) {
		setTimeout("adjustBodyManual()",500);
	}
	
	
	//This browser detection is apply a ie6 fix to the format of the accordion navigation.
	$.each(jQuery.browser, function(i, val) {
		if(i=="msie" && val && jQuery.browser.version.substr(0,1)<"7") {
			$(".ieFix").css("marginTop","6px");
		}
	});
	
	$("input").change(function() {
		setFormChanged();
	});
	
	$("select").change(function() {
		setFormChanged();
	});
	
	//Pop up info msg elements
	$(".moreInfoLink").click(function()	{			
		showMoreInfo(this);
	});
	
	//Pop up info msg elements
	$(".moreInfoLinkLg").click(function()	{			
		showMoreInfo(this);
	});
	//Set the image for the moreInfoLInks
	$(".moreInfoLink").attr("src", "/images/global/icons/Help12px.gif" );
	$(".moreInfoLinkLg").attr("src", "/images/global/icons/Help16px.gif" );
	
	
	//Set div corners.
	setDivCorners();

	
	//Toggle the tobleBox fields that are related for select options
	//Required spearation because IE detect events differently.
	$("select[toggleBox=1]").change(function(){
		toggleOptionalFieldsCheckbox(this);
	});
	//Toggle the tobbleBox fields that are related for checkboxes
	//Required spearation because IE detect events differently.
	$(":checkbox[toggleBox=1]").click(function(){
		toggleOptionalFieldsCheckbox(this);
	});
		
	
});