/**
 * Common Site Scripts
 *
 * A collection of utility functions for general site use
 *
 * @author     Melvin Waller <melvin.waller@gateway.com>
 * @since      2006
 * @version    CVS: $Id: common.js,v 1.13 2008/06/03 17:30:56 mwaller Exp $
 */

if (typeof(YAHOO) == "object") { // sets abbreviations for the YAHOO library
	var Yo=YAHOO, Yu=YAHOO.util, Yd=YAHOO.util.Dom, Ye=YAHOO.util.Event, Yc=YAHOO.widget.Calendar;
	var Ya=YAHOO.util.Anim, Ys=YAHOO.widget.Slider, Yl=YAHOO.util.Color;
}

function altTitle() // USAGE: initialize on page load using an attachEvent action
{ // Copies all image ALT values to a TITLE value to provide equivalent browser functionality
	var d=window.document;
	if (d.images.length > 0) { // test for script support
		for (var i=0; i < d.images.length; i++) { // repeat for all images
			if (d.images[i].alt.length > 0 && d.images[i].alt != " ") {
				d.images[i].title = d.images[i].alt;
			}
		}
	}
	if (d.links.length > 0) { // test for links script support
		for (var i=0; i < d.links.length; i++) { // repeat for all links
			var lnk = d.links[i];
			if (lnk != null && lnk.parentNode.tagName.toLowerCase() == "map") { // imagemap link
				d.links[i].title = d.links[i].alt + (d.links[i].title? d.links[i].title : "");
			}
		}
	}
}
if (Ye) { Ye.addListener(window, "load", altTitle); }


function transformLinkToSubmit(obj_form, txt_field_name)
{ // converts a link name to a hidden field and then submits the form
	var inputElement = document.createElement('input');
	inputElement.setAttribute('name', txt_field_name);
	inputElement.setAttribute('value', '1');
	inputElement.setAttribute('type', 'hidden');
	obj_form.appendChild(inputElement);
	obj_form.submit();
}

function maskPage(start_div, end_div)
{ // masks a section of a page, blocking general access links and forms
	var start=findPos(start_div), end=findPos(end_div);
	var height=end.y-start.y, elem=document.getElementById(start_div);
	if (elem) {
		var new_item = document.createElement("div");
		new_item.className = "loading_layer";
		new_item.id = "loading_layer";
		new_item.style.position = "absolute";
		new_item.style.top = start.y + "px";
		new_item.style.height = height + "px";
		new_item.style.margin = "0px 0px 0px -10px";
		new_item.style.width = "760px";
		new_item.innerHTML = "&nbsp;";
		elem.insertBefore(new_item, elem.firstChild);
	}
}

function findPos(id)
{ // get the x and y coordinates of an object within a document
	var objx, objy, x=0, y=0, t=true, d=document, coord=new Object();
	objx = objy = (d.getElementById)? d.getElementById(id) : (d.all)? d.all[id] : null;
	if (typeof(id) == "object") { objx = objy = id; }
	if (objx == null || !objx.offsetParent) return null;
	while (t) {
		x += objx.offsetLeft;
		if (!objx.offsetParent) t = false;
		objx = objx.offsetParent;
	}
	t = true;
	while (t) {
		y += objy.offsetTop;
		if (!objy.offsetParent) t = false;
		objy = objy.offsetParent;
	}
	coord.x = x;
	coord.y = y;
	return coord;
}

function offsetHeight()
{ // locate vertical window viewing position and height within the document
	var winOffset, winHeight, d=window.document;
	var nn = (navigator.appName.indexOf("Netscape") != -1);

	if (d.documentElement.scrollTop) { winOffset = d.documentElement.scrollTop; }
	else if (d.body.parentNode.scrollTop) { winOffset = d.body.parentNode.scrollTop; }
	else if (d.body.scrollTop) { winOffset = d.body.scrollTop; }
	else if (window.pageYOffset) { winOffset = window.pageYOffset; }
	else if (nn) { winOffset = pageYOffset; }
	else { winOffset = 0; }

	if (d.documentElement.clientHeight) { winHeight = d.documentElement.clientHeight; }
	else if (d.body.parentNode.clientHeight) { winHeight = d.body.parentNode.clientHeight; }
	else if (d.body.clientHeight) { winHeight = d.body.clientHeight; }
	else if (window.innerWidth) { winHeight = window.innerHeight; }
	else if (nn) { winHeight = innerHeight; }

	return new Array(winOffset, winHeight);
}

