function showcont(){

	var selObj = document.getElementById('orgtype');
	var txtTextObj = document.getElementById('txtText');

	var selIndex = selObj.selectedIndex;
	var selval=document.getElementById('strorg').value
	var txtval=selObj.options[selIndex].value;

	txtTextObj.value = selObj.options[selIndex].text;
	//if(document.getElementById('strorg').value == 'nfp')
	//	selObj.options[selIndex].text = "Not for Profit";

    if(txtTextObj.value == 'Not for Profit' && (selval != '' || selval == '')){
		document.getElementById("regnfp").style.display="inline";
		document.getElementById("refcod").style.display="none"; 
		document.getElementById("orgbus").style.display="none";
		document.getElementById("subcat").style.display="inline";
		//document.getElementById("noragr").style.display="none";
		document.getElementById("nfpagr").style.display="inline";
		}
    else if(txtTextObj.value != 'Not for Profit' && selval != ''){
		document.getElementById("regnfp").style.display="none";
		document.getElementById("refcod").style.display="inline"; 
		document.getElementById("orgbus").style.display="inline";
		document.getElementById("subcat").style.display="none";
		//document.getElementById("noragr").style.display="inline";
		document.getElementById("nfpagr").style.display="none";
		}
	else {
		document.getElementById("regnfp").style.display="none";
		document.getElementById("refcod").style.display="inline"; 
		document.getElementById("orgbus").style.display="inline";
		document.getElementById("subcat").style.display="none";
		//document.getElementById("noragr").style.display="inline";
		document.getElementById("nfpagr").style.display="none";
		}
}

function call_nfp(nfpval)
{
  if(nfpval == 'Not for Profit'){
	profilevalidation1()
//   if(confirm("Are you show to disagree dandora declaration?"))
//	{
//		document.profile.operation.value="disagree";
//		document.profile.submit();
//	}else 
//	{
//		return false;
//	}
  
  }
}

function showtype(type)
{
	if(type=='individual')
	{
		document.getElementById("usertype_ind").checked=true;
		showhide('orgrow_id','none');
		//showhide('cntpersonrow_id','none');
		//showhide('addcntpersonrow_id','none');

		showhide('institlerow_id','inline');
		showhide('insfullnamerow_id','inline');
		showhide('insgenderrow_id','inline');
		showhide('insemailrow_id','inline');
		document.getElementById("phone_lbl").innerHTML="Phone Number";
		document.getElementById("mobileex").innerHTML="";
		
	}else if(type=='institution')
	{
		document.getElementById("usertype_ins").checked=true;
		showhide('orgrow_id','inline');
		//showhide('cntpersonrow_id','inline');
		//showhide('addcntpersonrow_id','inline');

		showhide('institlerow_id','none');
		showhide('insfullnamerow_id','none');
		showhide('insgenderrow_id','none');
		showhide('insemailrow_id','none');
		document.getElementById("phone_lbl").innerHTML="Contact Number";
		document.getElementById("mobileex").innerHTML="<br>(Eg.91-1234567890)";
	}
}
function checkuserexists()
{
	var username=document.getElementById("user_name").value;

	if(validateNotEmpty(username))
	{
		if(!validateAlphaNumericUserName_new(username) || username==0 || UserName1(username) || !validateAlphaNumericUserName(username))
		{		
			alert("Please enter valid user name");
			document.profile.user_name.value="";
			var t=setTimeout("setfocus('user_name');",10);
			return false;
		}
		if(username.length<5)
		{
			alert ("User name should be minimum 5 characters");
			document.getElementById("user_name").focus();
			document.profile.user_name.value="";
			var t=setTimeout("setfocus('user_name');",10);
			return false;
		}
		var url="modules/newuser/ajaxfunctions.php";
		var passvar="emptyarg&function=checkuserexists&username="+username;
		loadmajax(url,'POST',passvar,'userexists_msg');
		return false;
	}
}
function aftercheck()
{
	var result=document.getElementById("userexists").value;
	showhide('userexists_msg_row','inline');
	if(result=="1")
	{
		document.getElementById("user_name").value='';
		var t=setTimeout("setfocus('user_name');",10);
		return false;
	}
}
function checkrcodeexists()
{
	var refcode=document.getElementById("refcode").value;
	//if(!validateNotEmpty(refcode))
	//{
		//alert('in chk');
		//if(refcode=='')
		//{		
		//	alert("Please enter valid dandora referral code");
		//	document.getElementById("refcode").value='';
		//	var t=setTimeout("setfocus('refcode');",10);
		//	return false;
		//}

		var url="modules/newuser/ajaxfunctions.php";
		var passvar="emptyarg&function=checkrcodeexists&rcode="+refcode;
		loadmajax(url,'POST',passvar,'refcodeexists_msg');
		return false;
	//}
}
function aftercheckcode()
{
	var result=document.getElementById("refcodeexists").value;
	//showhide('refcodeexists_msg_row','none');
	showhide('refcodeexists_msg_row','inline');
	//alert('result '+result);	
	//var t=setTimeout("checkrefcode('result');",10);
	var t=setTimeout("checkrefcode("+result+");",200);
}

function checkrefcode(result){
	//alert('chkres '+result);
if(result=="1")
	{
		//alert('wel 1');	
		document.getElementById("refcode").value='';
		//showhide('refcodeexists_msg_row','none');
		//var t=setTimeout("setfocus('refcode');",10);
		document.getElementById("refcode").focus();
		return false;
	}
	else if(result=="0")
	{
		toupperval(document.getElementById("refcode").value);
		profilevalidation()
	}
	else if(result=="2")
	{
		profilevalidation()
	}


}

