// JavaScript Document

function trim(stringToTrim)
{
return stringToTrim.replace(/^\s+|\s+$/g,"");
}


// This function for showHide Nri Sub Menu

function showHideNriSubMenu(showHide){
	//alert(showHide);
	//alert(document.getElementById("nri-sub-menu").style.display);
	if(showHide == 'show'){
		document.getElementById("nri-sub-menu").style.display = '';
	} else {
		document.getElementById("nri-sub-menu").style.display = 'none';
	}
	//alert(document.getElementById("nri-sub-menu").style.display);
}

// This function for showHide Wealth Management Sub Menu

function showHidePortfolioSubMenu(showHide){
	if(showHide == 'show'){
		document.getElementById("portfolioMgmt-sub-menu").style.display = '';
	} else {
		document.getElementById("portfolioMgmt-sub-menu").style.display = 'none';
	}
}

// This function for showHide IPOs/NFOs Sub Menu

function showHideIpoNfoSubMenu(showHide){
	if(showHide == 'show'){
		document.getElementById("ipoNfo-sub-menu").style.display = '';
	} else {
		document.getElementById("ipoNfo-sub-menu").style.display = 'none';
	}
}

// JavaScript Document
function validate_email(){
	var email = trim(document.getElementById("email").value);
	
	// Check email Id
	if(!checkEmail(trim(email.value))){
		email.focus();
		return false;	
	}
}

// Function for form validation
function validate_form(){
	var name = (document.getElementById("fullName"));
	var email = (document.getElementById("email"));
	var phone = (document.getElementById("phone"));
	
	
	//check name for blank values 
	if(trim(name.value) == ""){
		alert("Please, Enter your Name!");
		name.focus();
		return false;
	}

	// Check email Id
	if(!checkEmail(trim(email.value))){
		email.focus();
		return false;	
	}
}

	//check name for blank values 
	if(trim(phone.value) == ""){
		alert("Please, Enter Proper Phone No!");
		phone.focus();
		return false;
	}

	//check phone No for character
	if(!IsInteger(trim(phone.value))){
		alert("please, Enter only numeric value");
		phone.focus();
		return false;
	}

	//Check Phone No not greater than 11 digit
if((phone.value.length > 6)||(phone.value.length < 15)){
		alert("Please, Enter min 6 digit and max 15 digit phone no");
		phone.focus();
		return false;
	}




// Function for checking Email id
function checkEmail(email){
	
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)){
		return true;
	}
	alert("Please Enter valid E-mail Id");
	return false;
}


// Function for checking Email id 
function checkEmail(email){
	
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)){
		return true;
	}
	alert("Please Enter valid E-mail Id");
	return false;
}


// Function for checking phone no.
function IsInteger(no){
	var i;
	for(i=0 ; i < no.length; i++){
		var c= no.charAt(i);
		if((( c < "0") || (c > "9")))
			return false;
	}
	return true;
}


// Function for form validation for Services Section
function validate_form_pms(){
	var namepms = document.getElementById("fullNamePms");
	var emailpms = document.getElementById("emailPms");
	var phonepms = document.getElementById("phonePms");
	
	
	//check name for blank values 
	if(trim(namepms.value) == ""){
		alert("Please, Enter your Name!");
		namepms.focus();
		return false;
	}

	// Check email Id
	if(!checkEmailpms(trim(emailpms.value))){
		emailpms.focus();
		return false;	
	}

	//check name for blank values 
	if(trim(phonepms.value) == ""){
		alert("Please, Enter Proper Phone No!");
		phonepms.focus();
		return false;
	}

	//check phone No for character
	if(!IsInteger(trim(phonepms.value))){
		alert("please, Enter only numeric value");
		phonepms.focus();
		return false;
		
	}
}
	// Function for checking Email id 
function checkEmailpms(emailpms){
	
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailpms)){
		return true;
	}
	alert("Please Enter valid E-mail Id");
	return false;
}


/*********************** Validation for IBT Form ******************/

// Function for form validation for Services Section
function validate_form_ibt(){
	var nameibt = document.getElementById("fullNameIbt");
	var emailibt = document.getElementById("emailIbt");
	var phoneibt = document.getElementById("phoneIbt");
	
	
	//check name for blank values 
	if(trim(nameibt.value) == ""){
		alert("Please, Enter your Name!");
		nameibt.focus();
		return false;
	}

	// Check email Id
	if(!checkEmailibt(trim(emailibt.value))){
		emailibt.focus();
		return false;	
	}

	//check name for blank values 
	if(trim(phoneibt.value) == ""){
		alert("Please, Enter Proper Phone No!");
		phoneibt.focus();
		return false;
	}

	//check phone No for character
	if(!IsInteger(trim(phoneibt.value))){
		alert("please, Enter only numeric value");
		phoneibt.focus();
		return false;
		
	}
}
	// Function for checking Email id 
function checkEmailibt(emailibt){
	
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailibt)){
		return true;
	}
	alert("Please Enter valid E-mail Id");
	return false;
}

/*********************** Validation for Financial Planning Form ******************/

// Function for form validation for Services Section
function validate_form_finplan(){
	var namefin = document.getElementById("fullNameFin");
	var emailfin = document.getElementById("emailFin");
	var phonefin = document.getElementById("phoneFin");
	
	
	//check name for blank values 
	if(trim(namefin.value) == ""){
		alert("Please, Enter your Name!");
		namefin.focus();
		return false;
	}

	// Check email Id
	if(!checkEmailfin(trim(emailfin.value))){
		emailfin.focus();
		return false;	
	}

	//check name for blank values 
	if(trim(phonefin.value) == ""){
		alert("Please, Enter Proper Phone No!");
		phonefin.focus();
		return false;
	}

	//check phone No for character
	if(!IsInteger(trim(phonefin.value))){
		alert("please, Enter only numeric value");
		phonefin.focus();
		return false;
		
	}
}
	// Function for checking Email id 
function checkEmailfin(emailfin){
	
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailfin)){
		return true;
	}
	alert("Please Enter valid E-mail Id");
	return false;
}