	//**cak** dt:02/26/2001 added to change state field to a text box from select box
	// validate state ... if valid return true ,return false otherwise
	function chkstate(st)
	{
	var starr=new Array(55);
 starr[0]='AK';
 starr[1]='AL'; 
 starr[2]='AR'; 
 starr[3]='AZ'; 
 starr[4]='CA'; 
 starr[5]='CO'; 
 starr[6]='CT'; 
 starr[7]='DE'; 
 starr[8]='FL'; 
 starr[9]='GA'; 
 starr[10]='HI'; 
 starr[11]='IA'; 
 starr[12]='ID'; 
 starr[13]='IL'; 
 starr[14]='IN'; 
 starr[15]='KS'; 
 starr[16]='KY'; 
 starr[17]='LA'; 
 starr[18]='MA'; 
 starr[19]='MD'; 
 starr[20]='ME'; 
 starr[21]='MI'; 
 starr[22]='MN'; 
 starr[23]='MO'; 
 starr[24]='MS'; 
 starr[25]='MT'; 
 starr[26]='NC'; 
 starr[27]='ND'; 
 starr[28]='NE'; 
 starr[29]='NH'; 
 starr[30]='NJ'; 
 starr[31]='NM'; 
 starr[32]='NV'; 
 starr[33]='NY'; 
 starr[34]='OH'; 
 starr[35]='OK'; 
 starr[36]='OR'; 
 starr[37]='PA'; 
 starr[38]='RI'; 
 starr[39]='SC'; 
 starr[40]='SD'; 
 starr[41]='TN'; 
 starr[42]='TX';
 starr[43]='UT';
 starr[44]='VA';
 starr[45]='VT';
 starr[46]='WA';
 starr[47]='WI'; 
 starr[48]='WV'; 
 starr[49]='WY';
 starr[50]='DC';
 starr[51]='AS';
 starr[52]='GU';
 starr[53]='PR';
 starr[54]='VI';
 st=st.toUpperCase();
 for(var c=0;c<=54;c++)
 {
   if(starr[c]==st)
   {
	return true;
   }
 }
 return false;
}
	
	function trim(strString)
	{
		//trim Leading spaces
		while(''+strString.charAt(0)==' ')
			strString=strString.substring(1,strString.length);

		//trim trailing spaces
		while(''+strString.charAt(strString.length - 1) == ' ')
			strString=strString.substring(0,strString.length - 1);

		return strString;
	}
			
	function isNumeric(field)
		{
			var valid = "0123456789";
			
			if(field.length < 1) 
			{
				return false;
			}
			else
			{
				for (var i=0; i< field.length;i++)
				{
					temp = "" + field.substring(i, i+1);
					if (valid.indexOf(temp) == "-1")
					{
						return false;
					}
				}
			}
			return true;
		}


function isEmailIDValid(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.lastIndexOf(".") == email.length-1) {  // . must not be the last character
	return false;
    } else if (email.indexOf("@.") >= 0) { // . must not follow @
	return false;
    } else if (email.indexOf(".@") >= 0) { // . must not immediately precede @
	return false;
    } else if (email.indexOf("@") != email.lastIndexOf("@")) { // there has to be only one @
	return false;
    }
	
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_'";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

  function isValidEmail(e) {
    // Author: Matthew Loupe - 03/28/2000
    // Returns an error in string format if e is not a valid email in 
    // name@domain.x format where name.length >= 2 , domain.length >=2 
    // and x.length >= 2.
 
    var tmp = "" + e;   
    if( tmp.search(/ /)>-1 ) 
     return "is not valid email address.";
    if (tmp.search(/@/) < 1)
       return "is not a valid email address.";

    tmp = tmp.substring(tmp.search(/@/) + 1,tmp.length);
    
    if (tmp.search(/@/) > -1)
       return "is not a valid email address.";
       
    if (tmp.search(/\./) < 2) 
       return "is not a valid email address.";
      
    tmp = tmp.substring(tmp.search(/\./) + 1,tmp.length);

    if (tmp.length < 2)
       return "is not a valid email address.";                
  
   return "";
  
  }

 function isValidMonthDay(mm,dd)
 {
	var lastDay;
    var sMonth;    
  switch (mm) { 
       case 1:
         lastDay = 31;
         sMonth = "January";
         break;
       case 2:       
            lastDay = 29;
         sMonth = "Febuary";
         break;
       case 3:
         lastDay = 31;
         sMonth = "March";
         break;
       case 4:
         lastDay = 30;
         sMonth = "April";
         break;
       case 5:
         lastDay = 31;
         sMonth = "May";
         break;
       case 6:
         lastDay = 30;
         sMonth = "June";
         break;
       case 7:
         lastDay = 31;
         sMonth = "July";
         break;
       case 8:
         lastDay = 31;
         sMonth = "August";
         break;
       case 9:
         lastDay = 30;
         sMonth = "September";
         break;
       case 10:
         lastDay = 31;
         sMonth = "October";
         break;
       case 11:
         lastDay = 30;
         sMonth = "November";
         break;
       default:
         lastDay = 31;
         sMonth = "December";
         break;  
    }     
    if (dd < 1 || dd > lastDay) 
       return "does not contain a valid day (01.." + lastDay +") for " + sMonth +".";               
    return "";
 }

