function isValidUserName(str)
{
	var a=0;
	while(a<str.length)
	{
		if(!(( str.charAt(a) >= '0' && str.charAt(a) <= '9' ) || ( str.charAt(a) >= 'A' && str.charAt(a) <= 'Z' ) || ( str.charAt(a) >= 'a' && str.charAt(a) <= 'z' ) || str.charAt(a) == '_'  || str.charAt(a) == '-'  || str.charAt(a) == ''))
			return false;
		a++;
	}
	return true;
}

function CheckEmailSpecialCharacter(str)
{
	var a=0;
	while(a<str.length)
	{
		if(!(( str.charAt(a) >= '0' && str.charAt(a) <= '9' ) || ( str.charAt(a) >= 'A' && str.charAt(a) <= 'Z' ) || ( str.charAt(a) >= 'a' && str.charAt(a) <= 'z' ) || str.charAt(a) == '.' || str.charAt(a) == '@' || str.charAt(a) == '_' ))
			return false;
		a++;
	}
	return true;
}

function isValidName(str)
{
	var a=0;
	while(a<str.length)
	{
		if(!(( str.charAt(a) >= 'A' && str.charAt(a) <= 'Z' ) || ( str.charAt(a) >= 'a' && str.charAt(a) <= 'z' ) || str.charAt(a) == '_'  || str.charAt(a) == '-'  || str.charAt(a) == ' '))
			return false;
		a++;
	}
	return true;
}

function isValidString(str)
{
	var a=0;
	while(a<str.length)
	{
		if( str.charAt(a)== '\'' || str.charAt(a) == '\\' )
			return false;
		a++;
	}
	return true;
}

function isSpaceExist(str)
{
	var a=0;
	while(a<str.length)
	{
		if( str.charAt(a)== ' ' )
			return false;
		a++;
	}
	return true;
}


