// JavaScript Document

function showdiv(a)
{
	for(i=1;i<=6;i++)
	{
		if(i==a)
		{
			document.getElementById("div" + i).style.display="block";
			if(document.getElementById('tab' + i + '') != null)
			{
				document.getElementById('tab' + i + '').src="images-ms_new/tab" + i + "_O.gif";
			}
		}
		else
		{
			document.getElementById("div" + i).style.display="none";
			if(document.getElementById('tab' + i + '') != null)
			{
				document.getElementById('tab' + i + '').src="images-ms_new/tab" + i + ".gif";
			}
		}
	}
}

function showhideform(a)
{
	for(i=1;i<=2;i++)
	{
		if(i==a)
		{
			document.getElementById('Step' + i + 'Form').style.display = 'block';
		}
		else
		{
			document.getElementById('Step' + i + 'Form').style.display = 'none';
		}
	}
}

function formcheck()
{
	var MobileNo = document.form1.mobile.value;
	
	if	(isWhitespace(document.form1.fname.value) || isEmpty(document.form1.fname.value))
		{
			alert("Please enter your first name");
			document.form1.fname.select();
			return false;
		}
	else if	(isWhitespace(document.form1.lname.value) || isEmpty(document.form1.lname.value))
		{
			alert("Please enter your last name");
			document.form1.lname.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.loanamt.selectedIndex==0)
		{
			alert("Please select loan amount");
			document.form1.loanamt.focus();
			return false;
		}
	else if (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 (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.city.selectedIndex==0)
		{
			alert("Please select your city");
			document.form1.city.focus();
			return false;
		}
	else if (document.form1.salary.selectedIndex==0)
		{
			alert("Please select your monthly salary");
			document.form1.salary.focus();
			return false;
		}
	
	alert("You are eligilble for an ICICI Bank Home loan, only if your age is above 25 yrs & the loan amount you are applying for is above 8 lacs.");
	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 formcheckmailer()
{
	var MobileNo = document.form1.mobile.value;
	
	if	(isWhitespace(document.form1.fname.value) || isEmpty(document.form1.fname.value))
		{
			alert("Please enter your first name");
			document.form1.fname.select();
			return false;
		}
	else if	(isWhitespace(document.form1.lname.value) || isEmpty(document.form1.lname.value))
		{
			alert("Please enter your last name");
			document.form1.lname.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.loanamt.selectedIndex==0)
		{
			alert("Please select loan amount");
			document.form1.loanamt.focus();
			return false;
		}
	else if (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 (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 (isWhitespace(document.form1.pincode.value) || isEmpty(document.form1.pincode.value))
		{
			alert("Please enter 6 digit pincode");
			document.form1.pincode.select();
			return false;
		}
	else if (isNaN(document.form1.pincode.value))
		{
			alert("Please enter numbers only");
			document.form1.pincode.select();
			return false;
		}
	else if (document.form1.pincode.value.length != 6)
		{
			alert("Please enter valid pincode");
			document.form1.pincode.select();
			return false;
		}
	
	return true;	
}

function fillIncome(val)
{
	var modeldrp = document.form1.salary;
	
	for(var a = modeldrp.options.length-1; a>=0; a--)
	{
		modeldrp.remove(a);
	}
	
	modeldrp.options.add(new Option('Please Select',''));
	
	var strcat;
	if(val != "0:0:0")
	{
		var mySplitResult = val.split(":");
		strcat = mySplitResult[2];
	}
	
	switch(strcat)
	{
		case 'A':
			modeldrp.options.add(new Option('less than Rs 18000 not eligible','less than Rs 18000 not eligible'));
		  break;
		case 'B':
			modeldrp.options.add(new Option('less than Rs 18000 not eligible','less than Rs 18000 not eligible'));
		  break;
		case 'C':
			modeldrp.options.add(new Option('less than Rs 15000 not eligible','less than Rs 15000 not eligible'));
			modeldrp.options.add(new Option('Above Rs 15000','Above Rs 15000'));
		  break;
	}
	
	modeldrp.options.add(new Option('Above Rs 18000','Above Rs 18000'));
	modeldrp.options.add(new Option('Above Rs 50000','Above Rs 50000'));
	modeldrp.options.add(new Option('Above Rs 1 Lakh','Above Rs 1 Lakh'));
}

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;
		}
}