function profilevalidation()
{
	var alertlist="";
	var fcs="";

	if(!validateNotEmpty(document.profile.user_name.value)){alertlist+="Please enter \"User Name\"\n";fcs+="-user_name";}
	username=document.profile.user_name.value;
	if(validateNotEmpty(username))
	{
		if(!validateAlphaNumericUserName_new(username) || username==0 || UserName1(username) || !validateAlphaNumericUserName(username))
		{		
			alert("Please enter valid user name");
			document.profile.user_name.value="";
			var t=setTimeout("setfocus('user_name');",10);
			return false;
		}
		if(username.length<5)
		{  
			alert ("User name should be minimum 5 characters");
			document.getElementById("user_name").focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.password.value)){alertlist+="Please enter \"Password\"\n";fcs+="-password";}
	if(validateNotEmpty(document.profile.password.value))
	{
		if(!validatePassword_new(document.profile.password.value) || document.profile.password.value==0)
		{
			alert("Please enter valid password");
			document.profile.password.value='';
			document.profile.conf_password.value='';
			document.profile.password.focus();
			return false;
		}
		if(document.profile.password.value==document.profile.user_name.value)
		{
			alert("User name and password should not be same");
			document.profile.password.value='';
			document.profile.conf_password.value='';
			document.profile.password.focus();
			return false;
		}
		if(document.profile.password.value.length<6 || document.profile.password.value.length>15)
		{
			alert("Password should be minimum 6 and maximum 15 characters");
			document.profile.password.value='';
			document.profile.conf_password.value='';
			document.profile.password.focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.conf_password.value)){alertlist+="Please enter \"Confirm Password\"\n";fcs+="-conf_password";}
	if(validateNotEmpty(document.profile.conf_password.value))
	{
		if(document.profile.conf_password.value.length<6 || document.profile.conf_password.value.length>15)
		{
			alert("Confirm Password should be minimum 6 and maximum 15 characters")
			document.profile.conf_password.focus();
			return false;
		}

		if(document.profile.password.value != document.profile.conf_password.value)
		{
			document.profile.password.value='';
			document.profile.conf_password.value ='';
			alert("Password and Confirm Password doesn't match")
			document.profile.password.focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.orgname.value)){alertlist+="Please enter \"Organisation Name\"\n";fcs+="-orgname";}

	if(document.profile.formname.value!='nfp')
	{
		if(!validateNotEmpty(document.profile.orgtype.value)){alertlist+="Please enter \"Organisation type\"\n";fcs+="-orgtype";}
		if(!validateNotEmpty(document.profile.businesstype.value)){alertlist+="Please enter \"Type of Business\"\n";fcs+="-businesstype";}
	}
	else
	{
		if(!validateNotEmpty(document.profile.businesssubtype.value)){alertlist+="Please select \"Organisation Category\"\n";fcs+="-businesssubtype";}
		if(document.getElementById('orgsubtype').value=='--Select--'){alertlist+="Please select \"Sub Category\"\n";fcs+="-orgsubtype";}
	}

	
//-----------------------Individual Validation---start------------------------------//
	if(validateNotEmpty(document.profile.orgname.value))
	{
		if(document.profile.orgname.value==0 || !validateAlpha1BusinessName(document.profile.orgname.value))
		{
			alert("Please enter valid organisation name")
			document.profile.orgname.focus();
			return false;			
		}
		var Org_Name= document.profile.orgname.value.length;
		
		if(Org_Name < 3)
		{
			alert("Please enter maximum 3 characters organisation name")
			document.profile.orgname.focus();
			return false;			
		}
	}
	if(document.profile.title.value== '--Select--'){alertlist+="Please select \"Title\"\n";fcs+="-title";}
	if(!validateNotEmpty(document.profile.fullname.value)){alertlist+="Please enter \"Full Name\"\n";fcs+="-fullname";}
	if(validateNotEmpty(document.profile.fullname.value) && !validateAlpha1(document.profile.fullname.value))
	{
		alert("Please enter valid full name");
		document.profile.fullname.focus();
		return false;
	}
	if(document.getElementById("gender_m").checked==false && document.getElementById("gender_f").checked==false){alertlist+="Please select \"Gender\"\n";fcs+="-gender_m";}
	if(!validateNotEmpty(document.profile.email.value)){alertlist+="Please enter \"E-mail ID\"\n";fcs+="-email";}
	if(validateNotEmpty(document.profile.email.value))
	{
		if(!validateEmail(document.profile.email.value))
		{
			alert("Please enter valid email id");
			document.profile.email.focus();
			return false;
		}
		if(document.getElementById("indemailexists").value==1)
		{
			alert("E-mail ID already exists");
			document.getElementById("email").focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.address1.value)){alertlist+="Please enter \"Address Line 1\"\n";fcs+="-address1";}
	if(validateNotEmpty(document.profile.address1.value))
	{
		if(!checkaddress(document.profile.address1.value) || document.profile.address1.value==0)
		{
			alert("Please enter valid address line 1");
			document.profile.address1.focus();
			return false;
		}
	}
	if(validateNotEmpty(document.profile.address2.value))
	{
		if(!checkaddress(document.profile.address2.value) || document.profile.address2.value==0)
		{
			alert("Please enter valid address line 2");
			document.profile.address2.focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.city.value)){alertlist+="Please enter \"City\"\n";fcs+="-city";}
	if(validateNotEmpty(document.profile.city.value))
	{
		if(!validateAlphaSpaceCity(document.profile.city.value) || document.profile.city.value.length<2)
		{
			alert("Please enter valid city")
			document.profile.city.focus();
			return false;
		}
	}
	if(document.profile.country.value=='--Select--'){alertlist+="Please select \"Country\"\n";fcs+="-country";}
	var txtval=document.profile.country.options[document.profile.country.selectedIndex].text;
	if(txtval=="India")
	{
		if(document.getElementById("state").value=='--Select--'){alertlist+="Please select \"State\"\n";fcs+="-state";}
	}else if(txtval!="India")
	{
		if(!validateNotEmpty(document.getElementById("otherstate").value)){alertlist+="Please enter \"State\"\n";fcs+="-otherstate";}
		if(validateNotEmpty(document.getElementById("otherstate").value))
		{
			if(!validateAlphaSpaceCity(document.getElementById("otherstate").value) || document.getElementById("otherstate").value.length<2)
			{
				alert("Please enter valid state");
				document.getElementById("otherstate").focus();
				return false;
			}
		}
	}
	if(!validateNotEmpty(document.profile.zipcode.value)){alertlist+="Please enter \"Postal Code\"\n";fcs+="-zipcode";}
	if(validateNotEmpty(document.profile.zipcode.value) && document.profile.country.options[document.profile.country.selectedIndex].text=="India")
	{
		if(!validateInteger(document.profile.zipcode.value) || document.profile.zipcode.value==0)
		{
			alert("Please enter valid postal code");
			document.profile.zipcode.focus();
			return false;
		}
		if(document.profile.zipcode.value.length==7 || document.profile.zipcode.value.length<6 || document.profile.zipcode.value.length>8)
		{
			alert("Please enter valid postal code");
			document.profile.zipcode.focus();
			return false;
		}
	}
	if(validateNotEmpty(document.profile.zipcode.value) && document.profile.country.options[document.profile.country.selectedIndex].text!="India")
	{
		if(!validateZipcode(document.profile.zipcode.value))
		{
			alert("Please enter valid postal code");
			document.profile.zipcode.focus();
			return false;
		}
	}

	if(validateNotEmpty(document.profile.orgtype.value) && document.profile.orgtype.options[document.profile.orgtype.selectedIndex].text!="Not for Profit")
	{
		var dty="";
		
		if(validateNotEmpty(document.profile.regdtyr.value)) {
			var dt=document.profile.regdtyr.value;
			fcs_splt1=dt.split("/");

			if(fcs_splt1[1]>12 || ((fcs_splt1[2].length == 2) || (fcs_splt1[2].length == 3)))
			{
						alert("Please enter valid date & year of registration");
						document.profile.regdtyr.focus();
						return false;
			}

//			alert('d '+fcs_splt1[0]);
//			alert('m '+fcs_splt1[1]);
//			alert('y '+fcs_splt1[2]);
//			alert('l '+fcs_splt1[2].length);
		}
			//document.getElementById(fcs_splt[1]).focus();


//		if(!validateZipcode(document.profile.zipcode.value))
//		{
//			alert("Please enter valid postal code");
//			document.profile.zipcode.focus();
//			return false;
//		}
	}


	if(!validateNotEmpty(document.profile.phone.value) && !validateNotEmpty(document.profile.mobile.value)){alertlist+="Please enter \"Phone Number or Mobile Number\"\n";fcs+="-phone";}
	if(validateNotEmpty(document.profile.phone.value) && validate_Phonenumber('phone','phone','yes','','')==false)
	{
		return false;
	}
	if(validate_Phonenumber('fax','fax','no','','')==false)
	{
		return false;
	}
	if(validate_Phonenumber('mobile','mobile','no','','')==false)
	{
		return false;
	}

	//if(!validateNotEmpty(document.profile.refcode.value)){alertlist+="Please enter \"Dandora Referral Code\"\n";fcs+="-refcode";}
	//alert('refc '+document.profile.refcode.value);
	//if(validateNotEmpty(document.profile.refcode.value))
	//{
		//if(document.profile.refcode.value=='')
		//{
		//	alert("Please enter valid referral code");
		//	document.profile.refcode.focus();
		//	return false;
		//}
	//}
	
	//if(checkrcodeexists())
	//	{
	//		alert("Please enter valid referral code");
	//		document.profile.refcode.focus();
	//		return false;
	//	}
//-----------------------Individual Validation---end------------------------------//

	if(document.getElementById("regnfp").style.display =='inline'){

	if(!validateNotEmpty(document.profile.regnumber.value)) {alertlist+="Please enter \"Registration Number\"\n";fcs+="-regnumber";}

	if(!validateNotEmpty(document.profile.regdtyr.value)) {alertlist+="Please enter \"Date of Registration\"\n";fcs+="-regdtyr";}



	var datesplit =document.profile.regdtyr.value;
	var splres = datesplit.split("/");
	var flagdate,flagmonth,flagyear;

	//var date = new Date();
	//var curryear = date.getYear();
	
	var curryear = document.profile.curryear.value;
		for(var s=0;s<=splres.length;s++)
			{
				if(splres[0]>31)
					flagdate=11;
				if(splres[1]>12)
					flagmonth=12;
				if(splres[2]>curryear || splres[2]<curryear)
				flagyear=13;
			}

	if(flagdate=='11'){alertlist+="Please enter \"Valid Date\"\n";fcs+="-regdtyr";}	
	if(flagmonth=='12'){alertlist+="Please enter \"Valid Month\"\n";fcs+="-regdtyr";}
	if(flagyear=='13'){alertlist+="Please enter \"Valid Current Year\"\n";fcs+="-regdtyr";}




	if(!validateNotEmpty(document.profile.regauth.value)){alertlist+="Please select \"Registration Authority\"\n";fcs+="-regauth";}
	}

	if(document.getElementById("declaration_y").checked==false)
	{
		alertlist+="Please agree \"Declaration\"\n";
		fcs+="-declaration_y";
	}
	if(document.getElementById("termscond_y").checked==false)
	{
		alertlist+="Please agree \"Terms and Conditions\"\n";
		fcs+="-termscond_y";
	}
	if(document.getElementById("antispam_y").checked==false)
	{
		alertlist+="Please agree \"Anti Spam\"\n";
		fcs+="-antispam_y";
	}
	if(alertlist!="")
	{
		
		alert(alertlist);
		fcs_splt=fcs.split("-");
		
		document.getElementById(fcs_splt[1]).focus();
		alertlist="";
		fcs="";
		return false;
	}

	if(document.getElementById("regnfp").style.display =='inline'){

		if(parent.ifileframe.document.getElementById("imagedisp").style.display=='none')

		if(!validateNotEmpty(parent.ifileframe.document.fileform.attach_file.value)) {alert("Please upload \"Registration Certificate\"\n");parent.ifileframe.document.fileform.attach_file.focus();return false;}
		else
		{
			alert("Please click \"Attach Button\"\n");
			parent.ifileframe.document.fileform.upload_btn.focus();
			return false;
		}
	}

	document.profile.operation.value="preview";
	document.profile.submit();
}

