VALID_ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
VALID_NUMERIC = "1234567890";
VALID_ANSI = "-=\`~!@#$%^&*()_+|{}[]';:,./?><";
VALID_PUNCTUATION = " &();':,.?/-";
VALID_WILDCARDS = "?*#";
VALID_BLANK = " "

// JavaScript Document

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 turnAllOff() {
	MM_showHideLayers('about','','hide','industry','','hide','policy','','hide', 'consumer','','hide','nutrition', '', 'hide', 'submission','','hide', 'sponsors','','hide', 'pubs','','hide', 'comm','','hide', 'events','','hide', 'committee','','hide', 'forum','','hide', 'groups','','hide', 'media','','hide', 'linklayer','','hide', 'hideall','','hide');
}

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_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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//Webmonkey toolbar
function WM_toggle(id){
   if (document.all){
     if(document.all[id].style.display == 'none'){
       document.all[id].style.display = '';
     } else {
       document.all[id].style.display = 'none';
     }
  return false;
   } else if (document.getElementById){
     if(document.getElementById(id).style.display == 'none'){
       document.getElementById(id).style.display = 'block';
     } else {
       document.getElementById(id).style.display = 'none';
     }
  return false;
   }
 }
 
function parentChangeSubmitForm() {
	if (document.forms.form1.ParentPageID.value != '') {
		alert("The page must now reload in order to refresh the List Position. \nYour data will not be affected."); 
		eWebEditPro.save();
		document.forms.form1.submit();
	}
}

// Opens the pop up windows for the year planner
function openYearPlannerWindow(pageID) { 
  var pageName = 'index.cfm?id=' + pageID;
  var windowName = 'YearPlanner';
  window.open(pageName,windowName,'scrollbars=yes,resizable=yes,width=600,height=400');
}

counter = 0;
function submitCount() {
	counter++;
	if(counter > 1) {
		return false;
	}
	return true;
}
function ConfirmKeyPressIsValid (vntValidString, vntFieldStyle)
{
  var vntOK = false;
  
  // record the keypress
  var vntKeyPressed = String.fromCharCode(window.event.keyCode);
  
  // ensure the keypress is valid
  for (var i=0; i < vntValidString.length; i++)
    if (vntValidString.charAt(i) == vntKeyPressed)
      vntOK = true;
  
  // 
	if (arguments.length < 2) vntFieldStyle = "";
	switch (vntFieldStyle)
	{
	  case "NumericStyleA":
	    // the rules for this style are:
	    // 1) it is possible to have only one decimal point and negative sign
	    if (vntKeyPressed == '.' && window.event.srcElement.value.search(/\./) != -1) vntOK = false;
	    if (vntKeyPressed == '-' && window.event.srcElement.value.search(/-/) != -1) vntOK = false;
	    break;
	}
	
	if (!vntOK)
	  alert ("You have used an invalid keystroke.\r\nValid keystrokes for this field include:\r\n" + vntValidString);
	  
  return vntOK;
}
   
function WindowPopUp(URL)
{
    var vLeft=(window.screen.width - screen.width)/2;
    var vTop=((window.screen.height - screen.height)/2);
    window.open(URL,'','toolbar,resizable,dependent=yes,alwaysRaised=yes,scrollbars,left=' + vLeft + ',top=' + vTop + ',screenX=0,screenY=0,width=900,height=600')
    window.event.returnValue=false
}

function PDFPopUp(arg1,arg2,arg3,arg4,arg5)
{
    URL="../Survey/UserDownload.aspx?x=" + arg1 + "&y=" + arg2 + "&z=" + arg3 + "&w=" + arg5;
    var vLeft=(window.screen.width - screen.width)/2;
    var vTop=((window.screen.height - screen.height)/2);
    window.open(URL,'','toolbar,resizable,dependent=yes,alwaysRaised=yes,scrollbars,left=' + vLeft + ',top=' + vTop + ',screenX=0,screenY=0,width=900,height=600')
    window.event.returnValue=false
}

//*****************************************************************************
//If Enter is pressed submit form.
//*****************************************************************************
function checkKey()
{
	if (window.event.keyCode==0xD) 
		if (ValidateOK() == true)
		{
			document.aspnetForm.submit();
		}
}

//*****************************************************************************
//Server-side check for illegal characters.
//*****************************************************************************
function IllegalChars(vntField)
{
	if (vntField.search(String.fromCharCode(34)) != -1 || vntField.search("<") != -1)
		return(true)
	else
		return(false);
}

function CheckComBoxLength(o)
{
    if(o.value.length>2000)
    {
        alert('The comment box entry has exceeded the maximum number of characters allowed');
        window.event.returnValue = false;
        o.focus();
    }
}
function CalculateTotal(vntField)
{
    var vntaField = vntField.split(",");
    var Prefix = "ctl00_ContentPlaceHolder1_BPS_TBX_";
    var total=0;     
    for (var i=0;i<vntaField.length-1;i++)
    {
        e = window.document.getElementById(Prefix + vntaField[i]);
        if (e.value=="")
            e.value = 0;
        total = total + parseFloat(e.value);
    }  
    e = window.document.getElementById(Prefix + vntaField[vntaField.length -1]);       
    e.value = total;
    
}
function addPrefix(vntField)
{
    var vntaField = vntField.split(",");
    var Prefix = "ctl00_ContentPlaceHolder1_BPS_STR_";
    e.value = Prefix;
    
}
function GetUserConfirm()
{
	if (!confirm("You are about to begin the 2009 survey, this will close the 2006, 2007 and 2008 surveys to data entry. Is this okay?"))
		return(false)
	else
		return(true);
}
function CheckOptions(o)
{
if (o.id == "ctl00_ContentPlaceHolder1_dlOptions_ctl00_chkOptions")
{
    if (o.checked == true)
    {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(true)
    }
    else
    {
         e1 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl01_chkOptions");
         e2 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl02_chkOptions");
         if (e1.checked == true)
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(false)
         }
         else if (e2.checked == true)
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(false)
         }
         else
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = false;
         return(false);
         }
    }
}
else if (o.id == "ctl00_ContentPlaceHolder1_dlOptions_ctl01_chkOptions")
{
    if (o.checked == true)
        {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(true)
        }
        else
        {
         e1 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl00_chkOptions");
         e2 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl02_chkOptions");
         if (e1.checked == true)
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(false)
         }
         else if (e2.checked == true)
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(false)
         }
         else
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = false;
         return(false);
         }
        }
}
else if (o.id == "ctl00_ContentPlaceHolder1_dlOptions_ctl02_chkOptions")
{
    if (o.checked == true)
        {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(true)
        }
        else
        {
         e1 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl00_chkOptions");
         e2 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl01_chkOptions");
         if (e1.checked == true)
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(false)
         }
         else if (e2.checked == true)
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = true;
         return(false)
         }
         else
         {
         e = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions");
         e.disabled = false;
         return(false);
         }
        }
}
else if (o.id == "ctl00_ContentPlaceHolder1_dlOptions_ctl03_chkOptions")
{
    if (o.checked == true)
        {
         e1 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl00_chkOptions");
         e2 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl01_chkOptions");
         e3 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl02_chkOptions");
         e1.disabled = true;
         e2.disabled = true;
         e3.disabled = true;
         return(true)
        }
        else
        {
         e1 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl00_chkOptions");
         e2 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl01_chkOptions");
         e3 = window.document.getElementById("ctl00_ContentPlaceHolder1_dlOptions_ctl02_chkOptions");
         e1.disabled = false;
         e2.disabled = false;
         e3.disabled = false;
         return(false);
        }
}
else
    {
         return(false);
    }
    
}