function showNRIAccountOnline()
{
	window.open("http://www.icicibank.com/pfsuser/icicibank/ibank-nri/OnlineAcOpeningMain.html");
	
}

function showTearms()
{
//	window.open("TermsConditions/terms_conditions.htm");
	window.open("terms.htm");
}


function validate()
{
 if(document.FrmNriIcici.chk_TrmCond.checked==false)
 {
	alert("Please check the Term and Condition Checkbox");
	document.FrmNriIcici.chk_TrmCond.focus();
	return;	
 }
  	if(emailCheck(document.FrmNriIcici.EMAIL.value))
	{
		if(empty(document.FrmNriIcici.PASSWD1))
		{
	 		if(passlen(document.FrmNriIcici.PASSWD1))
	 		{
				if(empty(document.FrmNriIcici.PASSWD2))
					{
						if(compare(document.FrmNriIcici.PASSWD1.value,document.FrmNriIcici.PASSWD2.value))
							{
								if(empty(document.FrmNriIcici.PASSHINT))
								{
									if(empty(document.FrmNriIcici.PASSANS))
									{
										if(empty(document.FrmNriIcici.FNAME))
										{
											if(empty(document.FrmNriIcici.LNAME))
											{
												if(empty(document.FrmNriIcici.ADDRESS1))
												{
													if(empty(document.FrmNriIcici.CITY))
													{
														if(empty(document.FrmNriIcici.STATE))
														{
															if(empty(document.FrmNriIcici.POSTAL_CODE))
															{
																if(emptycombo(document.FrmNriIcici.COUNTRY))
																{
																	if(empty(document.FrmNriIcici.C_PHONE))
																	{
																		if(empty(document.FrmNriIcici.CI_PHONE))
																		{
																			if(empty(document.FrmNriIcici.PHONE))
																			{
		 																		if(empty(document.FrmNriIcici.AGE))
																				{
																					if(isValidDate(document.FrmNriIcici.AGE,document.FrmNriIcici.hid_date))
																					{				
																							var to_comp = compareTwoDate(document.FrmNriIcici.AGE.value,'27-01-2003');
																							if(to_comp != 0)
																								{
																									alert('Date Of Birth cannot be greater than or equal to Today Date. ');
																									return;
																								}
																						document.FrmNriIcici.method = "post";
//																						document.FrmNriIcici.action='/m2i/CustomerInterface/RG_new_registration_insrt.jsp';
																						https://money2india.icicibank.co.in/RG_new_registration.htm
																						document.FrmNriIcici.action='https://money2india.icicibank.co.in/m2i/CustomerInterface/RG_new_registration_insrt.jsp';
																						document.FrmNriIcici.target='midd';
																						document.FrmNriIcici.submit();
																					}
																				}
																			
														
																			}															
																		}														
													  				}														
																}
															}
														}
													}
												}
											}
										}
									}
								}
		 					}
						
				}
			}
		}
	}
}
function empty(val)
{
	//alert('inside empty');
	var p=val.value;
	if(p=='')
	{
		alert('Mandatory field cannot be empty !!');
		val.focus(); 
		return false;
	}
	return true;
	
}
function emptycombo(val)
{
 	
	if(val.selectedIndex=="0")
	{
		alert('Mandatory field cannot be empty !!');
		val.focus(); 
		return false;
	
	}
	return true;
}
function sendtoSite()
{
	window.open("http://www.icici.com/nri/pf_nriman002.htm");
}
function chkForSpace(obj)
{
	var m = '';
	var l = 0
	var s = ''; 
	m = obj.value;
	l = m.length;
	for (var n=0;n<l;n++)
	{
	   s= m.charAt(0);	
	   if(s == ' ')
		if (m.length==1)
			m="";		
		else
			m=m.slice(1);
	}
	obj.value=m;
}

