/*

Link with 
<script type="text/javascript" src="PATH/hhgreggCore.js"></script>

*/

var allGood 
allGood = "yes";
var storesChecked = "no";

var toggleMode = "none"
function toggleViewMode()
{
	if (toggleMode == "none")
	{
		toggleMode = "block";
	}
	else
	{
		toggleMode = "none";
	}
}

function submitItPlain(nameofform){
	if (allGood == "no"){
		//alert("All fields are required.\n\rPlease ensure all fields are properly completed and then try again.");
		allGood = "yes"
	}
	else{
		
		document.forms(nameofform).submit();
	}
}

function valField(formFieldValue, customMessage){
	if (formFieldValue == ''){		
		allGood = "no";
		alert(customMessage);
	}
}

function submitIt(nameofform, sel, Key){
alert("tes");
	if (allGood == "no"){
		//alert("All fields are required.\n\rPlease ensure all fields are properly completed and then try again.");
		allGood = "yes"
	}
	else{	
	    document.forms(nameofform).Selection.value = sel;
		document.forms(nameofform).Key.value = Key;	
		document.forms(nameofform).submit();
	}
}

function doKeySubmit(sel, Key)
{   
    document.mainform.Selection.value = sel;        
    document.mainform.Key.value = Key;        
    document.mainform.submit();
    
}

function doKeySubmitForm(sel, Key, formName)
{   
    document.forms(formName).Selection.value = sel;
    document.forms(formName).Key.value = Key;
    document.forms(formName).submit();
    
}

function ImageLoadFailed() {
  window.event.srcElement.style.display = "None";
}

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_preloadImages() { //v3.0
try{
  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];}}
}
catch(e){}
}

function MM_findObj(n, d) { //v3.0
  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); 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 MM_openBrWindow(theURL,winName,features) { //v2.0
	var str = new String(features);
	var hStartPos, hEndPos, hVal 
	var wStartPos, wEndPos, wVal	
	var x, y
	
	if((str.indexOf("height") >= 0)&&(str.indexOf("width") >= 0)) {
		hStartPos = str.indexOf("height");	
		hEndPos = str.indexOf(",", hStartPos);
		hVal = str.substring(hStartPos + 7, hEndPos);
	
		wStartPos = str.indexOf("width");	
		wEndPos = str.indexOf(",", wStartPos);
		wVal = str.substring(wStartPos + 6, wEndPos);
	
		x = (screen.availWidth / 2) - (wVal / 2)
		y = (screen.availHeight / 2) - (hVal / 2)
		
		var newWin = window.open(theURL,winName,features);
		newWin.moveTo(x, y);
	}
	else {
		window.open(theURL,winName,features);
	}
}

/* Not sure but this one was on both headers
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
*/


function close_window() {
    window.close();
}

