
<!--
var ngcetAlfaChars='abcdefghijklmnopqrstuvwxyz';
var ngcetNumChars='1234567890';
var ngcetNameChars=ngcetAlfaChars+"'. -";
var ngcetPasswordChars=ngcetNumChars+'!@#$%^&*;\"\'';
var ngcetEmailChars='abcdefghijklmnopqrstuvwxyz01234567890.@-_';
var jLogText=null;
var jLogWindow=null;
var jLogCount=null;


// jLog functions are used for debugging only. /////////////////////////////jLog Start
//
// level 0 no logging (This should be set to 0 for production
// level 1 (level one messages only)
// level 2 (level one and two messages only)
// level 3 (level one,two and three messages only)

var jLogLevel = 0; 

if(jLogLevel>0){
     openJLogWindow();
}       

function getJLogDate()
{
   var now         = new Date();
   var monthnumber = now.getMonth()+1;
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = year +
                    '-' +
                    monthnumber +
                    '-' +
                    monthday;
   return dateString;
} // function getCalendarDate()

function getJLogTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   if (hour   < 10) { hour="0"+hour          }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour +
                    ':' +
                    minute +
                    ':' +
                    second ;
   return timeString;
} // function getJLogTime()


var jLogText=null;
var jLogWindow=null;
var jLogCount=null;

// open the jLog window
var jLogFile="/nfl/jscript/jlog.jsp";
function openJLogWindow(){
 if(jLogWindow==null)
   jLogWindow=window.open(jLogFile,"jlog");

} //function openJLogWindow()


// getThe jLogTextArea from the jLogWindow

function setJLogText(){
  if(jLogWindow && jLogWindow.jLogText )
     jLogText=jLogWindow.jLogText;
  if(jLogText)
       return true;
  return false;

}//function setJLogText()

// message to log at desired level see top of this file

//write the message to the log  if the level is greater than or equal to the the permissible level;
function writeJLog(msg,level){
  if(jLogLevel < level){
    return;
  }   
  if( !jLogWindow){
     openJLogWindow();
  }   
  if (!jLogWindow ){
     return;
  }
  if(!jLogText){
    setJLogText();
    
  }
  if(jLogText){
    var val=jLogText.value;
    jLogCount++;
    var now=new Date();
    jLogText.value=val+"\n("+jLogCount+") "+getJLogDate()+" "+getJLogTime()+" "+ msg;

  } 
  return;
}//function writeJLog

///////////////////////////////////////////////////////////////////////////////jLog End
//
//
// Test for the existance of a variable
//
function ngcetIsDefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}
//
// Any character is ok
//
function ngcetAllKeyBoardChars(fieldId){
      return true;
}
//
// test for existance of  data in a form field identified by it's id
//
function ngcetRequired(fieldId){
    var val=ngcetGetVal(fieldId);
    
    if(val)
      val=ngcetStripSpaces(val);
    if (val==null || val=="" ){
          return false;
    }
    return true;

}
//
// Goes through the inputString and replaces every occurrence of fromString with toString
//
function ngcetReplaceString( inputString, fromString, toString) {
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn t exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
}

//
// required if flag is true
//
function ngcetRequiredFlagged(fieldId,flag){
    if(!flag)
     return true;
    return ngcetRequired(fieldId);

}
//
// verify field conforms to password
//
function ngcetCheckPassword (fieldId) {
  var thisField= ngcetGetField(fieldId);
  if(!thisField)
    return true;
  var pwd=ngcetStripSpaces(thisField.value);
  if (pwd == "") {
    return false;
    
  }
  if ((pwd.length < 6) ) 
       //The password you entered must be at least 6 characters long.
       
  pwd=pwd.toLowerCase();
  hasChar=false;
  hasAlfa=false;
  if(error==""){
    //Your password must have at least one alpha (a thru z) and one non-alpha character (0123456789!@#$%^&*)
    for(i=0;i<pwd.length;++i){
       c=pwd.charAt(i);
  
       if(ngcetPasswordChars.indexOf(c)>=0)
         hasChar=true;
       if(ngcetAlfaChars.indexOf(c)>=0)
         hasAlfa=true;
    }
  }  
  if(hasAlfa && hasChar)

    return true;
  
  ngcet_focus(thisField);
  return false;
}