function vis(ID, state)
{ // object visibility toggle, style visibility
	var d, see;
	state = (state)? state : null;
	if (document.layers) {
		d = document.layers[ID];
		if (state && state === true) { see = "show"; }
		else if (state && state === false) { see = "hide"; }
		else see = (d.visibility == "hide")? "show" : "hide";
		if (see) { d.visibility = see; }
	}
	else {
		d = document.getElementById(ID);
		if (state && state === true) { see = "visible"; }
		else if (state && state === false) { see = "hidden"; }
		if (!state) { see = (d.style.visibility == "hidden")? "visible" : "hidden"; }
		if (see) { d.style.visibility = see; }
	}
}

function showHide(id)
{ // function that hides or shows an element, style display
	if (!document.getElementById) { document.getElementById = function() { return null; } }
	if (id == null || id == "") { return; }
	var tag = document.getElementById(id);
	var icon = id + "_toggle";
	var state = tag.style.display;
	if (tag) {
		if (document[icon].src) {
			tag.style.display = (state == "none")? "inline" : "none";
			document[icon].src = (state == "none")?
			 "/store/img/icon_contract.gif" : "/store/img/icon_expand.gif";
			document[icon].alt = (state == "none")?
			 "Hide Description" : "View Description";
		}
		else { tag.style.display = (state == "none")? "block" : "none"; }
	}
}

function oWindow(Uri, Wth, Hgt, Resize, Scroll, Name, Left, Top, Params)
{ // Fully definable pop-up windows [backwards compatible with openWin]
	Uri = Uri || "/";
	Name = Name || "buttons";
	if (!Params) {
		Wth = (Wth == parseInt(Wth))? Wth : 500;
		Hgt = (Hgt == parseInt(Hgt))? Hgt : 500;
		var Center = oCenter(Wth, Hgt);
		Resize = (Resize == parseInt(Resize))? Resize : 0;
		Scroll = (Scroll == parseInt(Scroll))? Scroll : 1;
		Left = (Left == "center")? Center[0] : (Left == parseInt(Left))? Left : 50;
		Top = (Top == "center")? Center[1] : (Top == parseInt(Top))? Top : 50;
		Params = "toolbar=0,location=0,directories=0,status=0,menubar=0" +
		 ",resizable=" + Resize + ",scrollbars=" + Scroll +
		 ",width=" + Wth + ",height=" + Hgt + ",left=" + Left + ",top=" + Top;
	}
	var Win = window.open(Uri, Name, Params);
	Win.focus();
}
function openWin(Uri, Wth, Hgt, Resize, Scroll) { oWindow(Uri, Wth, Hgt, Resize, Scroll); }
function openWin2(Uri, Wth, Hgt, Resize, Scroll) { oWindow(Uri, Wth, Hgt, Resize, Scroll); }
function openWin3(Uri, Wth, Hgt, Resize, Scroll, Name) { oWindow(Uri, Wth, Hgt, Resize, Scroll, Name); }
function popMS(Uri) 
{ // MDA Pop-Up Window
	var Wth=500, Hgt=500, pct=0.85; // 85% of parent window size
	if (parseInt(navigator.appVersion) > 3) {
		Wth = parseInt(screen.availWidth * pct);
		Hgt  = parseInt(screen.availHeight * pct);
	}
	oWindow(Uri, Wth, Hgt, 1, 1, "Genuine")
	return true;
}
function oCenter(Wth, Hgt)
{ // (left-top) screen center based on the provided object's width and height
	return new Array( (screen.width - Wth) / 2, (((screen.height - Hgt) / 2) - 20) );
}

function PopUpTrackInfo(Uri)
{ // Added for New Order Status
	oWindow(Uri, 500, 500, 1, 1, "TrackInfo", "center", "center");
}

/* makePopup: controls what links open a popup, close a popup, or open a new window
 *
 * Ex: function MYFUNCTIONNAME() { makePopup(TYPE, new Array(a,b,c), METHOD, ACTION, LABEL); }
 *  MYFUNCTIONNAME = name of the function that calls makePopup with the desired parameters
 *  TYPE = identifies the type of page link to change, ex: 'host'= host name, 'page'= page name
 *  new Array(a,b,c) = an array of host/page links to alter (based on href value)
 *  METHOD = the type of new window: 'pop' for popup, 'new' (or empty) for new window
 *  ACTION = if type='pop': 'open' to open window, 'close' (or empty) to close window
 *           if type='new': name of target new window, or '_blank' if not defined
 *  LABEL = name of the target popup window, 'popup' if not defined
 */
