
// BULLET ROLLOVERS
// ADD CLASS="IMGOVER" TO IMAGE SRC TAG
// EXAMPLE: <img src="images/splash/circle_arrow.gif" width="25" height="25" border="0" alt=""  class="imgover" />

function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function initRollovers() {

 if (!document.getElementById) return
 
 var aPreLoad = new Array();
 var sTempSrc;
 var aImages = document.getElementsByTagName('img');

 for (var i = 0; i < aImages.length; i++) {  
  if (aImages[i].className == 'imgover') {
   var src = aImages[i].getAttribute('src');
   var ftype = src.substring(src.lastIndexOf('.'), src.length);
   var hsrc = src.replace(ftype, '_o'+ftype);
 
   aImages[i].setAttribute('hsrc', hsrc);
   
   aPreLoad[i] = new Image();
   aPreLoad[i].src = hsrc;
   
   aImages[i].onmouseover = function() {
    sTempSrc = this.getAttribute('src');
    this.setAttribute('src', this.getAttribute('hsrc'));
   } 
   
   aImages[i].onmouseout = function() {
    if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
    this.setAttribute('src', sTempSrc);
   }
  }
 }
 
 startList();
}
 
function Test1(imgname,mtype)
{
   Imageobj = document[imgname];
   var src = Imageobj.src;
   var ftype = src.substring(src.lastIndexOf('.'), src.length);
   var hsrc = src.replace(ftype, '_o'+ftype);
   if (mtype == 1)
   {
      Imageobj.src = hsrc; 
   }
   else
   {
       sTempSrc = src.replace('_o'+ftype, ftype);
       Imageobj.src = sTempSrc;
   }
}
 



// Submit Button Rollover
 
<!--
var submitRolls = new Object();
function submitroll(src, oversrc, name)
{
this.src=src;
this.oversrc=oversrc;
this.name=name;
this.alt="Search";
this.write=submitroll_write;
}
function submitroll_write()
{
var thisform = 'document.forms[' + (document.forms.length - 1) + ']';
submitRolls[this.name] = new Object();
submitRolls[this.name].over = new Image();
submitRolls[this.name].over.src = this.oversrc;
submitRolls[this.name].out = new Image();
submitRolls[this.name].out.src = this.src;
document.write
 (
 '<A onMouseOver="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].over.src"' + 
 ' onMouseOut="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].out.src"' + 
 ' HREF="javascript:'
 );
if (this.sendfield)
 {
 if (! this.sendvalue)
 this.sendvalue = 1;
 document.write(thisform, ".elements['", this.sendfield, "'].value='", this.sendvalue, "';");
 }
document.write(thisform + '.submit();void(0);"');
if (this.msg)document.write(' onClick="return confirm(\'' , this.msg, '\')"');
document.write('>');
document.write('<IMG SRC="' + this.src + '" ALT="' + this.alt + '" BORDER=0 NAME="' + this.name + '"');
if (this.height)document.write(' HEIGHT=' + this.height);
if (this.width)document.write(' WIDTH=' + this.width);
if (this.otheratts)document.write(' ' + this.otheratts);
document.write('></A>');
if (this.sendfield)
 {
 document.write('<INPUT TYPE=HIDDEN NAME="' + this.sendfield + '">');
 document.forms[document.forms.length - 1].elements[this.sendfield].value='';
 }
}


// FORM BUTTON ROLLOVER
function cssActive( buttonname)
{
  document.getElementsByName(buttonname)[0].style.backgroundColor = "#e45111";
}

function cssInactive( buttonname)
{
  document.getElementsByName(buttonname)[0].style.backgroundColor = "#999999";
}

// FUNCTION TO OPEN A CONSTRAINED WINDOW
function openWin(URL) {
newWindow=window.open(URL,"newwindow","width=380,height=315,status=no,scrollbars=yes,resizable=yes,location=0,menubar=0,toolbar=no");
newWindow.focus();
}

//function that drives you to another page from a drop down list
function urlMenu(that) {
	theURL = that.options[that.selectedIndex].value; 

	if (theURL) {
		window.location = theURL;
	}
}

//-->


function hidediv() 
{ 
	
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow').style.visibility = 'hidden'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow.visibility = 'hidden'; 
		} 
		else { // IE 4 
			document.all.hideShow.style.visibility = 'hidden'; 
		} 
	}
} 

function showdiv() 
{ 
	
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow').style.visibility = 'visible'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow.visibility = 'visible'; 
		} 
		else { // IE 4 
			document.all.hideShow.style.visibility = 'visible'; 
		} 
	}
} 
// *****************BEGIN GENERIC FUNCTIONS*******************************

/* ======================================================================
FUNCTION:  	IsAlpha
INPUT:		str (string) - the string to be tested
RETURN:  	true, if the string contains only alphabetic characters false, otherwise.
====================================================================== */
function IsAlpha( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;

	str += "";	// convert to a string for performing string comparisons.

	// Loop through string one character at time,  breaking out of for
	// loop when an non Alpha character is found.
  	for (i = 0; i < str.length; i++) {
		// Alpha must be between "A"-"Z", or "a"-"z"
		if ( !( ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ) ) {
         				isValid = false;
         				break;
      			}
   } // end for loop
   
	return isValid;
}  // end IsAlpha 


/* ======================================================================
FUNCTION:	IsAlphaNum
INPUT:		str (string) - a string that will be tested to ensure that
    		each character is a digit or a letter.
RETURN:  	true, if all characters in the string are a character from 0-9
     		or a-z or A-Z;  
			false, otherwise
====================================================================== */
function checkDate(dVal) {
	//Check date is valid
		
	if (dVal.length == 0){
		return false; // cancel the submit
	}
	if (isNaN(Number(new Date(dVal)))){
		return false; // cancel the submit
	}
			
	return true; // dont cancel
}