//
//  Quantity test 1-999
//
function ngcetIsQte(fieldId){
    if(!ngcetRequired(fieldId)) return false;
    if(!ngcetNumCharsOnly(fieldId)) return false;
    var fieldItem=document.getElementById(fieldId);
    if(!fieldItem){
      return false;
    }
    if(fieldItem.options){
      val=fieldItem.options[fieldItem.selectedIndex].value;
    } else val=fieldItem.value;
    var valI=parseInt(val);
    if(valI <=0 || valI >999) return false;
    return true;

}
//
// Sets a field
//
function ngcetSetField(fieldId,val)
{
    var fieldItem=document.getElementById(fieldId);
    if(!fieldItem){
      return true;
    }
    if(fieldItem.options){
      fieldItem.selectedIndex=val;
    } else fieldItem.value=val;
    
}
//
// Test field for equality with a given value 
// 
//
function ngcetSetTo(fieldId,defaultVal)
{
    fieldItem=document.getElementById(fieldId);
    if(!fieldItem){
      return true;
    }
    if(fieldItem.options){
      val=fieldItem.options[fieldItem.selectedIndex].value;
    } else val=fieldItem.value;
    return (val == defaultVal);
}

//
// SkipRest function, returns true (Skip) if target set to a given value
//
function ngcetSkipRestDif(fieldId,targetId,valId)
{
    fieldItem=document.getElementById(targetId);
    if(!fieldItem){
      return true;
    }
    if(fieldItem.options){
      val=fieldItem.options[fieldItem.selectedIndex].value;
    } else val=fieldItem.value;
    
    valItem=document.getElementById(valId);
    if(!valItem){
      return true;
    }
    if(valItem.options){
      val2=valItem.options[valItem.selectedIndex].value;
    } else val2=valItem.value
    
    return (val == val2);
}
function ngcetSkipRestEmpty(fieldId)
{
    return !ngcetRequired(fieldId);
}
//
// true is field contains only Alpha chars and space
//
function ngcetAlphaSpace(fieldId){
    return ngcetInSet(fieldId,ngcetAlfaChars+" ");
}
function ngcetAlfaSpace(fieldId){
    return ngcetInSet(fieldId,ngcetAlfaChars+" ");
}
//
// true is field contains only Alpha chars
//

function ngcetAlphaOnly(fieldId){
    return ngcetInSet(fieldId,ngcetAlfaChars);
}
function ngcetAlfaOnly(fieldId){
    return ngcetInSet(fieldId,ngcetAlfaChars);
}

//
// true is field contains only Name chars
//

function ngcetNameCharsOnly(fieldId){
    return ngcetInSet(fieldId,ngcetNameChars);
}

//
// true is field contains only Number chars and space
//

function ngcetNumCharsOnly(fieldId){
    return ngcetInSet(fieldId,ngcetNumChars);
}

//
// true is field contains only (a..z,0..9 period & space)
//

function ngcetAlphaNumericPeriodSpace(fieldId){
    return ngcetInSet(fieldId,ngcetNumChars+ngcetAlfaChars+". ");
}
//
// true is field contains only (a..z, period & space)
//

function ngcetAlphaPeriodSpace(fieldId){
    return ngcetInSet(fieldId,ngcetAlfaChars+". ");
}

//
// true is field contains a valid email address
//

function ngcetEmailOnly(fieldId){
    return ngcetInSet(fieldId,ngcetEmailChars);
}
//
// true is field contains at least ln characters
//
function ngcetMinLength (fieldId,ln) {
  thisField=ngcetGetField(fieldId);
  if(!thisField)
    return false;
  pwd=ngcetStripSpaces(thisField.value);
  return (pwd.length >= ln);
}
//
// true is field contains any special password characters;
//

function ngcetPasswordCharsAny(fieldId){
    return ngcetHasOne(fieldId,ngcetNumChars+ngcetPasswordChars);
}

//
// true is fieldA==FieldB
//
function ngcetMatch(fieldIdA,fieldIdB){
    thisFieldA=document.getElementById(fieldIdA);
    thisFieldB=document.getElementById(fieldIdB);
    if(!thisFieldA || !thisFieldB ||!thisFieldA.value || !thisFieldB.value || (thisFieldA.value!=thisFieldB.value))

  	       return false;

	return true;
}


//
// makes field uppercase and returns true
//
function ngcetMakeUpper(fieldId){
    thisField=ngcetGetField(fieldId);

    if(!thisField){
      alert("Configuartion error: '"+fieldId+"' Not a valid field id");
      return false;
    }
    val=thisField.value;
    thisField.value=val.toUpperCase();
    return true;
}

//
// makes field lowercase and returns true
//
function ngcetMakeLower(fieldId){
    thisField=ngcetGetField(fieldId);


    if(!thisField){
      alert("Configuartion error: '"+fieldId+"' Not a valid field id");
      return false;
    }
    val=thisField.value;
    thisField.value=val.toLowerCase();
    return true;
}