function emailCheck (emailStr) 
{
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


var matchArray=emailStr.match(emailPat)
if (matchArray==null) 
{
	alert("Email address seems incorrect (check @ and .'s)")
	document.FrmNriIcici.EMAIL.select();
	document.FrmNriIcici.EMAIL.focus();
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) 
{
    // user is not valid
    alert("The username doesn't seem to be valid.")
	document.FrmNriIcici.EMAIL.select();
	document.FrmNriIcici.EMAIL.focus();
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) 
{
    // this is an IP address
	  for (var i=1;i<=4;i++) 
	{
	    if (IPArray[i]>255) 
	    {
	        alert("Destination IP address is invalid!")
			document.FrmNriIcici.EMAIL.select();
			document.FrmNriIcici.EMAIL.focus();
			return false
	    }
    }
	
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
	document.FrmNriIcici.EMAIL.select();
	document.FrmNriIcici.EMAIL.focus();
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("The address must end in a three-letter domain, or two letter country.")
   document.FrmNriIcici.EMAIL.select();
   document.FrmNriIcici.EMAIL.focus();
   return false
}

if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   document.FrmNriIcici.EMAIL.select();
   document.FrmNriIcici.EMAIL.focus();
   return false
}

return true;
}
function compare(string1,string2)
{
	if(string1!=string2)
	{
		alert('Confirmation password is not matching with the password');
		document.FrmNriIcici.PASSWD2.select();
		document.FrmNriIcici.PASSWD2.focus();
		return false;
	}
	return true;
}
function passlen(obval)
{
	var pass=document.FrmNriIcici.PASSWD1.value;
		if(pass.length<6)
		{
			alert("Password should be of minimum six characters !!")
			document.FrmNriIcici.PASSWD1.focus();
			return false;
		}
		return true;
}
function isValidDate(date,hid_date)
{
	dateStr = date.value;
	if(dateStr.length!=0)
	{
 		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

		var matchArray = dateStr.match(datePat); // is the format ok?
		if (matchArray == null)
		{
			alert("Date is not in a valid format.");
			date.focus();
			date.select();
			return false;
		}
		day = matchArray[1]; // parse date into variables
		month = matchArray[3];
		year = matchArray[4];
		if (month < 1 || month > 12)
		{ // check month range
			alert("Month must be between 1 and 12.");
			date.focus();
			date.select();
			return false;
		}
		if (day < 1 || day > 31)
		{
			alert("Day must be between 1 and 31.");
			date.focus();
			date.select();
			return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31)
		{
			alert("Month "+month+" doesn't have 31 days!");
			date.focus();
			date.select();
			return false;
		}
		if (month == 2)
		{
			 // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap))
			{
			alert("February " + year + " doesn't have " + day + " days!");
			date.focus();
			date.select();
			return false;
		   	}
		}
		if(year < 1901)
		{
			alert("Year should not be less than 1901 ");
			date.focus();
			date.select();
			return false;
		}

                hid_date.value = year+"-"+month+"-"+day; 
		return  true;
   }
  // date is valid

}
function frmReset()
{
	document.FrmNriIcici.reset();
}
function putFocus()
{
	document.FrmNriIcici.EMAIL.focus();
	//window.open("m2i/CustomerInterface/Rakhi/rakhi.jsp","mywin","status=no,resize=no,toolbar=no,scrollbars=no,width=300,height=370,maximize=no");
}

function compareTwoDate(first,last)
{
	fst = first;
	lst = last;
	fst_dt = new Array();
	lst_dt = new Array();
	var fst_search;
	var lst_search;

	if((fst.indexOf('-',0)+1)>0)
		fst_search = "-";
	else
		fst_search = "/";

	if((lst.indexOf('-',0)+1)>0)
		lst_search = "-";
	else
		lst_search = "/";


	fst_dt = fst.split(fst_search);
	lst_dt = lst.split(lst_search);
	first_dt = new Date(parseInt(fst_dt[2],10),parseInt(fst_dt[1],10)-1,parseInt(fst_dt[0],10));
	last_dt = new Date(parseInt(lst_dt[2],10),parseInt(lst_dt[1],10)-1,parseInt(lst_dt[0],10));
	if((first_dt - last_dt)<0)
	return 0;
	else
	return 1;
}