function makePopup(type, pages, method, action, label)
{ // USAGE: initialize on page load using an attachEvent action
	var pageref, pagetype, d=document.links;
	label = (label == "" || label == null)? "popup" : label;
	if (d.length > 0) { // links are modifiable
		for (var i=0; i < d.length; i++) { // loop through links
			href = d[i].href;
			pageref = urlSplit(href);
			pagetype = (type == "host")? pageref.host : pageref.page;
			for (var j=0; j < pages.length; j++) { // loop through array of 'pages'
				if (pages[j] == pagetype) {
					if (method == "pop") { // popup window
						if (action == "open") { // window open
							d[i].onclick = "oWindow('" + href + "',600,500,1,0," +
							 label + ",'center','center');return false;";
						}
						else { // window close
							d[i].onclick = "opener.window.location.href='" +
							 opener.window.location.href + "';window.close();return false;";
						}
					}
					else { // new window (method == "new")
						d[i].target = (action)? action : "_blank";
					}
				}
			}
		}
	}
}

function urlSplit(href)
{ // [utility] disassemble a URL (required by makePopup)
	var str, host, page, query;

	str = href.split("?"); // split query from URL
	query = (str.length > 1)? str[1] : ""; // query string

	str = href.split("//"); // split off protocol
	host = (str.length > 1)? true : false; // host specified
	str = (str.length > 1)? str[1] : str;

	str = href.split("/"); // split up path
	host = (host)? str[0] : ""; // host name
	page = (str.length > 1)? str[str.length - 1] : ""; // page name
	page = (page == "" || page == null)? b[b.length - 2] : ""; // directory/host name if no page
	page = (page == null)? "" : page; // no null values

	str.host = host;
	str.page = page;
	str.query = query;
	return str;
}


function testPassword(label,val)
{	
	var result = '';
	if(val.length < 1){
		result = "Please enter "+label+".\n";
	}
	if (val.length < 6 || val.length > 10){
		result += label + " must be 6-10 characters and contain" + 
				 " at least one number and one letter.\n" +
				 "Passwords are case-sensitive.";
	}
	else if (val.match('^[a-zA-Z]+$')){
		result = label + " must also have at least one number.";
	}
	else if (/^\d+$/.test(val)){
		result = label + " must also have at least one letter, upper or lower cased.";
	}
	
	if (result.length > 0) {
		alert(result);
		return false;
	}
	return true;
}

function matchPassword(label1,label2,val1,val2){
	if (val1 != val2) {
		alert(label1+" and "+label2+" fields must match. Please try again.");
		return false;
	}
	return true;
}

/**
 * tTip - Advanced ToolTip
 *
 * USAGE:
 *   MouseOver : tTip.tipRun(event, [message], [follow])
 *   MouseOut  : tTip.tipOff()
 *
 *   event     : a keyword that must be provided
 *  [message]  : message array number to display ('mda' will use item 0 for the MDA tip)
 *  [follow]   : 0 = no follow with 2.5 second delay (default), 1 = follow without a delay
 */
var tTip = new Object(); tTip.Msgs = new Array();

/* --- BEGIN: User Defined Variables --- */
tTip.Follow = true; tTip.offX = 20; tTip.offY = 20; // Mouse properties

// Box properties
tTip.Fnt = "'Arial','Helvetica',sans-serif"; tTip.Wth = 300; tTip.Paddings = 8;
tTip.BgColor = "#fff"; tTip.FntColor = "#333"; tTip.FntSize = "11px";
tTip.BorderW = 1; tTip.BorderS = "ridge"; tTip.BorderC = "#999";

tTip.MDA = "Genuine Windows is authentic Windows software that is properly licensed and legally" +
 " installed. Learn more about the special benefits reserved for genuine Windows customers by" +
 " visiting <a href=\"http://www.microsoft.com/genuine/\">www.microsoft.com/genuine<\/a>.";

// Message Array (IMG, append IMG extras, HTML, BgColor[optional], FntColor[optional])
tTip.Msgs[0] = new Array( // Empty Default Placeholder Message
	"/media/icon_help.gif", "\" alt=\"Information\" width=\"15\" height=\"15\" style=\"margin-right:6px", ""
);
/* --- END: User Defined Variables --- */

