// JavaScript Document
function page_init(){
	window.document.getElementById("idBody").style.display = "block";
}

function submitPopUpForm(aForm , oekey) {
	if(oekey == "zipchange") {
			aForm.action  =  "/en_US/OWE/residential/newenroll.jsp";
			aForm.submit();
	} else if(oekey == "verify") {
			aForm.action  =  "/en_US/OE/personal_info.jsp" ;
			aForm.submit();
	}
      else if(oekey == "start_date") {
			aForm.action  =  "/en_US/OE/SrvcDetailsMoveIn.jsp" ;
			aForm.submit();
	}
      else if(oekey == "payment") {
			aForm.action  =  "/en_US/OE/Prepay/prepayPaymentOptions.jsp" ;
			aForm.submit();
	}

}

function checkBirthYear(year){
	var fieldID = year.name;
	var yearVal = year.value;
	if(yearVal.length > 1 && yearVal.length < 3){
		if(yearVal < 100){
			document.getElementById(fieldID).value = '19'+yearVal;
		}
	}
	var d = new Date(); 
	var y = d.getFullYear();
	checkDateRange(year,y - 120,y);
}

function checkDateRange(field,low,high){

	if(field.value != ""){
		if(field.value < low || field.value > high)
		{
			/*field.className= "formTextboxInvalid";*/
			field.value = PadDigits(field.value, 2); 
			
		}else
		{
			/*field.className= "TextBox";*/
			field.value = PadDigits(field.value, 2);
				
		}
	}
}
function isNumberKey(evt){
		
		 var charCode = (evt.which) ? evt.which : event.keyCode;
		 if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
         return true;
      }
function matchFields(aFld,bFld){
	if(aFld.value == document.getElementById(bFld).value)
	{
	 	aFld.className = "TextBox";
		document.getElementById(bFld).className = "TextBox";
	}else{
		aFld.className = "formTextboxInvalid";
		document.getElementById(bFld).className = "formTextboxInvalid";
	}
}
function doCheck(elem)
{
	document.getElementById(elem).checked = true;	
}
function toggleCheck(elem)
{
	if(document.getElementById(elem).checked)
		document.getElementById(elem).checked = false;
	else
		document.getElementById(elem).checked = true;
}

function changeClass(divID,newClass)
{
	document.getElementById(divID).className = newClass;
}

function showProcessing(){
	changeClass('processing','showProcessing');
	changeClass('MainContainer','dispOff')	
}

function setBreadCrumb(crumbID)
{
	document.getElementById(crumbID).className = "dispOn";
}

function toggleDisp(divID)
{
if(document.getElementById(divID).className == "dispOff")
	{
		document.getElementById(divID).className = "dispOn";
	}else
	{
		document.getElementById(divID).className = "dispOff";		
	}
}



 
function PadDigits(n, totalDigits) 
{ 
        n = n.toString(); 
        var pd = ''; 
        if (totalDigits > n.length) 
        { 
            for (i=0; i < (totalDigits-n.length); i++) 
            { 
                pd += '0'; 
            } 
        } 
        return pd + n.toString(); 
}
//Removed apostrophe character allowing validation for IM737758
function isAlphaNumeric(inVal) {
		str = "";
		str = inVal.value;
		newVal = "";
		for(i=0;i<str.length;i++) {
			if (str.charAt(i).match(/^[a-zA-Z0-9_-]+$/) || str.charAt(i).match(/[\s\/,.:ÇüéâäàåçêëèïîìÄÅÉôöòûùÖÜáíóúñÑªº¿¡]/)) {
				newVal += str.charAt(i);
			} else {
				inVal.value = newVal;
				return;
			}
		}
	}
 function isAlpha(inVal) {
		str = "";
		str = inVal.value;
		newVal = "";
		for(i=0;i<str.length;i++) {
			if (str.charAt(i).match(/^[a-zA-Z_-]+$/) || str.charAt(i).match(/[\s\/,.:ÇüéâäàåçêëèïîìÄÅÉôöòûùÖÜáíóúñÑªº¿¡]/)) {
				newVal += str.charAt(i);
			} else {
				inVal.value = newVal;
				return;
			}
		}
	}
function isAlphaKey(evt){
		 var charCode = (evt.which) ? evt.which : event.keyCode;
         if ((charCode >=97 && charCode <= 122) || (charCode >= 65 && charCode <= 90))
            return true;
         return false;
      }
      
function isAlphaNumericKey(evt){
		 var charCode = (evt.which) ? evt.which : event.keyCode;
         if ((charCode >=97 && charCode <= 122) || (charCode >= 65 && charCode <= 90) || (charCode >= 48 && charCode <= 57))
            return true;
         return false;
      }

function cleanApt(Inval) {
	     str  = "";
	     str  = Inval;
	     newVal = "";
	     
	     
	     nums="0123456789";
	     		for(i=0;i<str.length;i++) {
	     			if(nums.indexOf(str.charAt(i)) >= 0) {
	     				newVal += str.charAt(i);
	     			} 
			}
	    	
	    return newVal;
	}
	
	
function isEmailKey(evt){
		 var charCode = (evt.which) ? evt.which : event.keyCode;
         if ((charCode >=97 && charCode <= 122) || (charCode >= 65 && charCode <= 90) || (charCode >= 48 && charCode <= 57) || (charCode == 8) || (charCode == 45) || (charCode == 46) || (charCode == 64) || (charCode == 95))
            return true;
         return false;
}
      
      
function validateHomeZip(zipField) {
			
		tempVal = "";

		for(i=0;i<zipField.value.length;i++) {
			if(isDigit(zipField.value.charAt(i))) {
				tempVal = tempVal + zipField.value.charAt(i);
			}
		}
		zipField.value = tempVal;
	}

function isDigit(num) {
	    if (num.length>1){
		return false;
	    }
	    var string="1234567890";
	    if (string.indexOf(num)!=-1){
		return true;
	    }
	    return false;
}      
      
function isValidApt(inVal) {
	str = "";
	str = inVal.value;
	newVal = "";
	for(i=0;i<str.length;i++) {
		if (str.charAt(i).match(/^[a-zA-Z0-9_-]+$/) || str.charAt(i).match(/[\s#.ÇüéâäàåçêëèïîìÄÅÉôöòûùÖÜáíóúñÑªº¿¡]/)) {
			newVal += str.charAt(i);
		} else {
			inVal.value = newVal;
			return;
		}
	}
}

function isValidPO(inVal) {
	str = "";
	str = inVal.value;
	newVal = "";
	for(i=0;i<str.length;i++) {
		if (str.charAt(i).match(/^[a-zA-Z0-9_-]+$/) || str.charAt(i).match(/[\s\/:;'".ÇüéâäàåçêëèïîìÄÅÉôöòûùÖÜáíóúñÑªº¿¡]/)) {
			newVal += str.charAt(i);
		} else {
			inVal.value = newVal;
			return;
		}
	}
}