function profilevalidation1()
{
	var alertlist="";
	var fcs="";

	if(!validateNotEmpty(document.profile.user_name.value)){alertlist+="Please enter \"User Name\"\n";fcs+="-user_name";}
	username=document.profile.user_name.value;
	if(validateNotEmpty(username))
	{
		if(!validateAlphaNumericUserName_new(username) || username==0 || UserName1(username) || !validateAlphaNumericUserName(username))
		{		
			alert("Please enter valid user name");
			document.getElementById('declaration_y').checked=true;
			document.profile.user_name.value="";
			var t=setTimeout("setfocus('user_name');",10);
			return false;
		}
		if(username.length<5)
		{  
			alert ("User name should be minimum 5 characters");
			document.getElementById('declaration_y').checked=true;
			document.getElementById("user_name").focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.password.value)){alertlist+="Please enter \"Password\"\n";fcs+="-password";}
	if(validateNotEmpty(document.profile.password.value))
	{
		if(!validatePassword_new(document.profile.password.value) || document.profile.password.value==0)
		{
			alert("Please enter valid password");
			document.getElementById('declaration_y').checked=true;
			document.profile.password.value='';
			document.profile.conf_password.value='';
			document.profile.password.focus();
			return false;
		}
		if(document.profile.password.value==document.profile.user_name.value)
		{
			alert("User name and password should not be same");
			document.getElementById('declaration_y').checked=true;
			document.profile.password.value='';
			document.profile.conf_password.value='';
			document.profile.password.focus();
			return false;
		}
		if(document.profile.password.value.length<6 || document.profile.password.value.length>15)
		{
			alert("Password should be minimum 6 and maximum 15 characters");
			document.getElementById('declaration_y').checked=true;
			document.profile.password.value='';
			document.profile.conf_password.value='';
			document.profile.password.focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.conf_password.value)){alertlist+="Please enter \"Confirm Password\"\n";fcs+="-conf_password";}
	if(validateNotEmpty(document.profile.conf_password.value))
	{
		if(document.profile.conf_password.value.length<6 || document.profile.conf_password.value.length>15)
		{
			alert("Confirm Password should be minimum 6 and maximum 15 characters")
			document.getElementById('declaration_y').checked=true;
			document.profile.conf_password.focus();
			return false;
		}

		if(document.profile.password.value != document.profile.conf_password.value)
		{
			document.profile.password.value='';
			document.profile.conf_password.value ='';
			alert("Password and Confirm Password doesn't match")
			document.getElementById('declaration_y').checked=true;
			document.profile.password.focus();
			return false;
		}
	}
//-----------------------Individual Validation---start------------------------------//
	if(validateNotEmpty(document.profile.orgname.value))
	{
		if(document.profile.orgname.value==0 || !validateAlpha1BusinessName(document.profile.orgname.value))
		{
			alert("Please enter valid organisation name")
			document.getElementById('declaration_y').checked=true;
			document.profile.orgname.focus();
			return false;			
		}
		var Org_Name= document.profile.orgname.value.length;
		
		if(Org_Name < 3)
		{
			alert("Please enter maximum 3 characters organisation name")
			document.getElementById('declaration_y').checked=true;
			document.profile.orgname.focus();
			return false;			
		}
	}
	if(document.profile.title.value== '--Select--'){alertlist+="Please select \"Title\"\n";fcs+="-title";}
	if(!validateNotEmpty(document.profile.fullname.value)){alertlist+="Please enter \"Full Name\"\n";fcs+="-fullname";}
	if(validateNotEmpty(document.profile.fullname.value) && !validateAlpha1(document.profile.fullname.value))
	{
		alert("Please enter valid full name");
		document.getElementById('declaration_y').checked=true;
		document.profile.fullname.focus();
		return false;
	}
	if(document.getElementById("gender_m").checked==false && document.getElementById("gender_f").checked==false){alertlist+="Please select \"Gender\"\n";fcs+="-gender_m";}
	if(!validateNotEmpty(document.profile.email.value)){alertlist+="Please enter \"E-mail ID\"\n";fcs+="-email";}
	if(validateNotEmpty(document.profile.email.value))
	{
		if(!validateEmail(document.profile.email.value))
		{
			alert("Please enter valid email id");
			document.getElementById('declaration_y').checked=true;
			document.profile.email.focus();
			return false;
		}
		if(document.getElementById("indemailexists").value==1)
		{
			alert("E-mail ID already exists");
			document.getElementById('declaration_y').checked=true;
			document.getElementById("email").focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.address1.value)){alertlist+="Please enter \"Address Line 1\"\n";fcs+="-address1";}
	if(validateNotEmpty(document.profile.address1.value))
	{
		if(!checkaddress(document.profile.address1.value) || document.profile.address1.value==0)
		{
			alert("Please enter valid address line 1");
			document.getElementById('declaration_y').checked=true;
			document.profile.address1.focus();
			return false;
		}
	}
	if(validateNotEmpty(document.profile.address2.value))
	{
		if(!checkaddress(document.profile.address2.value) || document.profile.address2.value==0)
		{
			alert("Please enter valid address line 2");
			document.getElementById('declaration_y').checked=true;
			document.profile.address2.focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.profile.city.value)){alertlist+="Please enter \"City\"\n";fcs+="-city";}
	if(validateNotEmpty(document.profile.city.value))
	{
		if(!validateAlphaSpaceCity(document.profile.city.value) || document.profile.city.value.length<2)
		{
			alert("Please enter valid city")
				document.getElementById('declaration_y').checked=true;
			document.profile.city.focus();
			return false;
		}
	}
	if(document.profile.country.value=='--Select--'){alertlist+="Please select \"Country\"\n";fcs+="-country";}
	var txtval=document.profile.country.options[document.profile.country.selectedIndex].text;
	if(txtval=="India")
	{
		if(document.getElementById("state").value=='--Select--'){alertlist+="Please select \"State\"\n";fcs+="-state";}
	}else if(txtval!="India")
	{
		if(!validateNotEmpty(document.getElementById("otherstate").value)){alertlist+="Please enter \"State\"\n";fcs+="-otherstate";}
		if(validateNotEmpty(document.getElementById("otherstate").value))
		{
			if(!validateAlphaSpaceCity(document.getElementById("otherstate").value) || document.getElementById("otherstate").value.length<2)
			{
				alert("Please enter valid state");
				document.getElementById('declaration_y').checked=true;
				document.getElementById("otherstate").focus();
				return false;
			}
		}
	}
	if(!validateNotEmpty(document.profile.zipcode.value)){alertlist+="Please enter \"Postal Code\"\n";fcs+="-zipcode";}
	if(validateNotEmpty(document.profile.zipcode.value) && document.profile.country.options[document.profile.country.selectedIndex].text=="India")
	{
		if(!validateInteger(document.profile.zipcode.value) || document.profile.zipcode.value==0)
		{
			alert("Please enter valid postal code");
			document.getElementById('declaration_y').checked=true;
			document.profile.zipcode.focus();
			return false;
		}
		if(document.profile.zipcode.value.length==7 || document.profile.zipcode.value.length<6 || document.profile.zipcode.value.length>8)
		{
			alert("Please enter valid postal code");
			document.getElementById('declaration_y').checked=true;
			document.profile.zipcode.focus();
			return false;
		}
	}
	if(validateNotEmpty(document.profile.zipcode.value) && document.profile.country.options[document.profile.country.selectedIndex].text!="India")
	{
		if(!validateZipcode(document.profile.zipcode.value))
		{
			alert("Please enter valid postal code");
			document.getElementById('declaration_y').checked=true;
			document.profile.zipcode.focus();
			return false;
		}
	}

	if(validateNotEmpty(document.profile.orgtype.value) && document.profile.orgtype.options[document.profile.orgtype.selectedIndex].text!="Not for India")
	{
		var dty="";
		
		if(validateNotEmpty(document.profile.regdtyr.value)) {
			var dt=document.profile.regdtyr.value;
			fcs_splt1=dt.split("/");

			if(fcs_splt1[1]>12 || ((fcs_splt1[2].length == 2) || (fcs_splt1[2].length == 3)))
			{
						alert("Please enter valid date & year of registration");
						document.getElementById('declaration_y').checked=true;
						document.profile.regdtyr.focus();
						return false;
			}

//			alert('d '+fcs_splt1[0]);
//			alert('m '+fcs_splt1[1]);
//			alert('y '+fcs_splt1[2]);
//			alert('l '+fcs_splt1[2].length);
		}
			//document.getElementById(fcs_splt[1]).focus();


//		if(!validateZipcode(document.profile.zipcode.value))
//		{
//			alert("Please enter valid postal code");
//			document.profile.zipcode.focus();
//			return false;
//		}
	}


	if(!validateNotEmpty(document.profile.phone.value) && !validateNotEmpty(document.profile.mobile.value)){alertlist+="Please enter \"Phone Number or Mobile Number\"\n";fcs+="-phone";}
	if(validateNotEmpty(document.profile.phone.value) && validate_Phonenumber('phone','phone','yes','','')==false)
	{
		return false;
	}
	if(validate_Phonenumber('fax','fax','no','','')==false)
	{
		return false;
	}
	if(validate_Phonenumber('mobile','mobile','no','','')==false)
	{
		return false;
	}

	//if(!validateNotEmpty(document.profile.refcode.value)){alertlist+="Please enter \"Dandora Referral Code\"\n";fcs+="-refcode";}
	//alert('refc '+document.profile.refcode.value);
	//if(validateNotEmpty(document.profile.refcode.value))
	//{
		//if(document.profile.refcode.value=='')
		//{
		//	alert("Please enter valid referral code");
		//	document.profile.refcode.focus();
		//	return false;
		//}
	//}
	
	//if(checkrcodeexists())
	//	{
	//		alert("Please enter valid referral code");
	//		document.profile.refcode.focus();
	//		return false;
	//	}
//-----------------------Individual Validation---end------------------------------//

/*	if(document.getElementById("declaration_y").checked==false)
	{
		alertlist+="Please choose \"Declaration\"\n";
		fcs+="-declaration_y";
	}*/
	if(alertlist!="")
	{
		
		alert(alertlist);
		fcs_splt=fcs.split("-");
		
		document.getElementById(fcs_splt[1]).focus();
		alertlist="";
		fcs="";
		document.getElementById('declaration_y').checked=true;
		return false;
	}

if(confirm("Are you show to disagree dandora declaration?"))
	{
		document.profile.operation.value="disagree";
		document.profile.submit();
	}else 
	{
		document.getElementById('declaration_y').checked=true;
		document.getElementById('declaration_y').focus();
		return false;
	}
}