function getQueryVariable(variable) 
	{
		var query = window.location.search.substring(1);
		var vars = query.split("&");
		for (var i=0;i<vars.length;i++) 
		{
			var pair = vars[i].split("=");
			if (pair[0] == variable) 
			{
				return pair[1];
			}
		} 
		return '';
	}
 
function isValidPhone(p){

  if (p.length != 10 && p.length != 12 && p.length != 13)
     return "is not a valid phone number. Try (xxx)xxx-xxxx or xxx.xxx.xxxx";
     
  if (p.length == 10)
     if (!isNumeric(p))
        return "is not a valid phone number. Try (xxx)xxx-xxxx or xxx.xxx.xxxx";

  if (p.length == 12)
     if (!isNumeric(p.substr(0,3)) || !isNumeric(p.substr(4,3)) ||!isNumeric(p.substr(8,4)))
        return "is not a valid phone number. Try (xxx)xxx-xxxx or xxx.xxx.xxxx";
  
  if (p.length == 13)
     if (!isNumeric(p.substr(1,3)) || !isNumeric(p.substr(5,3)) ||!isNumeric(p.substr(9,4)))           
        return "is not a valid phone number. Try (xxx)xxx-xxxx or xxx.xxx.xxxx";               
        
  return "";      
}


function formatPhone(p){

   if (isValidPhone(p) != "")
      return p;
                      
   if (p.length == 10) 
      return ("(" + p.substr(0,3) + ")" + p.substr(3,3) + "-" + p.substr(6,4));
   if (p.length == 12)       
      return ("(" + p.substr(0,3) + ")" + p.substr(4,3) + "-" + p.substr(8,4));
   if (p.length == 13) 
      return ("(" + p.substr(1,3) + ")" + p.substr(5,3) + "-" + p.substr(9,4));         
         
   return p;       
}

function formatURL(u){
      
   if (u.length == 0)
      return u;
                      
   if (u.substr(0,4) != "http") 
      return ("http://" + u);
 
   return u;       
}

function salutation() {
   var today = new Date();
   
   if (today.getHours() <= 11)       
      return "Good morning";
   if (today.getHours() > 11 && today.getHours() <= 16)       
      return "Good afternoon";
   if (today.getHours() > 16)       
      return "Good evening";   
}

//input parameters: Radio Button Name, Form Name
//return parameters: The value of the checked radio button, or '' (null string)
//if no radio button was selected
//author: R. Robbins March 29,2000
function getRadioValue(radioName,frmName) 
{
	var frm = document.forms[frmName];
	var rdo = frm.elements[radioName];
	
	if(!rdo.length)
		if(rdo.checked)
			return rdo.value;
		else
			return '';
	
	for(var i=0;i< rdo.length;i++)
	{
		if(rdo[i].checked == true)
			return rdo[i].value;  
	}
	return '';
}

function getMultiCheckBoxValue(chkName,frmName) 
{
	var frm = document.forms[frmName];
	var chk = frm.elements[chkName];
	var str='';
	if(!chk.length)
		if(chk.checked)			
			str = chk.value;			
		else
			str= '';
	else
	{		
		for(var i=0;i< chk.length;i++)
		{
			
			if(chk[i].checked == true)
				str = str + chk[i].value + ',';  
		}
	}		
	if (str.length>0) 
		str=str.slice(0,-1);	
	
	return str;
}

function DisplayAlert(IssueID,SessionID)
{
   var x,y;
   
   
   y = window.screenTop 
   x =(window.screen.width / 2) - 300
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;
          
   var url1;
   url1="ViewAlert.asp?IssueID=" + IssueID + "&sessionid=" + URLEncode(SessionID)
    PopUp(url1,600,350);
   //window.open(url1,"Alert","Width=600,Height=350,scrollbars=yes,resizable=no,screenX="+x+",screenY="+y +",left="+x+",top= "+y )      
}


