function openWindow1() 
{
	sealWin = window.open("/faq1.jsp","win1",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=520,height=460');
	self.name = "mainWin1"; 
}

function what()
{
	//postwindow = window.open("/whatisthis_ccav.jsp","CCAvenue","status=no","toolbar=no","scrollbars=no","dependent=yes","alwaysRaised=yes","resizable=no","width=200","height=100","maximize=no");
	//window.status="done";
	sealWin = window.open("/whatisthis_ccav.jsp","win1",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=520,height=460');
	self.name = "mainWin1";     
	  
}

function submitRegForm() {

	var frm = document.mer_reg;

	trimAll(frm);  

	if(!chkBlank(frm.contact_name,"contact person name")) return;
	
	if(!chkGreaterLen(frm.contact_name,"Contact person name","50")) return;
	if (!chkSpecialCharCustom(frm.contact_name, "Contact person name", "01234567890'`~!@#$%^*&(+-[]{}\/|;:,<>.?")) return;
	
	if(frm.sel_staus[frm.sel_staus.selectedIndex].value=="sel") { alert("Please select your Business Status"); frm.sel_staus.focus(); return; }

	//validation code added by Abhijit Kedare    	
	if(!chkBlank(frm.address,"Address")) return; 
	if(!chkGreaterLen(frm.address,"Address","200")) return;
	if(!chkSpecialCharCustom(frm.address, "Address", "'`\\~!@#$%^*&(+-[]{}/|;:<>.?")) return;                
	
	if(!chkBlank(frm.contact_city,"City")) return;
	if(!chkSpecialCharCustom(frm.contact_city, "City", "01234567890'`~!@#$%^*&(+-[]{}\\/|;:,<>.?")) return;
	if(!chkGreaterLen(frm.contact_city,"City","30")) return;
	
	if(frm.contact_state[frm.contact_state.selectedIndex].value=="sel") { alert("Please select your State"); 		frm.contact_state.focus(); return; }
	
	if(!chkBlank(frm.contact_zip,"Zip")) return;
	if(!chkSpecialCharCustom(frm.contact_zip, "Zip", "'`~!@#$%^*&(+-[]{}\\/|;:,<>.?")) return;
	if(!chkNaN(frm.contact_zip,"Zip/Postal Code.")) return;  
	if(!chkGreaterLen(frm.contact_zip,"Zip/Postal Code","15")) return;  
	
	
	

	//end of code by Abhijit kedare
	
	if (!chkSpecialCharCustom(frm.ph_countryCode, "Country", "'`~!@#$%^*&(+-[]{}\\/|;:,<>.?")) return;
	if (!chkSpecialCharCustom(frm.ph_areaCode, "Area code for telephone number", "'`~!@#$%^*&(+-[]{}\\/|;:,<>.?")) return;
	if (!chkSpecialCharCustom(frm.ph_phoneNumber, "Telephone number", "'`~!@#$%^*&(+-[]{}\\/|;:,<>.?")) return;
	
	
	if(!chkBlank(frm.country,"Country")) return;
	if(!chkBlank(frm.ph_countryCode,"Country code for telephone number")) return;
	if(!chkNaN(frm.ph_countryCode,"telephone number.")) return;	
	if(!chkBlank(frm.ph_areaCode,"Area code for telephone number")) return;
	if(!chkNaN(frm.ph_areaCode,"telephone number.")) return;	
	if(!chkBlank(frm.ph_phoneNumber,"Telephone number")) return;
	if(!chkNaN(frm.ph_phoneNumber,"telephone number.")) return;
	
	
	// assambling phone number
	frm.tel_no.value = frm.ph_countryCode.value + "-" + frm.ph_areaCode.value + "-" + frm.ph_phoneNumber.value
	
	if (frm.fax_no.value != "" ) { 
		if(!chkGreaterLen(frm.fax_no,"Fax Number should be less than 50 Characters","50")) return;
		if(!chkNaN(frm.fax_no,"Fax Number.")) return;	
	}
	
	if(!chkBlank(frm.email, "Email address")) return;
	if(!chkEmail(frm.email, "Email address")) return;
	if(!chkSpecialCharCustom(frm.email, "Email address", "'`~!#$%^*&(+-[]{}\\/|;:<>?")) return;
	  
	if(!chkBlank(frm.url, "site URL")) return;
	
	else {
		frm.url.value = (frm.url.value).replace("http://", "");
	}
	if (!chkSpecialCharCustom(frm.url, "site URL", "'`~!@#$%^*&(+-[]{}\\/|;:,<>?")) return;

	if(frm.acct_type[frm.acct_type.selectedIndex].value=="sel") { alert("Please Select the Account Type"); frm.acct_type.focus(); return; }
	// Validating bank details parameters ===============================
	if(!chkBlank(frm.pay_to, "Pay To")) return;

	if(!chkGreaterLen(frm.pay_to,"Pay To", "100")) return;
//	if (!chkSpecialChar(frm.pay_to, "Pay To")) return;
	if (!chkSpecialCharCustom(frm.pay_to, "Pay To","01234567890'`~!@#$%^&()+[]{}\\/|;:,<>?'")) return;       
	// ----added by parag to validate IFSC ----
	if (!chkSpecialCharCustom(frm.ifsc, "IFSC code","'`~!@#$%^&()+[]{}/\\|;:,<>.?'")) return;
	if (!chkBlank(frm.account_num, "Account Number")) return;
	if (!chkCharacters(frm.account_num, "1234567890 -")) {
		alert("Please enter valid account number");
		frm.account_num.focus();
		return;
	}
	if(!chkBlank(frm.bank_acc_type, "Bank Account Type")) return;
	 
	if(frm.bank_name.value == "") {
		alert("Please select bank name from the drop down list or\nIf not in the list then specify your bank name in the below text box.");
		frm.selBank_name.focus();
		return;
	}    
	
	if(!chkSpecialCharCustom(frm.bank_name, "bank name", "01234567890'`~!@#$%^*&(+-[]{}\\/|;:,<>?")) return;
	if(!chkBlank(frm.branch_name, "Branch Name")) return;
	if(!chkSpecialCharCustom(frm.branch_name, "Branch Name", "01234567890'`~!@#$%^*&(+-[]{}\\/|;:,<>?")) return;
	if(!chkBlank(frm.branch_city, "Branch City")) return;
	if(!chkSpecialCharCustom(frm.branch_city, "Branch City", "01234567890'`~!@#$%^*&(+-[]{}\\/|;:,<>?")) return;
	
	// assambaling bank details and populating bankAcc_detail form element for old usage only
	frm.bankAcc_detail.value = "ACCNO:"+frm.account_num.value + " ACCTYPE:" + frm.bank_acc_type.value + " BANK:" + frm.bank_name.value + " BRANCH:" + frm.branch_name.value + " CITY:" + frm.branch_city.value
	//alert(frm.bankAcc_detail.value);	return;
	//=========================================================================================
	
	// validation for additional details
	if(!chkBlank(frm.promoter_detail,"Promoter & Financial stake details")) return;
	if(!chkGreaterLen(frm.promoter_detail,"Promoter & Financial stake details","200")) return;
	if(!chkSpecialCharCustom(frm.promoter_detail, "Promoter & Financial stake details", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return;
	if(!chkSpecialCharCustom(frm.vc_detail, "Angel / VC funding details", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return;
             
    	  
	// validation for brif description
	if(!chkBlank(frm.about_com,"Description about your Company & Site")) return;
	if(!chkGreaterLen(frm.about_com,"Description about your Company & Site","475")) return;
	if(!chkSpecialCharCustom(frm.about_com, "Description about your Company & Site", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return;
	
	if(!chkBlank(frm.about_ser,"Description about your Products & Service")) return;
	if(!chkGreaterLen(frm.about_ser,"Description about your Products & Service","450")) return;
	if(!chkSpecialCharCustom(frm.about_ser, "Description about your Products & Service", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return;
	///------------------------------- FOR 3  NEW FIELDS----------- ADDED ON WEDNESDAY, JULY 14, 2004. 12:02 PM------------
		if(!chkBlank(frm.minTransAmount,"amount for the cost of unit sold")) return;
		if(!chkNaN(frm.minTransAmount,"Cost of Units Sold.")) return;	
		if(!chkSpecialCharCustom(frm.minTransAmount, "amount for the cost of unit sold", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return;
		  
		formelem = frm.avgCostOfUnitsSold;
		if(!chkBlank(frm.avgCostOfUnitsSold,"Avg. cost of unit sold")) return;
		if(!chkNaN(frm.avgCostOfUnitsSold,"Avg. cost of unit sold.")) return;	
		if(!chkSpecialCharCustom(frm.avgCostOfUnitsSold, "Avg. cost of unit sold", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return;
		
		formelem = frm.noOfTransPerMonth;
		if(!chkBlank(frm.noOfTransPerMonth,"number of transactiosn per month")) return;
		if(!chkNaN(frm.noOfTransPerMonth,"number of transactiosn per month.")) return;
		if(!chkSpecialCharCustom(frm.noOfTransPerMonth, "number of transactiosn per month.", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return;
   
	//----------------------------------- ENDS HERE ------------------------------------------------------------------------------
       
	if(!chkBlank(frm.logPartner_detail,"Logistics partner details")) return;  
	if(!chkGreaterLen(frm.logPartner_detail,"Logistics partner details","200")) return;
	if(!chkSpecialCharCustom(frm.logPartner_detail, "Logistics partner details", "'`~!@#$%^*&(+-[]{}\\/|;:<>?")) return; 
	/*           
	// validating login information  
	if(!chkBlank(frm.uname,"User Name")) return;
	if(!chkLessLen(frm.uname,"User Name","5")) return;
	if (!chkSpecialChar(frm.uname, "User Name")) return;
	
	if(!chkBlank(frm.pword,"password")) return;
	if(!chkLessLen(frm.pword,"password","8")) return;
	//if (!chkSpecialCharPwd(frm.pword, "password")) return;
	//code added by Abhijeet Kedare 
	var passVal=frm.pword.value;
	var re = /^.*(?=.{8,20})(?=.*\d)(?=.*[a-z])((?=.*[!@#$*%^&+=]).*$)/;
	if(passVal.length > 20){
		alert("Password length should not be more than 20 characters");
		return false; 
	}
	else if(passVal.length < 8){
		alert("Password length should not be less than 8 characters");
		return false;
	}
	//var re = /^.*(?=.*\d)(?=.*[a-z])((?=.*[@#$%^&+=]).*$)/;
	if ((!re.test(passVal)) ) { 
		alert("Please enter a valid password!. \nIt Should be alphanumeric with at least one special character"); 
		return false;  
	}
	//end of the code by Abhijeet Kedare
	
	
	
	// intervalidation for user name and both passwords
	if(frm.pword.value==frm.uname.value) { alert("Username & Password should not be the same"); frm.pword.focus(); return; }
	if((frm.pword1.value=="") || (frm.pword1.value<1)) { alert("Please Renter your password"); frm.pword1.focus(); return; }
	if(frm.pword.value!=frm.pword1.value) { alert("Password doesn't match\nPlease Re-enter your password"); frm.pword.value='';frm.pword1.value='';frm.pword.focus(); return; }
	*/
	    
	function removeSpaces(string) {
		 return string.split(' ').join('');   
	}
	      
	if ( removeSpaces(frm.capt.value) == '')
	{  
		alert('Please Enter the characters you see in the image.');
		frm.capt.focus();
		return false;    
	}
	  
	frm.action="/mer_register/mer_register_ccav.jsp";
	frm.submit();
	// commented by Aniruddha on 19/05/2011 to remove the use of chkUname.jsp
/*	document.getElementById("validtxt").innerHTML = "";
	url = "/mer_register/chkUname.jsp";
	var uname = frm.uname.value
	url=url+"?val="+uname;
   
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp!=null){
		xmlHttp.onreadystatechange=stateChanged1;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}else{
		frm.submit();
	}
*/
}

function validate(){
	var frm = document.mer_reg;
	document.getElementById("validtxt").innerHTML = "";
	if(!chkBlank(frm.uname,"User Name")) {frm.uname.focus(); frm.uname.select(); return;}
	if(!chkLessLen(frm.uname,"User Name","5")) {frm.uname.focus(); frm.uname.select(); return;}
	if (!chkSpecialChar(frm.uname, "User Name")) {frm.uname.focus(); frm.uname.select();  return;}
	url = "/mer_register/chkUname.jsp"+"?val="+frm.uname.value;
	//var uname = frm.uname.value
	//url=url+"?val="+uname;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		window.open("chkUname.jsp?u_id="+uname,'newwin',"toolbar=0,location=0,directories=0,status=1,menubar=no,scrollbars=no,resizable=no,width=450,height=100,menubar=0");
		return;
	}

	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	

}

function stateChanged(){
	var frm = document.mer_reg;
	if (xmlHttp.readyState==4){ 
		if(xmlHttp.responseText.indexOf("Available") < 0){
			var message = xmlHttp.responseText;
			alert("User Name Already Exists. Please Try entering different user name");
			document.getElementById("validtxt").innerHTML=xmlHttp.responseText;
		}else{
			alert("This user name is Available");
		}
	}
}

function stateChanged1(){
	var frm = document.mer_reg;
	if (xmlHttp.readyState==4){
		if(xmlHttp.responseText.indexOf("Available") > 0){
			frm.submit();
		}else{
			alert("User Name Already Exists. Please Try entering different user name");
			document.getElementById("validtxt").innerHTML=xmlHttp.responseText;
		}
	}
}

function GetXmlHttpObject(){
	var xmlHttp=null;
		try{
		// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}catch (e){
		// Internet Explorer
			try{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}catch (e){
				try{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}catch (e){
					return null;
				}
			}
		}
	return xmlHttp;
}



function chkSpecialCharPwd(formelement,text) {

	var msg='true';
	var a=formelement.value;
	var b=a.length;
	var cha='%;';
	var ch=cha.length;
	var i,j;
	for(i=0;i<ch;i++)
	{
		var ch1=cha.substring(i,i+1);
		for(j=0;j<b;j++)
		{
			var a1=a.substring(j,j+1);
			if(a1==ch1)
			{
				msg='Special Characters like ' +cha+ 'are not allowed in '+text;
				alert(msg);
				formelement.focus();
				return false;
			}
		}
	}
	if (msg=='true')
	{
	return true;
	}
}    