// Browser detect, mainly for older browser support
tTip.dom = (document.getElementById)? true : false;
tTip.ns5 = (tTip.dom && (navigator.userAgent.indexOf("Gecko") > -1))? true : false;
tTip.ie5 = (tTip.dom && (navigator.userAgent.indexOf("MSIE") > -1))? true : false;
tTip.op5 = (tTip.dom && (navigator.userAgent.indexOf("Opera") > -1))? true : false;
tTip.ns4 = (!tTip.dom && document.layers)? true : false;
tTip.ie4 = (!tTip.dom && document.all)? true : false;
tTip.noDH = (!tTip.ns4 && !tTip.ns5 && !tTip.ie4 && !tTip.ie5 && !tTip.op5)? true : false;
tTip.origW = 0; tTip.origH = 0; tTip.baloons = false; tTip.imgPth = "";
if (tTip.ns4) {
	tTip.origW = window.innerWidth;
	tTip.origH = window.innerHeight;
	window.onresize = function() {
		if (window.innerWidth != tTip.origW || 
		 window.innerHeight != tTip.origH) { history.go(0); }
	}
}
if (tTip.noDH) { tTip.event = "nope"; }
tTip.OpnStr = "<div style=\"width:" + tTip.Wth + "px; text-align:left\"><img src=\"";
tTip.MidStr = "\" />";
tTip.EndStr = "<\/div>";
tTip.Ok = null;
tTip.tipcss = null;
tTip.t1 = null;
tTip.t2 = null;
tTip.mouseX = 0;
tTip.mouseY = 0;
tTip.tipOn = false; // check if over tTip.Ok link
tTip.tipRun = function(evt, num, tail) {
	tTip.Follow = (!tail || tail == 0)? false : true;
	if (!tTip.Ok) { return; }
	if (tTip.ns5 || tTip.ie4 || tTip.ie5 || tTip.op5) { // ns4 would lose all this on rewrites
		tTip.Ok.className = "";
		tTip.tipcss.width = tTip.Wth + "px";
		tTip.tipcss.height = "auto";
		tTip.tipcss.fontFamily = tTip.Fnt;
		tTip.tipcss.fontSize = tTip.FntSize;
		tTip.tipcss.color = tTip.FntColor;
		tTip.tipcss.background = tTip.BgColor + " none";
		tTip.tipcss.borderColor = tTip.BorderC;
		tTip.tipcss.borderWidth = tTip.BorderW + "px";
		tTip.tipcss.padding = tTip.Paddings + "px";
		tTip.tipcss.borderStyle = tTip.BorderS;
		tTip.Ok.innerHTML = "";
	}
	if (tTip.t1) { clearTimeout(tTip.t1); }
	if (tTip.t2) { clearTimeout(tTip.t2); }
	if (num == "mda") { // activate item 0 as MDA
		tTip.Msgs[0][2] = tTip.MDA;
		num = 0;
	}
	var curBgColor, curFontColor;
	tTip.tipOn = true;
	if (tTip.Msgs[num][3]) { curBgColor = tTip.Msgs[num][3]; }
	else { curBgColor = tTip.BgColor; }
	if (tTip.Msgs[num][4]) { curFontColor = tTip.Msgs[num][4]; }
	else { curFontColor = tTip.FntColor; }
	if (tTip.baloon) {
		tTip.tipcss.backgroundColor = curBgColor;
		tTip.Ok.innerHTML = "<div style=\"width:" + (tTip.Wth + 24) + "px\"><img src=\"" +
		 tTip.imgPth + "tip-tr.gif\" alt=\"\" style=\"float:right\" />" +
		 "<img src=\"" + tTip.imgPth + "tip-tl.gif\" alt=\"\" style=\"float:left\" />" +
		 "<div style=\"background:url('" + tTip.imgPth + "tip-t.gif') repeat-x left top;" +
		 " margin:0px 12px; height:12px\">&nbsp;<\/div><\/div>" +
		 "<div style=\"background:url('" + tTip.imgPth + "tip-l.gif') repeat-y left top;" +
		 " padding-left:12px\"><div style=\"width:" + tTip.Wth + "px; text-align:left; font-family:" +
		 tTip.Fnt + "; font-size:" + tTip.FntSize + "; color:" + curFontColor +
		 "; background: #f0f0f0 url('" + tTip.imgPth + "tip-r.gif') repeat-y right top;" +
		 " padding-right:12px\">" + tTip.Msgs[num][2] + "<\/div><\/div>" +
		 "<div style=\"width:" + (tTip.Wth + 24) + "px\"><img src=\"" + tTip.imgPth +
		 "tip-br.gif\" alt=\"\" style=\"float:right\" />" +
		 "<img src=\"" + tTip.imgPth + "tip-bl.gif\" alt=\"\" style=\"float:left\" />" +
		 "<div style=\"background:url('" + tTip.imgPth + "tip-b.gif') repeat-x left top;" +
		 " margin:0px 12px; height:12px\">&nbsp;<\/div><\/div>" +
		 "<div id=\"tTail\" style=\"position:absolute;" +
		 " width:22px; height:16px; background:url('" + tTip.imgPth +
		 "tip-qtl.gif') no-repeat left top\"></div>";
	}
	else if (tTip.ns4) {
		tTip.Ok.write("<div style=\"background:" + tTip.BorderC + " none; width:" +
		 tTip.Wth + "px; padding:" + tTip.BorderW + "px;\"><div style=\"background:" +
		 curBgColor + " none; padding:" + tTip.Paddings + "px\">" + tTip.OpnStr +
		 tTip.Msgs[num][0] + tTip.Msgs[num][1] + tTip.MidStr + "<br /><span style=\"font-family:" +
		 tTip.Fnt + "; font-size:" + tTip.FntSize + "; color:" + curFontColor +
		 ";\">" + tTip.Msgs[num][2] + "<\/span>" + tTip.EndStr + "<\/div><\/div>");
		tTip.Ok.close();
	}
	else if (tTip.ie4 || tTip.ie5 || tTip.ns5 || tTip.op5) {
		tTip.tipcss.backgroundColor = curBgColor;
		tTip.Ok.innerHTML = tTip.OpnStr + tTip.Msgs[num][0] + tTip.Msgs[num][1] +
		 tTip.MidStr + "<span style=\"font-family:" + tTip.Fnt + "; font-size:" +
		 tTip.FntSize + "; color:" + curFontColor + ";\">" +
		 tTip.Msgs[num][2] + "<\/span>" + tTip.EndStr;
	}
	if (!tTip.Follow) { tTip.positionTip(evt); }
	else { tTip.t1 = setTimeout("tTip.tipcss.visibility='visible'", 100); }
};
tTip.trackMouse = function(evt) {
	if (tTip.Follow == false) { return; }
	tTip.mouseX = (tTip.ns4 || tTip.ns5)? evt.pageX :
	 window.event.clientX + document.body.scrollLeft;
	tTip.mouseY = (tTip.ns4 || tTip.ns5)? evt.pageY :
	 window.event.clientY + (document.body.scrollTop? document.body.scrollTop : 0);
	if (tTip.tipOn) { tTip.positionTip(evt); }
};
tTip.positionTip = function(evt) {
	var tpWd, tpHt, winWd, winHt, offset=offsetHeight();
	if (!tTip.Follow) {
		tTip.mouseX = (tTip.ns4 || tTip.ns5)? evt.pageX :
		 window.event.clientX + document.body.scrollLeft;
		tTip.mouseY = (tTip.ns4 || tTip.ns5)? evt.pageY :
		 offset[0] + window.event.clientY ;
	}
	tpWd = (tTip.ns4)? tTip.Ok.width: (tTip.ie4 || tTip.ie5 || tTip.op5)?
	 tTip.Ok.clientWidth : tTip.Ok.offsetWidth;
	tpHt = (tTip.ns4)? tTip.Ok.height: (tTip.ie4 || tTip.ie5 || tTip.op5)?
	 tTip.Ok.clientHeight : tTip.Ok.offsetHeight;
	winWd = (tTip.ns4 || tTip.ns5)? window.innerWidth - 20 + window.pageXOffset :
	 document.body.clientWidth + document.body.scrollLeft;
	winHt = (tTip.ns4 || tTip.ns5)? window.innerHeight - 20 + window.pageYOffset :
	 offset[0] + offset[1];
	var horz, vert, h, v;
	if (tTip.mouseX + tpWd + (2 * tTip.offX) > winWd) { // to left
		horz = (tTip.mouseX - tpWd - tTip.offX + (tTip.baloon? 10 : 0)) + (tTip.ns4? "" : "px");
		h = "l";
	}
	else { // to right
		horz = (tTip.mouseX + tTip.offX - (tTip.baloon? 30 : 0)) + (tTip.ns4? "" : "px");
		h = "r";
	}
	if (tTip.mouseY + tpHt + (2 * tTip.offY) > winHt) { // to top
		vert = ((tTip.ie5? offset[0] : 0) + tTip.mouseY - tpHt - tTip.offY) + (tTip.ns4? "" : "px");
		v = "t";
	}
	else { // to bottom
		vert = ((tTip.ie5? offset[0] : 0) + tTip.mouseY + tTip.offY) + (tTip.ns4? "" : "px");
		v = "b";
	}
	tTip.tipcss.left = horz;
	tTip.tipcss.top = vert;
	var tTail = document.getElementById("tTail");
	if (tTail) {
		tTail.style.backgroundImage = "url('" + tTip.imgPth + "tip-q" + v + h + ".gif')";
		tTail.style.left = ((h == "l")? (tTip.Wth - 40) : 40) + "px";
		if (v == "t") { tTail.style.top = ""; tTail.style.bottom = "0px"; }
		else { tTail.style.bottom = ""; tTail.style.top = "0px"; }
	}
	if (!tTip.Follow) { tTip.t1 = setTimeout("tTip.tipcss.visibility='visible'", 500); }
};
tTip.tipOff = function() {
	if (!tTip.Ok) { return; }
	tTip.t2 = setTimeout("tTip.blank();", (tTip.Follow == false)? 2500 : 100);
	tTip.tipOn = false;
};
tTip.blank = function() {
	if (tTip.Ok && (tTip.ns5 || tTip.ie4 || tTip.ie5 || tTip.op5)) { // ns4 would lose all this on rewrites
		tTip.Ok.innerHTML = "";
	}
	if (tTip.Ok && tTip.Follow && tTip.ns4) {
		tTip.Ok.write("");
		tTip.Ok.close();
	}
	tTip.tipcss.visibility="hidden";
};
tTip.initTip = function() {
	if (tTip.noDH) { return; }
	tTip.Ok = (tTip.ns4)? document.tipDiv.document : (tTip.ie4)? document.all["tipDiv"] :
	 (tTip.ns5 || tTip.ie5 || tTip.op5)? document.getElementById("tipDiv") : null;
	if (tTip.Ok) { tTip.tipcss = (tTip.ns4)? document.tipDiv : tTip.Ok.style; }
	if (tTip.Ok && tTip.Follow) {
		if (tTip.ns4) { document.captureEvents(Event.MOUSEMOVE); }
		document.onmousemove = tTip.trackMouse;
	}
};
if (Ye) { Ye.addListener(window, "load", tTip.initTip); }

