var expphone = /[^\d|\-|\+|\,]+/;
var expaddress = /[^\w|\s|\~|\!|\@|\#|\&|\(|\)|\_|\-|\+|\{|=|\[|\]|\:|\,|\.|\/]+/;	

var emailexp  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var expname = /[^\w|\s|\!|\=|\&|\$|\'|\?|\.|\/|\_|\)|\(|\[|\]|\:|\-]+/;
var expvarchar  =/[^\w|\s|\~|\!|\@|\#|\&|\(|\)|\{|\}|=|\[|\]|\:|\.|\'|\?|\/|\$|\*|\,|\-|\%]+/;
var explevelvarchar =/[\~|\!|\@|\_|\{|\}|=|\[|\]|\:|\"]+/;
var expValueDomain  =/[^\w|\s|\~|\!|\@|\#|\&|\(|\)|\{|\}|=|\[|\]|\:|\.|\'|\?|\/|\$|\*|\,|\-|\%]+/;

var expMassage = '(\",%,;,~,@,#,%,^,*,{}\)';
var expVDomainMassage = '(\",~,^,{,}\)';

// Function to Validate the Add Address Details
/*function validate()
{	
	var address;
	address=document.form1.txtAddress.value.replace(/ /g,"");
	if (address=="")	
	{
		alert("Please enter the Address");
		document.form1.txtAddress.focus();
		return false;
	}
	else 
	if (address!="") 
	{
	   	if(document.form1.txtAddress.value.length>1000)
		{
			alert("Address can only be 1000 characters long")
			document.form1.txtAddress.focus();
			return false;
		}
	}	
			
	var city;
	city=document.form1.txtCity.value.replace(/ /g,"");
	if (city=='')
	{	
		alert("Please enter the City");
		document.form1.txtCity.focus();
		return false;
	} 
	if (city!="")
	{
		if(expvarchar.test(city)==true)
		{
			alert("Special characters like (\",%,;,~,@,#,%,^,*,{}\) are not allowed in City.");
			document.form1.txtCity.focus();
			return false;	
		}		
    }
	var zip;
	zip=document.form1.txtZipcode.value.replace(/ /g,"");
	if (zip=='')
	{	
		alert("Please enter the Zipcode");
		document.form1.txtZipcode.focus();
		return false;
	} 	
	if (zip!='')
	{
		if(expvarchar.test(zip)==true)
		{
			alert("Special characters like (\",%,;,~,@,#,%,^,*,{}\) are not allowed in Pin / Zip Code.");
			document.form1.txtZipcode.focus();
			return false;	
		}			
	}	
	var state;
	state=document.form1.txtState.value.replace(/ /g,"");
	if (state=='')
	{	
		alert("Please enter the State / Province ");
		document.form1.txtState.focus();
		return false;
	} 
	if (state!='')
	{
		if(expvarchar.test(state)==true)
		{
			alert("Special characters like (\",%,;,~,@,#,%,^,*,{}\) are not allowed in State / Province .");
			document.form1.txtState.focus();
			return false;	
		}			
	}		
	var country;
	country=document.form1.txtCountry.value.replace(/ /g,"");
	if (country=='')
	{	
		alert("Please enter the Country");
		document.form1.txtCountry.focus();
		return false;
	} 
	if (country!='')
	{	
		if(expvarchar.test(country)==true)
		{
			alert("Special characters like (\",%,;,~,@,#,%,^,*,{}\) are not allowed in Country.");
			document.form1.txtCountry.focus();
			return false;	
		}	
	}
	var phone;
	phone = document.form1.txtPhone.value.replace(/ /g,'');
	if (phone != '')
	{
		if(expvarchar.test(phone)==true)
		{
		//	alert('Phone can contain only "0-9" and "- , + ( )" character(s)')
			alert("Special characters like (\",%,;,~,@,#,%,^,*,{}\) are not allowed in Phone.");
			document.form1.txtPhone.focus();
			return false;	
		}	
	}
	var fax;
	fax = document.form1.txtFax.value.replace(/ /g,'');
	if (fax != '')
	{
		if(expvarchar.test(fax)==true)
		{
		//	alert('Fax can contain only "0-9" and "- , + ( )" character(s)');
			alert("Special characters like (\",%,;,~,@,#,%,^,*,{}\) are not allowed in Fax.");
			document.form1.txtFax.focus();
			return false;
		}
	}	
	var emailAdd;
	emailAdd = document.form1.txtEmailID.value.replace(/ /g,"");
	if (emailAdd == "")
	{
		alert("Please enter the Email ID");
		document.form1.txtEmailID.focus();
		return false;
	} 	
	if (emailAdd != "")
	{
		if(emailexp.test(emailAdd)== false)	
		{
		alert("Invalid Email ID! Please re-enter.\n e.g. admin@business-asia.net");
		document.form1.txtEmailID.select();
		return false;
		}			
	}	
	
	var url = document.form1.txtWebsite.value.replace(/ /g,"");
	var urlexp = /http:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/; 
	if (url!=="")
	{
		if (urlexp.test(url)==false)		
		{
			alert ("Invalid Website ! Please re-enter.\n e.g. http://www.business-asia.net"); 
			document.form1.txtWebsite.focus(); 
			return false;
		}
	}	
}*/
//Function to Check the Characters length of the TextArea Fields
function checkCharLength(strObj,strName,maxlen)
{
	strTestObj = "document.form1."+strObj 
	if (eval(strTestObj+".value.length")>maxlen)
	{
	  eval(strTestObj+".value="+strTestObj+".value.substring(0,"+maxlen+")");
	  alert(strName+" can only be "+ maxlen +" characters long");
	}
}

//Function To alown the Attachments like .pdf or .zip
function isOnlyFIle(obj,msg)
{
	var nam = obj.value;
	//nam = nam.trim();
	
	var arr=new Array();
	arr=obj.value.split('.');
	if(arr[arr.length-1].toUpperCase() != "PDF" && arr[arr.length-1].toUpperCase()!="ZIP" )		
	{
		alert(msg);
		obj.focus();
		return 0;
	}			

} 

	
//Function To Limit the Attachments like .doc or .xls or .txt
function LimitAttach(form,file,fileext)
{
	 var strExt = new String();
		 strExt = fileext;	 
	   extArray = strExt.split(",")	 
	var allowSubmit = false;
	if (!file) return;
		while (file.indexOf("\\") != -1)
			file = file.slice(file.indexOf("\\") + 1);
		
		ext  = file.slice(file.indexOf(".")).toLowerCase();
			
			
			for (var i = 0; i < extArray.length; i++)
			{	
				if (extArray[i] == ext) { allowSubmit = true; break; }
			}			
			if (allowSubmit) 
			{
				return true;
			}					
			else
			{
				alert("Only (" + (extArray.join("  ")) + ") files are allowed to upload," +
				"\nPlease select a new "
				+ "file and upload again.");				
				return false;
			} 
}
