<!--
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//Global Variables, Add to HEAD Section of page
//general variables ********************************************************
var glbErrorMsg = "";
var ErrorBGColor = "#FF8080";
var GoodBGColor = "#FFFFFF";

//detect browser
var browser_type = navigator.appName
var browser_version = parseInt(navigator.appVersion)
//NS 6
var NS6 = (browser_type=="Netscape"&&browser_version>=5) ? true : false;
//IE 4+
var IE5 = (browser_type=="Microsoft Internet Explorer"&&browser_version>=5) ? true : false;
//NS4+
var NS4 = (browser_type=="Netscape"&&browser_version>=4) ? true: false;

//regular expression ******************************************************
var EmailRE = "^.+@.+\\.\\w{2,3}$|^$" //regular expression for a proper email address
var EmailRE2 = "^[^@ ]+@\.[^@ \.]+$"
var ZipRE = "(^\\d{5}$|^\\d{5}-\\d{4}$)|(^[A-Za-z]\\d[A-Za-z]\\s{0,1}\\d[A-Za-z]\\d$)" //*** DGS_20040528 Changed zip code pattern. ***
var ZipRE2 = "^\\d{5}[(\\-\\d{4})]$"
var StateRE = "^\\w{2}$|^$"
var PhoneRE = "^\\d{3}\\W\\d{3}\\W\\d{4}$|^$"
var FaxRE = "^\\d{3}\\W\\d{3}\\W\\d{4}$|^$"
var NumberRE = "^\\d+$|^\\d{0,}\\.\\d+$|^\\d+\\.\\d{0,}$|^\\.\\d+$"
var WordRE = "^\\w+"

