/* ------------------------------------------------------------
 * PROJECT        : Matrix Games
 * FILENAME       : jqload.js
 * ------------------------------------------------------------
 * DATE CREATED   : 14 Sep 2007
 * LAST UPDATED   : 15 Nov 2007
 * ------------------------------------------------------------
 * AUTHOR(S)      : Kevin Scholl (http://www.ksscholl.com/)
 * ------------------------------------------------------------ */
 
/* ------------------------------------------------------------
 * BASIC DECLARATIONS
 * ------------------------------------------------------------ */

$(document).ready(function(){

	// close any popup window when page unloads
	//	$(window).unload(function(){
	//		closePopWin(POPWIN);
	//		});

	// set search field actions
	$("#txtSearch, #txtUserid, #txtPasswd").toggleActive();

	// display the PRINT PAGE link
	$("#actionnav p.datestamp")
	  .prepend("<a href=\"#\" class=\"linkPrint\" onclick=\"window.print(); return false;\">Print Page</a><span>&nbsp; || &nbsp;</span>");

  // remove margin from specified element(s)
  $("p:last-child, ul:last-child, ol:last-child, dl:last-child, dd:last-child").css("marginBottom","0");
	$("div.comingsoon div.item23:nth-child(3n)").css("marginRight","0");
  // remove border from specified element(s)
  $("#mainnav p a:first-child").css("borderLeft","0");		
	$("div.feature5:last-child, div li:last-child").css("borderBottom","0");
	$("div.screenshots ul li:nth-child(4n)").css("borderRight","0").css("borderBottom","2px solid #FFF");
	$("div.grid ul li:nth-child(5n)").css("marginRight","0");
	$("div.features li:last-child").css("borderBottom","1px solid #DDD");

	// alternate background colors for specified element(s)
	$("div.colLeft10 div.item28:nth-child(even)").css("background","#F6F6F6");
	$("div.colLeft10 div.item00:nth-child(even), div.colLeft12 div.item00:nth-child(even), div.grid div.item00:nth-child(even)").css("background","#F6F6F6");
	$("div.features li:nth-child(odd)").css("backgroundColor","#F6F6F6");

	});

/* ------------------------------------------------------------
 * FUNCTIONS
 * ------------------------------------------------------------ */

var CURR_SPECIAL = "";

function displaySpecial(newSpec) {
	if (CURR_SPECIAL == "") {
		$(newSpec).animate({opacity: 'show'},500);
		CURR_SPECIAL = newSpec;
		}
	else {
		$(CURR_SPECIAL).animate({opacity: 'hide'},500);
		if (CURR_SPECIAL != newSpec) {
			$(newSpec).animate({opacity: 'show'},500);
			CURR_SPECIAL = newSpec;			
			}
		else {
			CURR_SPECIAL = "";			
			}
		}
	}

var CURR_CF = "cfAlpha";

function showCoverFlow(cf) {
	if (cf != CURR_CF) {
		$("#" + CURR_CF).hide();
	  $("#" + cf).show();
		CURR_CF = cf;
		}
	}

/* ------------------------------------------------------------
 * JQUERY PLUGINS
 * ------------------------------------------------------------ */

jQuery.fn.toggleActive = function(settings) {
	settings = jQuery.extend({
		focusBG: "#FFF5EA",
		focusFG: "#333",
		blurBG:  "#F6F6F6",
		blurFG:  "#999"
		}, settings);
	this.each(function() {
		$(this)
	  .focus(function() {
			$(this).css({ backgroundColor: settings.focusBG, color: settings.focusFG });
			if (this.value == this.defaultValue) {
				this.value = "";
				}
			})
		.blur(function() {
			$(this).css({ backgroundColor: settings.blurBG, color: settings.blurFG });
			if (this.value == "") {
				this.value = this.defaultValue;
				}
			});
		});
	}