function change_state(country_id)
{
	/*
	var url="modules/newuser/ajaxfunctions.php";
	var passvar="emptyarg&function=change_state&country_id="+country_id;
	loadmajax(url,'POST',passvar,'st');
	return false;
	*/
	var txtval=document.profile.country.options[document.profile.country.selectedIndex].text;
	if(txtval=="India")
	{
		document.getElementById("otherstate").value='';
		document.getElementById("state").value='--Select--';
		document.getElementById("otherstate").style.display='none';
		document.getElementById("state").style.display='inline';
		
	}else if(txtval!="India")
	{
		document.getElementById("otherstate").value='';
		document.getElementById("state").value='--Select--';
		document.getElementById("otherstate").style.display='inline';
		document.getElementById("state").style.display='none';
	}

}

function change_org(org_id)
{
	
	var url="modules/newuser/ajaxfunctions.php";
	var passvar="emptyarg&function=change_org&org_id="+org_id;
	loadmajax(url,'POST',passvar,'storg');
	return false;
	
}


function goto_home(actn)
{
	document.profile.operation.value=actn;
	document.profile.submit();
}
function gotohome_payment()
{
	//document.payprofile.operation.value=actn;
	//document.payprofile.submit();
	window.location='index.php';
}
function preview_showtype(type)
{
	if(type=='individual')
	{
		showhide('orgrow_id','none');
		showhide('cntpersonrow_id','none');
		showhide('addcntpersonrow_id','none');

		showhide('institlerow_id','inline');
		showhide('insfullnamerow_id','inline');
		showhide('insgenderrow_id','inline');
		showhide('insemailrow_id','inline');
	
		
	}else if(type=='institution')
	{
		showhide('orgrow_id','inline');
		showhide('cntpersonrow_id','inline');
		showhide('addcntpersonrow_id','inline');

		showhide('institlerow_id','none');
		showhide('insfullnamerow_id','none');
		showhide('insgenderrow_id','none');
		showhide('insemailrow_id','none');
		
	}
}
function show_plans(path)
{
	window.open("index.php?rid="+path, '', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=680,height=370,left=75,top=100'); 
}

function previewaction(path)
{
window.location=path;
}
function savedetail(path)
{

	//alert(document.profilePreview.hidcap.value);
//	alert(document.profilePreview.security_code.value);

	document.profilePreview.operation.value="savedetails";
	document.profilePreview.action=path;	
	document.profilePreview.submit();
}
function select_state(fld,vl)
{
	//var t=setTimeout("select_state1('"+fld+"'"+vl+"');",3000);
	//document.getElementById(fld).value=vl;
	var url="modules/newuser/ajaxfunctions.php";
	var passvar="emptyarg&function=select_state&fld="+fld+"&vl="+vl;
	loadmajax(url,'POST',passvar,'test');
	return false;
}
function select_state1(fld,vl)
{
	alert(fld+"--"+vl);
	document.getElementById(fld).value=vl;
}
function setamountvalue(planid)
{
	var url="modules/newuser/ajaxfunctions.php";
	var passvar="emptyarg&function=setamountvalue&planid="+planid;
	loadmajax(url,'POST',passvar,'emptyid');
	return false;
}
function setamountvalue1(inr,usd)
{
	document.getElementById("inr").value=inr;
	document.getElementById("usd").value=usd;
}
function payment()
{
	var alertlist="";
	var fcs="";
	if(!validateNotEmpty(document.payprofile.inr.value)){alertlist+="Please select \"Subscription Plan\"\n";fcs+="-subplan";}
	if(document.payprofile.pref_currency.value== '--Select--'){alertlist+="Please select \"Currency Type\"\n";fcs+="-pref_currency";}
	if(document.payprofile.paymode.value== '--Select--'){alertlist+="Please select \"Payment Mode\"\n";fcs+="-paymode";}
	if(!validateNotEmpty(document.payprofile.instrumentno.value)){alertlist+="Please enter \"Instrument Number\"\n";fcs+="-instrumentno";}
	if(validateNotEmpty(document.payprofile.instrumentno.value))
	{
		if(document.payprofile.paymode.options[document.payprofile.paymode.selectedIndex].text!="Cheque" || document.payprofile.paymode.options[document.payprofile.paymode.selectedIndex].text!="Demand Draft")
		{
			if(!validatechequ_other(document.payprofile.instrumentno.value) || document.payprofile.instrumentno.value==0)
			{
				alert("Please enter valid Instrument Number");
				document.payprofile.instrumentno.focus();
				return false;
			}
		}
		if(document.payprofile.paymode.options[document.payprofile.paymode.selectedIndex].text=="Cheque" || document.payprofile.paymode.options[document.payprofile.paymode.selectedIndex].text=="Demand Draft")
		{
			if(!validateAlphaNumeric(document.payprofile.instrumentno.value))
			{
				alert("Please enter valid Instrument Number");
				document.payprofile.instrumentno.focus();
				return false;
			}
		}
	}
	if(!validateNotEmpty(document.payprofile.instrumentdate.value)){alertlist+="Please select \"Instrument Date\"\n";fcs+="-instrumentdate";}
	if(!validateNotEmpty(document.payprofile.bank_name.value)){alertlist+="Please enter \"Bank Name\"\n";fcs+="-bank_name";}
	if(validateNotEmpty(document.payprofile.bank_name.value))
	{
		if(!BankName2(document.payprofile.bank_name.value) || document.payprofile.bank_name.value==0)
		{
			alert("please enter valid bank name ")
			document.payprofile.bank_name.focus();
			return false;
		}
	}
	if(!validateNotEmpty(document.payprofile.branch_name.value)){alertlist+="Please enter \"Branch Name\"\n";fcs+="-branch_name";}
	if(validateNotEmpty(document.payprofile.branch_name.value))
	{
		if(!BankName2(document.payprofile.branch_name.value) || document.payprofile.branch_name.value == 0)
		{
			alert("Please enter valid branch name ")
			document.payprofile.branch_name.focus();
			return false;			
		}
	}
	if(!validateNotEmpty(document.payprofile.city.value)){alertlist+="Please enter \"City / Country\"\n";fcs+="-city";}
	if(validateNotEmpty(document.payprofile.city.value))
	{
		if(!validateCountryCity( document.payprofile.city.value) || document.payprofile.city.value==0)
		{
			alert("Please enter valid city / country")
			document.payprofile.city.focus();
			return false;			
		}
	}
	if(alertlist!="")
	{
		alert(alertlist);
		fcs_splt=fcs.split("-");
		document.getElementById(fcs_splt[1]).focus();
		alertlist="";
		fcs="";
		return false;
	}

	document.payprofile.operation.value="payment";
	document.payprofile.submit();
}
function checkmailexists(fld,resultid,resultfld)
{  
	var email=document.getElementById(fld).value;

	if(validateNotEmpty(email))
	{
		if(!validateEmail(email))
		{  
			alert("Please enter valid email id");
			document.getElementById(fld).value='';
			var t=setTimeout("setfocus('email');",10);
			return false;
		}
	}
	if(email!='')
	{ 
		var url="modules/newuser/ajaxfunctions.php";
		var passvar="emptyarg&function=checkmailexists&email="+email+"&fld="+fld+"&resultfld="+resultfld;
		loadmajax(url,'POST',passvar,resultid);
		return false;
	}
}
function mailexists_result(fld,resultfld)
{
	if(document.getElementById(resultfld).value==1)
	{
		alert("E-mail ID already exists");
		document.getElementById(fld).focus();
		return false;
	}
	if(document.getElementById("validmail").value=="invalid")
	{
		alert("Please enter valid email id");
		document.getElementById(fld).value='';
		var t=setTimeout("setfocus('email');",10);
		return false;
	}
}
function setprodvalues(prdid,prdname)
{
	//document.getElementById("prdname").innerHTML=prdname;
	document.getElementById("product_id").value=prdid;
}
function printviewprofile(action1,printpath)
{	
	window.open('index.php?rid='+printpath,'PopUpCalendar','height=1000,width=700,top=10,left=10,toolbars=no,scrollbars=yes,status=no,resizable=yes');
}
function pay_receipt(operation1,action)
{
	document.frm_receipt.operation.value = operation1
	//document.frm_receipt.action.value=action;
	//document.frm_receipt.action="index.php?rid="+action;
	document.frm_receipt.submit();
}
function trialuser()
{
	var alertlist="";
	var fcs="";

	if(!validateNotEmpty(document.profile.email.value)){alertlist+="Please enter \"E-mail ID\"\n";fcs+="-email";}
	if(validateNotEmpty(document.profile.email.value))
	{
		if(!validateEmail(document.profile.email.value))
		{
			alert("Please enter valid email id");
			document.profile.email.focus();
			return false;
		}
	}
	if(alertlist!="")
	{
		alert(alertlist);
		fcs_splt=fcs.split("-");
		//alert(fcs_splt[1]);
		document.getElementById(fcs_splt[1]).focus();
		alertlist="";
		fcs="";
		return false;
	}
	disablebuttons("-submit_btn-close_btn");
	email=document.profile.email.value;
	var url="modules/newuser/ajaxfunctions.php";
	var passvar="emptyarg&function=checkemailvalid&email="+email;
	loadmajax(url,'POST',passvar,'emptyid');
	return false;
}
function submitform()
{
	disablebuttons("-submit_btn-close_btn");
	document.profile.operation.value="trynow";
	document.profile.submit();
}
function invalidmail()
{
	alert("Please enter valid e-mail id");
	document.profile.email.focus();
	document.getElementById("submit_btn").disabled=false;
	document.getElementById("close_btn").disabled=false;
	return false;
}
function setprodvalues(prdid,prdname)
{
	document.getElementById("prdname").innerHTML=prdname;
}

function displaymsg()
{

	if(document.profilePreview.msg.value!="")
	{
		alert(document.profilePreview.msg.value);
		document.profilePreview.security_code.focus();

	}
}

function getcodenew(url)
{  
	var url="modules/newuser/captchaajax.php";
	loadmajax(url,'POST','','cap');
	return false;	
}

//function getcodenew1(url)
//{  
//	var url="modules/newuser/captchaajax.php";
//	loadmajax(url,'POST','tt','cap');
//	return false;	
//}

	/**  Function	: toupperfirst(str)
	*    ---------------------------------------------------------------- 
	*    Name		:	toupperfirst
	*    Purpose    :	To change the string first char is change to upper case and also remove the continious space
	*    Arguments  :	str
	*    Return		:	Get the result values
	*/ 

 //---added--by--Thalavai.D--29-09-08-To show the multiple selection list box process---/
function toupperval(str){ 
	var strval="";

	for (i=0;i<str.length ;i++ ){
		if(i==0)
			strval=str.charAt(i).toUpperCase();
		else if(i==1)
			strval+=str.charAt(i).toUpperCase();
		else
			strval+=str.charAt(i);

	}
	//alert('val '+strval);
	document.getElementById("refcode").value=strval;
	//return strval;
}
function enable_preview(){
	document.getElementById("preview_btn").disabled=false;
}
function disable_preview(){
	document.getElementById("preview_btn").disabled=true;
}
function onKeyPressBlockNumbers(e)
{
	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);
	reg = /[a-zA-Z\&\s\_\-\(\)\,\.\=\*\&\^\$\%\#\@\~\`\!\;\+\\\/\?\>\<\|]/;

	var chars = document.getElementById("regdtyr").value;
	
if(chars.length==2)
	document.getElementById("regdtyr").value=chars+'/';
if(chars.length==5)
	document.getElementById("regdtyr").value=chars+'/';

	return !reg.test(keychar);
}

/*
' Script Functions
'---------------------------------------------------------
'   Lang               : JavaScript  
'   Function Name      : orgfun
'   Action             : show the organization type
'   @param             : -
'   @return            : Alert message
'----------------------------------------------------------
*/
function subcatfunc()
{
	//alert('welcome');
	document.getElementById("subcat").style.display="none";
	document.getElementById("subcattype").style.display="inline";	
	document.getElementById("orgtypname").focus();
}


/*
' Script Functions
'---------------------------------------------------------
'   Lang               : JavaScript  
'   Function Name      : savefun
'   Action             : Save the organization type
'   @param             : -
'   @return            : Alert message
'----------------------------------------------------------
*/
function saveorgfun(val,val1)
{
	//alert('org '+val);
	//alert('org sub '+val1);

    //document.getElementById("showtype").style.display="none";
	//document.getElementById("showmsg").style.display="inline";
	//alert(document.getElementById("orgsubtype").value);
	document.getElementById("txtText1").value=val1;

	//alert('sorg '+document.getElementById("txtText1").value);
	var selObj = document.getElementById('orgtype');
	var txtTextObj = document.getElementById('txtText');
	var usrname=document.getElementById("user_name").value;

	var selIndex = selObj.selectedIndex;
	var txtval=selObj.options[selIndex].value;



	
	if(val != '' && val1 != '' && usrname != '')
		ListSomthing("modules/newuser/checkstatus.php?catid="+txtval,val,"addorg");
	else if(val != '' && val1 != '' && usrname == ''){
		alert('Please enter user name');
		document.getElementById("user_name").focus();
		closeorgfun();
		}
	else if(val != '' && val1 == '' && usrname != ''){
		alert('Please select Organisation category');
		document.getElementById("businesssubtype").focus();
		closeorgfun();
		}
	else{
		
			alert('Please enter Sub Category');
			document.getElementById("orgtypname").focus();
	
	 }
}

/*
' Script Functions
'---------------------------------------------------------
'   Lang               : JavaScript  
'   Function Name      : resetorgfun
'   Action             : Reset the organization type
'   @param             : -
'   @return            : Alert message
'----------------------------------------------------------
*/
function resetorgfun()
{
	//alert('welcome');
	document.getElementById("orgtypname").value="";
	document.getElementById("orgtypname").focus();
}
/*
' Script Functions
'---------------------------------------------------------
'   Lang               : JavaScript  
'   Function Name      : closeorgfun
'   Action             : Close the organization type
'   @param             : -
'   @return            : Alert message
'----------------------------------------------------------
*/
function closeorgfun()
{
	//alert('welcome');
	document.getElementById("orgtypname").value="";
	document.getElementById("subcattype").style.display="none";
	document.getElementById("subcat").style.display="inline";
}

/*
' Script Functions
'---------------------------------------------------------
'   Lang               : JavaScript  
'   Function Name      : closethkfun
'   Action             : Close the organization type
'   @param             : -
'   @return            : Alert message
'----------------------------------------------------------
*/
function closethkfun()
{
	//alert('welcome');
	document.getElementById("showmsg").style.display="none";
	document.getElementById("subcat").style.display="inline";
}

var req;
var doesNotSupport = true;
function ListSomthing(url,arg1,arg2)
{	
	if (window.XMLHttpRequest) {
        	req = new XMLHttpRequest;
    	} else if (window.ActiveXObject) {
        	req = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	if (req) {
			//alert(url);
			req.open("POST",url, true);
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			var postvalues="";
			if(arg2=="addorg"){
				postvalues="orgcatid="+document.getElementById("txtText1").value+"&subcatname="+arg1+"&username="+document.getElementById("user_name").value;
				req.send(postvalues);
				req.onreadystatechange = processReqChange;
			}	

    	} else {
       		alert("Please use latest version of the current browser to function properly");
       		doesNotSupport = false;
    	}
}

function processReqChange(){
	if (req.readyState == 4) {
	   	if (req.status == 200) {
			//alert(req.responseText);
			if(req.responseText==0){
				alert('The suggested sub category is already exists'); 
				document.getElementById("orgtypname").value='';
				document.getElementById("orgtypname").focus();
			}
		    else{
				document.getElementById("orgtypname").value="";
				document.getElementById("subcattype").style.display="none";
				document.getElementById("showmsg").style.display="inline";
			}
		}
	}
}
