function markChanges(frm, cName) {
var frmname = document.qafrm;
var mychanges = frmname.lstchanges.value 
                frmname.lstchanges.value = mychanges + cName + ";"
}

function NEW_doPrintSelectionWindow(wintype,id){
switch(wintype) {
case "1" : 
	var url = "/htmldoc/webapps/SmallBusVr/Default.asp?print=yes&mode=prc&action=process&Pid="+id+"&type=html"; 
    var winname="_blank";
	window.open(url,winname,'')
	break;		
case "2" : 
	var url = "/webapps/SmallBusVr/Default.asp?print=yes&mode=prc&action=process&Pid="+id+"&type=html"; 
    var winname="_html";
	window.open(url,winname,'')
	break;		
 }
}

function doPrintSelectionWindow(wintype,id){
switch(wintype) {
case "1" : 
//    window.alert("This features is not currently available.");
//    break;
	if(confirm("This process may take several seconds to complete. Continue anyway?")) {
	   var url = "/webapps/SmallBusVr/Default.asp?print=yes&mode=prc&action=process&Pid="+id+"&type=pdf"; 
       var winname="_pdf";
	   window.open(url,winname,'')
    } 
	break;	
case "2" : 
	var url = "/webapps/SmallBusVr/Default.asp?print=yes&mode=prc&action=process&Pid="+id+"&type=html"; 
    var winname="_html";
	window.open(url,winname,'')
	break;		
 }
}

function addtargetId( frm , Pid , action , mode ) 
{
 //top.window.location.href="/webapps/SmallBusVr/default.asp?mode="+mode+"&action="+action+"&Pid="+Pid
 frm.Pid.value=Pid;
 frm.action.value=action
 frm.mode.value=mode
 frm.submit();
}

function OpenWin( URL , action , sWidth , sHeight ) 
{
  var popup
  var properties = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+sWidth+',height='+sHeight+',left=' + (screen.width - sWidth) / 2 + ',top=' + (screen.height - sHeight) / 2
      if(action=="open") {
       popup = window.open( URL , 'Popup', properties ); 
	   }
	     else if(action=="close") {
		  popup = window.open( URL , 'Popup', properties ); 
          popup.close()
	  }
}

function doPrintScreen()
{
 window.focus();
 window.print();
}


function chkForm() {
var test = 0
var frm = document.qafrm
var validEmail = frm.EMail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
var sCity = frm.CITY.value.replace(" ","")
	for(i=0;i<sCity.length;i++){
	    sCity = sCity.replace(" ","")
    }
	if(boolEmpty(frm.FIRST_NAME.value)==false) { 
		alert("First Name is required"); 
		frm.FIRST_NAME.focus(); 
		test = 1
	} else if(frm.LAST_NAME.value == "") {
		alert("Last Name is required"); 
		frm.LAST_NAME.focus(); 
		test = 1
	} else if(frm.ADDRESS1.value == "") {
		alert("Address is required"); 
		frm.ADDRESS1.focus(); 
		test = 1
	} else if(frm.CITY.value == "") {
		alert("City is required"); 
		frm.CITY.focus(); 
		test = 1
	} else if(boolAlpha(sCity)==false) {
		alert("City can only contain alphabetical characters"); 
		frm.CITY.focus(); 
		test = 1
	} else if(frm.STATE.value == "") {
		alert("State is required"); 
		frm.STATE.focus(); 
		test = 1
	} else if(boolZip(frm.ZIP.value)==false) {
		alert("Zip Code is invalid or formatted incorrect (85051) or (85051-1234)"); 
		frm.ZIP.focus(); 
		test = 1
	} else if(frm.COUNTY.value == "") {
		alert("County is required"); 
		frm.COUNTY.focus(); 
		test = 1
	}
	if(test==0) {
		frm.submit();
	}
}

function boolZip( strValue ) {
var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
  return objRegExp.test(strValue);
}

function boolAlpha(strValue) { 
var objRegExp  = /\b[abcdefghijklmnopqrtsuvwxyz]/i;
  for(var i = 0; i < strValue.length; i++) {
   var booltest = objRegExp.test( strValue.charAt(i) )
   if(!booltest) {
	   return false;
   }
  }
}

function boolEmpty( strValue ) {
   var objRegExp = /^(\s*)$/;
       strValue = strValue.replace(objRegExp, '');
	   if(strValue.length > 0) {
	     } else {
		  return false;
     }
}

function addclearText(frm) {
var test = 0
var validEmail = frm.toemail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if(frm.toemail.value == "") 
{
 alert("Missing \"Send To\" email address")
 test = 1;
 return false
 }
if(frm.toemail.value != "") {
  if (validEmail){  
   } 
  else {   
    test = 1;
	alert("Invalid email address.") 
    return false
   }
 }
if(frm.subject.value == "") 
{
 alert("Missing \"Subject Line\"")
 test = 1;
 return false
 }

 if(test==0) {
 //alert("Please wait...We are sending your email out now\n\nThis window will close automatically and\nthe prior page will be refreshed.")
      window.opener.document.prcfrm.mode.value = frm.mode.value
      window.opener.document.prcfrm.action.value = frm.action.value
      window.opener.document.prcfrm.Pid.value = frm.Pid.value
      window.opener.document.prcfrm.emailit.value = frm.emailit.value
      window.opener.document.prcfrm.prompt.value = frm.prompt.value
      window.opener.document.prcfrm.attchBox.value = frm.toemail.value
      window.opener.document.prcfrm.attchfrmBox.value = frm.fromemail.value
      window.opener.document.prcfrm.attchSubject.value = frm.subject.value
	  window.opener.document.prcfrm.attchMessage.value = frm.body.value
      window.opener.document.prcfrm.submit();
	  window.close();
 }
}

function jsRemove(plaintext) {
   sbegin = plaintext.indexOf("<");
     send = plaintext.indexOf(">");
      len = plaintext.length;
     sSub = plaintext.substring(0, sbegin);
      if(send == -1)
              send = sbegin;
              sCapture = plaintext.substring((send + 1), len);
              plaintext = sSub + sCapture;
   tagCheck = plaintext.indexOf("<");
if(tagCheck != -1)
       plaintext = jsRemove(plaintext);
return plaintext;
}

function chkForHTML() { if(document.mailfrm.body.value!="") document.mailfrm.body.value = jsRemove(document.mailfrm.body.value); }

