/* ------------------------------------------------------------
 * PROJECT        : 
 * FILENAME       : jqload.js
 * ------------------------------------------------------------
 * LAST UPDATED   : 15 Dec 2009
 * ------------------------------------------------------------
 * AUTHOR(S)      : Kevin Scholl (ksscholl@magellanhealth.com)
 * ------------------------------------------------------------
 * NOTE(S)        : 
 * ------------------------------------------------------------ */

$(document).ready(function(){
 
	// adjust margin(s)
  $(""
		+ "div:last-child,"
		+ "fieldset:last-child,"
		+ "form:last-child,"
		+ "img:last-child,"
		+ "li:last-child,"
		+ "ol:last-child,"
		+ "p:last-child,"
		+ "table:last-child,"
		+ "ul:last-child,"
		+ "").css("margin-bottom","0");
	
	$("div.withBorder").parent().find("div.withBorder:first").css("margin-top","10px");
	$("div.withBorder").parent().find("div.withBorder:last").css("margin-bottom","10px");
	
	$("#appbar").css("opacity",".85");

	// rounded corners
	var BG_CORNERS = "#F8F8F8"; // page background color
	$(".errorMsg, .systemMsg, .warningMsg")     .cornerz({background:"" + BG_CORNERS + "", radius:8});
	$("fieldset:not(.tabHeading, .tabPane)")    .cornerz({background:"" + BG_CORNERS + "", radius:8});
	$("fieldset.tabHeading, fieldset.tabPane")  .cornerz({background:"" + BG_CORNERS + "", radius:8, corners:"tr bl br"});

  // data grids and tables
	// alternate row coloring and row/column hover highlighting
	$("table.dataGrid").find("tbody").each(function(){
		$("tr:nth-child(even)").addClass("alt");
		$("tr:last-child").addClass("lastRow");
		});
	$("table.dataGrid tbody, table.sortGrid tbody").each(function(){
		$("tr").hover(
		  function() {$(this).addClass("over"); },
			function() {$(this).removeClass("over"); }
			);
//		if(!IS_IE6_BELOW) {
//			$("td").hover(
//				function() {$(this)
//					.addClass("highlight")
//					.parents("table").find("tbody td:nth-child(" + (this.cellIndex + 1) + ")").addClass("over");},
//				function() {$(this)
//					.removeClass("highlight")
//					.parents("table").find("tbody td:nth-child(" + (this.cellIndex + 1) + ")").removeClass("over");}
//				);
//			}
		});
	$("table.mColGrid tbody").each(function(){
		$("tr:last-child").addClass("lastRow");
		});

  // substitute asterisks for sensitive data
	$(".hideText").each(function(){
		var i = "";
		for (j = 0; j < $(this).text().length; j++) { i = i + "*"; }
		$(this).text(i);
		});

	// form field focus
 	$("input:file, input:password, input:text, select, textarea").not("[readonly]").toggleActive();
 	$("input:text[value*='http']").toggleActive({
	  toggleVal : true
		});

	// position radio buttons and checkboxes
	$("input:radio").addClass("radioBtn");
	$("input:checkbox").addClass("checkBox");

	// application bar help text for icons
	$("a[rel='hasHelpText']")
	  .mouseover(function(){
		  $(this).parent().append("<span class=\"helpText\"><span>&#160;|&#160;</span>" + $(this).attr("title") + "</span>");
			})
		.mouseout(function(){
			$(this).parent().find("span.helpText").remove();
			});

  });