var IE = (document.all) ?true:false;

var NS6 = (document.getElementById) ?true:false;

function setBlockDisplay(id,display_type)
{
	_getElement(id).style.display = display_type;
}

function _getElement(id)
{
	if (document.getElementById && document.getElementById(id)) {
		return document.getElementById(id);
	}
	else if (document.all && document.all[id]) {
		return document.all[id];
	}
	else {
		return false;
	}
}

function showHideContent(id,show,txtLinkId,txtShow,txtHide)
// if txtLinkId is given, it is the css id of the text link to toggle between 'txtShow' and 'txtHide' values
// if id is an array (typeof=object), then apply the show/hide to each DIV id in that array
{
	//  var elem = document.getElementById(id);
	var txtElem = _getElement(txtLinkId);
	var idArr = new Array();

	/* build array of ids to process - if parm 'id' is object, then extract ids from it, if part is string, just add it */
	if (typeof(id)=='object') {
		for(var no=0;no<id.length;no++) {
			idArr[idArr.length]=id[no];
		}
	} else {
		idArr[idArr.length]=id;
	}

	for(var no=0;no<idArr.length;no++) {
		var elem = _getElement(idArr[no]);
		if (elem)
		{
			if (show == 'toggle')
			{
				if (elem.style.display == 'none' || elem.style.display=='' ) {
					//elem.style.display = 'block';
					setBlockDisplay(idArr[no],'block')
					elem.style.visibility = 'visible';
					if (txtElem) txtElem.innerHTML = txtHide;
				} else {
					//elem.style.display = 'none';
					setBlockDisplay(idArr[no],'none')
					if (!IE) {
						elem.style.visibility = 'collapse';
					}
					if (txtElem) txtElem.innerHTML = txtShow;
				}
			}
			else if (show == 'show')
			{
				//elem.style.display = 'block';
				setBlockDisplay(idArr[no],'block')
				elem.style.visibility = 'visible';
				if (txtElem) txtElem.innerHTML = txtHide;
			}
			else
			{
				//elem.style.display = 'none';
				setBlockDisplay(idArr[no],'none')
				if (!IE) {
					elem.style.visibility = 'collapse';
					if (txtElem) txtElem.innerHTML = txtShow;
				}
			}
		}
	}
}









/*
	top menu highlighting code
*/

function extractPageName(wholeurl)
{
   x = wholeurl.length;
   while((wholeurl.substring(x,x-1)) != "/"){ x--; } clipstart = x;
   pn = wholeurl.substring(wholeurl.length,clipstart);
   return (pn ? pn : '/');
}
 
function setActiveMenu(arr, crtPage)
{
	for (var i=0; i < arr.length; i++)
		if(extractPageName(arr[i].href) == crtPage)
			if (arr[i].parentNode.tagName != "DIV")	{
				arr[i].className = "selected";
				arr[i].parentNode.className = "selected";
			}
}
 
function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;
 
	if (document.getElementById("mainnav") !=null )
	setActiveMenu(document.getElementById("mainnav").getElementsByTagName("a"), extractPageName(hrefString));
}

window.onload=function()
{
	setPage();
}
/*
	end of top menu highlighting code
*/

function isValidCreditCard(type, ccnum) {
   if (type == "visa") {
      // Visa: length 16, prefix 4, dashes optional.
      var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "mc") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "disc") {
      // Discover: length 16, prefix 6011, dashes optional.
      var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "amex") {
      // American Express: length 15, prefix 34 or 37.
      var re = /^3[4,7]\d{13}$/;
   } else if (type == "diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var re = /^3[0,6,8]\d{12}$/;
   }
   if (!re.test(ccnum)) return false;
   // Remove all dashes for the checksum checks to eliminate negative numbers
   ccnum = ccnum.split("-").join("");
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   var checksum = 0;
   for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
      checksum += parseInt(ccnum.charAt(i-1));
   }
   // Analyze odd digits in even length strings or even digits in odd length strings.
   for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
      var digit = parseInt(ccnum.charAt(i-1)) * 2;
      if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
   }
   if ((checksum % 10) == 0) return true; else return false;
}