//
// makes field titlecase and returns true
//
function ngcetMakeTitle(fieldId){
    thisField=ngcetGetField(fieldId);

    if(!thisField){
      alert("Configuartion error: '"+fieldId+"' Not a valid field id");
      return false;
    }
    val=ngcetStripSpaces(thisField.value);
    if(!val)
      return true;
    if(val.length==0)
      return true;
      mtU=true;
      nVal="";
      for (ti=0;ti<val.length;++ti){
        theChar=val.substring(ti,ti+1);
        if(mtU)
          nVal=nVal+theChar.toUpperCase();
        else
          nVal=nVal+theChar.toLowerCase();
        mtU=ngcetValHasOne(theChar,' -');

      }
     thisField.value=nVal;
    return true;
}
//
// returns true if valid email
//

function ngcetCheckGiftEmail(fieldId){
  return ngcetIsEmail(fieldId);
}

//
//  Full email test
//
function ngcetIsEmail(fieldId)
{
  thisField=document.getElementById(fieldId);
  email=ngcetStripSpaces(thisField.value);
  thisField.value=email;
  if (thisField.value == "")
    return false;    
  else if (email.length < 5 || !ngcet_isEmailAddr(email))
    return false;

  return true;
}


function ngcet_isEmailAddr(email)
{
  var result = false
  var index = email.indexOf("@");
  if ((index > 0) && (index+1< email.length))
  {
    dom=email.substring(index+1);
    pindex = dom.indexOf(".");
    if ((pindex > 0) && (pindex+1 < dom.length))
	result = true;
  }
  return result;
}

//
// removes leading spaces
//

function ngcet_LStrip(x)
{
   while (x.substring(0,1) == ' ') x = x.substring(1);
   return x;
}

//
// removes trailing spaces
//

function ngcet_RStrip(x)
{
  while (x.substring(x.length-1,x.length) == ' ') x = x.substring(0,x.length-1);
  return x;
}

//
// removes leading and trailing spaces
//

function ngcetStripSpaces(x)
{
   return ngcet_RStrip(ngcet_LStrip(x));
}

//
// removes leading and trailing spaces and returns true
//
function ngcetStripIt(fieldId)
{
    fieldItem=document.getElementById(fieldId);
    if(!fieldItem){
      return true;
    }
    val=ngcetStripSpaces(fieldItem.value);
    fieldItem.value=val;
    return true;
}

//
// changes the display.style of a given field to the specified value
// (makes things magically appear or disappear)
//

function ngcetChangeDisplayStyle(targetId,style){
  target=ngcetGetField(targetId);
  if (!target)
     return;
  if(!target.style){
     return;
  }   
  target.style.display=style;
}

//
// gets the field object given an ID
//

function ngcetGetField(thisId){
    var target=document.getElementById(thisId);

    if(!target)
      alert("Configuartion error: '"+thisId+"' Not a valid Id");
    return target;
}
//
// get the value of a form field identified by it's id
//
function ngcetGetVal(fieldId){
    
    var fieldItem=ngcetGetField(fieldId);
    
    if(!fieldItem)
      return null;
    if(fieldItem.options){
      return fieldItem.options[fieldItem.selectedIndex].value;
    } else 
      return fieldItem.value;
    

}
function ngcetGetValItem(fieldItem){
    
    if(!fieldItem)
      return null;
    if(fieldItem.options){
      return fieldItem.options[fieldItem.selectedIndex].value;
    } else 
      return fieldItem.value;
    

}

//
// does nothing very well.
//
function ngcetNada(){return true;}

//
// returns true if all the characters of a given field belong to the given set
//
function ngcetInSet(fieldId,set){
    
	var val=ngcetGetVal(fieldId);
	if(!val)
	  return true;
	for(var i=0;i<val.length;++i){
		var keychar=val.substring(i,i+1).toLowerCase();

		if (set.indexOf(keychar) == -1)
		return false;
	}
	return true;
}

//
// returns true if all the characters of a given field belong to the given set
//
function ngcetHasOne(fieldId,set){
    var val=ngcetGetVal(fieldId);
    if(val==null)
      return false;
    return ngcetValHasOne(val,set);  
}

function ngcetValHasOne(val,set){
    for(var i=0;i<val.length;++i){
	   var keychar=val.substring(i,i+1).toLowerCase();

	   if (set.indexOf(keychar) > -1)
  	       return true;
    }
    return false;
}

  function clearSearchField(field,onlyThis){
       if(onlyThis && onlyThis==field.value)
	   field.value="";
       field.style.color="black";	        
  }


  function setSearchField(fieldId,color){
    var field=ngcetGetField(fieldId);
    
        if(field)
            field.style.color=color;	
  }
  
  function ngcetCopyThisTo(from,toId){
    var to=ngcetGetField(toId);
    if(to==null)
      return;
     if(from==null)
      return;
    to.value=from.value;
  
  
  }
  
  function ngcetMoveThisTo(from,toId){
    var to=ngcetGetField(toId);
    if(to==null)
      return;
     if(from==null)
      return;
    to.value=ngcetGetValItem(from);
  
  
  }

