function passvalue()
{
document.enterdata.form_completed.value = document.enterdata.person_name.value+" "+document.enterdata.person_name_last.value;
}

function validate() {
	postcode = document.editdata.xipostcode.value;
	email = document.editdata.xiemail.value;
	pname = document.editdata.xiperson_name.value;
	fax = document.editdata.xifax.value;
	phone = document.editdata.xiphone.value;
	compdir = document.editdata.xicompany_director.value;
	staff = document.editdata.xinumber_staff.value;
	url = document.editdata.xiurl.value;
	
	
	
	
	
	
	if (!((postcode == "") || (postcode.match(/^\s*[ \t]*$/)))) {
		if (!(postcode.match(/^[\s0-9][0-9][0-9][0-9]$/))) {
			alert ("Please enter a valid post code!");
			return false;
		}
	}
	if (!((email == "") || (email.match(/^\s*[ \t]*$/)))) {
	if (!(email.match(/^[\s]{0,2}[a-zA-Z_]*[\.]*[a-zA-Z0-9_]*@[a-zA-Z0-9_-]*[\.][\.a-zA-Z0-9_-]*$/))) {
			alert ("Please enter a vaid email address! Eg: abc@someplace.com");
			return false;
		} 
	}
	if (!((pname == "") || (pname.match(/^\s*[\t]*$/)))) {
		if  (!(pname.match(/^[A-Za-z\s][A-Za-z\s]*[A-Za-z\s]$/))) {	
			alert ("Please enter a valid person name!");
			return false;
		}
	}
	if (!((fax == "") || (fax.match(/^\s*[ \t]*$/)))) {
		if (!(fax.match(/^[\(\s][0-9][0-9]\)\s[0-9]{8}\s*$/))) {
			alert ("Please enter a valid fax number! Eg: (03) 98564756");
			return false;
		}
	}
	if (!((phone == "") || (phone.match(/^\s*[ \t]*$/)))) {
		if (!((phone.match(/^[\(\s][0-9][0-9]\)\s[0-9]{8}\s*$/)) || (phone.match(/^[\s0-9][0-9][0-9][0-9]\s[0-9]{6}$/)))) {
			alert ("Please enter a valid phone number! Eg: (03) 98564756 or 0411 788997");
			return false;
		}
	}
	if (!((compdir == "") || (compdir.match(/^\s*[ \t]*$/)))) {
		if (!(compdir.match(/^[a-zA-Z\.\s]*$/))) {
			alert ("Please enter a valid company director name!");
			return false;
		}
	}
	if (!((staff == "") || (staff.match(/^\s*[ \t]*$/)))) {

		if (!((staff.match(/^[0-9][-0-9][0-9]$/)) || (staff.match(/^[0-9]*/)))) {
			alert ("Number of staff is invalid!");
			return false;
		}
		}
	if (!((url == "") || (url.match(/^\s*[ \t]*$/)))) {
		if (!(url.match(/^http:\/\/www.[\.a-zA-Z0-9]*\.[a-z]{2,3}$/))) {
			alert ("Please enter a valid URL! Eg: http://www.abc.com");
			return false;
		}
	}
	
	
  }