/* ======================================================================
FUNCTION:	IsAlphaNum
INPUT:		str (string) - a string that will be tested to ensure that
			each character is a digit or a letter.
RETURN:  	true, if all characters in the string are a character from 0-9
			or a-z or A-Z; false, otherwise
====================================================================== */
function IsAlphaNum( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;
	
	// convert to a string for performing string comparisons.
   	str += "";	

	// Loop through length of string and test for any alpha numeric 
	// characters
   	for (i = 0; i < str.length; i++)
   	{
			// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
      	if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
      			((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z"))))
			{
				isValid = false;
				break;
			}	
   	} // END for   
   
   	return isValid;
}  // end IsAlphaNum



/* ======================================================================
FUNCTION:	IsAlphaNum
INPUT:		str (string) - a string that will be tested to ensure that
			each character is a digit or a letter.
RETURN:  	true, if all characters in the string are a character from 0-9
			or a-z or A-Z or spaces; false, otherwise
====================================================================== */
function IsAlphaNumOrSC( str ) {

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;
	
	// convert to a string for performing string comparisons.
   	str += "";	

	// Loop through length of string and test for any alpha numeric 
	// characters
   	for (i = 0; i < str.length; i++)
   	{
			// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
      	if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
      			((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z"))||    
				(str.charAt(i) == " ")||
				(str.charAt(i) == "'") ))
			{
				isValid = false;
				break;
			}	
   	} // END for   
   
   	return isValid;
}  // end IsAlphaNumOrSpace



/* ======================================================================
FUNCTION:	IsAlphaNumOrUnderscore
INPUT:		str (string) - the string to be tested
RETURN:  	true, if the string contains only alphanumeric characters or underscores.
			false, otherwise.
====================================================================== */
function IsAlphaNumOrUnderscore( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;

	str += "";	// convert to a string for performing string comparisons.
	// Loop through string one character at a time. If non-alpha numeric
	// is found then, break out of loop and return a false result

	for (i = 0; i < str.length; i++)
   	{
		// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
      		if ( !( ((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
      			((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ||
      			(str.charAt(i) == "_") ) )
      		{
   				isValid = false;
         		break;
      		}

	} // END for   
   
	return isValid;

}  // end IsAlphaNumOrUnderscore




/* ======================================================================
FUNCTION:  	IsInt
INPUT:  	numstr (string/number) 	 - the string that will be tested to ensure 
			that each character is a digit
			allowNegatives (boolean) - (optional) when true, allows numstr to be
			negative (contain a '-').  When false, any negative number or a string starting
			with a '-' will be considered invalid.
RETURN:  	true, if all characters in the string are a character from 0-9,
			regardless of value for allowNegatives
			true, if allowNegatives is true and the string starts with a '-', and all other
			characters are 0-9. false, otherwise.
====================================================================== */
function IsInt( numstr, allowNegatives ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;

	// Default allowNegatives to true when undefined or null
	if (allowNegatives+"" == "undefined" || allowNegatives+"" == "null")	
		allowNegatives = true;

	var isValid = true;

	// convert to a string for performing string comparisons.
	numstr += "";	

	// Loop through string and test each character. If any
	// character is not a number, return a false result.
 	// Include special case for negative numbers (first char == '-').   
	for (i = 0; i < numstr.length; i++) {
    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || (numstr.charAt(i) == "-"))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "-" && i != 0) || 
				(numstr.charAt(i) == "-" && !allowNegatives)) {
       	isValid = false;
       	break;
      }
         	         	       
   } // END for   
   
   	return isValid;
}  // end IsInt




/* ======================================================================
FUNCTION:	IsBlank
INPUT:		val - the value to be tested
RETURN:  	true, if the string is null, undefined or an empty string, ""
			false, otherwise.
CALLS:		IsNull(), IsUndef() which are defined elsewhere in the Script Library
====================================================================== */
function IsBlank( str ) {
	var isValid = false;

 	if ( IsNull(str) || IsUndef(str) || (str+"" == "") )
 		isValid = true;
		
	return isValid;
}  // end IsBlank




/* ======================================================================
FUNCTION:	IsNull
INPUT:		val - the value to be tested
RETURN:  	true, if the value is null;
      		false, otherwise.
====================================================================== */
function IsNull( val ) {
	var isValid = false;

 	if (val+"" == "null")
 		isValid = true;
		
	return isValid;
}  // end IsNull




/* ======================================================================
FUNCTION:  	IsNum
INPUT:  	numstr (string/number) - the string that will be tested to ensure 
      		that the value is a number (int or float)
RETURN:  	true, if all characters represent a valid integer or float
     		false, otherwise.
====================================================================== */
function IsNum( numstr ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;

	var isValid = true;
	var decCount = 0;		// number of decimal points in the string

	// convert to a string for performing string comparisons.
	numstr += "";	

	// Loop through string and test each character. If any
	// character is not a number, return a false result.
 	// Include special cases for negative numbers (first char == '-')
	// and a single decimal point (any one char in string == '.').   
	for (i = 0; i < numstr.length; i++) {
		// track number of decimal points
		if (numstr.charAt(i) == ".")
			decCount++;

    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || 
				(numstr.charAt(i) == "-") || (numstr.charAt(i) == "."))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "-" && i != 0) ||
				(numstr.charAt(i) == "." && numstr.length == 1) ||
			  (numstr.charAt(i) == "." && decCount > 1)) {
       	isValid = false;
       	break;
      }         	         	       
//if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9")) || 
   } // END for   
   
   	return isValid;
}  // end IsNum



/* ======================================================================
FUNCTION:  	IsMoney
INPUT:  	numstr (string/number) - the string that will be tested to ensure 
      		that the value is a number (int or float),
      		fldName - the name of the form field 
RETURN:  	true, if all characters represent a valid integer or float
     		false, otherwise.
====================================================================== */
function IsMoney( numstr, fldName ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;
	
	var isValid = true;
	var decCount = 0;		// number of decimal points in the string

	// convert to a string for performing string comparisons.
	numstr += "";	

	// Loop through string and test each character. If any
	// character is not a number, return a false result.
 	// Include special cases for dollar sign (first char == '$'), comma (any char in string == ','),
	// and a single decimal point (any one char in string == '.').   
	for (i = 0; i < numstr.length; i++) {
		// track number of decimal points
		if (numstr.charAt(i) == ".")
			decCount++;

    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || (numstr.charAt(i) == ",") || 
				(numstr.charAt(i) == "$") || (numstr.charAt(i) == "."))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "$" && i != 0) ||
				(numstr.charAt(i) == "." && numstr.length == 1) ||
				(numstr.charAt(i) == "," && numstr.length < 4) ||
				(numstr.charAt(i) == "." && decCount > 1)) {
       	isValid = false;
       	break;
      }         	         	       