//
// legacy leave alone
//

function ngcetAllowOnly(e,allowed){
return true;
}


function advance(currentField,nextField,size) { 
	var pNext = document.getElementById(nextField);
	if(currentField.value.length>size)
	  currentField.value=currentField.value.substring(0,size-1);
        if(currentField.value.length==size)
	  if(pNext)
	    pNext.focus();
 }

function ngcetNumbersOnly(myfield, e, dec){
	var key;
	var keychar;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
		return true;
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;
	// decimal point jump
	else if (dec && (keychar == ".")){
		if(myfield.value.indexOf('.')>-1){
			alert('You have already entered a decimal point.');
			return false;
		}
		else return true;
	}
	alert("'"+keychar+"' is not a correct entry. Please enter a number. ");
	return false;
}

function ngcetWholeNumbersOnly(myfield, e){
  return ngcetNumbersOnly(myfield, e);
}





var curField = 0;
var maxField=4;
 
function nextOne(){
  curField++;
  if(curField>maxField){
    ngcetChangeDisplayStyle('more','none');
    return;
  }
  ngcetChangeDisplayStyle('giftCert'+curField,'');

}

function open_window(url,width,height) {
	 if(width == null)
	 	var width=602;
	 if (height == null)
	 	var height=384;
	 {
	    popUpWin =window.open(url,'NewWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+(width)+',height='+(height));
	 }
}

function openInvestWin(url) {
	popUpWinI = window.open(url,'affiliate','height=620,width=850,fullscreen=no,menubar=no,location=no,resizable=yes,scrollbars=yes,titlebar=yes,toolbar=no');
}
function ngcetCheckWord(myfield) {
  if(ngcetIsDefined('naughtyWords'))
   return ngcetCheckIt(myfield,naughtyWords);
  else 
   return true; 
}

function ngcetCheckIt(myfield,nword) {
var val=ngcetGetVal(myfield);
if(!val)
  return true;
        var wrd=val.toUpperCase();
        wrd=ngcetStripSpaces(wrd);
        if(!wrd || wrd=="")
          return true;
	var i=0;
	 for(i=0;i<nword.length;++i) {

	  if (nword[i].toUpperCase()==wrd){
	    return false;
	  }
	  if(nword[i].toUpperCase()>wrd)
	    return true;
	 }
	 return true;
}
function ngcetCheckTeamNameNumber(fieldId){
        
        if(!ngcetIsDefined('teamNameNumber'))
          return true;
//        var myfield=ngcetGetField(fieldId); 
        
//	var id=myfield.id;
//	var nameId="cpv"+id.substring(3,id.length-1)+'0';
//	var numberId="cpv"+id.substring(3,id.length-1)+'1';
//        var nameItem=document.getElementById(nameId);
//        if(!nameItem || !nameItem.value)
//           return true;

//        var numberItem=document.getElementById(numberId);
//        if(!numberItem || !numberItem.value)
//          return true;
//        var number=numberItem.value;
//        var name=nameItem.value;
//
//	var teamMaxItem=document.getElementById("productTeamMax");
//	var teamMax=teamMaxItem.value;
//	for(i=0;i<teamMax;++i){
//	   var aTeam=document.getElementById("productTeam_"+i);
//	   if(aTeam && aTeam.value){
//			var wrd=aTeam.value+'|'+name+'|'+number;
//			wrd=wrd.toUpperCase();
//	      var j=0;
//	      for(j=0;j<teamNameNumber.length;++j){
//		if (teamNameNumber[j].toUpperCase()==wrd){
//			 myfield.value='';
//			 return false;
//		}
//	         if(teamNameNumber[j].toUpperCase()>wrd)
//	           break;
//	       }
//	    }
//	}
//
	return true;
}

function fixSizePasswordField(field,size)
{
		var field = ngcetGetField(field);
		field.style.width=size;
}


function nav_ClickSearch(formId)
{
	var navForm = document.getElementById(formId);
	if(navForm)
	{
		navForm.submit();
	} 
	else 
	{
		alert("Your version of Javascript does not support the minminum functionality required by this appilcation");
	}
}

function clearSearch(field)
{
field.value="";
field.style.color="000000";	        
}

function ngcetIsOptionSelected (fieldId) {
var selectField=ngcetGetField(fieldId);
if (selectField.selectedIndex == 0)
{
	return false;
}
else
	return true;
}

function textCounter(fieldId,maxlimit) 
{
	var field = document.getElementById(fieldId);
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
		alert("Only " + maxlimit + " characters are allowed in this field.");
	}
}
//-->