function checkform()
{
	form_completed= document.enterdata.form_completed.value;
	company_director= document.enterdata.company_director.value;
	person_name= document.enterdata.person_name.value;
	number_staff = document.enterdata.number_staff.value;
	
	//patch allows to bypass validation if we enter exateam for names and 10000 for number of staff
	if(form_completed != "exateam exateam" && form_completed == "")
	{
	alert("Please enter the name of the person who has completed the form");
	return false;
	}
	
	
	
	if(company_director != "exateam" && company_director == "")
	{
	alert("Please enter the Director's name");
	return false;
	}
	
	
	
	if(number_staff == "" && number_staff != 10000)
	{
		
	alert("Please enter the number of staff");
	return false;
	}
	
	

/*if(document.enterdata.datei.value != "")
{
		
	 var im,filesize;
	 
	 im = new Image();
     im.src = document.enterdata.datei.value;
	 alert("checking filesize...");
	 //alert(im.src);
	 alert("Image size: " + im.fileSize);
     filesize = im.fileSize;
	 if(filesize > 16384){
		 
		  alert("File uploaded should be less than 16KB");
		  document.enterdata.datei.focus();
	      return false;
		 
	 }
	 else{
		 alert("File size OK")
	 }
	 
	if(document.enterdata.datei.value.indexOf('.jp')==-1)
	{
		alert ("Images with .jpeg or .jpg extension can only be uploaded  ");
		document.enterdata.datei.focus();
		return false;
	}
		
	
}*/


if (document.enterdata.name.value =="")
{
alert ("Please Enter a Company Name!");
document.enterdata.name.focus();
return false;
}

if (document.enterdata.name.value.length <2)
{
alert ("Name need min. 2 letters!");
document.enterdata.name.focus();
return false;
}


i/*f(document.enterdata.datei.value != "")
{
		
	 var im,fileSize;
	 im = new Image();
     im.src = document.enterdata.datei.value;
	 alert("checking filesize...");
	 //alert(im.src);
	 alert("Image size: " + im.fileSize);
     filesize = im.fileSize;
	 if(filesize > 16384){
		 
		  alert("File uploaded should be less than 16KB");
		  document.enterdata.datei.focus();
	      return false;
		 
	 }
	 else{
		 alert("File size OK")
	 }
	 
	if(document.enterdata.datei.value.indexOf('.jp')==-1)
	{
		alert ("Images with .jpeg or .jpg extension can only be uploaded  ");
		document.enterdata.datei.focus();
		return false;
	}
		
	
}*/

/*if(document.enterdata.datei.value != "")
{
	 var im;
	 im = new Image();
     im.src = document.enterdata.datei.value;
	 alert(im.src);
	 alert("Image size: " + im.fileSize);
	 if(im.fileSize > 16384){
		 
		  alert("File uploaded should be less than 16KB");
		  document.enterdata.datei.focus();
	      return false;
		 
	 }

	
}*/
if (document.enterdata.url.value !="")
{
	if (document.enterdata.url.value =="http://www.")
	{
	alert ("Please enter a URL or delete the Field!");
	document.enterdata.url.focus();
	return false;
	}

	if (document.enterdata.url.value.length < 7)
	{
	alert ("Please enter a URL or delete the Field! A valid URL have to start with http://");
	document.enterdata.url.focus();
	return false;
	}

	if (document.enterdata.url.value.indexOf('http://')==-1)
	{
	alert ("Please enter a URL or delete the Field! A valid URL have to start with http://");
	document.enterdata.url.focus();
	return false;
	}
}

if (document.enterdata.email.value !="")
{
	if (document.enterdata.email.value.indexOf('@')==-1 || document.enterdata.email.value.indexOf('.')==-1)
	{
	alert ("Please enter a valid email address! exp. info@exa.com.au");
	document.enterdata.email.focus();
	return false;
	}
}

if (document.enterdata.phone.value !="")
{
   if (document.enterdata.phone.value =="(03) " || document.enterdata.phone.value =="(03)" || document.enterdata.phone.value.length < 5 ) 
    {
      alert ("Please enter a valid Phonenumber or remove all letters from the field! 'exp. (03) 99236688' or nothing!")
	  document.enterdata.phone.focus();
	  return false;
	}
}

if (document.enterdata.fax.value !="")
{
   if (document.enterdata.fax.value =="(03) " || document.enterdata.fax.value =="(03)" || document.enterdata.fax.value.length < 5 ) 
    {
      alert ("Please enter a valid Faxnumber or remove all letters from the field! 'exp. (03) 99236688' or nothing!")
	  document.enterdata.phone.focus();
	  return false;
	}
}

if (document.enterdata.classification.value =='')
{
	alert ("Please select an appropriate category for your business!" );   
	document.enterdata.classification.focus();
	return false;
}

if (document.enterdata.consultant.value =='')
{
alert ("Please choice an Consultant! When a new Consultant has make this job, please insert the first with phpMySql or edit later only the Consultant with phpMyAdmin!" );   
document.enterdata.classification.focus();
return false;
}
if (document.enterdata.chk1.checked == false)
{
	alert ("Please check the agreement tickbox!" );   	
	document.enterdata.classification.focus();
	return false;	
}
}