//if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9")) || 
   } // END for   
   
  // alert ("isValid=" + isValid)
   if (isValid){
		var strRes = StripNonNumericMoney(numstr,fldName)
	//	alert ("strRes=" + strRes)
		if (strRes !=""){
		 	isValid = true;
		}else{
			isValid = false;
		}	
	}
	return isValid;
}  // end IsMoney



/* ======================================================================
FUNCTION:	IsUndef
INPUT:		val - the value to be tested
RETURN:  	true, if the value is undefined
      		false, otherwise.
====================================================================== */
function IsUndef( val ) {
	var isValid = false;

 	if (val+"" == "undefined")
 		isValid = true;
		
	return isValid;
}  // end IsUndef




/* ======================================================================
FUNCTION:  	ParseQueryString
INPUT:		searchstr - the querystring value to be returned
RETURN:  	the value of that querystring item, or "" if blank
====================================================================== */
function ParseQueryString(searchStr) 
{
	var tempStr = window.location.search;
	var startOfString = tempStr.indexOf(searchStr);
	var result = "";

	result = "";
	if (startOfString != -1) {
		var endOfString = tempStr.indexOf("&",startOfString+searchStr.length+1);
	
		if (endOfString != -1)  {               
			var result = tempStr.substring(startOfString+searchStr.length+1, endOfString);
		} else {
			var result = tempStr.substring(startOfString+searchStr.length+1, tempStr.length);
		}
	}
	return unescape(result);
}



/* ======================================================================
FUNCTION:  	StripNonNumeric
INPUT:    	str (string)
RETURN:  	true, if the string contains digits and dashes in the form 111-12-3456;
CALLS:		IsInt(), which is defined elsewhere in the Script Library
====================================================================== */
function StripNonNumeric( strN, fldName, formName ) {
	// Return immediately if an invalid value was passed in
	if (strN+"" == "undefined" || strN+"" == "null" || strN+"" == "")	
		return "";
		
	strN += "";	// make sure it's a string
	var strD = strN;

	for (j = 0; j < strN.length; j++) {
		if (strD+"" == "" || strD.length == 0) return;
		
		// track number of decimal points
		if (strN.charAt(j) == " " || !IsNum(strN.charAt(j))) {
			strD = strN.substring(0,j) + strN.substring(j+1,strN.length);
			j-- ;
		}else{
			if (strN.charAt(j) == "-") strD = strN.substring(0,j) + strN.substring(j+1,strN.length);
			if (strN.charAt(j) == "(") strD = strN.substring(0,j) + strN.substring(j+1,strN.length);
			if (strN.charAt(j) == ")") strD = strN.substring(0,j) + strN.substring(j+1,strN.length);
			if (strN.charAt(j) == " ") strD = strN.substring(0,j) + strN.substring(j+1,strN.length);
		}
		strN = strD;
	}
	
	if (fldName != "") {
		var eStr = "document." + formName + "." + fldName + ".value=" + strD + ";";
		eval(eStr);
	}

// alert(strD);
 	return strD;
} // end StripNonNumeric

/* ======================================================================
FUNCTION:  	StripNonNumericMoney
INPUT:    	str (string)
RETURNS:  	if successful, will set form field to string of numbers
			(all characters stripped except decimal);
CALLS:		IsInt(), which is defined elsewhere in the Script Library
====================================================================== */
function StripNonNumericMoney( strN, fldName ) {
	// Return immediately if an invalid value was passed in
	if (strN+"" == "undefined" || strN+"" == "null" || strN+"" == "")	
		return "";
		
	strN += "";	// make sure it's a string
	var strD = strN;

	for (j = 0; j < strN.length; j++) {
		if (strD+"" == "" || strD.length == 0) return;
		
		// track number of decimal points
		
		if (!IsNum(strN.charAt(j))){
			if (strN.charAt(j)!= ".") {
				strD = strN.substring(0,j) + strN.substring(j+1,strN.length);
				j-- ;
			}
		}
		strN = strD;
	}
	
	if (fldName != "" && strD != "") {
		var eStr = "document.forms[0]." + fldName + ".value=" + strD + ";";
		eval(eStr);
	}

// alert(strD);
 	return strD;
} // end StripNonNumericMoney



// *****************END GENERIC FUNCTIONS*********************************





// *****************BEGIN SPECIAL FUNCTIONS*******************************

/* ======================================================================
FUNCTION:  	IsValidEmail
INPUT:    	str (string) - an e-mail address to be tested
RETURN:  	true, if the string contains a valid e-mail address which is a string
			plus an '@' character followed by another string containing at least 
			one '.' and ending in an alpha (non-punctuation) character.
			false, otherwise
CALLS:		IsBlank(), IsAlpha() which are defined elsewhere in the Script Library
====================================================================== */
function IsValidEmail( str ) {

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;

	str += "";

	namestr = str.substring(0, str.indexOf("@"));  // everything before the '@'
	domainstr = str.substring(str.indexOf("@")+1, str.length); // everything after the '@'
	dotstr = domainstr.substring(domainstr.indexOf(".")+1, domainstr.length);
	// Rules: namestr cannot be empty, or that would indicate no characters before the '@',
	// domainstr must contain a period that is not the first character (i.e. right after
	// the '@').  The last character must be an alpha.
   	if (IsBlank(str) || (namestr.length == 0) || 
			(domainstr.indexOf(".") <= 0) ||
			(domainstr.indexOf("@") != -1) ||
			(dotstr == 0) ||
			!IsAlpha(str.charAt(str.length-1)))
		isValid = false;

//		if (dotstr.length < 2 || dotstr.length > 4)
//		isValid = false;

		CharText = "[]'.@-_+`~&^1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
		for(j=0; j<str.length ;j++)
		{
			if(CharText.indexOf(str.charAt(j))<0)
				isValid = false;
		} 
		if(str.indexOf("..") > 0 )
			isValid = false;
		if(str.indexOf("@@") > 0 )
			isValid = false;
		if(str.indexOf("[[") > 0 )
			isValid = false;
		if(str.indexOf("]]") > 0 )
			isValid = false;
		if(str.indexOf("''") > 0 )
			isValid = false;
   	return isValid;
} // end IsValidEmail



