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)
{
    URL="../Survey/UserDownload.aspx?x=" + arg1 + "&y=" + arg2 + "&z=" + arg3;
    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 ChangeUserStatus(vntField)
{
    if (vntField==1)
    {        
        window.document.getElementById('ctl00_ContentPlaceHolder1_dllUser').disabled = false;        
    }
    else
        {
            window.document.getElementById('ctl00_ContentPlaceHolder1_dllUser').disabled = true;
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtName').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtPhoneNumber').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtCompanyName').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtProjectManager').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtDate').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtReferenceNumber').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtProjectDescription').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtPracticeArea').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtRegion').value = "";  
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtPracticeArea').value = "";
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtRegion').value = ""; 
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtEmail').value = ""; 
            window.document.getElementById('ctl00_ContentPlaceHolder1_txtRole').value = "";              
        }  
    window.document.getElementById('ctl00_ContentPlaceHolder1_dllUser').selectedIndex = 0;    
}
function isEmailAddr()
{
  var email =  window.document.getElementById('ctl00_ContentPlaceHolder1_txtEmail').value;
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  if (!result)
  {
    alert("This is not a valid E-Mail address!");
	window.document.getElementById('ctl00_ContentPlaceHolder1_txtEmail').focus();			
  }
  return result;
}
function isContactSelected()
{
  if (window.document.getElementById('ctl00_ContentPlaceHolder1_dllUser').value== " - New Respondent - ")
  {
    alert("Please select a respondent to delete!");
	window.document.getElementById('ctl00_ContentPlaceHolder1_dllUser').focus();
	return false;			
  }
  return true;
}
function isUserandSurveySelected()
{
  if (window.document.getElementById('ctl00_ContentPlaceHolder1_dllUser').value== " - New Respondent - ")
  {
    alert("Please select a respondent.");
	window.document.getElementById('ctl00_ContentPlaceHolder1_dllUser').focus();
	return false;			
  }
  if (window.document.getElementById('ctl00_ContentPlaceHolder1_dllSurvey').value== " - Select a survey - ")
  {
    alert("Please select a survey.");
	window.document.getElementById('ctl00_ContentPlaceHolder1_dllSurvey').focus();   
	return false;			
  }
  return true;
}
function isEmailSent()
{  
  if (window.document.getElementById('ctl00_ContentPlaceHolder1_txtSessionID').value== "")
  {
    alert("Please Assign a survey to selected respondent.");
	window.document.getElementById('ctl00_ContentPlaceHolder1_dllSurvey').focus();
	return false;			
  }
  if (window.document.getElementById('ctl00_ContentPlaceHolder1_txtSent').value== "Y")
  {
    if (!confirm("The email has been sent, do you want to send another one?"))
    {	    
	    return false;	
	}		
  }
  return true;
}
function RADSelected(vntQuesID,vntmyID)
{    
    var Prefix = "ctl00_ContentPlaceHolder1_BPS_RAD_";
    if (vntmyID !=3)
    {
        e = window.document.getElementById(Prefix + vntQuesID + "_8_0");
        e.checked=false;
    }
    else
    {
        e = window.document.getElementById(Prefix + vntQuesID + "_8_0");        
        if (e.checked==true)
        {
            e = window.document.getElementById(Prefix + vntQuesID + "_4_0"); 
            e.checked=false;
            e = window.document.getElementById(Prefix + vntQuesID + "_4_1"); 
            e.checked=false;  
            e = window.document.getElementById(Prefix + vntQuesID + "_4_2"); 
            e.checked=false;  
            e = window.document.getElementById(Prefix + vntQuesID + "_7_0"); 
            e.checked=false;  
            e = window.document.getElementById(Prefix + vntQuesID + "_7_1"); 
            e.checked=false;  
            e = window.document.getElementById(Prefix + vntQuesID + "_7_2"); 
            e.checked=false;  
        }
    }   
}
function isValidated()
{       
    var Prefix = "ctl00_ContentPlaceHolder1_BPS_RAD_";
    for (var i=3;i<20;i++)
    {
        e = window.document.getElementById(Prefix + i + "_8_0");
        if (e != null) 
        {
            if (e.checked==false)
            {
              
                e1 = window.document.getElementById(Prefix + i + "_4_0");                 
                e2 = window.document.getElementById(Prefix + i + "_4_1");                
                e3 = window.document.getElementById(Prefix + i + "_4_2");               
                e4 = window.document.getElementById(Prefix + i + "_7_0");                  
                e5 = window.document.getElementById(Prefix + i + "_7_1");                
                e6 = window.document.getElementById(Prefix + i + "_7_2"); 
               
                if(e1.checked||e2.checked||e3.checked)
                {
                    if (!e4.checked&&!e5.checked&&!e6.checked)
                    {
                        alert("You have select an option from 'Your Needs/Expections', please make a selection from 'How did we perform vs expections'.")
                        e.focus();
                        return false;
                    }
                }
                if(e4.checked||e5.checked||e6.checked)
                {
                    if (!e1.checked&&!e2.checked&&!e3.checked)
                    {
                        alert("You have select an option from 'How did we perform vs expections', please make a selection from 'Your Needs/Expections'.")
                        e.focus();
                        return false;
                    }
                }
            }        
        }  
    }
    return true;
}
