/* ------------------------------------------------------------
 * PROJECT        : Provider Synergies
 * FILENAME       : jqload.js
 * ------------------------------------------------------------
 * DATE CREATED   : 06 June 2008
 * LAST UPDATED   : 27 June 2008
 * ------------------------------------------------------------
 * AUTHOR(S)      : Kevin Scholl (ksscholl@cvty.com)
 * ------------------------------------------------------------ */
 
/* ------------------------------------------------------------
 * BASIC DECLARATIONS
 * ------------------------------------------------------------ */

$(document).ready(function(){

  /* $("a#overview").css("border-bottom","1px solid #066").css("background-position","-160px 0"); */

  $(""
		+ "div:last-child,"
		+ "img:last-child,"
		+ "ol:last-child,"
		+ "p:last-child,"
		+ "ul:last-child,"
		+ "").css("margin-bottom","0");

	$("#txtSearch").toggleActive({
		toggleVal :  true
	  });

  $("body.overview").find("a#overview").css({
	  borderBottom: '1px solid #066', 
		backgroundPosition: '-160px 0'
		}).addClass("current");
  $("body.services").find("a#services").css({
	  borderBottom: '1px solid #066', 
		backgroundPosition: '-160px 0'
		}).addClass("current");
  $("body.company").find("a#company").css({
	  borderBottom: '1px solid #066', 
		backgroundPosition: '-160px 0'
		}).addClass("current");
  $("body.contact").find("a#contact").css({
	  borderBottom: '1px solid #066', 
		backgroundPosition: '-160px 0'
		}).addClass("current");

  $("div#mainNav").find("a").not(".current")
	  .mouseover(function() {
			$(this).css("backgroundPosition","-80px 0");
			})
	  .mouseout(function() {
			$(this).css("backgroundPosition","0 0");
			})

	// datatable
	$("table.dataTable tbody").each(function(){
		$("tr:nth-child(even)").addClass("alt");
		$("tr:last-child").addClass("lastRow");
		$("tr").hover(
		  function() {$(this).addClass("over"); },
			function() {$(this).removeClass("over"); }
			);
		});

	});

/* ------------------------------------------------------------
 * JQUERY PLUGINS
 * ------------------------------------------------------------ */

// toggle default value and coloring on form field focus/blur
// usage: $("#elementID").toggleActive(settings);
jQuery.fn.toggleActive = function(settings) {
	settings = jQuery.extend({
		focusBG   : "#FFF",
		focusFG   : "#333",
		blurBG    : "#FFF",
		blurFG    : "#999",
		toggleVal :  false
		}, settings);
	this.each(function() {
		$(this)
			.focus(function() {
				$(this).css({ backgroundColor: settings.focusBG, color: settings.focusFG });
				if (settings.toggleVal == true && this.value == this.defaultValue && this.value != "http://") {
					this.value = "";
					}
				})
			.blur(function() {
				$(this).css({ backgroundColor: settings.blurBG, color: settings.blurFG });
				if (settings.toggleVal == true && this.value == "") {
					this.value = this.defaultValue;
					}
				});
		});
	};
