// JavaScript Document

function showdiv(a)
{
	for(i=1;i<=2;i++)
	{
		if(i==a)
		{
			document.getElementById('td' + i +'').className = "menubac1";
			document.getElementById('div' + i +'').style.display="block";
		}
		else
		{
			document.getElementById('td' + i +'').className = "menubac";
			document.getElementById('div' + i +'').style.display="none";
		}			

	}	
}

function showmsdiv(a)
{
	for(i=1;i<=4;i++)
	{
		if(i==a)
		{
			document.getElementById("div" + i).style.display="block";
			document.getElementById('tab' + i + '').src="images_ms/tab" + i + "_O.gif";
		}
		else
		{
			document.getElementById("div" + i).style.display="none";
			document.getElementById('tab' + i + '').src="images_ms/tab" + i + ".gif";
		}
	}
}

function showdivnew(a)
{
	for(i=1;i<=2;i++)
	{
		if(i==a)
		{
			document.getElementById('img' + i +'').src = "images_8Jun/menu"+ i +"_over.gif";
			document.getElementById('div' + i +'').style.display="block";
		}
		else
		{
			document.getElementById('img' + i +'').src = "images_8Jun/menu"+ i +".gif";
			document.getElementById('div' + i +'').style.display="none";
		}

	}	
}

function disable_income()
{
	if(document.form1.occupation[0].checked==true)
	{
		document.form1.income.disabled=true;
		document.form1.annualitr.disabled=false;
	}
	if(document.form1.occupation[1].checked==true)
	{
		document.form1.annualitr.disabled=true;
		document.form1.income.disabled=false;
	}
}

function formcheck()
{
	var MobileNo = document.form1.mobile.value;
	
	if	(document.form1.fname.value==" Full Name" || isWhitespace(document.form1.fname.value) || isEmpty(document.form1.fname.value))
		{
			alert("Please enter your full name");
			document.form1.fname.select();
			return false;
		}
	else if (document.form1.age.selectedIndex==0)
		{
			alert("Please select your age");
			document.form1.age.focus();
			return false;
		}
	else if (document.form1.contactno.value==" Resi/Office No." || isWhitespace(document.form1.contactno.value) || isEmpty(document.form1.contactno.value))
		{
			alert("Please enter your Resi/Office Number");
			document.form1.contactno.select();
			return false;
		}
	else if (isNaN(document.form1.contactno.value))
		{
			alert("Please enter numbers only");
			document.form1.contactno.select();
			return false;
		}
	else if (document.form1.mobile.value==" Mobile No." || isWhitespace(document.form1.mobile.value) || isEmpty(document.form1.mobile.value) || document.form1.mobile.value.length!=10)
		{
			alert("Please Enter Atleast 10 Digit for Mobile Number");
			document.form1.mobile.select();
			return false;
		}
	else if (isNaN(document.form1.mobile.value))
		{
			alert("Please Enter Valid Mobile Number");
			document.form1.mobile.select();
			return false;
		}
	else if(document.form1.mobile.value.substr(0,1)!=9)
		{
			alert("Please Enter a Valid Mobile Number \n(Do not enter 0 or +91)");
			document.form1.mobile.select();
			return false;
		}
	else if(document.form1.mobile.value.length !=10)
		{
			alert("Please Enter a Valid Mobile Number \n(Do not enter 0 or +91)");
			document.form1.mobile.select();
			return false;
		}
	else if((MobileNo == 0000000000) || (MobileNo == 9999999999) || (MobileNo == 9999999998) || (MobileNo == 9999999997) || (MobileNo == 9999999996) || (MobileNo == 9999999995) || (MobileNo == 9999999994) || (MobileNo == 9999999993) || (MobileNo == 9999999992) || (MobileNo == 9999999991) || (MobileNo == 9999999990))
		{
			alert("Please Enter Valid Mobile Number");
			document.form1.mobile.select();
			return false;
		}
	else if (document.form1.emailid.value==" Email ID" || isWhitespace(document.form1.emailid.value) || isEmpty(document.form1.emailid.value))
		{
			alert("Please Enter Your Email Address");
			document.form1.emailid.select();
			return false;
		}
	else if (isEmail(document.form1.emailid.value) != true)
		{
			alert("Please Enter Your Valid Email Address");
			document.form1.emailid.select();
			return false;
		}
	else if (document.form1.city.selectedIndex==0)
		{
			alert("Please select your city");
			document.form1.city.focus();
			return false;
		}
	else if((document.form1.occupation[0].checked==false) && (document.form1.occupation[1].checked==false))
		{
			alert("Please select your occupation");
			document.form1.occupation[0].focus();
			return false;
		}
	else if (document.form1.occupation[0].checked==true && document.form1.annualitr.selectedIndex==0)
		{
			alert("Please select your average 2 yr ITR");
			document.form1.annualitr.focus();
			return false;
		}
	else if (document.form1.occupation[1].checked==true && document.form1.income.selectedIndex==0)
		{
			alert("Please select your yearly income");
			document.form1.income.focus();
			return false;
		}	
	else if (document.form1.loanamt.selectedIndex==0)
		{
			alert("Please select loan amount");
			document.form1.loanamt.focus();
			return false;
		}
	else if (document.form1.propertytype.selectedIndex==0)
		{
			alert("Please select type of property");
			document.form1.propertytype.focus();
			return false;
		}
	else if (document.form1.propertymarketvalue.selectedIndex==0)
		{
			alert("Please select market value of property");
			document.form1.propertymarketvalue.focus();
			return false;
		}	
	
	return true;	
}

function formcheck1()
{
	if	(isWhitespace(document.form1.VerificationCode.value) || isEmpty(document.form1.VerificationCode.value))
		{
			alert("Please Enter Verification Code");
			document.form1.VerificationCode.focus();
			return false;
		}
	if (document.form1.VerificationCode.value.length != 4)
		{
			alert("Please Enter a Valid Verification Code");
			document.form1.VerificationCode.select();
			return false;
		}
		
	return true;
}

function showMessage(){
	document.getElementById('mobMessage').style.display="block";
}
function hideMessage(){
	document.getElementById('mobMessage').style.display="none";
}

// Function to disallow alphabets in numeric fields like price, area
// USAGE:  onkeypress="return isNumberKey(event)"
function isNumberKey(evt,enabledot)
{
	if(!enabledot) enabledot=0;
 var charCode = (evt.which) ? evt.which : event.keyCode
 if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=46 && enabledot==1)
	return false;
 else if (charCode > 31 && (charCode < 48 || charCode > 57) && enabledot==0)
	return false;

 return true;
}

////allow only characters///////
function charonly(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
	
	if (unicode!=8)
		{
			if ((unicode!=32 && (unicode<65 || (unicode>90 && (unicode<97 || unicode>122)))) && unicode!=39 && unicode!=45 && unicode!=13 && unicode!=15 && unicode!=37 &&  unicode!=39 && unicode!=14 && unicode!=9  )
			return false;
		}
}