function viewTip(event, thisId)
{ // Opens the ToolTip to display the product description
	var nam = Yd.get(thisId).innerHTML;
	var dsc = Yd.get("d_" + thisId).innerHTML;
	if (dsc.length > 0) {
		if (tTip.baloon) { tTip.Msgs[0][2] = dsc; }
		else { tTip.Msgs[0][2] = "<big><strong>" + nam + "</strong></big><br />" + dsc; }
		tTip.tipRun(event, 0, 1);
	}
}

function hideTip(thisId)
{ // Closes the ToolTip
	tTip.tipOff();
}

function ltrim(val)
{ // Removes leading whitespace
	var re = /\s*((\S+\s*)*)/;
	return (val && val.length != 0)? val.replace(re, "$1") : "";
}

function rtrim(val)
{ // Removes trailing whitespace
	var re = /((\s*\S+)*)\s*/;
	return (val && val.length != 0)? val.replace(re, "$1") : "";
}

function trim(val)
{ // Removes leading and trailing whitespace
	return (val && val.length != 0)? ltrim(rtrim(val)) : "";
}

function checkKeyCode(e, type)
{
	var keycode = (window.event)? window.event.keyCode : e.which;
	var element = (window.event)? window.event.srcElement : e.target;
	var regex = "";
	switch (type) {
		case "digit":
			regex = /\d/;
			break;
		case "float":
			regex = (element.value && element.value != "" && element.value.search(/\./) != -1)? /\d/ : /[0-9.]/;
			break;
		default:
			return true;
	}

	// on FireFox keycode 8 = (backspace), 0 = (tab)
	return (regex.test(String.fromCharCode(keycode)) || keycode == 8 || keycode == 0);
}

function tableStripe(id, start, stop, cssclass)
{ // Zebra: Colors alternating rows automatically in tables and lists
	var i, obj=document.getElementById(id);
	start = (start)? Math.abs(parseInt(start)) : 0; // rows from top to start striping, positive integer
	stop = (stop)? Math.abs(parseInt(stop)) : 0; // rows from end stop striping, positive integer
	cssclass = (cssclass)? cssclass : "BgBlLhtGry"; // CSS class to use for striping, default to light grey
	if (!obj) { return; }
	var row = obj.getElementsByTagName("tr");
	for (i=start; i < row.length - stop; i+=2) { row[i].className += " " + cssclass; }
}