function MM_showHideLayers() { //v3.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_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 confirmDelete() {
	if(confirm("Are you sure you want to DELETE this item?")){
		return true;
	}else{
		return false;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function moveup(uSel) {
   var intNewValue;
   var strNewText;
	for (i=1;i<uSel.options.length;i++)
		if (uSel.options[i].selected)
		{
		   intNewText = uSel.options[i-1].text;
		   intNewValue = uSel.options[i-1].value;
		   uSel.options[i-1].text = uSel.options[i].text;
		   uSel.options[i-1].value = uSel.options[i].value;
		   uSel.options[i].text = intNewText;
		   uSel.options[i].value = intNewValue;
		   uSel.options[i].selected = false;    
		   uSel.options[i-1].selected = true;    
		}
		
}
function movedown(uSel) {
   var intNewValue;
   var strNewText;
	for (i=uSel.options.length - 2;i>=0;i--)
		if (uSel.options[i].selected)
		{
		   intNewText = uSel.options[i+1].text;
		   intNewValue = uSel.options[i+1].value;
		   uSel.options[i+1].text = uSel.options[i].text;
		   uSel.options[i+1].value = uSel.options[i].value;
		   uSel.options[i].text = intNewText;
		   uSel.options[i].value = intNewValue;
		   uSel.options[i].selected = false;    
		   uSel.options[i+1].selected = true;    
		   
		}
}		

function showStatus(uSel, uSelEdit) {

	if(uSel.selectedIndex==-1)
		return false;
	
	var str = new String(uSel(uSel.selectedIndex).text);
	var iPos;
	
	// index position of the 'A' or 'I' char
	// find the space char and add 1
	iPos = str.indexOf(" ") + 1
	
	if(str.substr(iPos) == 'Active') {
		//set to Active
		uSelEdit.options[0].selected = true;
		}
	else {
		//set to Inactive
		uSelEdit.options[1].selected = true;
		}		
}

function updateStatus(uSel, uSelEdit) {

	if(uSel.selectedIndex==-1)
		return;
				
	var str = new String(uSel(uSel.selectedIndex).text);
	var iPos;
	var strBegin;
	var strEnd; 
	
	// index position of the 'A' or 'I' char
	// find the space char and add 1
	iPos = str.indexOf(" ") + 1

	// store the first part of the string (i.e. "1, ") 
	strBegin = str.substr(0,iPos)
	strEnd = uSelEdit(uSelEdit.selectedIndex).text

	uSel(uSel.selectedIndex).text = strBegin + strEnd;
}

function updateline(uSel,uTxt) {
       if (uTxt.value.length > 0) {
		  // uSel(uSel.selectedIndex).value = uTxt.value;  
		   uSel(uSel.selectedIndex).text = uTxt.value;
		}   
}

function editline(uSel,uTxt) {
		   uTxt.value = uSel(uSel.selectedIndex).text 
}

function addline(uSel,uTxt) {
   var intLength;
       if (uTxt.value.length > 0) {
           intLength = uSel.options.length;   
		   uSel.options[intLength] = new Option("prompt");
		   uSel(intLength).value = "-1";  
		   uSel(intLength).text = uTxt.value;
		   uTxt.value = "";  
       }   
}
function deleteline(uSel,uTxt,dTxt) {
	for (i=uSel.options.length - 1;i>=0;i--){
		if (uSel.options[i].selected){
			if ((dTxt.value.length) < 1){ 
				dTxt.value = uSel(uSel.selectedIndex).value
			    }
			else {
				dTxt.value = dTxt.value + "," + uSel(uSel.selectedIndex).value
			    }  
	   		for (x=i;x<uSel.options.length - 1;x++){
			   uSel.options[x].text = uSel.options[x+1].text;
			   uSel.options[x].value = uSel.options[x+1].value;
			}
		    uSel.options[x] = null;
        }
    }        		  

//   var intSelected;
//   if (uTxt.value.length > 0) {
//		intSelected = uSel.selectedIndex;/
//		if ((dTxt.value.length) < 1){ 
//			dTxt.value = uSel(uSel.selectedIndex).value
//		    }
//		else {
//			dTxt.value = dTxt.value + "," + uSel(uSel.selectedIndex).value
//		    }  
//		for (i=1;i<uSel.options.length - 1;i++)
//			if (i == intSelected )
//			{
//			   uSel.options[i].text = uSel.options[i+1].text;
//			   uSel.options[i].value = uSel.options[i+1].value;
//		       intSelected++
//			}   
  //     	   uSel.options[i].selected = false;    
//			uSel.options[intSelected] = null;
//		   uTxt.value = "";  
		   
//     }   		   
		    
}

function submitform(uSel,uTxt) {
    var strSubmitString
    strSubmitString = "";
  	for (i=0;i<uSel.options.length;i++)
  	    {
  		if (i == 0) {
  	       strSubmitString = i + "," + uSel.options[i].value + "," + uSel.options[i].text 
           }
           else
           {
  	       strSubmitString = strSubmitString + "|" + i + "," + uSel.options[i].value + "," + uSel.options[i].text 
           }
        }   
       //alert('test');    
       uTxt.value = strSubmitString; 
        
      // document.hostform.submit();  
      // return true;   		   
	    
}

function deleteall(uSel,uTxt,dTxt) {
	   
		var i;
		for (i = uSel.options.length -1 ; i >= 0; i--) {

			if ((dTxt.value.length) < 1){ 
				dTxt.value = uSel(i).value
			    }
			else {
			    dTxt.value = dTxt.value + "," + uSel(i).value
			    }             
 			uSel.options[i] = null;
           }
            uTxt.value = "";  
}

        function Left(str, n)
        /***
                IN: str - the string we are LEFTing
                    n - the number of characters we want to return

                RETVAL: n characters from the left side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                        return "";
                else if (n > String(str).length)   // Invalid bound, return
                        return str;                // entire string
                else // Valid bound, return appropriate substring
                        return String(str).substring(0,n);
        }

function selectitem(uSel,uSeld) {
   var intNewValue;
   var strNewText;
	for (i=uSel.options.length - 1;i>=0;i--){
		if (uSel.options[i].selected){
			intNewText = uSel.options[i].text;
			intNewValue = uSel.options[i].value;
	   		for (x=i;x<uSel.options.length - 1;x++){
			   uSel.options[x].text = uSel.options[x+1].text;
			   uSel.options[x].value = uSel.options[x+1].value;
			}
			uSeld.options[uSeld.options.length] = new Option("Prompt");
			uSeld.options[uSeld.options.length - 1].text = intNewText
			uSeld.options[uSeld.options.length - 1].value = intNewValue
		    uSel.options[x] = null;
        }
    }        		  
}

function selectall(uSel) {
       // alert('test');
		for (i = uSel.options.length -1 ; i >= 0; i--) {
				uSel.options[i].selected = true;
			    }
}

function moveToNextField(uTxt,sVal,iLen){
	if(String(sVal).length == iLen){
		uTxt.focus();
	}
}

// Check whether string s is empty.
function isEmpty(s) {
   return ((s == null) || (s.length == 0))
}

// whitespace characters
var whitespace = " \t\n\r";

// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace (s) {   
	var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function isDigit (c) {   
	return ((c >= "0") && (c <= "9"))
}

function isInteger (s) {   
	var i;

    if (isEmpty(s))
		return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


// fieldList is comma separated, no whitespace
function chkReqdFields(formName, fieldList) {
	var arrFields;
	var i = 0
//	alert('Checking ' + formName);

	arrFields = fieldList.split(',');
	for(i = 0; i<arrFields.length; i++) {
		//alert('Checking ' + arrFields[i]);
		if(isWhitespace(eval('document.forms["' + formName + '"].' + arrFields[i] + '.value'))) {
			alert("Please fill in all required fields.");
			return false;
		}
	}
	return true;
}




<!-- Begin
		function emailCheck (emailStr) {
		var checkTLD=1;
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
		if (emailStr ==""){
		}
		else{
		if (matchArray==null) {
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		alert("Ths username contains invalid characters.");
		return false;
		   }
		}
		for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		alert("Ths domain name contains invalid characters.");
		return false;
		   }
		}

		if (user.match(userPat)==null) {
		alert("The username doesn't seem to be valid.");
		return false;
		}

		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {

		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
		alert("Destination IP address is invalid!");
		return false;
		   }
		}
		return true;
		}
		 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
		alert("The domain name does not seem to be valid.");
		return false;
		   }
		}

		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
		}

		if (len<2) {
		alert("This address is missing a hostname!");
		return false;
		}

		return true;
		}
		}//this is the closing bracket of the second of if/else statement--(the one that says if emailStr == "" then)

