function popUp(theURL,name,w,h,t,m,st,sc,r,X,Y){
if ( X == -1) {
X = screen.availWidth - w ;
X = X/2;
}
if (Y == -1) {
Y = screen.availHeight -h ;
Y = Y/2;
}
p="width=" + w + ",height=" + h + ",toolbar=" + t + ",menubar=" + m + ",status=" + st + ",scrollbars=" + sc + ",resizable=" + r + "directories=0,screenX=" + X + ",screenY=" + Y + ",left=" + X + ",top=" + Y + ",header=0";
share=window.open(theURL,name,p);
}


function fnViewDim(){
	//var divBranch = document.getElementById("divBranch");
	var State = document.getElementById("State");
	var city = document.getElementById("city");
	if(State.options[State.selectedIndex].value=="")
	{
	alert("Please Select State");
	State.focus();
	return false;
	}
	if(city.options[city.selectedIndex].value=="")
	{
	alert("Please Select City");
	city.focus();
	return false;
	}
	
	
	
	/*if(divBranch.style.display==""){
		divBranch.style.display = "None";
		
	}else{
		divBranch.style.display = "";
		
	}*/
	var strURL = 'SBI_Demat_RegisterBranch.jsp?State='+State.value+'&city='+city.value;
	popUp(strURL,'Branch_Locator',400,300,0,0,0,'Yes',0,450,0);
}
function fnOpen(){
	
//	window.open("../SBI_Demat_Register_Action.jsp");
}
function doNothing()
{
}

/*function validate(form_id,email) {
var address = document.getElementById("email");
return validateEmail(address.value);
}*/

function validateEmail(emailID){
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = emailID;
if(reg.test(address) == false) {
//alert('Invalid Email Address');
return false;
}
else{
return true;
}
}
/*Email Validation*/
function eMailCheck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	var returnValue = true;
	if (str.indexOf(at)==-1){
	   returnValue = false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   returnValue = false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    returnValue = false;
	}
	 if (str.indexOf(at,(lat+1))!=-1){
	    returnValue = false;
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    returnValue = false;
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
	    returnValue = false;
	 }	
	 if (str.indexOf(" ")!=-1){
	    returnValue = false;
	 }
	return returnValue;					
}

	/*function allowcharacterReg()
	
	{
	
            var Name =document.getElementById("Name");;


            Pattern name = Pattern.compile("^[a-zA-Z]+$");
            for (int i = 0; i < Name.length(); i++) {
                Matcher mt = name.matcher(Name);
                if (!mt.matches()) {

                    alert("Please enter character only");
                } 
               
                
            
        }
	
	}*/


function formOnSubmit(){

	//updateRTE('txtProductSpec');
	//updateRTE('txtSalesProject');
	
	
	var email = document.getElementById("email");
	var Name = document.getElementById("Name");
	var selProduct = document.getElementById("selProduct");
	
	var MOBILE = document.getElementById("MOBILE");
	
	//var txtbranch = document.getElementById("txtbranch");
	var State = document.getElementById("State");
		var city = document.getElementById("city");
	
	var txtPin = document.getElementById("txtPin");
	
	
	if(Name.value == ""){
		alert("Please enter your Name");
		Name.select();
		return false;
	}
	if(selProduct.options[selProduct.selectedIndex].value=="")	
		{
		alert("Please Select Product");
		selProduct.focus();
		return false;
			}
	if(MOBILE.value == ""){
		alert("Please enter your Mobile");
		MOBILE.select();
		return false;
	}
					
	if(email.value == ""){
		alert("Please enter your Email Address");
		email.select();
		return false;
	}else{
		if(!(validateEmail(email.value))){
			alert("Please enter a valid Email Address");
			email.select();
			return false;
		}	
	}
	
	if(State.options[State.selectedIndex].value=="")	
		{
		alert("Please Select State");
		State.focus();
		return false;
		
		}
	if(city.options[city.selectedIndex].value=="")
	{
	alert("Please Select City");
	city.focus();
	return false;
	}
	/*if(txtbranch.value == ""){
		alert("Please enter your Branch");
		txtbranch.select();
		return false;
	}*/
	if(txtPin.value == ""){
		alert("Please enter your Pin Code");
		txtPin.select();
		return false;
	}else{
		if(!isInteger(txtPin.value)){
			alert("Please enter numeric only for Pincode");
			txtPin.select();
			return false;
		}else if(txtPin.value.length!=6){
			alert("Please enter you six digit Pincode");
			txtPin.select();
			return false;
		}
	}
	
	//converingFormelemntstoUpperCase();	
	document.frmDematRegister.action = 'SBI_Demat_Register_Action.jsp';
	//alert(document.frmDematRegister.action);
	//document.frmDematRegister.submit();
}

function converingFormelemntstoUpperCase()
{
	var elem = document.getElementById('frmDematRegister').elements;
	for(var i = 0; i < elem.length; i++)
	{	
	if(elem[i].type=='text'){
			elem[i].value  = elem[i].value.toUpperCase();
		}		
	}
}

