function MarriStatChange()
{
	if(frmeCRMagic.cboMariStat.value==1)
	  {
	   frmeCRMagic.cboMarriDateYear.disabled=false; 
	   frmeCRMagic.cboMarriDateMont.disabled=false; 
	   frmeCRMagic.cboMarriDateDay.disabled=false;
 	   frmeCRMagic.txtSpouName.disabled=false;	
	  }
	else
	  {
	   frmeCRMagic.cboMarriDateYear.disabled=true; 
	   frmeCRMagic.cboMarriDateMont.disabled=true; 
	   frmeCRMagic.cboMarriDateDay.disabled=true; 
	   frmeCRMagic.txtSpouName.disabled=true;
	   frmeCRMagic.txtSpouName.value="";
	  }  	

}

function ValidateFormData(RegisForm)
{ 
	var strRetVal
	var difference;
	//alert(RegisForm.cboMariStat.value);
	//Validation for Loginame
	strRetVal=CheckLoginName(RegisForm.txtLogiName,"Login Name")
		if (strRetVal !="")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtLogiName);
				return false;
			}
		
	//Validation for Password 
		strRetVal=CheckPassWord(RegisForm.txtPassword,"Password")
		if (strRetVal !="")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtPassword);
				return false;
			}
	//Validation for Re enter Password 
		if (RegisForm.txtPassword.value!=RegisForm.txtReEnPass.value)  
			{
				alert("Password and Re entered Password should be same.");
				SetFocus(RegisForm.txtReEnPass);
				return false;				
			}
	//validation Hint Question 
		strRetVal=CheckAlphabets(RegisForm.txtHintQues,"Hint Question")  
		if (strRetVal !="")
		{
			alert(strRetVal);
			SetFocus(RegisForm.txtHintQues);
			return false;				
		}
	//Hint Answer
	if (IsEmpty(RegisForm.txtHintAnsw.value )==true)
		{
			alert("Hint Answer can not be blank.");
			SetFocus(RegisForm.txtHintAnsw);
			return false;
		}
	//validation for first name 
		strRetVal=CheckAlphabets(RegisForm.txtFirsName ,"First Name")  
		if (strRetVal !="")
		{
			alert(strRetVal);
			SetFocus(RegisForm.txtFirsName);
			return false;
		}
	
	//validation for Last name 
		strRetVal=CheckAlphabets(RegisForm.txtLastName ,"Last Name")  
		if (strRetVal !="")
		{
			alert(strRetVal);
			SetFocus(RegisForm.txtLastName);
			return false;
		}
	
		//Check for date of Birth
		strRetVal = checkDate(RegisForm.cboBirtDateDay.value, RegisForm.cboBirtDateMonth.value, RegisForm.cboBirtDateYear.value)
		if (strRetVal != "")
		{
			alert(strRetVal);
			SetFocus(RegisForm.cboBirtDateDay);
			return false;
		}

		//validate for email Address function 
		strRetVal=CheckEmailAddress(RegisForm.txtEmail ,"Email Address")  
		if (strRetVal !="")
		{
			alert(strRetVal);
			SetFocus(RegisForm.txtEmail);
			return false;
		}

		//Check Mobile Number
		if (IsAllSpace(RegisForm.txtMobile.value) == false)	//if some value is entered
		{
			//strRetVal = CheckAlphabetsNumeric(RegisForm.txtMobile, "Mobile Number");
			strRetVal = CheckNumericValue(RegisForm.txtMobile  , "Mobile Number")
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtMobile);
				return false;
			}
			var strMobile = RegisForm.txtMobile.value			
			if (strMobile.length < 10 )
			{
				alert("Enter Proper Mobile Number.\nPlease Re-Enter Your Data.")
				SetFocus(RegisForm.txtMobile);
				return false;			
			}
		}
		else
		{
			alert("Mobile cannot be blank.\nPlease Re-Enter Your Data.")
			SetFocus(RegisForm.txtMobile);
			return false;
		}
				
		//Check City -CheckAlphabetsNumeric
		strRetVal = CheckAlphabets(RegisForm.txtCity , "City", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
		if (strRetVal != "")
		{
			alert(strRetVal);
			SetFocus(RegisForm.txtCity);
			return false;
		}
		
		//for address Line 1
		if (IsAllSpace(RegisForm.txtAddr1.value) == false)	//if some value is entered
		{		
			strRetVal = CheckAlphabetsNumeric(RegisForm.txtAddr1, "Address Line 1", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtAddr1);
				return false;
			}
		}
		
		//Address Line 2
		if (IsAllSpace(RegisForm.txtAddr2.value) == false)	//if some value is entered
		{
			strRetVal = CheckAlphabetsNumeric(RegisForm.txtAddr2, "Address Line 2", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtAddr2);
				return false;
			}
		}
		
		//Address Line 3
		if (IsAllSpace(RegisForm.txtAddr3.value) == false)	//if some value is entered
		{
			strRetVal = CheckAlphabetsNumeric(RegisForm.txtAddr3, "Address Line 3", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtAddr3);
				return false;
			}
		}

		//Address Line 4
		if (IsAllSpace(RegisForm.txtAddr4.value) == false)	//if some value is entered
		{
			strRetVal = CheckAlphabetsNumeric(RegisForm.txtAddr4, "Address Line 4", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtAddr4);
				return false;
			}
		}

		
		//Check Pincode
		if ((RegisForm.cboCountry.value == 98) && (RegisForm.txtPincode.value != ""))
		{
			if (RegisForm.txtPincode.value.length <6)  
			{
				alert("Pincode should be a 6 digit number.");
				SetFocus(RegisForm.txtPincode);
				return false;		
			}
		}
		//Check State
		if ((RegisForm.cboState.value == 0) && (Trim(RegisForm.txtOtheStat.value) == ""))
		{
			alert("State should not be empty.");
			SetFocus(RegisForm.txtOtheStat);
			return false;
		}
				
		// Check Office Telephone Number
		if (IsAllSpace(RegisForm.txtOffTelephone.value) == false)	//if some value is entered
		{
			//strRetVal = CheckAlphabetsNumeric(RegisForm.txtOffTelephone, "Office Telephone Number", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			strRetVal = CheckNumericValue(RegisForm.txtOffTelephone  , "Office Telephone Number")
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtOffTelephone);
				return false;
			}
		}
		
		// Check Residence Telephone Number
		if (IsAllSpace(RegisForm.txtResiTelephone.value) == false)	//if some value is entered
		{
			//strRetVal = CheckAlphabetsNumeric(RegisForm.txtResiTelephone, "Residence Telephone Number", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			strRetVal = CheckNumericValue(RegisForm.txtResiTelephone  , "Residence Telephone Number")
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtResiTelephone);
				return false;
			}
		}
		
				
		// Check Fax Number
		if (IsAllSpace(RegisForm.txtFax.value) == false)	//if some value is entered
		{
			//strRetVal = CheckAlphabetsNumeric(RegisForm.txtFax, "Fax number", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			strRetVal = CheckNumericValue(RegisForm.txtFax  , "Fax Number")
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtFax);
				return false;
			}
		}

		// Check Anuual Income
		if (IsAllSpace(RegisForm.txtAnnuInco.value) == false)	//if some value is entered
		{
			strRetVal =CheckNumber(RegisForm.txtAnnuInco, "Annual Income", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
			if (strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtAnnuInco);
				return false;
			}
		}
		
		
		//Check for Marriage stat
		if(RegisForm.cboMariStat.value==1)
		{
			strRetVal = checkDate(RegisForm.cboMarriDateDay.value, 	RegisForm.cboMarriDateMont.value, RegisForm.cboMarriDateYear.value)
			
			if (strRetVal != "null" && strRetVal != "")
			{
				alert(strRetVal);
				SetFocus(RegisForm.cboMarriDateDay);
				return false;
			}
			
			//Compare Birth Date & Marriage Date
			dtBigDate = RegisForm.cboMarriDateDay.value + "-" + RegisForm.cboMarriDateMont.value + "-" + RegisForm.cboMarriDateYear.value
			dtSmallDate = RegisForm.cboBirtDateDay.value + "-" +  RegisForm.cboBirtDateMonth.value + "-" + RegisForm.cboBirtDateYear.value
			difference = DateDiff(dtBigDate,dtSmallDate,"d")
			if(difference == "Expired")
			{
				alert("Marriage date should be greater then Birth date");
				SetFocus(RegisForm.cboMarriDateDay);
				return false;
			}
			
			//validation for Spouce's name 
			
			if (IsAllSpace(RegisForm.txtSpouName.value) == false)	//if some value is entered
			{		
				strRetVal = CheckAlphabetsNumeric(RegisForm.txtSpouName, "Spouce's Name", " ", "_", ".", "-", "/", "'", ",", "(", ")", "[", "]");
				if (strRetVal != "")
				{
					alert(strRetVal);
					SetFocus(RegisForm.txtSpouName);
					return false;
				}
			}			
			
/*			strRetVal=CheckAlphabets(RegisForm.txtSpouName ,"Spouce's Name")  
			if (strRetVal !="")
			{
				alert(strRetVal);
				SetFocus(RegisForm.txtSpouName);
				return false;
			}*/

		}
			
	//If everything is fine then...
	return true;	
}//function


