// JavaScript Document
frmName="frmregistration";
function fieldValidation()
{
		
	if(nullCheck(document.frmregistration.txtContactName.value)==false)
	{
		msg("frmregistration","Please enter contact name.","txtContactName",1);		
		return false;
	}
	else if(nullCheck(document.frmregistration.txtPosition.value)==false)
	{
		msg("frmregistration","Please enter job title.","txtPosition",1);
		return false;
	}
	else if(nullCheck(document.frmregistration.txtFirmName.value)==false)
	{
		msg("frmregistration","Please enter firm name.","txtFirmName",1);
		return false;
	}
	else if(isValidCharacter(document.frmregistration.txtFirmName.value)==false)
	{
		msg("frmregistration","Invalid entry.","txtFirmName",1);
		return false;
	}
	else if(nullCheck(document.frmregistration.txtTelephoneNumber.value)==false)
	{
		msg("frmregistration","Please enter phone no.","txtTelephoneNumber",1);
		return false;
	} 
	else if(phoneNoValidation(document.frmregistration.txtTelephoneNumber.value)==false)
	{
		msg("frmregistration","Invalid phone number.","txtTelephoneNumber",2);
		return false;
	}
	else if(nullCheck(document.frmregistration.txtFaxNumber.value)==false)
	{
		msg("frmregistration","Please enter fax no.","txtFaxNumber",1);
		return false;
	}
	else if(nullCheck(document.frmregistration.txtEmail.value)==false)
	{
		msg("frmregistration","Please enter email address.","txtEmail",1);
		return false;
	}
	else if(emailValidation(document.frmregistration.txtEmail.value)==false)
	{
		msg("frmregistration","Invalid email id.","txtEmail",2);
		return false;
	}
	else if(nullCheck(document.frmregistration.txtStreet.value)==false)
	{
		msg("frmregistration","Please enter street.","txtStreet",1);
		return false;
	}
	else if(nullCheck(document.frmregistration.txtCity.value)==false)
	{
		msg("frmregistration","Please enter town.","txtCity",1);
		return false;
	}			
	else if(nullCheck(document.frmregistration.txtDistrict.value)==false)
	{
		msg("frmregistration","Please enter district.","txtDistrict",1);
		return false;
	}	
	else if(nullCheck(document.frmregistration.txtZip.value)==false)
	{
		msg("frmregistration","Please enter zip.","txtZip",1);
		return false;
	}
	else if(document.frmregistration.cmbJurisdictionType.value=="0")
	{
		msg("frmregistration","Please select country.","cmbJurisdictionType",1);
		return false;
	}
	else if(document.frmregistration.cmbJurisdictionType.value=="4" && nullCheck(document.frmregistration.txtCountry.value)==false)
	{
		msg("frmregistration","Please enter Your country.","txtCountry",1);
		return false;
	}
	else if(document.frmregistration.cmbJurisdictionType.value=="0")
	{
		msg("frmregistration","Please select your country.","cmbJurisdictionType",1);
		return false;
	}		
	else if(nullCheck(document.frmregistration.txtAbout.value)==false)
	{
		msg("frmregistration","Please enter about.","txtAbout",1);
		return false;
	}
	else if(document.frmregistration.optTypeOfFirm[0].checked==false && document.frmregistration.optTypeOfFirm[1].checked==false && document.frmregistration.optTypeOfFirm[2].checked==false && document.frmregistration.optTypeOfFirm[3].checked==false)
	{
		alert("Please select type of firm.");
		return false;		
	}
	else if(document.frmregistration.optTypeOfFirm[3].checked && nullCheck(document.frmregistration.txtOptionOther.value)==false)
	{
		msg("frmregistration","If Other ,Pls enter other text box","txtOptionOther",1);
		return false;
	}
	else
	{
		document.frmregistration.action="registration_action.php";
		document.frmregistration.submit();
		
	}
}
function cmbcountryOnchange()
{
	 if(document.frmregistration.cmbJurisdictionType.value=='4')
	{
		
		document.frmregistration.txtCountry.disabled=false;
		document.frmregistration.txtCountry.focus();
		alert("Please enter country.");
		
	}
	else
	{
		document.frmregistration.txtCountry.value="";
		document.frmregistration.txtCountry.disabled=true;
	}
}
function setFocus()
{
	document.frmregistration.txtContactName.focus();
}
function functionOptionOther()
{
	for(o=0;o<document.frmregistration.optTypeOfFirm.length;o++)
	{
		if(document.frmregistration.optTypeOfFirm[o].checked && document.frmregistration.optTypeOfFirm[o].value=="4")
		{
			document.frmregistration.txtOptionOther.disabled=false;
			msg("frmregistration","If other,please enter other text box","txtOptionOther",1);		
			return false;
			break;
		}
		else
		{
			document.frmregistration.txtOptionOther.value="";
			document.frmregistration.txtOptionOther.disabled=true;
		}
	}
	
}


function isValidCharacter(val)
{
	var flag=0;
	var str ;
	
	str = val;
	var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	for (var i = 0; i < str.length; i++)
	{
		if (Chars.indexOf(str.charAt(i)) == -1)
		{
			flag=1;	          
		}
	}
	
	if(flag==1)
	{
		return false;
	}
	else
	{
		return true;
	}
}