$(document).ready(
	function() {
		/*
		// set the functionality of the Access My Account
		// on focus, if the value is Enter Username, set it to empty
		$("#userid").focus(
			function() {
				if($(this).val() == "Enter Username") {
					$(this).val("");
				}
			}
		);
		// on blur, if the value is empty, set it to Enter Username
		$("#userid").blur(
			function() {
				if($(this).val() == "" || $(this).val() == " ") {
					$(this).val("Enter Username");
				}
			}
		);
	
		// set the functionality of the Pay your Bill
		// on focus, if the value is Enter Username, set it to empty
		$("#txt_username1").focus(
			function() {
				if($(this).val() == "Enter Username") {
					$(this).val("");
				}
			}
		);
		// on blur, if the value is empty, set it to Enter Username
		$("#txt_username1").blur(
			function() {
				if($(this).val() == "" || $(this).val() == " ") {
					$(this).val("Enter Username");
				}
			}
		);
		$("#txt_password1").focus(
			function() {
				if($(this).val() == "Enter Password") {
					$(this).val("");
				}
			}
		);
		// on blur, if the value is empty, set it to Enter Password
		$("#txt_password1").blur(
			function() {
				if($(this).val() == "" || $(this).val() == " ") {
					$(this).val("Enter Password");
				}
			}
		);
		*/
		
		// set the functionality of the Featured Articles
		// where are the images stored
		var imgPath = "/_res/images/home/";
		// set the active Featured Article
		featureActive = 0;
		// how many Featured Articles are there
		featureLen = $("#content-feature li").size() - 1;
		
		// because IE doesn't recognize psuedo classes
		if($.browser.msie && $.browser.version < 7) { 
			$("#content-feature li:first-child").show();
		}
		
		// if there are more than 1 Featured Articles
		if(featureLen > 0) {
			// add a navigation DIV
			$("#content-feature").append("<div id='feature-nav'></div>");
			// add a previous button
			$("#feature-nav").append("<a><img src='" + imgPath + "prev.gif' alt='' id='feature-prev' /></a>");
			// for each Featured Article add an indicator box
			$("#content-feature li").each(
				function(i) {
					// give a unique id to each LI to know which to hide/show
					$(this).attr("id", "feature" + i);
					// for the first Article, add an ON box, for all others, add an OFF box
					if(i == 0) {
						$("#feature-nav").append("<img src='" + imgPath + "box-on.gif' alt='' id='feature-box" + i + "' class='feature-box' />");
					}
					else {
						$("#feature-nav").append("<img src='" + imgPath + "box-off.gif' alt='' id='feature-box" + i + "' class='feature-box' />");
					}
				}
			);
			// add a next button
			$("#feature-nav").append("<a><img src='" + imgPath + "next.gif' alt='' id='feature-next' /></a>");
			
			// now that the images have been added to the page, lets make them functional
			$("img.feature-box").click(
				function() {
					// stop the rotating
					clearTimeout(featureTimer);
					
					$("#feature" + featureActive).fadeOut();
					
					$("#feature-box" + featureActive).attr("src", $("#feature-box" + featureActive).attr("src").replace("-on", "-off"));
					
					featureActive = $(this).attr("id").substring(11, 12);
					
					// change the indicator box for the NEW active Article
					$("#feature-box" + featureActive).attr("src", $("#feature-box" + featureActive).attr("src").replace("-off", "-on"));
					
					$("#feature" + featureActive).fadeIn();
				}
			);
			
			
			// add the "Next Article" functionality
			$("#feature-next").click(
				function() {
					// stop the rotating
					clearTimeout(featureTimer);
					
					// hide the active Article
					$("#feature" + featureActive).fadeOut();
					// change the indicator box for the active Article
					$("#feature-box" + featureActive).attr("src", $("#feature-box" + featureActive).attr("src").replace("-on", "-off"));
					
					// if we aren't on the last Featured Artice
					if(featureActive < featureLen) {
						// increment the Freatured Article by one
						featureActive++;
					}
					else {
						// set it back to the beginning
						featureActive = 0;
					}
					
					// change the indicator box for the NEW active Article
					$("#feature-box" + featureActive).attr("src", $("#feature-box" + featureActive).attr("src").replace("-off", "-on"));
					// show the NEW active Article
					$("#feature" + featureActive).fadeIn();
				}
			);
			// add the "Previous Article" functionality
			$("#feature-prev").click(
				function() {
					// stop the rotating
					clearTimeout(featureTimer);
					
					// hide the active Article
					$("#feature" + featureActive).fadeOut();
					// change the indicator box for the active Article
					$("#feature-box" + featureActive).attr("src", $("#feature-box" + featureActive).attr("src").replace("-on", "-off"));
						
					// if we aren't on the first Featured Artice
					if(featureActive > 0) {
						// decrease the Freatured Article by one
						featureActive--;
					}
					else {
						// set it to the last one
						featureActive = featureLen;
					}
					
					// change the indicator box for the NEW active Article
					$("#feature-box" + featureActive).attr("src", $("#feature-box" + featureActive).attr("src").replace("-off", "-on"));
					// show the NEW active Article
					$("#feature" + featureActive).fadeIn();
				}
			);
			
			
			var featureTimer;
			function timedCount() {
				$("#feature-next").click();
				featureTimer = setTimeout(function() {timedCount();}, 5000);
			}
			featureTimer = setTimeout(function() {timedCount();}, 5000);
		}
		
		// fix heights of three top homepage columns
		// get the height of all DIVs
		var hpcol_heights=Array();
			hpcol_heights.push($('#content-feature').height());
			hpcol_heights.push($('#content-alerts').height());
			hpcol_heights.push($('#content-service').height());
		var hpcol_max=1;
		
		// find the tallest item of these DIVs
		for(var hts=1; hts<hpcol_heights.length; hts++){
			if(hpcol_heights[hts]>hpcol_max){
				hpcol_max=hpcol_heights[hts];
		}
	}
		
		// now apply that height to the DIVs
		$('#content-feature').height(hpcol_max);
		$('#content-feature ul').height(hpcol_max-21);
		$('div.storm-warning').height(hpcol_max-3);
		$('div.storm-warning ul').height(hpcol_max-7);
		$('#content-alerts p').height(hpcol_max-133);
		$('#content-service form.expander').height(hpcol_max-($('#content-service').height()-$('form.expander').height()-1));
	}
);