/* ======================================================================
FUNCTION:  	IsValidPhone
INPUT:    	str (string) - an phone number to be tested
			incAreaCode (boolean) - if true, area code is included (10-digits);
			if false or undefined, area code not included
RETURN:  	true, if the string contains a 7-digit phone number and incAreaCode == false
			or is undefined 
			true, if the string contains a 10-digit phone number and incAreaCode == true
			false, otherwise
CALLS:		StripNonNumeric(), which is defined elsewhere in the Script Library
====================================================================== */
function IsValidPhone(str, fldName, formName, incAreaCode) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	// Set default value for incAreaCode to true, if undefined or null
	if (incAreaCode+"" == "undefined" || incAreaCode+"" == "null")	
		incAreaCode = true;

	var isValid = true;

	str += "";

	// After stripping out non-numeric characters, such as dashes, the
	// phone number should contain 7 digits (no area code) or 10 digits (area code)
	str = StripNonNumeric(str+"", fldName, formName);

	if (str.length != 10) isValid = false;
	
   	return isValid;
} // end IsValidPhone


/* ======================================================================
FUNCTION:  	IsValidCCNum
			This function tests a credit card number with a LUHN-10 algorithm
			to validate - it works for MasterCard, Visa, AMEX, Diners Club,
			Discover, EnRoute, and JCB
INPUT:		ccVal - the credit card number
RETURN:  	true or false
====================================================================== */
function IsValidCCNum(ccVal)
{
	var checkOK = "0123456789";
	var checkStr = ccVal;
	var CrValid = true;
	var checksum=0;
	var ddigit=0;
	var kdig = 0;
	if (checkStr.length < 13) alert ('You have not entered enough digits. Please check the number for errors.');

// CHECK FOR TEST CC NUMS
/* ALLOW ALL TEST CC NUMS TO WORK - TEMPORARILY
	if (ccVal == "4111111111111111") return false;	//FAKE VISA
	if (ccVal == "5555555555554444") return false;	//FAKE MASTERCARD
	if (ccVal == "378282246310005") return false;	//FAKE AMEX
	if (ccVal == "6011111111111117") return false;	//FAKE DISCOVER
*/
	for (i = checkStr.length-1;  i >= 0;  i--)
	{
		kdig++;
		ch = checkStr.charAt(i);
		if ((kdig % 2) != 0)
			checksum=checksum+parseInt(ch)
		else {
			ddigit=parseInt(ch)*2;

		if (ddigit >= 10)
			checksum=checksum+1+(ddigit-10)
		else
			checksum=checksum+ddigit;
		}

		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length)
			{
				return(false);
			}
		}

		if ((checksum % 10) != 0){
			return (false);
		}else{
			return(true);
		}
	}





/* ======================================================================
FUNCTION:  	IsValid5DigitZip
INPUT:    	str (string) - a 5-digit zip code to be tested
RETURN:  	true, if the string is 5-digits long
			false, otherwise
CALLS:		IsBlank(), IsInt() which are defined elsewhere in the Script Library
====================================================================== */
function IsValid5DigitZip( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;
	
	var isValid = true;

	str += "";

	// Rules: zipstr must be 5 characters long, and can only contain numbers from
   // 0 through 9
   if (IsBlank(str) || (str.length != 5) || !IsInt(str, false))
		isValid = false;
   
   return isValid;
} // end IsValid5DigitZip




/* ======================================================================
FUNCTION:  	IsValid5Plus4DigitZip
INPUT:    	str (string) - a 5+4 digit zip code to be tested
RETURN:  	true, if the string contains 5-digits followed by a dash followed by 4 digits
			false, otherwise
CALLS:		IsBlank(), IsInt() which are defined elsewhere in the Script Library
====================================================================== */
function IsValid5Plus4DigitZip( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;

	str += "";

	// Rules: The first five characters may contain only digits 0-9,
	// the 6th character must be a dash, '-', and 
	// the last four characters may contain only digits 0-9.
	// The total string length must be 10 characters.
   	if (IsBlank(str) || (str.length != 10) || 
			!IsInt(str.substring(0,5), false) || str.charAt(5) != '-' ||
			!IsInt(str.substring(6,10), false))
		isValid = false;
   
   	return isValid;
} // end IsValid5Plus4DigitZip




/* ======================================================================
FUNCTION:  	IsValidSSN
INPUT:    	str (string) - an phone number to be tested
			incDashes (boolean) - if true, str includes dashes (e.g. 111-12-3456);
			if false, str contains only digits
RETURN:  	true, if the string contains digits and dashes in the form 111-12-3456;
			true, if the string contains a 9-digit number and incDashes is false;
			false, otherwise
CALLS:		IsInt(), which is defined elsewhere in the Script Library
====================================================================== */
function IsValidSSN( str, incDashes ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;

	// Set default value for incDashes to true, if undefined or null
	if (incDashes+"" == "undefined" || incDashes+"" == "null")	
		incDashes = true;

	str += "";	// make sure it's a string

	if (!incDashes && (!IsNum(str) || str.length != 9))
		isValid = false;

	var part1 = str.substring(0,3);
	var part2 = str.substring(4,6);
	var part3 = str.substring(7,str.length);

	// Ensure that the first part is a number and 3 digits long,
	// the second part is a number and 2 digits long,
	// the third part is a number and 4 digits long, e.g. 111-22-3333
	if (incDashes && ((!IsInt(part1, false) || part1.length != 3) ||
			(!IsInt(part2, false) || part2.length != 2) || 
			(!IsInt(part3, false) || part3.length != 4)) )
		isValid = false;

   	return isValid;
} // end IsValidSSN


/* ======================================================================
FUNCTION:  	IsValidDate
INPUT:    	str (string) - a date string to be tested 
			Accepts dashes or forwardslashes as separators
RETURNS:  	true, if the string is a valid date;
			false, otherwise
CALLS:		LeapYear(), which is defined below
====================================================================== */
function IsValidDate(str) {

// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;
	
	if (str.length < 6)
		return false;
		
var strDatestyle = "US"; //United States date style
//var strDatestyle = "EU";  //European date style
var strDate = str;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var strSeparatorArray = new Array("-","/");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
   }
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}


