if(typeof(workformID)=="undefined")workformID="myForm";


	function submitAttach()
	{
		//workform.target="fileuploaderframe";
		var workform=document.forms[workformID];
		var filenamevalue=workform.AttachFile.value;
		if(filenamevalue==""){alert("Please Attach a File."); return false;}		
		var  ext=filenamevalue.substr(filenamevalue.lastIndexOf(".")).toLowerCase();
		
		
		var extarraystr="";
		var extallowed_flag=false;
		
		for(var k=0;k<extarray.length;k++)
		{
			extarraystr=extarraystr+extarray[k]+", ";
			if(extarray[k]==ext)
			{
				extallowed_flag=true;
			}
		}
		if(extallowed_flag){}
		else
		{
			alert("Files with "+extarraystr+" extensions only are allowed.");
			return false;
		}
		
		workform.enctype="multipart/form-data";
		workform.action=roottocm+"controller/cmcontroller/externalenquiry.php?reqPage=uploadfile";
		AIM.submit(workform, {'onStart' : startCallback, 'onComplete' : completeCallback});
		workform.submit();
		//completeCallback();
	}
	function startCallback() {
		return true;
	}
	
	function completeCallback(response)
	 {
		document.getElementById("uploadedfilesdiv").innerHTML=response;
	}
	function ValidateForm()
		{
			var workform=document.forms[workformID];
			if(workform.firstname.value=="" && workform.firstname){
					alert("Enter FirstName.");
					workform.firstname.focus();
					return false;
			}			
			if(workform.lastname.value==""){
					alert("Enter LastName.");
					workform.lastname.focus();
					return false;
			}
			if(workform.designation.value==0){
					alert("Enter Designation.");
					workform.designation.focus();
					return false;
			}
			if(workform.companyname.value==0){
					alert("Enter Company Name.");
					workform.companyname.focus();
					return false;
			}
			if(workform.industrysegment.value==0){
					alert("Enter Industry.");
					workform.industrysegment.focus();
					return false;
			}
			if(workform.email.value==""){
					alert("Enter EMail ID.");
					workform.email.focus();
					return false;
			}
			if(isValidEmail(workform.email.value)==false){					
					workform.email.focus();
					return false;
			}
			if(workform.phoneno.value==""){
					alert("Enter TelephoneNo.");
					workform.phoneno.focus();
					return false;
			}			
			if(isValidTelephoneNumber(workform.phoneno)==false){
					workform.phoneno.focus();
					return false;
			}
			/*	if(workform.mobileno.value!=""){					
					if(isValidTelephoneNumber(workform.mobileno)==false){
							workform.mobileno.focus();	
							return false;						
					}						
			}
			if(workform.country.value==0){
					alert("Enter Country.");
					workform.country.focus();
					return false;
			}	
			if(workform.InterestedIn.value==""){
					alert("Enter Interested In.");
					workform.InterestedIn.focus();
					return false;
			}			
			if(workform.knowusthro.value==0){
					alert("Enter how you came to know about AdsStation.Biz");
					workform.knowusthro.focus();
					return false;
			}	 */		
			if(workform.designation.value==""){
					alert("Enter Designation.");
					workform.designation.focus();
					return false;
			}
			if(workform.companyname.value==""){
					alert("Enter CompanyName.");
					workform.companyname.focus();
					return false;
			}	
		workform.target="_self";
		workform.action=roottocm+"controller/cmcontroller/externalenquiry.php?reqPage=extenquiry";
		workform.submit();
	}
	function deletefile(delfilename)
	{
		var workform=document.forms[workformID];
		document.getElementsByName("delfilename")[0].value=delfilename;
		workform.action=roottocm+"controller/cmcontroller/externalenquiry.php?reqPage=deletefile";
		AIM.submit(workform, {'onStart' : startCallback, 'onComplete' : completeCallback});
		workform.submit();
	}
	function enableothertextbox(elemname)
	{
		var elem=document.getElementsByName(elemname)[0];
		var otherelem=document.getElementsByName("other"+elemname)[0];
		
		if(elem.value.toLowerCase()=="other" || elem.value.toLowerCase()=="others")
		otherelem.style.display="";
		else
		otherelem.style.display="none";
	}
	function downloadfile(filename)
	{
		//var new_win=window.open(roottocm+"controller/cmcontroller/download_file.php?path="+filename,"downloadfilepopup","resizable=yes,scrollbars=yes,width=800,height=650");
		window.location.href=roottocm+"controller/cmcontroller/download_file.php?path="+filename;
	}
	function isValidEmail(fieldValue)
	{
	     var strEmail = fieldValue;
	     var bolValid = true;
	     if( strEmail.length < 7)
	     {
	          bolValid = false;
	     }
	     if(strEmail.lastIndexOf(" ") >0)
	     {
	          bolValid = false;
	     }
	     var intLastDot = strEmail.lastIndexOf(".")
	     if(intLastDot == -1 ||  strEmail.length - intLastDot >4)
	     {
	          bolValid = false;
	     }
	     var intAt = strEmail.lastIndexOf("@")
	     if(intAt == -1 ||  strEmail.length - intAt < 5)
	     {
	          bolValid = false;
	     }
	     if(!bolValid)
	     {
	          alert("Please enter a valid email address !");
	     }
	     return bolValid;
	}
	function isValidTelephoneNumber(field) 
	{
		var valid=" 0123456789-/+"

			for (var i=0; i<field.value.length; i++) {
				if (valid.indexOf(field.value.charAt(i)) < 0)
				 {
					 alert("Enter Valid Telephone Number.");
					return false
				}
			}
			return true
	}
	
	
	