function DisplayProfile(pType,mbrID,gacadmin_url)
{
	
   //cak
   var mbrIDStr=new String(mbrID);
   mbrIDStr=mbrIDStr.replace(/B/gi,'');
   mbrIDStr=mbrIDStr.replace(/X/gi,'');
   var x,y;
      
   y = window.screenTop 
   x =(window.screen.width / 2) - 300
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;
          
  if(mbrIDStr=="" || mbrIDStr=='Select Multiple')
   {
	if(pType=='E')
		alert('Please select an elected official from dropdown list');
	else if(pType=='M')
		alert('Please select a media contact from dropdown list');
	else if(pType=='C')
		alert('Please select a custom contact from dropdown list');
   }
   else
      window.open(gacadmin_url+"CommonPopUp.aspx?PageTitle=Profile&control=profile&mbr_id=" + mbrIDStr+"&type="+pType ,"Profile","Width=600,Height=350,scrollbars=yes,resizable=no,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
}

function DisplayProfileInLine(pType,mbrID,gacadmin_url)
{
   var mbrIDStr=new String(mbrID);
   mbrIDStr=mbrIDStr.replace(/B/gi,'');
   mbrIDStr=mbrIDStr.replace(/X/gi,'');
   var x,y;
   var url = gacadmin_url+"CommonPopUp.aspx?PageTitle=Profile&control=profile&mbr_id=" + mbrIDStr+"&type="+pType;   
   y = window.screenTop 
   x =(window.screen.width / 2) - 300
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;
          
  if(mbrIDStr=="" || mbrIDStr=='Select Multiple')
   {
	if(pType=='E')
		alert('Please select an elected official from dropdown list');
	else if(pType=='M')
		alert('Please select a media contact from dropdown list');
	else if(pType=='C')
		alert('Please select a custom contact from dropdown list');
   }
   else
      openinlinepopup("Profile",url,600,400);
}

function PopUpPrintWindow(url,width,height)
{
   var x,y;
      
   y = (window.screenTop-height)/2
   x =((window.screen.width -width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            
   
 //  alert(url);	  
 window.open(url ,"PopUp","Width=" + width + ",Height=" + height +",scrollbars=yes,resizable=yes,menubar=yes,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
   
}
function PopUp(url,width,height)
{
   var x,y;
      
   y = (window.screenTop-height)/2
   x =((window.screen.width -width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            
   
 //  alert(url);	  
 window.open(url ,"PopUp","Width=" + width + ",Height=" + height +",scrollbars=yes,resizable=no,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
   
}

function HelpWindow2(helpfilepath,path,section,width,height)
{
   var x,y;
      
   y = (window.screenTop-height)/2
   x =((window.screen.width -width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            
   
 //  alert(url);
  
 window.open(helpfilepath + 'AdminHelp.asp?path='+path+'&section=' +section ,"HelpWin","Width=" + width + ",Height=" + height +",scrollbars=yes,resizable=no,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
   
}
function HelpWindow(path,section,width,height)
{
	HelpWindow2('',path,section,width,height)   
}

function PopUpWinRef(popupname,url,width,height)
{
   var x,y;
      
   y = (window.screen.height-height)/2
   x =((window.screen.width-width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            
   
	  
 return window.open(url ,popupname,"Width=" + width + ",Height=" + height +",menubar=yes,scrollbars=yes,resizable=no,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
   
}
function ShowSurveyPreviewPopUP(url)
{
   var x,y;
   var height=500,width=800;      
   y = (window.screen.height-height)/2
   x =((window.screen.width-width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            
   
	  
 var w= window.open(url,'AdminSurveyPreview',"Width=" + width + ",Height=" + height +",menubar=no,scrollbars=yes,resizable=yes,screenX="+x+",screenY="+y +",left="+x+",top= "+y );   
 if(w)
 {
 w.focus();
 }else {
   alert("Popup is blocked. Please disable Popup blocker to see this window");
 }
}

function PopUpWithName(popupname,url,width,height)
{
   
  var x,y;
      
   y = (window.screen.height-height)/2
   x =((window.screen.width-width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            

  
  window.open(url,popupname,"Width=" + width + ",Height=" + height +",scrollbars=yes,resizable=yes,screenX="+x+",screenY="+y +",left="+x+",top= "+y ); 
}


function PopUpWithName_V2(popupname,url,width,height)
{
   var x,y;
      
   y = (window.screen.height-height)/2
   x =((window.screen.width-width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            
   
	  
 open(url ,popupname,"Width=" + width + ",Height=" + height +",scrollbars=yes,resizable=no,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
   
}

function hexChar(i) {
  //returns hexdecimal representation of i where i >=0 and i <=15
  var iStr,aStr;
  var result;

  iStr = '' + i;
  aStr="A";
  
  if (i < 10) 
     return iStr;
  else
     return String.fromCharCode((i-10) + aStr.charCodeAt(0));
}

function URLEncode(S) {
   var c;   
   var result = '';  
   var s;
         
     s = S;         
    while (s.length > 0){
   
      c = ''+ s.charAt(0);
      
      s = s.substr(1,(s.length - 1));
   
    
     if ((c.charAt(0) >= 'a' && c.charAt(0) <= 'z')||
           (c.charAt(0) >= 'A' && c.charAt(0) <= 'Z')||
           (c.charAt(0) >= '0' && c.charAt(0) <= '9')){
           result += c.charAt(0); 
      }           
    //  else if (c.charCodeAt(0) == 32){ //Space
   //        result += '+'; 
   //   }     
      else{
           result += '%' + hexChar(parseInt(c.charCodeAt(0)/16)) + hexChar(c.charCodeAt(0) % 16);                         
      }     
    
    }    
    return result;      
}
 
function SelValue(SelBox){
  //returns the value of the selected item in a select box 
 
  return (SelBox.options[SelBox.selectedIndex].value);

} 

function isSelected(SelBox) {
 //returns the true if anything is selected in the select box 
	return !(SelBox.selectedIndex==-1);
} 

function SelectValue(SelBox,v){

   for (i=0;i<SelBox.length;i++)
      
      if (SelBox.options[i].value == v){      
          SelBox.options[i].selected=true;
          return 0;
      }    
   
   return 0;

}
function SelAll_None(SelBox,b){

   for (i=0;i<SelBox.length;i++)
        SelBox.options[i].selected=b;                    
}

function ColorPicker(frmName,fldName,defColor){
    
    var x,y;
      
	y = window.screenTop 
	x =(window.screen.width / 2) - 300
		 
	if (x <= 0) x = 100;
	if (y <= 0 || isNaN(y)) y = 300;
   
   w=window.open("ColorPicker.asp?frmName=" + frmName + "&fldName=" + fldName + "&defColor=" + URLEncode(defColor),"Color_Pick","Width=350,Height=200,screenX="+x+",screenY="+y +",left="+x+",top= "+y);  
  
}

function OpenWindow(url,width,height){
    
    var x,y;
      
	y = window.screenTop 
	x =(window.screen.width / 2) - width
		 
	if (x <= 0) x = 100;
	if (y <= 0 || isNaN(y)) y = 300;
   
   w=window.open(url,"","Width=" + width + ",Height=" + height + ",screenX="+x+",screenY="+y +",left="+x+",top= "+y);  
  
}

//user login form validation 
    function ValidateUserLogin(userCompReq,userBusAddrReq,userHomeAddrReq,userEmailRequired,HideHomeInfoSection,HideBusinessInfoSection){               		
        var sErr= "";
        var newUser;            
       newUser = document.forms.frmUser.newUser.value;    
        
        var prefix=document.forms.frmUser.Prefix.options[document.forms.frmUser.Prefix.selectedIndex].value;
       if (prefix.length <= 0) 
            sErr += "-Prefix\n";        
    
        
       
        if (document.forms.frmUser.FName.value.length <= 0) 
            sErr += "-First Name\n";        
        if (document.forms.frmUser.LName.value.length <= 0) 
            sErr += "-Last Name\n";
		
		if ( userEmailRequired=='True' )
        {
			if(document.forms.frmUser.Email.value.length<=0)
			{
				sErr += "-Email\n";			
			}
        }
        
        if(HideHomeInfoSection!='True')
        {
			if( document.forms.frmUser.Address.value.length > 0 ||
			       document.forms.frmUser.City.value.length > 0 ||
			       document.forms.frmUser.State.value.length > 0 || userHomeAddrReq=='True'
			    )
			{           
			 if (document.forms.frmUser.Address.value.length <= 0) 
			     sErr += "-Home Address\n";

			 if (document.forms.frmUser.City.value.length <= 0) 
			     sErr += "-Home City\n";

			if(document.forms.frmUser.State.value.length<=0)
			 	sErr += "-Home State\n";
			 else
			 {
			 if(!chkstate(document.forms.frmUser.State.value))
			 	sErr += "-Valid Home State\n";
			 }
			 
			 if (document.forms.frmUser.Zip.value.length <= 0)         
			     sErr += "-Home Zip\n";
			}
        }
       
        if(HideBusinessInfoSection!='True')
        {        
         
        if(userCompReq=='True')
        {
			if (document.forms.frmUser.b_Name.value.length <= 0)         
				sErr += "-Company Name\n";        
        }
            
      
			if( document.forms.frmUser.b_Address.value.length > 0 ||
			   document.forms.frmUser.b_City.value.length > 0 ||
			   document.forms.frmUser.b_State.value.length > 0 || userBusAddrReq=='True'
			   )
			{        
			   if (document.forms.frmUser.b_Address.value.length <= 0) 
			     sErr += "-Business Address\n";

			   if (document.forms.frmUser.b_City.value.length <= 0) 
			     sErr += "-Business City\n";

			          
			    if(document.forms.frmUser.b_State.value.length<=0)
					sErr += "-Business State\n";
				else
				{
					if(!chkstate(document.forms.frmUser.b_State.value))
						sErr += "-Valid Business State\n";
				}
			   if (document.forms.frmUser.b_Zip.value.length <= 0)         
			     sErr += "-Business Zip\n";       
			}
        }
   /*
		var f=document.forms.frmUser;
        if(f.elements!=null)
        {
			for(var i=0;f.elements.length;i++)			
			{
				if(f.elements[i]!=null)				
				{
					if(f.elements[i].required!=null)				
					{
						if(f.elements[i].required=='true')
							alert(f.null);							
					}
				}
			}
		}*/
		
       /* var mm;
        var dd;
        if (newUser == 'true'){ 
			mm=document.forms.frmUser.month.options[document.forms.frmUser.month.selectedIndex].value;
			dd=document.forms.frmUser.day.options[document.forms.frmUser.day.selectedIndex].value;
		
			if (mm == -1) 
			    sErr += "-Month in Birthday \n";
			if (dd == -1)
			    sErr += "-Day in Birthday \n";

        }       
         */
        if (sErr.length > 0){
		    alert ('You are required to enter the following field(s): \n\n' + sErr);
		    return false;
		}
		//Error validation
		sErr='';
		if ( userEmailRequired=='True' )
        {
			var emailErrStr=isValidEmail(document.forms.frmUser.Email.value)
			if (emailErrStr!= "")
			{
				sErr += "-Email is invalid (Example: abc@xyz.com) ";
			}
		}
/*
		if (newUser == 'true') { 		      
			sErr1=isValidMonthDay(mm,dd);
			
			if (sErr1.length > 0) {
				sErr+= '-Birthday is invalid ' + sErr1 + ' \n';			   
			}
        }
        */
        if (sErr.length > 0){
			alert ('The following field(s) contain errors: \n\n' + sErr);
			return false;
		}
        
        
        
        return true;
    }
function buildDate(frmObjectName,dateName)
{
	var dt;
	dt = eval("document." + frmObjectName + "." + dateName + "_month.options[document." + frmObjectName + "." + dateName + "_month.selectedIndex" +"].value") + "/";
	dt = dt + eval("document." + frmObjectName + "." + dateName + "_day.options[document." + frmObjectName + "." + dateName + "_day.selectedIndex" +"].value") + "/";
	dt = dt + eval("document." + frmObjectName + "." + dateName + "_year.options[document." + frmObjectName + "." + dateName + "_year.selectedIndex" +"].value");
	return dt;
}	    
function confirmDelete(strName,strUrl)
{
	if(confirm('Are you sure you want to delete this ' + strName + ' ?'))
		window.location.href = strUrl;
}
    
function delConfirm(strName)
{
	return confirm('Are you sure you want to delete this ' + strName + '?');
	

}
function refreshLoginPage(ddList)
{
	var f=ddList.form;
	if(ddList.selectedIndex>0)
	{
		if(ddList.options[ddList.selectedIndex].value=='[Other]')
		{
			f.refreshpage.value='true';
			var act=f.action;
			act=act.replace('=User','=UserLogin');
			f.action=act;						
			f.submit();
		}
	}
}
function refreshSearchPageByField(ddList)
{
	var f= ddList.form;
	f.refreshpage.value='true';
	var valueField=eval('document.' + f.name + '.txtSearchText.type'); 	
	if(valueField=='select-one'){
		f.txtSearchText.selectedIndex=0;
	}	
	if(valueField=='text'){
		f.txtSearchText.value='';
	}	
	f.submit();	
}

function refreshSearchPageByStateSelection(ddList)
{
	var f= ddList.form;
	f.refreshpage.value='true';
	var valueField=eval('document.' + f.name + '.txtSearchText.type'); 	
	if(valueField=='select-one'){
		f.txtSearchText.selectedIndex=0;
	}	
	f.submit();	
}

function refreshSearchPageByValue(ddList)
{
	var f= ddList.form;
	if(ddList.selectedIndex>0)
	{
		if(ddList.options[ddList.selectedIndex].value=='Other')
		{
			f.refreshpage.value='true';
			f.submit();
		}
	}
}

function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}
function getcookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
document.cookie=cookiestring;
if(!getcookie(name)){
return false;
}
else{
return true;
}
}

function showMultiplePopUp(ddl,name)
{
var targetElement=null;
if (document.getElementById) // Netscape 6 and IE 5+
{			
	targetElement = document.getElementById('viewSelMultiple_' + name);						    
}
if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
{
    if(targetElement!=null)
		targetElement.style.visibility = 'visible';
	var f=ddl.form;
	var ddlFieldName=f.elements[name];	
	
	PopUpWithName('MultiSelBox','ShowMultiSelection.asp?frmName='+ f.name + '&Name=' + ddlFieldName.options[ddlFieldName.selectedIndex].text,650,220);	
}
else
{
	if(targetElement!=null)
	targetElement.style.visibility = 'hidden';
}
}

function showMultiplePopUpForASPX_CF(ddl,name,DisplayName,multipleValuesFieldName)
{
var targetElement=null;
if (document.getElementById) // Netscape 6 and IE 5+
{			
	targetElement = document.getElementById('viewSelMultiple_' + name);						    
}
if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
{
    if(targetElement!=null)
		targetElement.style.visibility = 'visible';
	var f=ddl.form;			
	PopUpWithName('MultiSelBox','ShowMultiSelection.asp?frmName='+ f.name + '&Name=' + DisplayName +'&SearchTextFieldName='+name + '&multipleValuesFieldName=' + multipleValuesFieldName,650,220);	
}
else
{
	if(targetElement!=null)
	targetElement.style.visibility = 'hidden';
}
}

function showMultiplePopUpForASPX(PageURL,ddl,name,searchTextFieldName,multipleValuesFieldName,viewSelMultipleFieldName)
{
var targetElement=null;
if (document.getElementById) // Netscape 6 and IE 5+
{			
	targetElement = document.getElementById(viewSelMultipleFieldName);						    
}

if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
{	
    if(targetElement!=null)
		targetElement.style.display = 'inline';
	var f=ddl.form;
	var ddlFieldName=f.elements[name];	
	
	//PopUpWithName('MultiSelBox',PageURL + '?frmName='+ f.name + '&Name=' + ddlFieldName.options[ddlFieldName.selectedIndex].text+'&SearchTextFieldName='+searchTextFieldName + '&multipleValuesFieldName=' + multipleValuesFieldName+'&doNotSubmit=true',650,220);	
	
	openinlinepopup('Select Multiple',PageURL + '?frmName='+ f.name + '&Name=' + ddlFieldName.options[ddlFieldName.selectedIndex].text+'&SearchTextFieldName='+searchTextFieldName + '&multipleValuesFieldName=' + multipleValuesFieldName+'&doNotSubmit=true',650,220);
}
else
{
	if(targetElement!=null)
	targetElement.style.display = 'none';
}
}

function showMultiplePopUpBox(PageURL,ddlName,DisplayName,multipleValuesFieldName,viewSelMultipleFieldName)
{
	if (document.getElementById) // Netscape 6 and IE 5+
	{			
		
		var targetElement=null;
		
		targetElement = document.getElementById(viewSelMultipleFieldName);						    
				
		var ddl = document.getElementById(ddlName);

		
		if(ddl!=null)
		{		
			
			if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
			{				
			    if(targetElement!=null)
					targetElement.style.display = 'inline';
				var f=ddl.form;
								
				PopUpWithName('MultiSelBox',PageURL + '?frmName='+ f.name + '&Name=' + DisplayName +'&SearchTextFieldName='+ ddlName + '&multipleValuesFieldName=' + multipleValuesFieldName+'&doNotSubmit=true',650,220);	
			}
			else
			{
				if(targetElement!=null)
				targetElement.style.display = 'none';
			}
		}
	}
}



function showMultiplePopUpForLoginScreen(ddl,name,displayName,multipleValuesFieldName)
{
var targetElement=null;
if (document.getElementById) // Netscape 6 and IE 5+
{			
	targetElement = document.getElementById('viewSelMultiple_' + name);						    
}
	    
if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
{
    if(targetElement!=null)
    targetElement.style.display = 'inline';
	var f=ddl.form;
	PopUpWithName('MultipleSelBox','ShowMultiSelection.asp?frmName='+ f.name + '&Name=' + displayName + '&multipleValuesFieldName=' + multipleValuesFieldName +  '&SearchTextFieldName=' + name + '&doNotSubmit=true',470,220);
}
else
{
	if(targetElement!=null)
	targetElement.style.display = 'none';
}
}

function showMultiplePopUpForComm(ddl,name)
{
if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
{
	var f=ddl.form;
	PopUpWithName('CommnetsMultiSelBox','ShowMultiSelection.asp?frmName='+ f.name + '&Name=' + name + '&multipleValuesFieldName=commMultipleValues&SearchTextFieldName=CommentsDropDown',650,220);
}
}

function showMultipleOtherEOsPopUp(ddl)
{
if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
{
	var f=ddl.form;	
	PopUpWithName('MultiSelBox','MultipleOtherEOsSelection.asp?frmName='+ f.name + '&Name=' + 'officials' ,710,220);
}
}

function showMultipleOtherMCsPopUp(ddl)
{
if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
{
	var f=ddl.form;	
	PopUpWithName('MultiSelBox','MultipleOtherMCsSelection.asp?frmName='+ f.name + '&Name=' + 'Media+Contacts' ,710,220);
}
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr,strDateName){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert(strDateName + ": The date format should be mm/dd/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert(strDateName + ": Please select a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert(strDateName + ": Please select a valid day");
		return false;
	}
	if (strYear.length != 4 || year==0 ){
		alert(strDateName + ": Please select a valid year");
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert(strDateName + ": Please enter a valid date");
		return false;
	}
return true;
}
function splitAfterSpellCheck()
{
	var v=parent.opener.document.frmCompose;
	if(v!=null)
	{
		var fType=v.FormType.value;
		if(fType=='a')
		{				
			v.Openingcomments.value= getContentesOfTag(v.txtSpellCheck.value,'vv_openingcommnets');
			if(v.isEditable.value=='True')
						v.Body.value=getContentesOfTag(v.txtSpellCheck.value,'vv_body');
			v.comments.value = getContentesOfTag(v.txtSpellCheck.value,'vv_closingcomments');
		}
		else
		{			
			v.Body.value=getContentesOfTag(v.txtSpellCheck.value,'vv_body');
		}			
	}
}

function getContentesOfTag(strContent,tagName)
{
	var posSt=strContent.indexOf('<'+tagName+'>');
	if(posSt!=-1)
	{
		var posEd=strContent.indexOf('</'+tagName+'>');
		if(posEd==-1)
			posEd = strContent.length;			
		return strContent.substring(posSt + ('<'+tagName+'>').length,posEd);	
	}
	return "";
}
function stripExtraWhiteSpaceAtTheEnd(strInput)
{
	var length=strInput.length;		
	while(''+strInput.charAt(length-1)==' ' || strInput.charAt(length-1)=='\n'  || strInput.charAt(length-1)=='\t' || strInput.charAt(length-1)=='\r' )			
		strInput=strInput.substring(0,--length);		
	return strInput;
}
function anyThingChecked(frm,ele) {
	var chk = frm.elements[ele];
	if(!chk)
		return false;
	if(!chk.length) {
		if(chk.checked)
			return true;
		else
			return  false;
	}
	else {
		for(var i=0;i< chk.length;i++)				
			if(chk[i].checked == true){
				return true;						
		}				
	}	
	return  false;
}

function cleanupAndFormatPhoneNumber(elePhone)
{
	cleanupPhoneNumber(elePhone);
	elePhone.value = formatPhone(elePhone.value);
}
function cleanupPhoneNumber(elePhone)
{
	elePhone.value=elePhone.value.replace(/[\D]/gi,'');
}

function SelectTheRadio(frmName,ele,index)
{
    var frm = document.forms[frmName];
	var chk = frm.elements[ele];
	if(!chk)
		return;
	if(!chk.length) {
		chk.checked = true;
	}
	else {
			chk[index].checked = true;
		}					
}

function VV_GetElementByName(frmName,eleName)
{
    var frm = document.forms[frmName];    
	var ele = frm.elements[eleName];
	return ele;
}


function OpenPrintWindow(btnPrint,width,height) 
{
//Get the form reference
var f=btnPrint.form;

//Get the form action to append PreintMode=true
var form_action  =f.action;
new_form_action  = form_action;

if(new_form_action.indexOf('?')!=-1)
	new_form_action = new_form_action + '&PrintMode=true';
else
	new_form_action = new_form_action + '?PrintMode=true';	


//Update the form action form submit target
f.action = new_form_action;
f.target="PRINT_WINDOW";

//Create a new window called PRINT_WINDOW to submit the printable version.
w = PopUpWinRef('PRINT_WINDOW',f.action,width,height);
w.focus();

//submit the form to new window.
f.submit();

//reset the form target and form_action so that the submitting form behaviour is not changed.
f.target="";
f.action = form_action;
}

//Auto save Page Data code.
var saveInterval = 10; // inseconds.
var x = saveInterval;
var cnt=0;
var saveFunc;

function AutoSavePageData(func)
{
saveFunc=func;
startSaveClock();
}

function startSaveClock(){
x--;
setTimeout("startSaveClock()", 1000)
if(x==0){
	x=saveInterval;
	saveFunc();			
	cnt++;
	window.status='saved - ' + cnt;
   }
}

/************************** CUSTOM VALIDATION FUNCTIONS FOR ASP.NET *********************/
function validateUSPhoneNumber ( src, arg ) {	
   args.IsValid = args.Value.replace(/[\D]/gi,'').length == 10;
}
/**************************** END OF CUSTOM VALIDATION FUCTION SECTION ******************/



/****************** BOB 06/12/2008 **********************************/
/****************** INLINE DIV LAYER/ DHTML WINDOWS SCRIPTS *********/

var mypopwin;
function openinlinepopup(popupname,url,width,height)
{ 
    if (url.indexOf("?")>0)
	url = url + "&inlinepopup=true";
    else
	url = url + "?inlinepopup=true";
    
    if(popupname == "")
    {
        popupname = "VoterVOICE";
    }
    if(typeof dhtmlwindow =="undefined")
    {
	//Some reason dhtml javascripts are not not included in page... try to load automatically
	loadjscssfile("/js/dhtmlwindow/dhtmlwindow.js", "js"); 
	loadjscssfile("/js/dhtmlwindow/dhtmlwindow.css","css");
    }

    //try to place the window centered to be consistent
    if(height > 400)
    {
    	y = (window.screen.height-height)/2
        x =((window.screen.width-width)/ 2)
    
        if (x <= 0) x = 100;
        if (y <= 0 || isNaN(y)) y = 125;
        center=0;
    }else
    {
	 center=1;
         x=100;
         y=125;
    }
    //mypopwin = dhtmlwindow.open("myinlinepopwin","iframe",url,popupname,"width="+width+"px,height="+height+"px,left="+x+"px,top="+y+"px,center="+center+",scrolling=1,resize=1");
    mypopwin = dhtmlmodal.open("myinlinepopwin","iframe",url,popupname,"width="+width+"px,height="+height+"px,left="+x+"px,top="+y+"px,center="+center+",scrolling=1,resize=1");
}

function closeinlinepopup()
{
    //****  closes the inlinepopup window opened in function above **/
    if(mypopwin)
    {
        mypopwin.hide();
    	mypopwin.close();
    }
}

function openinlinepopupandprint(popupname,url,width,height)
{
	//First open popup
	openinlinepopup(popupname,url,width,height);
	
	//Now print
	setTimeout(printinlinepopup,1000);
	
}

function printinlinepopup()
{
	window.frames['_iframe-myinlinepopwin'].focus(); 
	window.frames['_iframe-myinlinepopwin'].print(); 
}

function openInlineModalPopup(popupname,url,width,height)
{
    url = url+"&inlinepopup=true";
    mypopwin = dhtmlmodal.open("mypopwin","iframe",url,'Select Multiple',"width="+width+"px,height="+height+"px,center=1,scrolling=1");  
}

// Utility Function to Load JS and CSS Files On the fly

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

function ShowSurveyPreviewInlinePopUP(url)
{
   var x,y;
   var height=500,width=800;      
   y = (window.screen.height-height)/2
   x =((window.screen.width-width)/ 2)
    
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;            
  
 var w = openinlinepopup('Survey Preview',url,width,height);
}


function showMultiplePopUpForASPX2(PageURL,ddlName,name,searchTextFieldName,multipleValuesFieldName,viewSelMultipleFieldName)
{
	
	if (document.getElementById) // Netscape 6 and IE 5+
	{			
		
		var targetElement=null;
		
		targetElement = document.getElementById(viewSelMultipleFieldName);						    
				
		var ddl = document.getElementById(ddlName);
		
		if(ddl!=null)
		{		
			
			if(ddl.options[ddl.selectedIndex].value=='Select Multiple')
			{
			    if(targetElement!=null)
					targetElement.style.display = 'inline';
				var f=ddl.form;
				var ddlFieldName=f.elements[name];	
				
				openinlinepopup('Select Multiple',PageURL + '?frmName='+ f.name + '&Name=' + ddlFieldName.options[ddlFieldName.selectedIndex].text+'&SearchTextFieldName='+searchTextFieldName + '&multipleValuesFieldName=' + multipleValuesFieldName+'&doNotSubmit=true',650,220);	
			}
			else
			{
				if(targetElement!=null)
				targetElement.style.display = 'none';
			}
		}
	}
}

function openHelpWindow(application,page,section)
{
	var width = 400;
    var height = 200;
    var x,y;
    y = (window.screenTop-height)/2
    x =((window.screen.width -width)/ 2)
    if (x <= 0) x = 100;
    if (y <= 0 || isNaN(y)) y = 125;    
    
   
   if(typeof dhtmlwindow =="undefined")
    {
	mywindow = window.open ("/webapp/Help.aspx?application="+application+"&page="+page+"&section="+section,"help","Width=" + width + ",Height=" + height +",scrollbars=yes,resizable=no,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
    }else {
	   
    	mypopwin = dhtmlwindow.open("myinlinepopwin","iframe","/webapp/Help.aspx?application="+application+"&page="+page+"&section="+section,"Help","width="+width+"px,height="+height+"px,top="+ y+",left="+x+",scrolling=1,resize=1"); 
    }
}


function openmanualwindow(contentid)
{
	//Default
	var width= 600;
	var height = 400;
			
	//For Lower Resolutions	800x600 say
	if(window.screen.width < 810)
	{
	   	width = 600;
		height = 300;	
	}
		
	//For higher resolutions
	if(window.screen.width > 1200)
	{
		width = 800;
		height = 500;
	}
	

	var url = "/webapp/Help.aspx?contentid="+contentid;
	openinlinepopup("Help",url,width,height);
}


function DisplayVoterResources(stateID,AID,gacadmin_url)
{
	
   var x,y;
   y = window.screenTop 
   x =(window.screen.width / 2) - 300
   if (x <= 0) x = 100;
   if (y <= 0 || isNaN(y)) y = 125;
         
    window.open(gacadmin_url+"CommonPopUp.aspx?PageTitle=VoterResources&control=VoterResources&state=" + stateID + "&aid="+AID,"Resources","Width=600,Height=450,scrollbars=yes,resizable=yes,screenX="+x+",screenY="+y +",left="+x+",top= "+y );
}