/* ======================================================================
FUNCTION:  	IsValidTime
INPUT:    	timeStr
RETURN:  	True if valid time, else false
CALLS:		Nothing
====================================================================== */
function IsValidTime(timeStr) 
{
	// Checks if time is in HH:MM:SS AM/PM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

	var matchArray = timeStr.match(timePat);
	if (matchArray == null) {
		return false;
	}
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }

	if (hour < 0  || hour > 23) {
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
	}
	if (hour <= 12 && ampm == null) {
		if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
			alert("You must specify AM or PM.");
			return false;
		}
	}
	if  (hour > 12 && ampm != null) {
		alert("You can't specify AM or PM for military time.");
		return false;
	}
	if (minute<0 || minute > 59) {
		alert ("Minutes must be a number between 0 and 59.");
		return false;
	}
	if (second != null && (second < 0 || second > 59)) {
		alert ("Seconds must be a number between 0 and 59.");
		return false;
	}

	return true;
}


// *****************END SPECIAL FUNCTIONS*********************************




// *****************BEGIN CUSTOM FUNCTIONS********************************

/* ======================================================================
FUNCTION:  	testRadio
INPUT:    	radioFld - the field name of the radio button to test
RETURN:  	the value of the radio field's selected item. If none selected,
			then it returns "" (empty string). 
CALLS:		Nothing
====================================================================== */
	function testRadio(radioFld){
		var fReturn = "";
		for (var i=0; i < radioFld.length; i ++){
			if (radioFld[i].checked) fReturn = radioFld[i].value;
		}
		return fReturn;
	}

	
/* ======================================================================
FUNCTION:  	testCheckbox
INPUT:    	ckFld - the field name of the checkbox to test
RETURN:  	the value of the checkbox's selected item(s). If none selected,
			then it returns "" (empty string). 
CALLS:		Nothing
====================================================================== */
	function testCheckbox(ckFld){
		var fReturn = "";
		for (var i=0; i < ckFld.length; i ++){
			if (ckFld[i].checked) fReturn = fReturn + ckFld[i].value + ",";
		}
		return fReturn;
	}

// *****************END CUSTOM FUNCTIONS**********************************



/* ======================================================================
FUNCTION:  	FormatDateTime
INPUT:    	datetime, FormatType
			FomatType takes the following values
			1 - General Date = Friday, October 30, 1998
			2 - Typical Date = 10/30/98
			3 - Standard Time = 6:31 PM
			4 - Military Time = 18:31
RETURN:  	Returns an expression formatted as a date or time
CALLS:		Nothing
====================================================================== */

function FormatDateTime(datetime, FormatType)
{
	var strDate = new String(datetime);

	if (strDate.toUpperCase() == "NOW") {
		var myDate = new Date();
		strDate = String(myDate);
	} else {
		var myDate = new Date(datetime);
		strDate = String(myDate);
	}


	// Get the date variable parts
	var Day = new String(strDate.substring(0,3));
	if (Day == "Sun") Day = "Sunday";
	if (Day == "Mon") Day = "Monday";
	if (Day == "Tue") Day = "Tuesday";
	if (Day == "Wed") Day = "Wednesday";
	if (Day == "Thu") Day = "Thursday";
	if (Day == "Fri") Day = "Friday";
	if (Day == "Sat") Day = "Saturday";	
	
	var Month = new String(strDate.substring(4,7)), MonthNumber = 0;
	if (Month == "Jan") { Month = "January"; MonthNumber = 1; }
	if (Month == "Feb") { Month = "February"; MonthNumber = 2; }
	if (Month == "Mar") { Month = "March"; MonthNumber = 3; }
	if (Month == "Apr") { Month = "April"; MonthNumber = 4; }
	if (Month == "May") { Month = "May"; MonthNumber = 5; }
	if (Month == "Jun") { Month = "June"; MonthNumber = 6; }
	if (Month == "Jul") { Month = "July"; MonthNumber = 7; }
	if (Month == "Aug") { Month = "August"; MonthNumber = 8; }
	if (Month == "Sep") { Month = "September"; MonthNumber = 9; }
	if (Month == "Oct") { Month = "October"; MonthNumber = 10; }
	if (Month == "Nov") { Month = "November"; MonthNumber = 11; }
	if (Month == "Dec") { Month = "December"; MonthNumber = 12; }
	
	var curPos = 11;
	var MonthDay = new String(strDate.substring(8,10));
	if (MonthDay.charAt(1) == " ") {
		MonthDay = "0" + MonthDay.charAt(0);
		curPos--;
	}	
	
	var MilitaryTime = new String(strDate.substring(curPos,curPos + 5));
	
	var Year = new String(strDate.substring(strDate.length - 4, strDate.length));	
	
	document.write(strDate + "");	

	// Format Type decision time!
	if (FormatType == 1)
		strDate = Day + ", " + Month + " " + MonthDay + ", " + Year;
	else if (FormatType == 2)
		strDate = MonthNumber + "/" + MonthDay + "/" + Year.substring(2,4);
	else if (FormatType == 3) {
		var AMPM = MilitaryTime.substring(0,2) >= 12 && MilitaryTime.substring(0,2) != "24" ? " PM" : " AM";
		if (MilitaryTime.substring(0,2) > 12)
			strDate = (MilitaryTime.substring(0,2) - 12) + ":" + MilitaryTime.substring(3,MilitaryTime.length) + AMPM;
		else {
			if (MilitaryTime.substring(0,2) < 10)
				strDate = MilitaryTime.substring(1,MilitaryTime.length) + AMPM;
			else
				strDate = MilitaryTime + AMPM;
		}
	}	
	else if (FormatType == 4)
		strDate = MilitaryTime;


	return strDate;
}





