	var formSubmitted = false;
	var SubmitMsg = "You have already submitted a form. To resubmit a new form or an update to this form, \n please click the back button on your browser and return to this page."
	function capture() {
		if (event.keyCode == 27) {
			formSubmitted = false;
		}
	}
	function sendMeElsewhere(target) {
		window.location.href = target;
	}
	function printWindow(){
		bW = parseInt(navigator.appVersion)
		if (bW >= 4) window.print()
	}
	function cutSpaces(s)
	{
		var s1, x;
		x = s1 = "";
		l = s.length;
		for(i = 0; i < l; i++) {
			if((x = s.charAt(i)) != " ") {
				s1+=x;
			}
		}
		return s1;
	}
	function replaceAll(strChk, strFind, strReplace) {
	   var strOut = strChk;
	   while (strOut.indexOf(strFind) > -1) {
		 strOut = strOut.replace(strFind, strReplace);
	   }
	   return strOut;
	}

	function replace(stf,old,rplc) {
		var New='';
		while (stf.indexOf(old)!=-1) {
			var strt=stf.indexOf(old);
			New+=stf.substring(0,strt);
			New+=rplc;
			stf=stf.substring(strt+old.length,stf.length);
		}
		return New+stf;
	}

	function isNumeric(buf)
	{
		var i;
		for (i=0; i < buf.length; i++)
		{
			var c = buf.charAt(i);
			if (!isDigit(c)) {return false;}
		}
		return true;
	}

	function isStreetNumber(buf)
	{
		var i;
		for (i=0; i < buf.length; i++)
		{
			var c = buf.charAt(i);
			if (!(c >= "0") && (c <= "9") && c != "/") {return false;}
		}
		return true;
	}

	function isDigit(c)
	{
		return ((c >= "0") && (c <= "9"));
	}

	function isAlphaNumeric(buf)
	{
		var i;
		for (i=0; i < buf.length; i++) {
			var c = buf.charAt(i);
			if (!isLetter(c) && !isDigit(c)) {return false;}
		}
		return true;
	}

	function isAlpha(buf)
	{
		var i;
		for (i=0; i < buf.length; i++) {
			var c = buf.charAt(i);
			if (!isLetter(c)) {return false;}
		}
		return true;
	}

	function isLetter(c)
	{
		return (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")));
	}

	function isAllCaps(buf) {
		var i;
		for (i=0; i<buf.length; i++) {
			var c = buf.charAt(i);
			if (!(c >= "A" && c<= "Z")) {return false;}
		}
		return true;
	}

	function isEqual(aForm, field1, field2)
	{
		var formField1 = eval('aForm.' + field1);
		var formField2 = eval('aForm.' + field2);
		if (cutSpaces(formField1.value) != cutSpaces(formField2.value)) {return false;}
		return true;
	}

	var isValidChar=function (string,allowed) {
		for (var i=0; i< string.length; i++) {
		   if (allowed.indexOf(string.charAt(i)) == -1)
			  return false;
		}
		return true;
	}

	function radio_button_checker(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		var formField1Value;
		for (counter = 0; counter < formField1.length; counter++) {
			if (formField1[counter].checked) {
				var formField1Value = formField1[counter].value;
				break;
			}
		}
		if (typeof formField1Value == "undefined") {var formField1Value = '';}
		return formField1Value;
	}

	function isZip(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		formField1.value = cutSpaces(formField1.value);
		return (isNumeric(formField1.value) && (formField1.value.length == 5));
	}

	function isValidContractNumber(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		formField1.value = cutSpaces(formField1.value);
		return (isNumeric(formField1.value));
	}

	function isValidMeterNumber(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		formField1.value = cutSpaces(formField1.value);
		var buf = formField1.value;
		var i;
		var isLetterFound;
		var isNumbersFound;
		for (i=0; i < buf.length; i++) {
			var c = buf.charAt(i);
			if (i==0) {isLetterFound = isLetter(c);}
		}
		for (j=0; j < buf.length; j++) {
			var c = buf.charAt(j);
			if (j >= 1)
			{
				isNumbersFound = isDigit(c);
				if (!isNumbersFound) {break;}
			}
		}
		if (!isLetterFound || !isNumbersFound) {return false;}
		return true;
	}

	function isDigitsDeci(inString) {
	   	var errNo=0;
	   	if (inString != "") {
       		var digits="0123456789.";
       		var temp
       		for (var i=0;i<inString.length;i++){
        	    temp=inString.substring(i,i+1);
        	    if (digits.indexOf(temp)==-1){var errNo=1;}
        	}
	   }
	   return errNo;
	 }
	 function isDigits(inString) {
	   	var errNo=0;
	   	if (inString != "") {
       		var digits="0123456789";
       		var temp
			for (var i=0;i<inString.length;i++){
		  	    temp=inString.substring(i,i+1);
        	    if (digits.indexOf(temp)==-1){var errNo=1;}
        	}
	   }
	   return errNo;
	 }

	function isMoney(aForm, field1)
	{
		var payAmt = eval('aForm.' + field1 + '.value');
		payAmt = Trim(cutSpaces(payAmt));
		if (payAmt == "" || payAmt == 0) {
		    return false;
		}
		if (isDigitsDeci(payAmt) == 1) {
		     return false ;
		} else {
		   if(payAmt.indexOf("-") != -1) {return false;}
		   if (payAmt.indexOf(".") != -1)
			{
				if((payAmt.indexOf(".") + 1) == payAmt.length) {return false;}
				var payamt = payAmt.substring(payAmt.indexOf(".") + 1, payAmt.length);
				var paybdamt = payAmt.substring(0,payAmt.indexOf("."));
				if (paybdamt <= 0) {return false;}
				if (payamt.length > 2 || payamt.length < 2) {return false;}
			} else {
				return false;
			}
		  return true;
		}
	}

	function isPhoneNumber(aForm, field1, field2, field3)
	{
		var formField1 = eval('aForm.' + field1);
		var formField2 = eval('aForm.' + field2);
		var formField3 = eval('aForm.' + field3);
		return (isNumeric(formField1.value) &&
				isNumeric(formField2.value) &&
				isNumeric(formField3.value) &&
				(formField1.value.length == 3) &&
				(formField2.value.length == 3) &&
				(formField3.value.length == 4))
	}

        function isEmail(aForm, field1)
	{
	        var formField1 = eval('aForm.' + field1);
	        formField1.value = cutSpaces(formField1.value);
	        src = formField1.value;
	        var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	        return re.test(src);
	}

	function isPassword(aForm, field1)
	{
		var formField = eval('aForm.' + field1 + '.value');
		formField = cutSpaces(formField);
		if (!((formField.search(/[a-z]+/) > -1)
  		&& (formField.search(/[A-Z]+/) > -1)
  		&& (formField.search(/[0-9]+/) > -1)))return false;
		return isAlphaNumeric(formField);
	}

	function isElectricityAcctNbr1(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		formField1.value = cutSpaces(formField1.value);
		if (formField1.value.length == 0) {return false;}
		if (!isNumeric(formField1.value)) {return false;}
		return true;
	}

	function isElectricityAcctNbr2(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		formField1.value = cutSpaces(formField1.value);
		if (formField1.value.length != 1) {return false;}
		if (!isNumeric(formField1.value)) {return false;}
		return true;
	}

	function isUserName(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		return isAlphaNumeric(formField1.value);
	}

	function isSecurityQuestionAnswer(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		return isAlphaNumeric(formField1.value);
	}

	function isSecurityQuestionAnswerFormat(aForm, field1)
	{
		var formField1 = eval('aForm.' + field1);
		return isAlphaNumeric(formField1.value);
	}

	function selectNoAccess(aForm, field1, field2) {
		var formField1 = radio_button_checker(aForm, field1);
		var formField2 = radio_button_checker(aForm, field2);
		var tmpFormField1 = eval('aForm.' + field1);
		var tmpFormField2 = eval('aForm.' + field2);
		if (formField1 == "ACCESS") {
			tmpFormField2[0].checked = false;
			tmpFormField2[1].checked = false;
		}
	}

	function selectLive(aForm, field1, field2) {
		var formField1 = radio_button_checker(aForm, field1);
		var formField2 = radio_button_checker(aForm, field2);
		var tmpFormField1 = eval('aForm.' + field1);
		var tmpFormField2 = eval('aForm.' + field2);
		if (formField2 == "LIVE" || formField2 == "DEAD") {
			tmpFormField1[0].checked = false;
			tmpFormField1[1].checked = true;
		}
	}

	var strUserAgent = navigator.userAgent.toLowerCase();
	var isIE = strUserAgent.indexOf("msie") > -1;
	var isNS6 = strUserAgent.indexOf("netscape6") > -1;
	var isNS4 = !isIE && !isNS6  && parseFloat(navigator.appVersion) < 5;
	var isNS7 = strUserAgent.indexOf("netscape/7.0") > -1;

	var reValidChars = /d/;
	var reValidString = /^d*$/;
	var reKeyboardChars = /[x00x03x08x0Dx16x18x1A]/;
	var reClipboardChars = /[cvxz]/i;

	function checkClipboardCode(objEvent, strKey) {
		if (isNS7 || isNS6) {
			return objEvent.ctrlKey && reClipboardChars.test(strKey);
		} else {
			return false;
		}
	}

	function maskKeyPress(objEvent) {
		var iKeyCode, strKey, objInput;
		if (isIE) {
			iKeyCode = objEvent.keyCode;
			objInput = objEvent.srcElement;
		} else {
			iKeyCode = objEvent.which;
			objInput = objEvent.target;
		}

		strKey = String.fromCharCode(iKeyCode);

		if (checkClipboardCode(objEvent, strKey)) {
			return false;
		}
	}
	
	function norightclick(e) {
	  var message ="";
	  if (window.Event) 
	  {
	   if (!isIE) 
	   {
	    if (e.which == 2 || e.which == 3) 
	    {
	     (message);
	     return false;
	    }
	   }
	  } else if (event.button == 2 || event.button == 3) {
	   event.cancelBubble = true;
	   event.returnValue = false;
	   return false;
	  }
	}

	function nocontextmenu() {
		event.cancelBubble = true;
		event.returnValue = false;
		return false;
	}

	function maskPaste(objEvent) {
		var strPasteData = window.clipboardData.getData("Text");
		if (isIE) {
			objInput = objEvent.srcElement;
		} else {
			objInput = objEvent.target;
		}
		if (!isValid(strPasteData)) {
			objInput.focus();
			return false;
		}
	}

	function isValid(strValue) {
		return reValidString.test(strValue) || strValue.length == 0;
	}

	function maskChange(objEvent) {
		var objInput;
		if (isIE) {
			objInput = objEvent.srcElement;
		} else {
			objInput = objEvent.target;
		}
		if (!isValid(objInput.value)) {
			objInput.focus();
			objInput.select();
		} else {
			objInput.validValue = objInput.value;
		}
	}

	document.oncontextmenu = nocontextmenu;
	document.onmousedown = norightclick;
	document.onmouseup = norightclick;

	function validateLogin(aForm){
		if ( !formSubmitted ) {
			var username = aForm.USER.value;
			var passwd = aForm.PASSWORD.value;
			if (username == ""){return false;}
			if (passwd == ""){return false;}
			aForm.submit();
		} else {
			alert(SubmitMsg);
		}
		formSubmitted = true;
	}

	function key(aForm){
	   var from = aForm.hidlog.value
		if(event.keyCode==13) {
			if(from =="login") {isValidForm(aForm);} else {}
		}
	}
	
	function enterKey(aForm,aname){
	    if(event.keyCode==13) {
	    	  if(aname =="BankAcct") {
	    	    doSubmit(aForm);
	    	   } else if (aname == "txtZipcode") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "zip") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "AcctNickname") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "txtNickName") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "txtLastFourOfSSN" || aname == "txtDLN" || aname == "txtTIN" || aname == "txtMETERN") {
	    	     doSubmit(aForm);
	    	   }    	       	     
		}
		   
	}

	//New overloaded function added for capturing keyPress event being passed - RRR_APPCR_95661

	function enterKey(aForm,aname,$char,$mozChar){
	    if($char==13 || $mozChar==13) {
	    	  if(aname =="BankAcct") {
	    	    doSubmit(aForm);
	    	   } else if (aname == "txtZipcode") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "zip") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "AcctNickname") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "txtNickName") {
	    	     doSubmit(aForm);
	    	   } else if (aname == "txtLastFourOfSSN" || aname == "txtDLN" || aname == "txtTIN" || aname == "txtMETERN") {
	    	     doSubmit(aForm);
	    	   }    	   	    	     
		}
		   
	}

	// the view bill and global variable below is also located in the my account profile template inline
	var windowHandle = '';
	function viewBill(billingInvoiceNbr,accountNo,billInsertMarks,billInsertDates,printGroupId,companyCode)
			{
				
				//New change to get url host and protocol and form the final redirect url - APPCR 95419
				var urlProtocol = document.location.protocol.toString();
				var urlHost = document.location.host.toString();
							
				//************** Start - Comment out from here while blocking **************
				
				var url= urlProtocol + "//" + urlHost + "/en_US/OCS/residential/ocs/protected/ebill_statement.jsp";
				var qryStr = '?InvoiceID=' + billingInvoiceNbr + '&CSR=N&canumber=' + accountNo + '&L=1&BU=R&billInsertMarks=' + billInsertMarks + '&billInsertDates=' + billInsertDates+'&printGroupId='+printGroupId +'&companyCode='+companyCode;
				billUrl = url + qryStr;
				
				//changed width for OAM 2.6 Defect # 257
				windowHandle = window.open(billUrl,'Viewbill','scrollbars=yes,width=820,height=800,left=200,top=200,screenX=200,screenY=200');
				
				//************** End - Comment here while blocking **************

				//Start - Added to block the View Bill (Uncomment this part while blocking and later comment out)
				/*
				var url= urlProtocol + "//" + urlHost + "/en_US/Site_Down/viewBill_down_gen.htm";
				windowHandle = window.open(url,'Viewbill','scrollbars=yes,width=820,height=800,left=200,top=200,screenX=200,screenY=200');
				*/
				//End - Added to block the View Bill (Uncomment this part while blocking and later comment out)
	}


	//Added by DSHAH(LNT) for Mobious to DCTM Migration : Start
	function viewBillMigrate(billingInvoiceNbr,accountNo,billInsertMarks,billInsertDates,languageCode)
			{
				//New change to get url host and protocol and form the final redirect url
				var urlProtocol = document.location.protocol.toString();
				var urlHost = document.location.host.toString();
				//************** Start - Comment out from here while blocking **************
				
        var url= urlProtocol + "//" + urlHost + "/en_US/OCS/residential/ocs/protected/EBillWSCall.jsp";
				var qryStr = '?InvoiceID=' + billingInvoiceNbr + '&CSR=N&canumber=' + accountNo + '&L=1&BU=R&billInsertMarks=' + billInsertMarks + '&billInsertDates=' + billInsertDates+'&languageCode='+languageCode+'&docType=i';
				billUrl = url + qryStr;
				window.location = billUrl;
				
				//************** End - Comment here while blocking ************************
					
				//Start - Added to block the View Bill (Uncomment this part while blocking and later comment out)
				/*
				var url= urlProtocol + "//" + urlHost + "/en_US/Site_Down/viewBill_down_gen.htm";
				windowHandle = window.open(url,'Viewbill','scrollbars=yes,width=820,height=800,left=200,top=200,screenX=200,screenY=200');
				*/
				//End - Added to block the View Bill (Uncomment this part while blocking and later comment out)
	}
	//Added by DSHAH(LNT) for Mobious to DCTM Migration : End

	function statMsg(txt) {
			self.status = txt
	}

	function LTrim(str) {
		var whitespace = new String(" \t\n\r");
		var s = new String(str);
		if (whitespace.indexOf(s.charAt(0)) != -1) {
			var j=0, i = s.length;
			while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
				j++;
				s = s.substring(j, i);
			}
		}
		return s;
	}

	function RTrim(str) {
		var whitespace = new String(" \t\n\r");
		var s = new String(str);
		if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
			var i = s.length - 1;
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
				i--;
				s = s.substring(0, i+1);
			}
		}
		return s;
	}

	function Trim(str) {
		return RTrim(LTrim(str));
	}

	function chkUID(str)
	{
		str = str.replace(/\"/g," ");     
		str = str.replace(/^\s*/,"");
		str = str.replace(/\s*$/,"");
		str = str.replace(/\s+/g," ");
		str = str.replace(/\'/g,"&#39;");
		return str;
	}

	function parseQueryString (str)
	{
	  str = str ? str : location.search;
	  var query = str.charAt(0) == '?' ? str.substring(1) : str;
	  var args = new Object();
	  if (query) {
		var fields = query.split('&');
		for (var f = 0; f < fields.length; f++) {
		  var field = fields[f].split('=');
		  args[unescape(field[0].replace(/\+/g, ' '))] =
			unescape(field[1].replace(/\+/g, ' '));
		}
	  }
	  return args;
	}
	
	/******************************************************
	Function: autoTabKeyPress
	Purpose:  auto tabs to next field
	Inputs:   form object, event, max value of 
				field before tabbing, field to set focus on
	Returns:  n/a
	*******************************************************/		 
	 
	function autoTabKeyPress(what,e,max,action) {
		alert("testx =" + action + " " + e.target.value.length + " " + what.value.length);
	  if (isNS6 || isNS7) {
				if (e.target.value.length >= max)
					eval(action);
			}
			else if (document.all) {
				if (what.value.length > (max-1))
					eval(action);
					
			}
		}

	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	
	function autoTab(input,len, e) {
	  var keyCode = (isNN) ? e.which : e.keyCode; 
	  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	  if(input.value.length >= len && !containsElement(filter,keyCode)) {
	    input.value = input.value.slice(0, len);
	    input.form[(getIndex(input)+1) % input.form.length].focus();
	  }
	
	  function containsElement(arr, ele) {
	    var found = false, index = 0;
	    while(!found && index < arr.length)
	    if(arr[index] == ele)
	    found = true;
	    else
	    index++;
	    return found;
	  }
	
	  function getIndex(input) {
	    var index = -1, i = 0, found = false;
	    while (i < input.form.length && index == -1)
	    if (input.form[i] == input)index = i;
	    else i++;
	    return index;
	  }
	  return true;
	}
			
	/****************************************************
	Function: Check_Phone_Selection
	Purpose:  check to see if all phone no is numeric or not 
	         
	Inputs:   phone field value
	Returns:  1 or 2 . 1 means nonnumeric  and 2 means 
	          either alphabetic or empty
	*****************************************************/		 
	 
	function  Check_Phone_Selection(aForm) {
		//alert("type is " + type)

		var val1    = Trim(aForm.txtPhoneNo1.value);
		var val2    = Trim(aForm.txtPhoneNo2.value);
		var val3    = Trim(aForm.txtPhoneNo3.value);
		var val2length=3;		

		
		if ((val1 != "") || (val2 != "") || (val3 != "")) {
			if (((val1.length == 3) && (val2.length == val2length) && (val3.length == 4))) { 
			  	if ((isNaN(val1)) || (isNaN(val2)) || (isNaN(val3))) 
			  	{			  		
			  		return 1
				} else {
					var errp1=validatePhoneNumber(val1)
					var errp2=validatePhoneNumber(val2)
					var errp3=validatePhoneNumber(val3)
					if (errp1 == 1 || errp2 == 1 || errp3 == 1) {
				    	return 1
				     }
				}
			} else {
				return 1	
			}
		} else {
			if ((val1 == "") && (val2 == "") && (val3 == "")) {
				return 2
			}	
		}	  
	}
	/****************************************************
	Function: Check_Street_Num_Selection
	Purpose:  check to see if the address number is valid
	         
	Inputs:   street number
	Returns:  
	*****************************************************/		 
	 
	function  Check_Street_Num_Selection(aForm) {
		newVal = "";
		for(i=0;i<aForm.txtStreetNum.value.length;i++) {
			if(aForm.txtStreetNum.value.charAt(i) >= "0" && aForm.txtStreetNum.value.charAt(i) <= "9") {
				if(i<10) {
					newVal += aForm.txtStreetNum.value.charAt(i);
				}	
			}
		}
		aForm.txtStreetNum.value = newVal;
	}
	
	/****************************************************
	Function: validatePhoneNumber
	Purpose:  check to see if phone no is numeric or not 
	Inputs:   phone field value
	Returns:  1 or 0 . 1 means nonnumeric  
	*****************************************************/
	
	function validatePhoneNumber(phone) {
	   var errphone=0;
	   if (phone.value != "") {
       var digits="0123456789"
       var temp
       for (var i=0;i<phone.length;i++){
            temp=phone.substring(i,i+1)
            if (digits.indexOf(temp)==-1){
			
                   var errphone =1
			 }
          }
	   }
	   return errphone; 
	 }