function isCharsInBag (s, bag)
  {
    var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return(false);
    }
    return true;
  }
  
	function EmailCheck(email){
		
		if(email.value==''){
			alert("Enter Email Address");
            email.focus();            
            return false;
		}
		if ( !this.isCharsInBag( email.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._@-" ))
		{
		      
            alert("Invalid Email Address");
            email.focus();            
            return false;
		}
	
	if(email.value != '')
	   {
		var str=email.value;	
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var sdot=str.indexOf(dot,ldot+1);

		if (str.indexOf(at)==-1){
			alert("Invalid Email Address");
            email.focus();            
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		if (str.substring(ldot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if (str.substring(sdot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if(str.lastIndexOf(".") == str.length-1)
		 {
		 	alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
	}//end of else
	return true;
}

function fnFreeAdSubmit(oForm)
{
	var oDate = oForm.txtDate;
	if(trim(oDate.value) == '')
	{
		window.alert('Enter Date');
		oDate.focus();
		return;
	}
	
	var oPosition = oForm.sltCategory;
	var sSelectedText = oPosition.options[oPosition.selectedIndex].text.toLowerCase();
	if(oPosition.value == 'sel')
	{
		window.alert('Select Help Needed');
		oPosition.focus();
		return;
	}
	else if(sSelectedText.indexOf('other') != -1)
	{
		var oPosExplain = oForm.txtPosExplain;
		if(oPosExplain.value == '')
		{
			window.alert('Give Explaination For Help Needed');
			oPosExplain.focus();
			return;
		}
//		if(!isValidString(oPosExplain.value))
//		{
//			window.alert('Special characters such as \',\\ are not allowed in Explaination');
//			oPosExplain.focus();
//			return;
//		}
	}
	
	var oStartDate = oForm.txtStartDate;
	
	if(trim(oStartDate.value) == '')
	{
		window.alert('Select Start Date from Calendar\'s button');
		oStartDate.focus();
		return;
	}
	
	var oFirstName = oForm.txtFirstName;
	if(trim(oFirstName.value) == '')
	{
		window.alert('Enter First Name');
		oFirstName.focus();
		return;
	}
	if(!isValidName(oFirstName.value))
	{
		window.alert('Special characters and numbers are not allowed in First Name');
		oFirstName.focus();
		return;
	}
	if(!isSpaceExist(trim(oFirstName.value)))
	{
		window.alert('No Space allowed in First Name');
		oFirstName.focus();
		return;
	}
	
	
	var oEmail = oForm.txtEmail;
	if(!this.EmailCheck(oEmail))
	{
		return false;
	}
	
	var oState = oForm.sltState;
	if(oState.value == 'sel')
	{
		window.alert('Select State');
		oState.focus();
		return;
	}
	
	var oCity = oForm.txtCity;
	if(trim(oCity.value) == '')
	{
		window.alert('Enter City');
		oCity.focus();
		return;
	}
	if(!isValidString(oCity.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in City');
		oCity.focus();
		return;
	}
	
	var txtSpecNeeds = oForm.txtSpecNeeds;
	if(trim(txtSpecNeeds.value) == '')
	{
		window.alert('Enter Special Needs');
		txtSpecNeeds.focus();
		return;
	}
	if(trim(txtSpecNeeds.value)>500)
	{
		window.alert('You can enter upto 500 characters in Speecial Needs');
		txtSpecNeeds.focus();
		return;
	}
	
	
	var oAmount = oForm.txtAmount;
	if(trim(oAmount.value) == '')
	{
		window.alert('Enter Amount Willing To Pay');
		oAmount.focus();
		return;
	}
//	if(!isInteger(oAmount.value))
//	{
//		window.alert('Invalid Value of Amount Willing To Pay');
//		oAmount.focus();
//		return;
//	}

	
	var oTerms = oForm.chkTerms;
	if(oTerms.checked != true)
	{
		window.alert('Checked on Terms of Use Checkbox');
		oTerms.focus();
		return;
	}
	oForm.action = "freeadd.php?save=y&Page_Type=contact#apost";
	oForm.submit();
}



function fnHelperSubmit(oForm,type)
{
	var oDate = oForm.txtDate;
	if(trim(oDate.value) == '')
	{
		window.alert('Enter Date');
		oDate.focus();
		return;
	}
	
	var oPosition = oForm.sltCategory;
	var sSelectedText = oPosition.options[oPosition.selectedIndex].text.toLowerCase();
	if(oPosition.value == 'sel')
	{
		window.alert('Select Position Applying For');
		oPosition.focus();
		return;
	}
	else if(sSelectedText.indexOf('other') != -1)
	{
		var oPosExplain = oForm.txtPosExplain;		
		
		if(oPosExplain.value == '')
		{
			window.alert('Give Explaination For Position Applying');
			oPosExplain.focus();
			return;
		}
		/*else if(oPosExplain.value.toLowerCase() == "babysitter" || oPosExplain.value.toLowerCase() == "nanny" ||
				oPosExplain.value.toLowerCase() == "caregiver"	|| oPosExplain.value.toLowerCase() == "au pair" ||
				oPosExplain.value.toLowerCase() == "personal chef"	|| oPosExplain.value.toLowerCase() == "personal assistant" ||
				oPosExplain.value.toLowerCase() == "personal trainer"	|| oPosExplain.value.toLowerCase() == "housekeeper" ||
				oPosExplain.value.toLowerCase() == "lawn care")
		{
			window.alert('Please Enter Postion other than the above list otherwise Select from the list.');
			oPosExplain.focus();
			return;
		}*/
//		if(!isValidString(oPosExplain.value))
//		{
//			window.alert('Special characters such as \',\\ are not allowed in Explaination');
//			oPosExplain.focus();
//			return;
//		}
	}

	var oPartTime = oForm.radPartTime;
	if(!isRadioChecked(oPartTime))
	{
		window.alert('Select one of the Part Time option');
		oPartTime[0].focus();
		return;
	}
	
	var oFullTime = oForm.radFullTime;
	if(!isRadioChecked(oFullTime))
	{
		window.alert('Select one of the Full Time option');
		oFullTime[0].focus();
		return;
	}
	
	var oGender = oForm.radGender;
	if(!isRadioChecked(oGender))
	{
		window.alert('Select Gender');
		oGender[0].focus();
		return;
	}
	
	var oEmail = oForm.txtEmail;
	if(!this.EmailCheck(oEmail))
	{
		return false;
	}
	
	var oConfirmEmail = oForm.txtConfirmEmail;
	if(trim(oConfirmEmail.value) == '')
	{
		window.alert('Enter Confirm Email');
		oConfirmEmail.focus();
		return;
	}
	if(trim(oConfirmEmail.value) != trim(oEmail.value))
	{
		window.alert('Confirm Email and Email fields must be indentical');
		oConfirmEmail.focus();
		return;
	}
	
	var oUserName = oForm.txtUserName;
	if(trim(oUserName.value) == '')
	{
		window.alert('Enter User Name');
		oUserName.focus();
		return;
	}
	if(!isValidUserName(oUserName.value))
	{
		window.alert('User Name can be composed of letters(a-z,A-Z), numbers(0-9) and underscore(_) only');
		oUserName.focus();
		return;
	}
	
	var oPassword = oForm.txtPassword;
	if(trim(oPassword.value) == '' && type !='update')
	{
		window.alert('Enter Password');
		oPassword.focus();
		return;
	}
	if(oPassword.value.length > 0 && oPassword.value.length < 5 || oPassword.value.length > 8)
	{
		window.alert('Password should be 5-8 characters long');
		oPassword.focus();
		return;
	}
	if(!isValidString(oPassword.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in Password');
		oPassword.focus();
		return;
	}
	
	var oConfirmPassword = oForm.txtConfirmPassword;
	if(trim(oConfirmPassword.value) == ''  && type !='update')
	{
		window.alert('Enter Confirm Password');
		oConfirmPassword.focus();
		return;
	}
	if(oPassword.value != oConfirmPassword.value)
	{
		window.alert('Password and Confirm Password fields do not match');
		oConfirmPassword.focus();
		return;
	}
	
	var oFirstName = oForm.txtFirstName;
	if(trim(oFirstName.value) == '')
	{
		window.alert('Enter First Name');
		oFirstName.focus();
		return;
	}
	if(!isValidName(oFirstName.value))
	{
		window.alert('Special characters and numbers are not allowed in First Name');
		oFirstName.focus();
		return;
	}
	
	var oLastName = oForm.txtLastName;
	if(trim(oLastName.value) == '')
	{
		window.alert('Enter Last Name');
		oLastName.focus();
		return;
	}
	if(!isValidName(oLastName.value))
	{
		window.alert('Special characters and numbers are not allowed in Last Name');
		oLastName.focus();
		return;
	}
	
	var oAddress = oForm.txtAddress;
	if(trim(oAddress.value) == '')
	{
		window.alert('Enter Address');
		oAddress.focus();
		return;
	}
//	if(!isValidString(oAddress.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in Address');
//		oAddress.focus();
//		return;
//	}
	
	//var txtCity = oForm.txtCity;
	var txtCity = MWJ_findObj('txtCity');
	if(txtCity.value == 'sel' )
	{
		window.alert('Select City');
		txtCity.focus();
		return;
	}
	else if(txtCity.options[txtCity.selectedIndex].text == 'Other' )
	{
		var txtCity1 = oForm.txtCity1;
		if(txtCity1.value == '' )
		{
			window.alert('Enter City');
			txtCity1.focus();
			return;
		}
		if(!isValidString(txtCity1.value))
		{
		window.alert('Special characters such as \',\\ are not allowed in City');
		txtCity1.focus();
		return;
		}
	}	
	/*
	var oViolation = oForm.radViolation1;
	if(!isRadioChecked(oViolation))
	{
		window.alert('Select one of the Traffic violations\'s option');
		oViolation[0].focus();
		return;
	}
	if(oViolation[0].checked == true)
	{
		var oTrafficViolation = oForm.txtCity1;
		if(trim(oTrafficViolation.value) == '')
		{
			window.alert('Enter City');
			oTrafficViolation.focus();
			return;
		}
		if(!isValidString(oTrafficViolation.value))
		{
			window.alert('Special characters such as \',\\ are not allowed in City');
			oTrafficViolation.focus();
			return;
		}
	}
	if(oViolation[0].checked == false)
		var oTrafficViolation = oForm.txtCity;
		if(trim(oTrafficViolation.value) == 'sel')
		{
			window.alert('Select City');
			oTrafficViolation.focus();
			return;
		}
		*/
	
	/*
	var oCity = oForm.txtCity;
	if
		if(trim(oCity.value) == 'sel')
		{
			window.alert('Select City');
			oCity.focus();
			return;
		}
	
	if(!isValidString(oCity.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in City');
		oCity.focus();
		return;
	}
	*/
	var oState = oForm.sltState;
	if(oState.value == 'sel')
	{
		window.alert('Select State');
		oState.focus();
		return;
	}
	
	var oZipCode = oForm.txtZipCode;
	if(trim(oZipCode.value) == '')
	{
		window.alert('Enter Zip Code');
		oZipCode.focus();
		return;
	}
	else if(oZipCode.value.length != 5)
	{
		window.alert('Enter a valid Zip Code');
		oZipCode.focus();
		return;
	}
	if (!isInteger(oZipCode.value))
	{
	    alert("Invalid Zip Code");
	    oZipCode.focus();            
	    return;
	}
	
    var oHomePhone = oForm.txtHomePhone;
/*	if(trim(oHomePhone.value) == '')
	{
		window.alert('Enter Home Phone');
		oHomePhone.focus();
		return;
	}
*/	
	/*
	if(!isInteger(trim(oHomePhone.value)))
	{
		alert("Home Phone can contain numbers only.");
		oHomePhone.focus();
		return;
	}
	*/
	var oWorkPhone = oForm.txtWorkPhone;
/*	if(trim(oWorkPhone.value) != '')
	{
		if(!isValidString(oWorkPhone.value))
		{
			window.alert('Special characters such as \',\\ are not allowed in Work Phone');
			oWorkPhone.focus();
			return;
		}
	}
	*/
	var oMobilePhone = oForm.txtMobilePhone;
/*	if (!isInteger(trim(oMobilePhone.value)))
	{
	    alert("Mobile Phone can contain numbers only.");
	    oMobilePhone.focus();            
	    return;
	}
*/
	/*if(trim(oMobilePhone.value) == '')
	{
		window.alert('Enter Mobile Phone');
		oMobilePhone.focus();
		return;
	}
	if(trim(oMobilePhone.value) != '')
	{
		if(!isValidString(oMobilePhone.value))
		{
			window.alert('Special characters such as \',\\ are not allowed in Mobile Phone');
			oMobilePhone.focus();
			return;
		}
	}*/
	
	var oFelony = oForm.radFelony;
	if(!isRadioChecked(oFelony))
	{
		window.alert('Select one of the Convicted of felony\'s option');
		oFelony[0].focus();
		return;
	}
	
	var oViolation = oForm.radViolation;
	if(!isRadioChecked(oViolation))
	{
		window.alert('Select one of the Traffic violations\'s option');
		oViolation[0].focus();
		return;
	}
	if(oViolation[0].checked == true)
	{
		var oTrafficViolation = oForm.txtTrafficViolation;
		if(trim(oTrafficViolation.value) == '')
		{
			window.alert('Enter Traffice violation explaination');
			oTrafficViolation.focus();
			return;
		}
//		if(!isValidString(oTrafficViolation.value))
//		{
//			window.alert('Special characters such as \',\\ are not allowed in Explaination');
//			oTrafficViolation.focus();
//			return;
//		}
	}
	
	var oOlder = oForm.radOlder;
	if(!isRadioChecked(oOlder))
	{
		window.alert('Select one of the Age range\'s option');
		oOlder[0].focus();
		return;
	}
	
	if(oOlder[1].checked==true)
	{
	alert('Member must be 18 years above for reqistration');
	oOlder[0].focus();
	return;
	}
	
	var oCitizen = oForm.sltCitizen;
	if(oCitizen.value == 'sel')
	{
		window.alert('Select Your Residence');
		oCitizen.focus();
		return;
	}
	
	var oBilingual = oForm.radBilingual;
	
	if(!isRadioChecked(oBilingual))
	{
		window.alert("Please Select Yes/No for 'Are you Bilingual?'");
		oBilingual[0].focus();
		return;
	}
	if(oBilingual[0].checked)
	{
		var oLanguages = oForm.txtLanguages;
		if(oLanguages.value == "")
		{
			window.alert("Please enter the languages spoken");
			oLanguages.focus();
			return;
		}		
	}
	
	var oLanguages = oForm.txtLanguages;
	if(oLanguages.value != '')
	{
//		if(!isValidString(oLanguages.value))
//		{
//			window.alert('Special characters such as \',\\ are not allowed in Languages Spoken');
//			oLanguages.focus();
//			return;
//		}
	}
	
	var oCertifications = oForm.txtCertifications;
	if(oCertifications.value != '')
	{
//		if(!isValidString(oCertifications.value))
//		{
//			window.alert('Special characters such as \',\\ are not allowed in List of Certifications');
//			oCertifications.focus();
//			return;
//		}
	}
	
	var oDriveCar = oForm.radDriveCar;
	if(!isRadioChecked(oDriveCar))
	{
		window.alert('Select one of the Drive Car\'s option');
		oDriveCar[0].focus();
		return;
	}
	
	var oOwnCar = oForm.radOwnCar;
	if(!isRadioChecked(oOwnCar))
	{
		window.alert('Select one of the Own Car\'s option');
		oOwnCar[0].focus();
		return;
	}
	
	var oDrink = oForm.radDrink;
	if(!isRadioChecked(oDrink))
	{
		window.alert('Select one of the Drink\'s option');
		oDrink[0].focus();
		return;
	}
	
	var oSmoke = oForm.radSmoke;
	if(!isRadioChecked(oSmoke))
	{
		window.alert('Select one of the Smoke\'s option');
		oSmoke[0].focus();
		return;
	}
	
	var oSwim = oForm.radSwim;
	if(!isRadioChecked(oSwim))
	{
		window.alert('Select one of the Swim\'s option');
		oSwim[0].focus();
		return;
	}
	
	var oAnimals = oForm.radAnimals;
	if(!isRadioChecked(oAnimals))
	{
		window.alert('Select one of the Work Around Animals\'s option');
		oAnimals[0].focus();
		return;
	}
	
	var oTwins = oForm.radTwins;
	if(!isRadioChecked(oTwins))
	{
		window.alert('Select one of the Work with Twins/Triplets\'s option');
		oTwins[0].focus();
		return;
	}
	
	var oNewborns = oForm.radNewborns;
	if(!isRadioChecked(oNewborns))
	{
		window.alert('Select one of the Work with Newborns\'s option');
		oNewborns[0].focus();
		return;
	}
	
	var oSpecial = oForm.radSpecial;
	if(!isRadioChecked(oSpecial))
	{
		window.alert('Select one of the Work with Special Needs\'s option');
		oSpecial[0].focus();
		return;
	}
	
	var oHousekeeping = oForm.radHousekeeping;
	if(!isRadioChecked(oHousekeeping))
	{
		window.alert('Select one of the Do Housekeeping\'s option');
		oHousekeeping[0].focus();
		return;
	}
	
	var oMeals = oForm.radMeals;
	if(!isRadioChecked(oMeals))
	{
		window.alert('Select one of the Prepare Meals\'s option');
		oMeals[0].focus();
		return;
	}
	
	var oLiveIn = oForm.radLiveIn;
	if(!isRadioChecked(oLiveIn))
	{
		window.alert('Select one of the Live In\'s option');
		oLiveIn[0].focus();
		return;
	}
	
	var oLiveOut = oForm.radLiveOut;
	if(!isRadioChecked(oLiveOut))
	{
		window.alert('Select one of the Live Out\'s option');
		oLiveOut[0].focus();
		return;
	}
	
	var oWorkState1 = oForm.sltWorkState1;
	if(oWorkState1.value == 'sel')
	{
		window.alert('Select State willing to work in');
		oWorkState1.focus();
		return;
	}
	
	//var txtWorkCity1 = window.document.getElementById('txtWorkCity1');
	var txtWorkCity1 = MWJ_findObj('txtWorkCity1');
	//oForm.;
		//var txtWorkCity1 = oForm.txtWorkCity1;
	
	if(txtWorkCity1.value == 'sel' )
	{
		window.alert('Select City willing to work in');
		txtWorkCity1.focus();
		return;
	}
	else if(txtWorkCity1.options[txtWorkCity1.selectedIndex].text == 'Other' )
	{
		var txtWorkCity11 = oForm.txtWorkCity11;
		if(txtWorkCity11.value == '' )
		{
			window.alert('Enter City willing to work in');
			txtWorkCity11.focus();
			return;
		}
		if(!isValidString(txtWorkCity11.value))
		{
		window.alert('Special characters such as \',\\ are not allowed in City willing to work in');
		txtWorkCity11.focus();
		return;
		}
	}	
	
	
	var txtWorkCity2 = MWJ_findObj('txtWorkCity2');
	var sltWorkState2= oForm.sltWorkState2;
	
	if(sltWorkState2.value!="sel" && txtWorkCity2.value=="sel")
	{
	  	window.alert('Select City 2');
		txtWorkCity2.focus();
		return;
	}
	if(txtWorkCity2.options[txtWorkCity2.selectedIndex].text == 'Other' )
	{
		var txtWorkCity22 = oForm.txtWorkCity22;
		if(txtWorkCity22.value == '' )
		{
			window.alert('Enter City 2');
			txtWorkCity22.focus();
			return;
		}
		if(!isValidString(txtWorkCity22.value))
		{
		window.alert('Special characters such as \',\\ are not allowed in City 2');
		txtWorkCity22.focus();
		return;
		}
	}
	
	var txtWorkCity3 = MWJ_findObj('txtWorkCity3');
	var sltWorkState3= oForm.sltWorkState3;
	
	if(sltWorkState3.value!="sel" && txtWorkCity3.value=="sel")
	{
	  	window.alert('Select City 3');
		txtWorkCity3.focus();
		return;
	}
	if(txtWorkCity3.options[txtWorkCity3.selectedIndex].text == 'Other' )
	{
		var txtWorkCity33 = oForm.txtWorkCity33;
		if(txtWorkCity33.value == '' )
		{
			window.alert('Enter City 3');
			txtWorkCity33.focus();
			return;
		}
		if(!isValidString(txtWorkCity33.value))
		{
		window.alert('Special characters such as \',\\ are not allowed in City 3');
		txtWorkCity33.focus();
		return;
		}
	}
	
	var txtWorkCity4 =MWJ_findObj('txtWorkCity4');
	var sltWorkState4= oForm.sltWorkState4;
	
	if(sltWorkState4.value!="sel" && txtWorkCity4.value=="sel")
	{
	  	window.alert('Select City 4');
		txtWorkCity4.focus();
		return;
	}
	if(txtWorkCity4.options[txtWorkCity4.selectedIndex].text == 'Other' )
	{
		var txtWorkCity44 = oForm.txtWorkCity44;
		if(txtWorkCity44.value == '' )
		{
			window.alert('Enter City 4');
			txtWorkCity44.focus();
			return;
		}
		if(!isValidString(txtWorkCity44.value))
		{
		window.alert('Special characters such as \',\\ are not allowed in City 4');
		txtWorkCity44.focus();
		return;
		}
	}
	
	var txtWorkCity5 = MWJ_findObj('txtWorkCity5');
	var sltWorkState5= oForm.sltWorkState5;
	
	if(sltWorkState5.value!="sel" && txtWorkCity5.value=="sel")
	{
	  	window.alert('Select City 5');
		txtWorkCity5.focus();
		return;
	}
	if(txtWorkCity5.options[txtWorkCity5.selectedIndex].text == 'Other' )
	{
		var txtWorkCity55 = oForm.txtWorkCity55;
		if(txtWorkCity55.value == '' )
		{
			window.alert('Enter City 5');
			txtWorkCity55.focus();
			return;
		}
		if(!isValidString(txtWorkCity55.value))
		{
		window.alert('Special characters such as \',\\ are not allowed in City 5');
		txtWorkCity55.focus();
		return;
		}
 }
	
	var oPayRate = oForm.txtPayRate;
	if(trim(oPayRate.value) == '')
	{
		window.alert('Enter Expected Rate of Pay');
		oPayRate.focus();
		return;
	}
//	if(isNaN(Number(oPayRate.value)))
//	{
//		window.alert('Invalid Value of Expected Rate of Pay');
//		oPayRate.focus();
//		return;
//	}
/*	if (!isInteger(oPayRate.value))
	{
	    alert("Invalid Expected Rate of Pay");
	    oPayRate.focus();
	    return;
	}
	*/
	var oPRef = oForm.radPRef;
	if(!isRadioChecked(oPRef))
	{
		window.alert('Select one of the Have Personal Reference\'s option');
		oPRef[0].focus();
		return;
	}
	
	var oEmergencies = oForm.radEmergencies;
	if(!isRadioChecked(oEmergencies))
	{
		window.alert('Select one of the Available for Emergencies\'s option');
		oEmergencies[0].focus();
		return;
	}
	
	var oExperience = oForm.txtExperience;
	if(trim(oExperience.value) == '')
	{
		window.alert('Enter Experience Description');
		oExperience.focus();
		return;
	}
//	if(!isValidString(oExperience.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in Experience Description');
//		oExperience.focus();
//		return;
//	}
//	
	var oPhoto = oForm.txtPhoto;
	if(oPhoto.value != "")
	{
		var oAllowedExtensions = ['gif', 'jpg'];
		var sExtension = oPhoto.value.substring(oPhoto.value.lastIndexOf('.')+1);
		var bAllow = false;
		for(var counter = 0; counter < oAllowedExtensions.length; counter++)
		{
			if(sExtension.toLowerCase() == oAllowedExtensions[counter])
				bAllow = true;
		}
		if(!bAllow)
		{
			window.alert('Invalid Image Format\nOnly '+ oAllowedExtensions.join(',').toUpperCase() +' formats are allowed');
			oPhoto.focus();
			return;
		}
	}
	
	var oAudio = oForm.txtAudio;
	if(oAudio.value != "")
	{
		var oAllowedExtensions = ['mid', 'mp3', 'wav', 'ram', 'wma'];
		var sExtension = oAudio.value.substring(oAudio.value.lastIndexOf('.')+1);
		var bAllow = false;
		for(var counter = 0; counter < oAllowedExtensions.length; counter++)
		{
			if(sExtension.toLowerCase() == oAllowedExtensions[counter])
				bAllow = true;
		}
		if(!bAllow)
		{
			window.alert('Invalid Audio Format\nOnly '+ oAllowedExtensions.join(',').toUpperCase() +' formats are allowed');
			oAudio.focus();
			return;
		}
		//alert(oAudio.size);
		//return;
	}
	
	var oVideo = oForm.txtVideo;
	if(oVideo.value != "")
	{
		var oAllowedExtensions = ['mpeg', 'mpg', 'avi', 'wmv'];
		var sExtension = oVideo.value.substring(oVideo.value.lastIndexOf('.')+1);
		var bAllow = false;
		for(var counter = 0; counter < oAllowedExtensions.length; counter++)
		{
			if(sExtension.toLowerCase() == oAllowedExtensions[counter])
				bAllow = true;
		}
		if(!bAllow)
		{
			window.alert('Invalid Video Format\nOnly '+ oAllowedExtensions.join(',').toUpperCase() +' formats are allowed');
			oVideo.focus();
			return;
		}
		//alert(oVideo.size);
		//return;
	}
	var templateCheck = oForm.templateSelect;
	
	//return;
	if(templateCheck.value != 'true' && type !='update')
	{
		window.alert('Select template');
		return;
	}
	var oTerms = oForm.chkTerms;
	if(oTerms.checked != true)
	{
		window.alert('Checked on Terms of Use Checkbox');
		oTerms.focus();
		return;
	}
	oForm.submit();
}

function fnPostJobSubmit2(oForm,type)
{
	//alert("cll");
	var oAudio = oForm.txtAudio;
	if(oAudio.value != "")
	{
		var oAllowedExtensions = ['mid', 'mp3', 'wav', 'ram', 'wma'];
		var sExtension = oAudio.value.substring(oAudio.value.lastIndexOf('.')+1);
		var bAllow = false;
		for(var counter = 0; counter < oAllowedExtensions.length; counter++)
		{
			if(sExtension.toLowerCase() == oAllowedExtensions[counter])
				bAllow = true;
		}
		if(!bAllow)
		{
			window.alert('Invalid Audio Format\nOnly '+ oAllowedExtensions.join(',').toUpperCase() +' formats are allowed');
			oAudio.focus();
			return;
		}
	}
	
	var oVideo = oForm.txtVideo;
	if(oVideo.value != "")
	{
		var oAllowedExtensions = ['mpeg', 'mpg', 'avi', 'wmv'];
		var sExtension = oVideo.value.substring(oVideo.value.lastIndexOf('.')+1);
		var bAllow = false;
		for(var counter = 0; counter < oAllowedExtensions.length; counter++)
		{
			if(sExtension.toLowerCase() == oAllowedExtensions[counter])
				bAllow = true;
		}
		if(!bAllow)
		{
			window.alert('Invalid Video Format\nOnly '+ oAllowedExtensions.join(',').toUpperCase() +' formats are allowed');
			oVideo.focus();
			return;
		}
	}
	
	var oDate = oForm.txtDate;
	if(trim(oDate.value) == '')
	{
		window.alert('Enter Date');
		oDate.focus();
		return;
	}
	
	var oPosition = oForm.sltCategory;
	var sSelectedText = oPosition.options[oPosition.selectedIndex].text.toLowerCase();
	if(oPosition.value == 'sel')
	{
		window.alert('Select Help Needed');
		oPosition.focus();
		return;
	}
	else if(sSelectedText.indexOf('other') != -1)
	{
		var oPosExplain = oForm.txtPosExplain;
		if(oPosExplain.value == '')
		{
			window.alert('Give Explaination For Help Needed');
			oPosExplain.focus();
			return;
		}
//		if(!isValidString(oPosExplain.value))
//		{
//			window.alert('Special characters such as \',\\ are not allowed in Explaination');
//			oPosExplain.focus();
//			return;
//		}
	}
	
	var oStartDate = oForm.txtStartDate;
	if(trim(oStartDate.value) == '')
	{
		window.alert('Select Start Date from Calendar\'s button');
		oStartDate.focus();
		return;
	}
	
	/////////////////////////////////////////////////////////////////////////
	var today = new Date();
	var currFullYear = parseInt(today.getFullYear(),10);
	var currMonth = parseInt(today.getMonth(),10)+1;
	var currDate = parseInt(today.getDate(),10);
	
	var dateArray = oStartDate.value.split('-');
	
	var selectedYear = parseInt(dateArray[0],10);
	var selectedMonth = parseInt(dateArray[1],10);
	var selectedDate = parseInt(dateArray[2],10);
	
	//window.alert("curr yr = "+currFullYear);
	//window.alert("curr mnth = "+currMonth);
	//window.alert("curr dt = "+currDate);
	
	//window.alert("sel yr = "+selectedYear);
	//window.alert("sel mnth = "+selectedMonth);
	//window.alert("sel dt = "+selectedDate);
	
	
	if(selectedYear >= currFullYear)
		{
			if(selectedMonth >= currMonth)
			{
				if(selectedDate >= currDate)
				{
				//	return true;
				}
				else
				{
					alert('Start date cannot be lesser than the Current date.')
					return false;
				}
			}
			else
			{
				alert('Start date cannot be lesser than the Current date.')
				return false;
			}
		}
		else
		{
			alert('Start date cannot be lesser than the Current date.')
			return false;
		}		
	//return;
	//////////////////////////////////////////////////////////////////////////
	
	
	
	
	var oFirstName = oForm.txtFirstName;
	if(trim(oFirstName.value) == '')
	{
		window.alert('Enter First Name');
		oFirstName.focus();
		return;
	}
//	if(!isValidName(oFirstName.value))
//	{
//		window.alert('Special characters and numbers are not allowed in First Name');
//		oFirstName.focus();
//		return;
//	}
	
	var oLastName = oForm.txtLastName;
	if(trim(oLastName.value) == '')
	{
		window.alert('Enter Last Name');
		oLastName.focus();
		return;
	}
//	if(!isValidName(oLastName.value))
//	{
//		window.alert('Special characters and numbers are not allowed in Last Name');
//		oLastName.focus();
//		return;
//	}
	
	var oPhone = oForm.txtPhone;
	if(trim(oPhone.value) == '')
	{
		window.alert('Enter Phone Number');
		oPhone.focus();
		return;
	}
//	if(!isValidString(oPhone.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in Phone Number');
//		oPhone.focus();
//		return;
//	}
	
	var oEmail = oForm.txtEmail;
	if(!this.EmailCheck(oEmail))
	{
		return false;
	}
	
	var oConfirmEmail = oForm.txtConfirmEmail;
	if(trim(oConfirmEmail.value) == '')
	{
		window.alert('Enter Confirm Email');
		oConfirmEmail.focus();
		return;
	}
	if(trim(oConfirmEmail.value) != trim(oEmail.value))
	{
		window.alert('Confirm Email and Email fields must be indentical');
		oConfirmEmail.focus();
		return;
	}
	
	var oUserName = oForm.txtUserName;
	if(trim(oUserName.value) == '')
	{
		window.alert('Enter User Name');
		oUserName.focus();
		return;
	}
	if(!isValidUserName(oUserName.value))
	{
		window.alert('User Name can be composed of letters(a-z,A-Z), numbers(0-9) and underscore(_) only');
		oUserName.focus();
		return;
	}
	
	var oPassword = oForm.txtPassword;
	if(trim(oPassword.value) == '' && type !='update')
	{
		window.alert('Enter Password');
		oPassword.focus();
		return;
	}
	if(oPassword.value.length > 0 && oPassword.value.length < 5 || oPassword.value.length > 8)
	{
		window.alert('Password should be 5-8 characters long');
		oPassword.focus();
		return;
	}
//	if(!isValidString(oPassword.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in Password');
//		oPassword.focus();
//		return;
//	}
	
	var oConfirmPassword = oForm.txtConfirmPassword;
	if(trim(oConfirmPassword.value) == ''  && type !='update')
	{
		window.alert('Enter Confirm Password');
		oConfirmPassword.focus();
		return;
	}
	if(oPassword.value != oConfirmPassword.value)
	{
		window.alert('Password and Confirm Password fields do not match');
		oConfirmPassword.focus();
		return;
	}
	
	var oFullTime = oForm.radFullTime;
	if(!isRadioChecked(oFullTime))
	{
		window.alert('Select one of the Full Time option');
		oFullTime[0].focus();
		return;
	}
	
	var oPartTime = oForm.radPartTime;
	if(!isRadioChecked(oPartTime))
	{
		window.alert('Select one of the Part Time option');
		oPartTime[0].focus();
		return;
	}
	
	var oLiveIn = oForm.radLiveIn;
	if(!isRadioChecked(oLiveIn))
	{
		window.alert('Select one of the Live In\'s option');
		oLiveIn[0].focus();
		return;
	}
	
	var oLiveOut = oForm.radLiveOut;
	if(!isRadioChecked(oLiveOut))
	{
		window.alert('Select one of the Live Out\'s option');
		oLiveOut[0].focus();
		return;
	}
	
	var oHours = oForm.txtHours;
	if(trim(oHours.value) == '')
	{
		window.alert('Enter Hours Needed');
		oHours.focus();
		return;
	}
	
	var oState = oForm.sltState;
	if(oState.value == 'sel')
	{
		window.alert('Select State');
		oState.focus();
		return;
	}
	
	var oCity = oForm.txtCity;
	if(trim(oCity.value) == '')
	{
		window.alert('Enter City');
		oCity.focus();
		return;
	}
//	if(!isValidString(oCity.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in City');
//		oCity.focus();
//		return;
//	}
	var oAddress = oForm.txtAddress;
	if(trim(oAddress.value) == '')
	{
		window.alert('Enter Address');
		oAddress.focus();
		return;
	}
	var oZipCode = oForm.txtZipCode;
	if(trim(oZipCode.value) == '')
	{
		window.alert('Enter Zip Code');
		oZipCode.focus();
		return;
	}
	else if(oZipCode.value.length != 5)
	{
		window.alert('Enter a valid Zip Code');
		oZipCode.focus();
		return;
	}
	if (!isInteger(oZipCode.value))
	{
	    alert("Invalid Zip Code");
	    oZipCode.focus();            
	    return;
	}
	
	var oPayType = oForm.radPayType;
	if(!isRadioChecked(oPayType))
	{
		window.alert('Select one of the Pay Type option');
		oPayType[0].focus();
		return;
	}
	
	var oAmount = oForm.txtAmount;
	if(trim(oAmount.value) == '')
	{
		window.alert('Enter Amount Willing To Pay');
		oAmount.focus();
		return;
	}
//	if(!isInteger(oAmount.value))
//	{
//		window.alert('Invalid Value of Amount Willing To Pay');
//		oAmount.focus();
//		return;
//	}

	var oSpecialNeeds = oForm.txtSpecialNeeds;
//	if(oSpecialNeeds.value != '')
//	{
//		if(!isValidString(oSpecialNeeds.value))
//		{
//			window.alert('Special characters such as \',\\ are not allowed in Special Needs');
//			oSpecialNeeds.focus();
//			return;
//		}
//	}
	var templateCheck = oForm.templateSelect;
	if(templateCheck.value != 'true' && type !='update')
	{
		window.alert('Select template');
		return;
	}
	var oTerms = oForm.chkTerms;
	if(oTerms.checked != true)
	{
		window.alert('Checked on Terms of Use Checkbox');
		oTerms.focus();
		return;
	}
	

	oForm.submit();
}

function fnbackgroundSubmit(oForm)
{ 
	var oFirstName = oForm.txtFirstName;
	if(trim(oFirstName.value) == '')
	{
		window.alert('Enter Employer First Name');
		oFirstName.focus();
		return;
	}
//	if(!isValidName(oFirstName.value))
//	{
//		window.alert('Special characters and numbers are not allowed in First Name');
//		oFirstName.focus();
//		return;
//	}
	
	var oLastName = oForm.txtLastName;
	if(trim(oLastName.value) == '')
	{
		window.alert('Enter Employer Last Name');
		oLastName.focus();
		return;
	}
	
	var oState = oForm.txtState;
	if(oState.value == 'sel')
	{
		window.alert('Select State');
		oState.focus();
		return;
	}
//	if(!isValidName(oLastName.value))
//	{
//		window.alert('Special characters and numbers are not allowed in Last Name');
//		oLastName.focus();
//		return;
//	}
	
	var oPhone = oForm.txtPhone;
	if(trim(oPhone.value) == '')
	{
		window.alert('Enter Employer Phone Number');
		oPhone.focus();
		return;
	}
	
	var oEmail = oForm.txtEmail;
	if(!this.EmailCheck(oEmail))
	{
		return false;
	}
	
	var oFirstName = oForm.txteFirstName;
	if(trim(oFirstName.value) == '')
	{
		window.alert('Enter Employee First Name');
		oFirstName.focus();
		return;
	}
//	if(!isValidName(oFirstName.value))
//	{
//		window.alert('Special characters and numbers are not allowed in First Name');
//		oFirstName.focus();
//		return;
//	}
	
	var oLastName = oForm.txteLastName;
	if(trim(oLastName.value) == '')
	{
		window.alert('Enter Employee Last Name');
		oLastName.focus();
		return;
	}
	
	var oSSN = oForm.txteSSN;
	if(trim(oSSN.value) == '')
	{
		window.alert('Enter Employee SSN Number');
		oSSN.focus();
		return;
	}
	
	var oStartDate = oForm.txtBirthDate;
	if(trim(oStartDate.value) == '')
	{
		window.alert('Select Birth Date from Calendar\'s button');
		oStartDate.focus();
		return;
	}
	
		var oAddress = oForm.txteAddress;
	if(trim(oAddress.value) == '')
	{
		window.alert('Enter Employee Address');
		oAddress.focus();
		return;
	}
	
	var oState = oForm.txteState;
	if(oState.value == 'sel')
	{
		window.alert('Select State');
		oState.focus();
		return;
	}
	
	
	var oCity = oForm.txteCity;
	if(trim(oCity.value) == '')
	{
		window.alert('Enter City');
		oCity.focus();
		return;
	}
//	if(!isValidString(oCity.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in City');
//		oCity.focus();
//		return;
//	}
	
	var oZipCode = oForm.txteZip;
	if(trim(oZipCode.value) == '')
	{
		window.alert('Enter Zip Code');
		oZipCode.focus();
		return;
	}
	else if(oZipCode.value.length != 5)
	{
		window.alert('Enter a valid Zip Code');
		oZipCode.focus();
		return;
	}
	if (!isInteger(oZipCode.value))
	{
	    alert("Invalid Zip Code");
	    oZipCode.focus();            
	    return;
	}
	var oLicense = oForm.txtLicense;
	if(trim(oLicense.value) == '')
	{
		window.alert('Enter License');
		oLicense.focus();
		return;
	}
	var chkbox = document.getElementById('chkTerms');
	if(chkbox.checked != true)
	{
			alert("Checked on Terms of Use Checkbox");
			chkbox.focus();
			return;
	}
	//////////////////////////////////////////////////////////////////////////////////
	
	oForm.submit();
}

function isRadioChecked(oRadioCollection)
{
	for(var counter = 0; counter < oRadioCollection.length; counter++)
	{
		if(oRadioCollection[counter].checked == true)
			return true;
	}
	return false;
}

function RegistrationSubmit()
{
	var first,last,pass,conf,user,email;
	first = MWJ_findObj('firstName');
	if(trim(first.value) == '')
	{
		window.alert('Enter First Name');
		first.focus();
		return;
	}
	if(!isValidName(first.value))
	{
		window.alert('Special characters and numbers are not allowed in First Name');
		first.focus();
		return;
	}
	last = MWJ_findObj('lastName');
	if(trim(last.value) == '')
	{
		window.alert('Enter Last Name');
		last.focus();
		return;
	}
	if(!isValidName(last.value))
	{
		window.alert('Special characters and numbers are not allowed in Last Name');
		last.focus();
		return;
	}
	var addr1 = MWJ_findObj('address1');
	if(trim(addr1.value) == '')
	{
		window.alert('Enter Billing Address Line1');
		addr1.focus();
		return;
	}
//	if(!isValidString(addr1.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in first line of Address');
//		addr1.focus();
//		return;
//	}
//	addr1 = MWJ_findObj('address2');
//	if(!isValidString(addr1.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in second line of Address');
//		addr1.focus();
//		return;
//	}
	var city = MWJ_findObj('city');
	if(trim(city.value) == '')
	{
		window.alert('Enter City');
		city.focus();
		return;
	}
	if ( !isValidString( city.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " ))
	{
        alert('Special characters such as \',\\ are not allowed in City');
        city.focus();
		return;
 	}
	var state = MWJ_findObj('state');
	if(state.value == 'sel')
	{
		window.alert('Select State');
		state.focus();
		return;
	}
	var zip = MWJ_findObj('zipCode');
	if(trim(zip.value) == '')
	{
		window.alert('Enter Zip Code');
		zip.focus();
		return;
	}
	else if(zip.value.length != 5)
	{
		window.alert('Enter a valid Zip Code');
		zip.focus();
		return;
	}
	
	if (!isInteger(zip.value))
	{
      alert("Invalid Zip Code");
      zip.focus();            
      return;
	}

	var country = MWJ_findObj('country');
	if(country.value == 'sel')
	{
		window.alert('Select Country');
		country.focus();
		return;
	}
	var phone = MWJ_findObj('phone');
	if(trim(phone.value) == '')
	{
		window.alert('Enter Phone');
		phone.focus();
		return;
	}
	if(!isValidString(phone.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in Phone');
		phone.focus();
		return;
	}
	email = MWJ_findObj('email');
	if(!this.EmailCheck(email)){
		return false;
	}
	
	user = MWJ_findObj('userid');
	if(trim(user.value) == '')
	{
		window.alert('Enter User ID');
		user.focus();
		return;
	}
	if(!isValidUserName(user.value))
	{
		window.alert('User ID can be composed of letters(a-z,A-Z), numbers(0-9) and underscore(_) only');
		user.focus();
		return;
	}
	pass = MWJ_findObj('pass');
	conf = MWJ_findObj('confirm');
	if(trim(pass.value)=='' || pass.value.length < 5 || pass.value.length > 8)
	{
		window.alert('Password should be 5-8 characters long');
		pass.focus();
		return;
	}
	if(!isValidString(pass.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in Password');
		pass.focus();
		return;
	}
	if(pass.value != conf.value)
	{
		window.alert('Password and Confirm Password fields do not match');
		pass.focus();
		return;
	}
	state.disabled = false;


	var cfirst = MWJ_findObj('cfirstName');
	var clast = MWJ_findObj('clastName');
	var ctype = MWJ_findObj('cardtype');
	var cnumber = MWJ_findObj('cardnumber');
	var cmonth = MWJ_findObj('expmonth');
	var cyear = MWJ_findObj('expyear');
	var cverification = MWJ_findObj('verification');

	
	if(cfirst.value == '')
	{
		window.alert("Enter Credit Card Holder's First Name");
		cfirst.focus();
		return;
	}
	
	if(cfirst.value!='')
	{
		if(!isValidName(cfirst.value))
		{
		window.alert('Special characters and numbers are not allowed in First Name');
		cfirst.focus();
		return;
		}
		if ( !isValidString( cfirst.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ))
		{
            alert("Credit Card Holder's First Name can only contain Alphabets");
            cfirst.focus();            
            return;
		}
		
		if(clast.value == '')
		{
			window.alert("Enter Credit Card Holder's Last Name");
			clast.focus();
			return;
		}
		if(!isValidName(clast.value))
		{
		window.alert('Special characters and numbers are not allowed in Last Name');
		clast.focus();
		return;
		}
		if ( !isValidString( clast.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ))
		{
		      
	           alert("Credit Card Holder's Last Name can only contain Alphabets");
	           clast.focus();            
	           return;
		}
	
		if(ctype.value == 'sel')
		{
			window.alert('Select Credit Card Type');
			ctype.focus();
			return;
		}
		if(cnumber.value == '')
		{
			window.alert('Enter Credit Card Number');
			cnumber.focus();
			return;
		}
		else if(ctype.value == '3')
		{
			//if(cnumber.value.length !=15 || isInteger(cnumber.value) == false)
			if(cnumber.value.length !=15)
			{
				window.alert("Invalid value in credit card number.\nRemove {A-Z or a-z or Special Character like \"/\-+\'}\nAmerican Express Accept 15 digits credit card number.");
				cnumber.focus();
				return;
			}
		}
		else if(ctype.value != '3')
		{
			//if(cnumber.value.length != 16 || isInteger(cnumber.value) == false)
			if(cnumber.value.length != 16)
			{
				window.alert("Invalid value in credit card number.\nRemove {A-Z or a-z or Special Character like \"/\-+\'}\nAll credit card brand accept 16 digits credit card number excluding \"American Express\".");
				cnumber.focus();
				return;
			}
		}
		
		if(cmonth.value == 0)
		{
			window.alert('Select Expiry Month');
			cnumber.focus();
			return;
		}
		if(cyear.value ==0)
		{
			window.alert('Select Expiry Year');
			cnumber.focus();
			return;
		}
//		CurrentDate=new Date();
//		if(cyear.value==CurrentDate.getYear() && cmonth.value<CurrentDate.getMonth())
//		{
//			window.alert('Select Correct Month');
//			cmonth.focus();
//			return;
//		}

		if(cverification.value == '')
		{
			window.alert('Enter Credit Card Verification Number');
			cverification.focus();
			return;
		}
		else if(ctype.value == '3')
		{
			if(cverification.value.length != 4 || isInteger(cverification.value) == false)
			{
				window.alert('Enter a valid Credit Card Verification Number');
				cverification.focus();
				return;
			}
		}
		else if(ctype.value != '3')
		{
			if(cverification.value.length != 3 || isInteger(cverification.value) == false)
			{
				window.alert('Enter a valid Credit Card Verification Number');
				cverification.focus();
				return;
			}
		}
	}	
	document.forms['frmRegistration'].submit();
}

function isInteger(str)
{
	var a=0;
	while(a<str.length)
	{
		if( str.charAt(a)< '0' || str.charAt(a) > '9' )
			return false;
		a++;
	}
	return true;
}

function CreditCardSubmit()
{
	var button = MWJ_findObj('editsave');
	var type,number,verification;
	var first = MWJ_findObj('firstName');
	var last = MWJ_findObj('lastName');
	var type = MWJ_findObj('cardtype');
	var number = MWJ_findObj('cardnumber');
	var verification = MWJ_findObj('verification');
	var month = MWJ_findObj('expmonth');
	var year = MWJ_findObj('expyear');
	//alert(button.value);
	if(button.value == 'Edit')
	{
		button.value = 'Save';
		button = MWJ_findObj('continuereset');
		button.value = 'Reset';
		first.disabled = last.disabled = type.disabled = number.disabled = verification.disabled = month.disabled = year.disabled = false;
		return;
	}
	//window.alert('Register');
	if(trim(first.value) == '')
	{
		window.alert('Enter First Name');
		first.focus();
		return;
	}
	if(!isValidString(first.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in First Name');
		first.focus();
		return;
	}
	if(trim(last.value) == '')
	{
		window.alert('Enter Last Name');
		last.focus();
		return;
	}
	if(!isValidString(last.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in Last Name');
		last.focus();
		return;
	}
	if(type.value == 'sel')
	{
		window.alert('Select Credit Card Type');
		type.focus();
		return;
	}
	if(trim(number.value) == '')
	{
		window.alert('Enter Credit Card Number');
		number.focus();
		return;
	}
	// ::::: Credit Card Type :::::
	// 1) Master Card
	// 2) Visa Card
	// 3) American Express
	// 4) Discover
	else if(type.value == '3')
	{
		if(number.value.length != 15 || isInteger(number.value) == false)
		{
			window.alert("Invalid value in credit card number.\nRemove {A-Z or a-z or Special Character like \" / \ - + \'}\nAmerican Express Accept 15 digits credit card number.");
			number.focus();
			return;
		}
	}
	else if(type.value != '3')
	{
		if(number.value.length != 16 || isInteger(number.value) == false)
		{
			window.alert("Invalid value in credit card number.\nRemove {A-Z or a-z or Special Character like \"/\-+\'}\nAll credit card brand accept 16 digits credit card number excluding \"American Express\".");
			number.focus();
			return;
		}
	}

	if(month.value == 0)
	{
		window.alert('Select Expiry Month');
		month.focus();
		return;
	}
	if(year.value ==0)
	{
		window.alert('Select Expiry Year');
		year.focus();
		return;
	}
//	CurrentDate=new Date();
//	if(year.value==CurrentDate.getYear() && month.value<CurrentDate.getMonth())
//	{
//		window.alert('Select Correct Month');
//		month.focus();
//		return;
//	}	
	if(trim(verification.value) == '')
	{
		window.alert('Enter Credit Card Verification Number');
		verification.focus();
		return;
	}
	else if(type.value == '3')
	{
		if(verification.value.length != 4 || isInteger(verification.value) == false)
		{
			window.alert('Enter a valid Credit Card Verification Number');
			verification.focus();
			return;
		}
	}
	else if(type.value != '3')
	{
		if(verification.value.length != 3 || isInteger(verification.value) == false)
		{
			window.alert('Enter a valid Credit Card Verification Number');
			verification.focus();
			return;
		}
	}

	document.forms['frmCreditCardInformation'].submit();
}

function ShippingAddressSubmit()
{
	var first,last,same;
	same = MWJ_findObj('issame');
	if(same.checked)
	{
		document.forms['frmShippingAddress'].submit();
		return;
	}
	first = MWJ_findObj('firstName');
	if(first.value == '')
	{
		window.alert('Enter First Name');
		first.focus();
		return;
	}
	if(!isValidString(first.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in First Name');
		first.focus();
		return;
	}
	last = MWJ_findObj('lastName');
	if(last.value == '')
	{
		window.alert('Enter Last Name');
		last.focus();
		return;
	}
	if(!isValidString(last.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in Last Name');
		last.focus();
		return;
	}
	var addr1 = MWJ_findObj('address1');
	if(addr1.value == '')
	{
		window.alert('Enter first line of Address');
		addr1.focus();
		return;
	}
//	if(!isValidString(addr1.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in first line of Address');
//		addr1.focus();
//		return;
//	}
//	var addr1 = MWJ_findObj('address2');
//	if(!isValidString(addr1.value))
//	{
//		window.alert('Special characters such as \',\\ are not allowed in second line of Address');
//		addr1.focus();
//		return;
//	}
	var city = MWJ_findObj('city');
	if(city.value == '')
	{
		window.alert('Enter City');
		city.focus();
		return;
	}
	if(!isValidString(city.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in City');
		city.focus();
		return;
	}
	var state = MWJ_findObj('state');
	if(state.value == 'sel')
	{
		window.alert('Select State');
		state.focus();
		return;
	}
	var zip = MWJ_findObj('zipCode');
	if(zip.value == '')
	{
		window.alert('Enter Zip Code');
		zip.focus();
		return;
	}
	else if(zip.value.length != 5)
	{
		window.alert('Enter a valid Zip Code');
		zip.focus();
		return;
	}
	
	 if(isInteger(zip.value) == false)
	{
      alert("Invalid Zip Code");
      zip.focus();            
      return;
	}
	
	var country = MWJ_findObj('country');
	if(country.value == 'sel')
	{
		window.alert('Select Country');
		country.focus();
		return;
	}
	var phone = MWJ_findObj('phone');
	if(phone.value == '')
	{
		window.alert('Enter Phone');
		phone.focus();
		return;
	}
	if(!isValidString(phone.value))
	{
		window.alert('Special characters such as \',\\ are not allowed in Phone');
		phone.focus();
		return;
	}
	document.forms['frmShippingAddress'].submit();
}


function ResetCreditCard()
{
	var button = MWJ_findObj('continuereset');
	if(button.value == 'Continue')
	{
		var type,number,verification;
		var first = MWJ_findObj('firstName');
		var last = MWJ_findObj('lastName');
		type = MWJ_findObj('cardtype');
		number = MWJ_findObj('cardnumber');
		verification = MWJ_findObj('verification');
		var month = MWJ_findObj('expmonth');
		var year = MWJ_findObj('expyear');
		first.disabled = last.disabled = type.disabled = number.disabled = verification.disabled = month.disabled = year.disabled = false;
		document.forms['frmCreditCardInformation'].submit();
		return;
	}
	else
		document.forms['frmCreditCardInformation'].reset();
}

function ShipAddress()
{
	var same = MWJ_findObj('issame');
	var first,last,addr1,addr2,city,state,country,zip,phone;
	first = MWJ_findObj('firstName');
	last = MWJ_findObj('lastName');
	addr1 = MWJ_findObj('address1');
	addr2 = MWJ_findObj('address2');
	city = MWJ_findObj('city');
	zip = MWJ_findObj('zipCode');
	country = MWJ_findObj('country');
	phone = MWJ_findObj('phone');
	state = MWJ_findObj('state');
	if(same.checked && first.disabled == false)
	{
		//window.alert('test');
		first.disabled = true;
		ResetShippingForm();
		first.disabled = last.disabled = addr1.disabled = addr2.disabled = city.disabled = zip.disabled = country.disabled = phone.disabled = state.disabled = true;
	}
	else
	{	//window.alert('test2');
		first.value = last.value = addr1.value = addr2.value = city.value = zip.value = phone.value = '';
		country.value = state.value = 'sel';
		first.disabled = last.disabled = addr1.disabled = addr2.disabled = city.disabled = zip.disabled = country.disabled = phone.disabled = state.disabled = false;	
	}
}

function ResetShipForm(objCheckbox, sValue)
{
	var same = MWJ_findObj('issame');
	var first,last,addr1,addr2,city,state,country,zip,phone;
	
	first = MWJ_findObj('firstName');
	last = MWJ_findObj('lastName');
	addr1 = MWJ_findObj('address1');
	addr2 = MWJ_findObj('address2');
	city = MWJ_findObj('city');
	zip = MWJ_findObj('zipCode');
	country = MWJ_findObj('country');
	phone = MWJ_findObj('phone');
	state = MWJ_findObj('state');
	
	if(objCheckbox.checked == true  && first.disabled == false)
	{
		first.disabled = true;
		window.document.frmShippingAddress.reset();
		window.document.frmShippingAddress.state.value = sValue;
		first.disabled = last.disabled = addr1.disabled = addr2.disabled = city.disabled = zip.disabled = country.disabled = phone.disabled = state.disabled = true;
	}
	else
	{
		ShipAddress();
	}
}

var dfirst,dlast,daddr1,daddr2,dcity,dstate,dcountry,dzip,dphone;
	
function ResetShippingForm(sValue)
{
//    alert(sValue);
//	var first,last,addr1,addr2,city,state,country,zip,phone;
//	first = MWJ_findObj('firstName');
//	last = MWJ_findObj('lastName');
//	addr1 = MWJ_findObj('address1');
//	addr2 = MWJ_findObj('address2');
//	city = MWJ_findObj('city');
//	zip = MWJ_findObj('zipCode');
//	country = MWJ_findObj('country');
//	phone = MWJ_findObj('phone');
//	state = MWJ_findObj('state');
//	first.value = dfirst;
//	last.value = dlast;
//	addr1.value = daddr1;
//	addr2.value = daddr2;
//	city.value = dcity;
//	zip.value = dzip;
//	country.value = dcountry;
//	phone.value = dphone;
//	state.value = dstate ;
//	CountrySelect();

	window.document.frmShippingAddress.reset();
	window.document.frmShippingAddress.state.value = sValue;
}

function SaveShippingValues()
{
	var first,last,addr1,addr2,city,state,country,zip,phone;
	first = MWJ_findObj('firstName');
	last = MWJ_findObj('lastName');
	addr1 = MWJ_findObj('address1');
	addr2 = MWJ_findObj('address2');
	city = MWJ_findObj('city');
	zip = MWJ_findObj('zipCode');
	country = MWJ_findObj('country');
	phone = MWJ_findObj('phone');
	state = MWJ_findObj('state');
	dfirst = first.value;
	dlast = last.value;
	daddr1 = addr1.value;
	daddr2 = addr2.value;
	dcity = city.value;
	dzip = zip.value;
	dcountry = country.value;
	dphone = phone.value;
	dstate = state.value;
	//window.alert(dfirst);
}

function CountrySelect()
{
	var country,state;
	country = MWJ_findObj('country');
	state = MWJ_findObj('state');
	if(country.value == '1' || country.value == 'sel')
	{
		state.disabled = false;
		if(country.value == '1')
			state.value = 'sel';
	}
	else
	{
		state.value = '66';
		state.disabled = true;		
	}
//	window.alert(state);
}

function trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

/**
* Created 14th Deceber
* by Abddul Samad
* Check Email address 
* @return boolean
**/

function EmailCheck(email){
		
		if(email.value==''){
			alert("Enter Email Address");
            email.focus();            
            return false;
		}
		if ( !this.isCharsInBag( email.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._@-" ))
		{
		      
            alert("Invalid Email Address");
            email.focus();            
            return false;
		}
	
	if(email.value != '')
	   {
		var str=email.value;	
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var sdot=str.indexOf(dot,ldot+1);

		if (str.indexOf(at)==-1){
			alert("Invalid Email Address");
            email.focus();            
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		if (str.substring(ldot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if (str.substring(sdot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
	}//end of else
	return true;
}


/*
* @return Number
*/

function isCharsInBag (s, bag)
{
    var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return(false);
    }
    return true;
}




/**
* @return 
*/
  