//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}



 

				function Shape_Check()
				{
					var inputs = document.getElementsByTagName('input');
						//alert(inputs);
						var k = 1;
						var svalfrom = 0;
						var svalto = 0;
						
						for (var i=0; i<inputs.length; i++) 
						{
							if (inputs[i].type == 'checkbox' && inputs[i].name == "Shape") 
							{
								if ((inputs[i].checked && inputs[i].value != "BR") && (inputs[i].checked && inputs[i].value != "AR"))
								{
									k = 0;
									
								}
							}
						}
						
						if (k == 0)
						{
							document.Form1.AdvCrown_From.disabled=true;
							document.Form1.AdvCrown_To.disabled = true;
							document.Form1.AdvPavilion_From.disabled = true;
							document.Form1.AdvPavilion_To.disabled = true;

							document.Form1.AdvCrown_From.className = "minerform2";
							document.Form1.AdvCrown_To.className = "minerform2";
							document.Form1.AdvPavilion_From.className = "minerform2";
							document.Form1.AdvPavilion_To.className = "minerform2";
						}
						else
						{
							document.Form1.AdvCrown_From.disabled=false;
							document.Form1.AdvCrown_To.disabled = false;
							document.Form1.AdvPavilion_From.disabled = false;
							document.Form1.AdvPavilion_To.disabled = false;

							document.Form1.AdvCrown_From.className = "minerform";
							document.Form1.AdvCrown_To.className = "minerform";
							document.Form1.AdvPavilion_From.className = "minerform";
							document.Form1.AdvPavilion_To.className = "minerform";
						}
				}
				function ShapeImg_Click(sval)
				{
					var inputs = document.getElementsByTagName('input');
					//alert(inputs);
					var k = 1;
					for (var i=0; i<inputs.length; i++) 
					{
						if (inputs[i].type == 'checkbox' && inputs[i].name == "Shape") 
						{
							k++;
							if (inputs[i].value == sval)
							{
								if (inputs[i].checked)
								{
									inputs[i].checked = false;
									Shape_Check(inputs[i]);
								}
								else
								{
									inputs[i].checked = true;
									Shape_Check(inputs[i]);
								}
							}
						}
					}					
				}
			function Price_Check()
				{
					sval = parseInt(document.Form1.Adv_From_Price.options[document.Form1.Adv_From_Price.selectedIndex].value);
					sval2 = parseInt(document.Form1.Adv_To_Price.options[document.Form1.Adv_To_Price.selectedIndex].value);
					//alert(sval + ' / ' + sval2);
					if (sval > sval2)
					{
						alert("The first value for price range must be less than the second value.");
						document.Form1.Adv_From_Price.focus();
					}
				}

			function Price_CheckT(wher)
				{
					sval = parseInt(document.getElementById('From_PriceT').value);
					sval2 = parseInt(document.getElementById('To_PriceT').value);
					//alert(sval + ' / ' + sval2);
					if (sval != '' && sval2 != '')
					{
						if (sval >= sval2)
						{
							alert("The first value for price range must be less than the second value.");
							if (wher == 1) {
								document.getElementById('From_PriceT').value = '';
								document.getElementById('From_PriceT').focus();
							}
							else
							{
								document.getElementById('To_PriceT').value = '';
								document.getElementById('To_PriceT').focus();
							}
						}
					}
				}
				
				function Carat_Click(sval,sval2)
				{
					//document.Form1.From_Carat.options[sval].selected = true;
					//document.Form1.To_Carat.options[sval2].selected = true;
						document.Form1.To_Carat.value = sval2;
						document.Form1.From_Carat.value = sval;
				}
			
				function Carat_Check(wher)
				{
					sval = parseInt(document.Form1.From_Carat.options[document.Form1.From_Carat.selectedIndex].value);
					sval2 = parseInt(document.Form1.To_Carat.options[document.Form1.To_Carat.selectedIndex].value);
					//alert(sval + ' / ' + sval2);
					if (sval > sval2)
					{
						alert("The first value for carat range must be less than the second value.");
						if (wher == 1)
							document.Form1.From_Carat.focus();
						else
							document.Form1.To_Carat.focus();
					}
				}

				function Carat_CheckT(wher)
				{
					sval = parseFloat(document.getElementById('From_CaratT').value);
					sval2 = parseFloat(document.getElementById('To_CaratT').value);
					//alert(sval + ' / ' + sval2);
					if (sval != '' && sval2 != '')
					{
						if (sval >= sval2)
						{
							alert("The first value for carat range must be less than the second value.");
							if (wher == 1)  {
								document.getElementById('From_CaratT').value = '';
								document.getElementById('From_CaratT').focus();
							}
							else
							{
								document.getElementById('To_CaratT').value = '';
								document.getElementById('To_CaratT').focus();
							}
						}
					}
				}
			
				function Carat_Convert(what)
					{
						var whatwhat = document.getElementById(what);
						if ((whatwhat.value).indexOf('+') > -1)
							{whatwhat.value = '1000'}
						return true;
					}
					
			function Color_Click(chkBox,sval)
				{
					if (chkBox.checked)
					{
						var inputs = document.getElementsByTagName('input');
						//alert(inputs);
						var k = 1;
						var svalfrom = 0;
						var svalto = 0;
						
						for (var i=0; i<inputs.length; i++) 
						{
							if (inputs[i].type == 'checkbox' && inputs[i].name == "color") 
							{
//								if (k > sval)
//									break;
								k++;
								if (inputs[i].checked && svalfrom == 0)
								{
									svalfrom = i;
//									alert('from = ' + svalfrom + '  k = ' + k + '  sval = ' + sval + ' i = ' + i + ' // The checkbox named '+ inputs[i].name +' with the value of '+ inputs[i].value +' is checked? '+ inputs[i].checked);
								}
								
								if (i != svalfrom && svalfrom > 0 && inputs[i].checked)
								{
									svalto = i;
//									alert('to = ' + svalto + '   from = ' + svalfrom + '   k = ' + k + '  sval = ' + sval + ' i = ' + i + ' // The checkbox named '+ inputs[i].name +' with the value of '+ inputs[i].value +' is checked? '+ inputs[i].checked);
								}
							}
						}
						//alert(svalfrom + " / " + svalto);
						//paint the checkbox
						if (svalfrom > 0 && svalto > 0)
						{
							for (var i=svalfrom; i<svalto; i++) 
							{
								if (inputs[i].type == 'checkbox' && inputs[i].name == "color") 
								{
									inputs[i].checked = true;
								}
							}
						}
					}

				}
				function ColorImg_Click(sval)
				{
					var inputs = document.getElementsByTagName('input');
					//alert(inputs);
					var k = 1;
					for (var i=0; i<inputs.length; i++) 
					{
						if (inputs[i].type == 'checkbox' && inputs[i].name == "color") 
						{
							k++;
							if (inputs[i].value == sval)
							{
								if (inputs[i].checked)
									inputs[i].checked = false;
								else
								{
									inputs[i].checked = true;
									Color_Click(inputs[i], k);
								}
							}
						}
					}					
				}
				
				function Clarity_Click(chkBox,sval)
				{
					if (chkBox.checked)
					{
						var inputs = document.getElementsByTagName('input');
						//alert(inputs);
						var k = 1;
						var svalfrom = 0;
						var svalto = 0;
						
						for (var i=0; i<inputs.length; i++) 
						{
							if (inputs[i].type == 'checkbox' && inputs[i].name == "chkClarity") 
							{
//								if (k > sval)
//									break;
								k++;
								if (inputs[i].checked && svalfrom == 0)
								{
									svalfrom = i;
//									alert('from = ' + svalfrom + '  k = ' + k + '  sval = ' + sval + ' i = ' + i + ' // The checkbox named '+ inputs[i].name +' with the value of '+ inputs[i].value +' is checked? '+ inputs[i].checked);
								}
								
								if (i != svalfrom && svalfrom > 0 && inputs[i].checked)
								{
									svalto = i;
//									alert('to = ' + svalto + '   from = ' + svalfrom + '   k = ' + k + '  sval = ' + sval + ' i = ' + i + ' // The checkbox named '+ inputs[i].name +' with the value of '+ inputs[i].value +' is checked? '+ inputs[i].checked);
								}
							}
						}
						//paint the checkbox
						if (svalfrom > 0 && svalto > 0)
						{
							for (var i=svalfrom; i<svalto; i++) 
							{
								if (inputs[i].type == 'checkbox' && inputs[i].name == "chkClarity") 
								{
									inputs[i].checked = true;
								}
							}
						}
					}

				}
				function ClarityImg_Click(sval)
				{
					var inputs = document.getElementsByTagName('input');
					//alert(inputs);
					var k = 0;
					for (var i=0; i<inputs.length; i++) 
					{
						if (inputs[i].type == 'checkbox' && inputs[i].name == "chkClarity") 
						{
							k++;
							if (inputs[i].value == sval)
							{
								if (inputs[i].checked)
									inputs[i].checked = false;
								else
								{
									inputs[i].checked = true;
									Clarity_Click(inputs[i], k);
								}
							}
						}
					}					
				}
				
				
	function IsNumeric(strString)
	{
		var strValidChars = "0123456789.-";
   		var strChar;
   		var blnResult = true;

   		if (strString.length == 0) return false;

		for (i = 0; i < strString.length && blnResult == true; i++)
      	{
      		strChar = strString.charAt(i);
      		if (strValidChars.indexOf(strChar) == -1)
         	{
         		blnResult = false;
         	}
      	}
   		return blnResult;
   	}


	function createSearchRange()
	{
	
		//Form1 = document.Form1;
		var shpefound = false;
		for (i = 0; i < Form1.Shape.length; i++)
      	{
			if (Form1.Shape[i].checked)
         		shpefound = true;
      	}
		if (!shpefound)
		{
			alert("Select a Shape");
			return false;
		}
		if (Form1.AdvDepth_From.value.length > 0)
		{
			
			if (!IsNumeric(Form1.AdvDepth_From.value))
			{
				alert("Enter the Depth From valid characters");
				Form1.AdvDepth_From.focus();
				return false;
			}
		}
		if (Form1.AdvDepth_To.value.length > 0)
		{
			
			if (!IsNumeric(Form1.AdvDepth_To.value))
			{
				alert("Enter the Depth To valid characters");
				Form1.AdvDepth_To.focus();
				return false;
			}
		}
		
		if (Form1.AdvTable_From.value.length > 0)
		{
			
			if (!IsNumeric(tform.AdvTable_From.value))
			{
				alert("Enter the Table To valid characters");
				Form1.AdvTable_From.focus();
				return false;
			}
		}
		if (Form1.AdvTable_From.value.length > 0)
		{
			
			if (!IsNumeric(Form1.AdvTable_From.value))
			{
				alert("Enter the Table To valid characters");
				Form1.AdvTable_From.focus();
				return false;
			}
		}
//		if(tform.size1.value > document.form42.size2.value && document.form42.size2.value!='10.000')
//		{
//			alert('Please make sure that from size is less than to size.');
//			return false;
//		}
//		document.form42.size_range.value = document.form42.size1.value+'-'+document.form42.size2.value;
		return true;
	}


 ///////////////////////////////////////
	function Price_Text(what, e) {
		SelectThis(what);
		return OnlyPrice(e);
	}

	function OnlyPrice(e) {
		var sMask = "01234567890,.";
		var KeyTyped;
		
		//if( = String.fromCharCode(window.event.keyCode);
		
		KeyTyped = window.event ? String.fromCharCode(e.keyCode) : String.fromCharCode(e.which);
	   
		//var srcObject = window.event.srcElement;
		var srcObject = e.srcElement ? e.srcElement : e.target;
		var elementid = window.event ? e.srcElement.id : e.target.id;
		frigger = document.getElementById(elementid);
		keyCount = frigger.value.length;
		if (e.which) {var thiskey = e.which;} else if (e.keyCode) {var thiskey = e.keyCode;}
		if (sMask.indexOf(KeyTyped.toString()) == -1 && !((thiskey>=48&&thiskey<=57)||(thiskey>=37&&thiskey<=40)||thiskey==8||thiskey==9||thiskey==13 || thiskey==144|| thiskey==46))
			{
				alert("Please enter numbers only.");
				return false;
			} else {
				return true;
			}
	}

	function OnlyDecimal(e) {
		var sMask = "01234567890.";
		var KeyTyped;
		
		//if( = String.fromCharCode(window.event.keyCode);
		
		KeyTyped = window.event ? String.fromCharCode(e.keyCode) : String.fromCharCode(e.which);
	   
		//var srcObject = window.event.srcElement;
		var srcObject = e.srcElement ? e.srcElement : e.target;
		var elementid = window.event ? e.srcElement.id : e.target.id;
		frigger = document.getElementById(elementid);
		keyCount = frigger.value.length;
		if (e.which) {var thiskey = e.which;} else if (e.keyCode) {var thiskey = e.keyCode;}
		if (sMask.indexOf(KeyTyped.toString()) == -1 && !((thiskey>=48&&thiskey<=57)||(thiskey>=37&&thiskey<=40)||thiskey==8||thiskey==9||thiskey==13 || thiskey==144|| thiskey==46))
			{
				alert("Please enter numbers or decimal numbers only.");
				return false;
			} else {
				return true;
			}
	}

	function Price_Edit(what)  {
		//var thisnumber = what.value;
		//alert(what.value);
		//if ((thisnumber.length % 4) == 0 &&  thisnumber.length > 2)
		//{
		//	what.value = what.value.substr(0,1) + ',' + what.value.substring(0);
		//}
	}

	function SelectThis(what) {
		whatwhat = document.getElementById(what);
		if (!whatwhat.checked) {whatwhat.checked = true}
	}

