// Copyright (C) 20007
// Veronica Mercer
//
// Warning: This computer program is protected by copyright law
// and international treaties.  Unauthorized reproduction or distribution
// of this program, or any portion of it, may result in severe civil and
// criminal penalties, and will be prosecuted to the maximum extent
// possible under the law.

/***********************************************************
  Toggle between showing and hiding the display element
  (retrieved by passing the element's id).
***********************************************************/
function toggle(e)
{
	if (document.getElementById(e).style.display == "none")
	{
		document.getElementById(e).style.display = "block";
	}
	 else
	{
		document.getElementById(e).style.display = "none";
	}
}

// OLD STUFF
// OPEN WINDOW FUNCTIONS -------------------------------------------------------------------------------------------------------------------------
// LINK SAMPLE onclick="javascript:openGlossary('http://www.xxx.com')"
var popupVendor = null; 
var popupSummary = null; 
var popupCQ = null; 
var chasm = screen.availWidth;
var mount = screen.availHeight;
var wvend = 600;
var hvend = 500;
var wsumm = 600;
var hsumm = 500;
var wcq = 660;
var hcq = 500;

function openVendor(url) {
	popupVendor = window.open(url,'vendor','width=' + wvend + ',height=' + hvend + ',left=' + ((chasm - wvend - 10) * .5) + ',top=' + ((mount - hvend - 30) * .5) + ',toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	popupVendor.focus()
	}
function openSummary(url) {
	popupSummary = window.open(url,'summary','width=' + wsumm + ',height=' + hsumm + ',left=' + ((chasm - wsumm - 10) * .5) + ',top=' + ((mount - hsumm - 30) * .5) + ',toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes');
	popupSummary.focus()
	}
function openCompuquote(url) {
	popupCQ = window.open(url,'cqhome','width=' + wcq + ',height=' + hcq + ',left=' + ((chasm - wcq - 10) * .5) + ',top=' + ((mount - hcq - 30) * .5) + ',toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	popupCQ.focus()
	}

// APPLICATION SCRIPTS -------------------------------------------------------------------------------------------------------------------------
function EnsureNumericOnly(event)
{
	var charCode = (navigator.appName == "Navigator") ? event.which : event.keyCode
	if ((charCode < 48) || (charCode > 57)) { 
		return false
	}
	return true
}

function EnsureAlphaNumericOnlyEvent(event)
{
	var charCode = (navigator.appName == "Navigator") ? event.which : event.keyCode
	// Uppercase the key they've pressed if it's a lowercase alphabet character
	if ((charCode >= 97) && (charCode <= 122)) {
		(navigator.appName == "Navigator") ? (event.which = charCode - 32) : (event.keyCode	= charCode - 32)
	  charCode = charCode - 32
	}
	if ((charCode < 48) || ((charCode > 57) && (charCode < 65)) || (charCode > 90)) { 
		return false
	}
	return true
}

function EnsureAlphaNumericOnlyString(sString)
{
  sString = sString.toUpperCase()
  var charCode
  for (i = 0; i < sString.length - 1; i++) {
    charCode = sString.charCodeAt(i)
  	if ((charCode < 48) || ((charCode > 57) && (charCode < 65)) || (charCode > 90)) { 
  	  return false
    }
  }
  return true   
}

/***********************************************************
  Determine if a given string is a digit.
***********************************************************/
function isDigit(s)
{
	if (s.length < 1)
		return false;

	var i, c
	for (i = 0; i < s.length; i++)
	{   
		// Check that current character is a number.
		c = s.charAt(i);
		if ( (c < "0") || (c > "9") )
			return false;
	}
	// All characters are numbers.
	return true;
}

/*****************************************************************
Rollover
*****************************************************************/
function SwapImage(image_name, image_file)
{
	if (document.images)
	{
		document.getElementById(image_name).src = image_file;
	}
}


/*****************************************************************
Image Preload
*****************************************************************/
function MM_preloadimages() {
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); 
var i,j=d.MM_p.length,a=MM_preloadimages.arguments; for(i=0; i<a.length; i++) 
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} 
} 