function Save(RegisForm, strPageType)
{	
	  if(ValidateFormData(RegisForm)== false)
		{
			return false;
		}
//	 if(strPageType=='New')
//		{
//		var strSQLQuery = "SELECT LogiName FROM " + gstrUserDBConst  + "UCUserMast WHERE LogiName='" + RegisForm.txtLogiName.value.toLowerCase() + "'";
//		var rstTemp = GetRecordset(strSQLQuery);
//		if (rstTemp.recordCount > 0)
//		{
//			alert(RegisForm.txtLogiName.value + " is already exist. \nPlease try Some other Login Name.")
//			RegisForm.txtLogiName.select();
//			RegisForm.txtPassword.value="";
//			RegisForm.txtReEnPass.value="" ;
//			SetFocus(RegisForm.txtLogiName);
//			return false;
//		}
//		}//if new

		RegisForm.action="/content/user_registration/save_registration.asp" ;
		RegisForm.submit() ; 
		return true;
}//function
function CheckAvailability(RegisForm, strPageType)
{
		if (navigator.appName == "Netscape")
		{
			//alert ("Please use Internet Explorer to use this functionality")
			//return false;			
			var strLoginName = RegisForm.txtLogiName.value
			if(RegisForm.txtLogiName.value =="" || strLoginName.length < "4" )
				{
				//alert("Please Enter Login Name");
				alert("The Login Name field is either empty or less than 4 chars. \nPlease re-enter your Login Name.")			
				RegisForm.txtLogiName.focus();
				return false;
				}			
				RegisForm.action="/ecrmagicincludes/content/user_registration/Check_Regi_User.asp" ;
				RegisForm.submit() ; 			
				return true;
			
		}
		var strLoginName = RegisForm.txtLogiName.value
		if(RegisForm.txtLogiName.value =="" || strLoginName.length < "4" )
			{
			//alert("Please Enter Login Name");
			alert("The Login Name field is either empty or less than 4 chars. \nPlease re-enter your Login Name.")			
			RegisForm.txtLogiName.focus();
			return false;
			}
		//var strLoginName = RegisForm.txtLogiName.value
		//alert(strLoginName.length);
		
		if(strPageType=='New')
		{
			var strSQLQuery = "SELECT LogiName FROM " + gstrUserDBConst  + "UCUserMast WHERE LogiName='" + RegisForm.txtLogiName.value.toLowerCase() + "'";
			var rstTemp = GetRecordset(strSQLQuery);
		if (rstTemp.recordCount > 0)
			{
				//alert(RegisForm.txtLogiName.value + " is already exist. \nPlease try Some other Login Name.");
				alert("Login Name '"+RegisForm.txtLogiName.value+"' already taken by some other user,Please try something else.");
				RegisForm.txtLogiName.focus();
				return false;
			}
		else 
			
				//alert(RegisForm.txtLogiName.value + " is available");
				alert("Login Name '"+RegisForm.txtLogiName.value+"' does not exist. You can use the same.");
				RegisForm.txtPassword.focus();
				return true;
			
		}
}