function helpurl()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpurl","keywords","width=400,height=200,left=0,top=0");
}
function helpemail()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpemail","keywords","width=400,height=200,left=0,top=0");
}
function helpaddress_line1()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpaddress_line1","keywords","width=400,height=200,left=0,top=0");
}
function helpaddress_line2()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpaddress_line2","keywords","width=400,height=200,left=0,top=0");
}
function helpsuburb()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpsuburb","keywords","width=400,height=200,left=0,top=0");
}
function helppostcode()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helppostcode","keywords","width=400,height=200,left=0,top=0");
}
function helpform_completed()
{
	help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpformcompleted","keywords","width=400,height=200,left=0,top=0");
	
}

function helpstate()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpstate","keywords","width=400,height=200,left=0,top=0");
}
function helpphone()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpphone","keywords","width=400,height=200,left=0,top=0");
}
function helpfax()
{
help = window.open("adminx/php_templates/help.php?cmd=helpphone","keywords","width=400,height=200,left=0,top=0");
}
function helpcat()
{
help = window.open("adminx/php_templates/help.php?cmd=helpcat","keywords","width=400,height=200,left=0,top=0");
}
function helpimg()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpimg","keywords","width=400,height=200,left=0,top=0");
}
function helpkeywords()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpkeywords","keywords","width=400,height=200,left=0,top=0");
}
function helpdirector()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpdirector","keywords","width=400,height=200,left=0,top=0");
}

function helpname_last()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpname_last","keywords","width=400,height=200,left=0,top=0");
}

function helppersonname()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpdirector","keywords","width=400,height=200,left=0,top=0");
}
function helpposition()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpposition","keywords","width=400,height=200,left=0,top=0");
}
function helpstaff()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpstaff","keywords","width=400,height=200,left=0,top=0");
}
function helpbrochureholder()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpbrochureholder","keywords","width=400,height=200,left=0,top=0");
}
function helpnrbrochureholder()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpnrbrochureholder","keywords","width=400,height=200,left=0,top=0");
}
function helpcomments()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpcomments","keywords","width=400,height=200,left=0,top=0");
}
function helpconsultant()
{
help = window.open("http://whatsinmelbourne.com.au/adminx/php_templates/help.php?cmd=helpconsultant","keywords","width=400,height=200,left=0,top=0");
}


function findcat()
{
 if(typeof findcat2 =="undefined" || false == findcat2.open) 
 {
    findcat2 = window.open("/adminx/php_templates/categorie.php","findcat","width=450, height=600, menubar=yes, resizable=yes, scrollbars=yes");
 }
 else
	findcat2.close ();
    findcat2 = window.open("/adminx/php_templates/categorie.php","findcat","width=450, height=600, menubar=yes, resizable=yes, scrollbars=yes");
}

function findcat1()
{
 if(typeof findcat2 =="undefined" || false == findcat2.open) 
 {
    findcat2 = window.open("category.php","findcat","width=450, height=600, menubar=yes, resizable=yes, scrollbars=yes");
 }
 else
	findcat2.close ();
    findcat2 = window.open("category.php","findcat","width=450, height=600, menubar=yes, resizable=yes, scrollbars=yes");
}


function getdata()
{
	if (typeof findcat2 =="undefined")
			{
				alert ("Please open the Categorie Window at first! Push the Search Button!"); 
				
			}
	
	
	else 	{
				//alert (findcat.categoriexx.copyradio.length);
					for (i=0; i<findcat2.categoriexx.copyradio.length; i++) 
					{
						if (findcat2.categoriexx.copyradio[i].checked) 
						{
						document.enterdata.classification.value = findcat2.categoriexx.copyradio[i].value;
						}
						
					}
				      			
			}
	
}
 