//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function testRE(REStrv,strv,flagsv)
{
	if(flagsv)
	{
//*** BEGIN DGS_20040527 ***
//Comment the following line and change the way the regExp is constructed.
//For WHS5.1 compatability.
//		REv = new RegExp(REStrv, flagsv);
		REv = new RegExp(REStrv);
		
//*** END DGS_20040527 *****
	}
	else
	{
		REv = new RegExp(REStrv);
	}
//alert("REStrv = " + REStrv + "\nstrv = " + strv + "\nREv.test(strv) == true = " + REv.test(strv) == true);
//alert("REStrv = " + REStrv + "\nstrv = " + strv + "\nREv.test(strv) = " + REv.test(strv));
	if(REv.test(strv) == true)
	{
		return true;
	}

	return false;
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//open a child window
function openWindow(vUrl,vWidth,vHeight)
{
	pop = window.open(vUrl, "pop", "width=" + vWidth + ",height=" + vHeight + ",menubar=no,location=no,toolbar=no,scrollbars=yes");
	pop.focus();
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//center the child window, call from the child window onload
function centerWindow(vWidth,vHeight)
{
// get users screen resolution
	screenWidth = parseInt(screen.width);
	screenHeight = parseInt(screen.height);
	winWidth = parseInt(vWidth)
	winHeight = parseInt(vHeight)

// find center of screen
	newWinLeft = parseInt((screenWidth * .5) - parseInt(winWidth * .5));
	newWinTop = parseInt((screenHeight * .5) - parseInt(winHeight * .5));

// move window to the center of the screen
	window.moveTo(parseInt(newWinLeft),parseInt(newWinTop));
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//validate form elements upon submit, returns true or false
//<form id="test" name="test" method="post" action="./something.asp" onsubmit="return formBlankFieldChk(formName,strfldName,strfldDesc);">
function formBlankFieldChk(myFormName, myFldNames, myFldDesc)
{
	var myFormObj = document.forms[myFormName];

//1) Enter name of mandatory fields
	//var fieldRequired = Array("FirstName", "LastName");
	var fieldRequired = myFldNames.split('»');
//2) Enter field description to appear in the dialog box
	//var fieldDescription = Array("First Name", "Last Name");
	var fieldDescription = myFldDesc.split('»');

//3) Enter dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var orig_Msg = alertMsg.length;
	//validation for required fields
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = myFormObj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
					obj.style.backgroundColor = ErrorBGColor;
				}
				if (obj.selectedIndex == 1 || !obj.options[obj.selectedIndex].text == ""){
					obj.style.backgroundColor = GoodBGColor;
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
					obj.style.backgroundColor = ErrorBGColor;
				}
				if (obj.selectedIndex == 1){
					obj.style.backgroundColor = GoodBGColor;
				}
				break;
			case "text":
			
//*** begin DGS_20040430 ***
				if (obj.id == "fldcompname_ship" || obj.id == "fldaddress_ship")
				{
					if(!testRE("^\\w+",obj.value,"i"))
					{
						obj.value = "";
					}
				}
//*** END DGS_20040430 ***
			
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
					obj.style.backgroundColor = ErrorBGColor;
				}
				if (!obj.value == "" || obj.value == null){
					obj.style.backgroundColor = GoodBGColor;
				}
				break;
			default:

				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
					obj.style.backgroundColor = ErrorBGColor;
				}
				if (!obj.value == "" || obj.value == null){
					obj.style.backgroundColor = GoodBGColor;
				}

			}
		}
	}

	if (alertMsg.length == orig_Msg)
	{
		return true;
	}
	else
	{
		//alert(alertMsg);
		glbErrorMsg += alertMsg;
		return false;
	}
}
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
function callWinPrint()
{
	winPrint();
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function winPrint()
{
	if(testRE('MSIE 4',navigator.userAgent) && IE4)
	{ 
		printIE4();
	}
	else
	{
		top.frames['framMain'].focus();
		window.print();
	}
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//preload images
//onload="MM_preloadImages('.img/clr.gif','./img/picture.gif')"

function MM_preloadImages() { //v3.0
  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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function isDate(dateStr)
{
    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?

    if (matchArray == null) {
        //alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
        return false;
    }

    month = matchArray[1]; // parse date into variables
    day = matchArray[3];
    year = matchArray[5];

    if (month < 1 || month > 12) { // check month range
        //alert("Month must be between 1 and 12.");
        return false;
    }

    if (day < 1 || day > 31) {
        //alert("Day must be between 1 and 31.");
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        //alert("Month "+month+" doesn't have 31 days!")
        return false;
    }

    if (month == 2) { // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
            //alert("February " + year + " doesn't have " + day + " days!");
            return false;
        }
    }
    return true; // date is valid
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
var toFind = ""; // Variable that acts as keyboard buffer
var timeoutID = "";// Process id for timer (used when stopping the timeout)
timeoutInterval = 250;// Milliseconds. Shorten to cause keyboard buffer to be cleared faster
var timeoutCtr = 0;// Initialization of timer count down
var timeoutCtrLimit = 3 ; // Number of times to allow timer to count down
var oControl = "";// Maintains a global reference to the control that the user is working with.
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// This function is called when the user presses a key while focus is in 
// the listbox. It maintains the keyboard buffer.
// Each time the user presses a key, the timer is restarted. 
// First, stop the previous timer; this function will restart it.

function listbox_onkeypress()
{
	window.clearInterval(timeoutID)
	// Which control raised the event? We'll need to know which control to set the selection in.
	oControl = window.event.srcElement;
	var keycode = window.event.keyCode;
	if(keycode >= 32 )
	{
		var c = String.fromCharCode(keycode);// What character did the user type?
		c = c.toUpperCase(); // Convert it to uppercase so that comparisons don't fail
		toFind += c ; // Add to the keyboard buffer
		find();// Search the listbox
		timeoutID = window.setInterval("idle()", timeoutInterval); // Restart the timer
	}
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// This function is called when the user leaves the listbox.
function listbox_onblur()
{
	window.clearInterval(timeoutID);
	resetToFind();
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// This function is called if the timeout expires. If this is the 
// third (by default) time that the idle function has been called, 
// it stops the timer and clears the keyboard buffer
function idle()
{
	timeoutCtr += 1
	
	if(timeoutCtr > timeoutCtrLimit)
	{
		resetToFind();
		timeoutCtr = 0;
		window.clearInterval(timeoutID);
	}
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function resetToFind()
{
	toFind = ""
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function find()
{
	// Walk through the select list looking for a match
	var allOptions = document.all.item(oControl.id);
	
	// Gets the next item from the listbox
	for (i=0; i < allOptions.length; i++)
	{
		nextOptionText = allOptions(i).text.toUpperCase();
		// By default, the values in the listbox and as entered by the 
		// user are strings. This causes a string comparison to be made, 
		// which is not correct for numbers (1 < 11 < 2).
		// The following lines coerce numbers into an (internal) number 
		// format so that the subsequent comparison is done as a 
		// number (1 < 2 < 11).

		//if(!isNaN(nextOptionText) && !isNaN(toFind) )
		//{
		//	nextOptionText *= 1;// coerce into number
		//	toFind *= 1;
		//}

		// Does the next item match exactly what the user typed?
		if(toFind == nextOptionText)
		{
			// OK, we can stop at this option. Set focus here
			oControl.selectedIndex = i;
			window.event.returnValue = false;
			break;
		}

		// If the string does not match exactly, find which two entries 
		// it should be between.
		if(i < allOptions.length-1)
		{
			// If we are not yet at the last listbox item, see if the 
			// search string comes between the current entry and the next 
			// one. If so, place the selection there.
			lookAheadOptionText = allOptions(i+1).text.toUpperCase() ;
			if( (toFind > nextOptionText) && (toFind < lookAheadOptionText) )
			{
				oControl.selectedIndex = i+1;
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				break;
			} // if
		} // if
		else
		{
			// If we are at the end of the entries and the search string 
			// is still higher than the entries, select the last entry
			if(toFind > nextOptionText)
			{
				oControl.selectedIndex = allOptions.length-1 // stick it 
				// at the end
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				break;
			} // if
		} // else
	} // for
} // function
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// --> 