function focusthis(what)  {
	if (document.getElementById(what))  var whatwhat = document.getElementById(what);
	if (!whatwhat.disabled || !whatwhat.readOnly) whatwhat.focus();
}


//--- function to check ring size
function chkRingSizeRange(what, gender) {
	if ((document.getElementById(what).options[document.getElementById(what).selectedIndex].value < 4.5 || document.getElementById(what).options[document.getElementById(what).selectedIndex].value > 7.5) && gender != 'M') {
		document.getElementById('rs_disclaimer').innerHTML = '*<a href="#rsn" class="copylink">Please see Ring Size Note.</a>';
	} else {
		document.getElementById('rs_disclaimer').innerHTML = '';
	}
	return false;
}

/*****************************************************
 * ypSlideOutMenu
 * http://ypslideoutmenus.sourceforge.net/
 * 3/04/2001
 * 
 * a nice little script to create exclusive, slide-out
 * menus for ns4, ns6, mozilla, opera, ie4, ie5 on 
 * mac and win32. I've got no linux or unix to test on but 
 * it should(?) work... 
 *
 * Licensed under AFL 2.0
 * http://www.opensource.org/licenses/afl-2.0.php
 *
 * Revised: 
 * - 08/29/2002 : added .hideAll()
 * - 04/15/2004 : added .writeCSS() to support more 
 *                than 30 menus.
 * - 03/15/2005 : check if submenu exists -by DuDDo-
 *
 * --youngpup--
 *****************************************************/

ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 0
ypSlideOutMenu.hideDelay = 0
ypSlideOutMenu.minCPUResolution = 10

// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	this.css = "";

	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim		 = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0

		// global reference to this object
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")

		// add this menu object to an internal list of all menus
		ypSlideOutMenu.Registry[id] = this

		var d = document

		var strCSS = "";
		strCSS += '#' + this.id + 'Container { visibility:hidden; '
		//strCSS += 'left:' + left + 'px; '
		//strCSS += 'top:' + top + 'px; '
		strCSS += 'overflow:visible; z-index:10; }'
		strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
		strCSS += 'width:' + width + 'px; '
		strCSS += 'height:' + height + 'px; '
		strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
		strCSS += '}'

		this.css = strCSS;

		this.load()
	}
}

ypSlideOutMenu.writeCSS = function() {
	document.writeln('<style type="text/css">');

	for (var id in ypSlideOutMenu.Registry) {
		document.writeln(ypSlideOutMenu.Registry[id].css);
	}

	document.writeln('</style>');
}

ypSlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp

	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")

		//set initial state
		this.endSlide()
	}
}
	
ypSlideOutMenu.showMenu = function(id)
{
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]
	if (obj) {
	if (obj.container) {
		obj.over = true

		// close other menus.
		for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu)

		// if this menu is scheduled to close, cancel it.
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }

		// if this menu is closed, open it.
		if (!obj.open & !obj.aniTimer) reg[id].startSlide(true)
	} }
}

ypSlideOutMenu.hideMenu = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = ypSlideOutMenu.Registry[id]
	if (obj) {
  if (obj.container) {
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	} }
}

ypSlideOutMenu.hideAll = function()
{
	var reg = ypSlideOutMenu.Registry
	for (menu in reg) {
		ypSlideOutMenu.hide(menu);
		if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
	}
}

ypSlideOutMenu.hide = function(id)
{
	var obj = ypSlideOutMenu.Registry[id]
  obj.over = false

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	
	// flag that this scheduled event has occured.
	obj.hideTimer = 0

	// if this menu is open, close it.
	if (obj.open & !obj.aniTimer) obj.startSlide(false)
}

ypSlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()	
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}

ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open & this.dirType == "-")		d = -d
		else if (this.open & this.dirType == "+")	d = -d
		else if (!this.open & this.dirType == "-")	d = -this.dim + d
		else										d = this.dim + d

		this.moveTo(d)
	}
}

ypSlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open & !this.over) || (!this.open & this.over)) {
		this.startSlide(this.over)
	}
}

ypSlideOutMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

// events
ypSlideOutMenu.prototype.onactivate		= function() { }
ypSlideOutMenu.prototype.ondeactivate	= function() { }


var menus = [
	new ypSlideOutMenu("menu1", "down", 0, 0, 180, 155)
]

for (var i = 0; i < menus.length; i++) {
	//menus[i].onactivate = new Function("document.getElementById('act" + i + "').className='active';");
	//menus[i].ondeactivate = new Function("document.getElementById('act" + i + "').className='';");
}

ypSlideOutMenu.writeCSS();


<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v;
  }
}

function MM_showHideExtendLayers() { //v6.0
  var h=(document.documentElement.clientHeight);
  var i,p,v,obj,args=MM_showHideExtendLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v;
		if (navigator.appName!="Microsoft Internet Explorer"){
		obj.height=h;
		}
	}
}
// functionality will break if there are more than 30 Layers on the page
function MM_showHideAllLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideAllLayers.arguments;
  for (i=0; i<(30); i++) if ((obj=MM_findObj('Layer'+[i]))!=null) {
    obj.style.visibility='hidden'; 
	}
}
//-->


function makepage(src)
{
  // We break the closing script tag in half to prevent
  // the HTML parser from seeing it as a part of
  // the *main* page.

  return "<html>\n" +
    "<head>\n" +
    "<title>Temporary Printing Window</title>\n" +
    "<script>\n" +
    "function step1() {\n" +
    "  setTimeout('step2()', 10);\n" +
    "}\n" +
    "function step2() {\n" +
    "  window.print();\n" +
    "  window.close();\n" +
    "}\n" +
    "</scr" + "ipt>\n" +
    "</head>\n" +
    "<body onLoad='step1()'>\n" +
    "<img src='" + src + "'/>\n" +
    "</body>\n" +
    "</html>\n";
}

function printme(evt, image_src)
{
  if (!evt) {
    // Old IE
    evt = window.event;
  }
  var image = evt.target;
  if (!image) {
    // Old IE
    image = window.event.srcElement;
  }
  src = image.src;
  if (!src) {
	src = image_src;
  }
  link = "about:blank";
  var pw = window.open(link, "_new");
  pw.document.open();
  pw.document.write(makepage(src));
  pw.document.close();
}

