
function testem() {

    if(document.getElementById('vname').value == "") {
  document.getElementById('vname').style.background = "#CCCCCC";
    alert('You must provide your name');
    return false;           
   }  
   
  
    if(document.getElementById('vsurname').value == "") {
  document.getElementById('vsurname').style.background = "#CCCCCC";
    alert('You must provide your surname');
    return false;           
   } 
   
  
     if(document.getElementById('vcompname').value == "") {
  document.getElementById('vcompname').style.background = "#CCCCCC";
    alert('You must must provide your company name');
    return false;          
   } 

   
    if(document.getElementById('vadd1').value == "") {
  document.getElementById('vadd1').style.background = "#CCCCCC";
    alert('You must must provide your address');
    return false;          
   }
   
   
      if(document.getElementById('vtown').value == "") {
  document.getElementById('vtown').style.background = "#CCCCCC";
    alert('You must must provide your town');
    return false;          
   }
 
 
    if(document.getElementById('vpstcode').value == "") {
  document.getElementById('vpstcode').style.background = "#CCCCCC";
    alert('You must must provide your post code');
    return false;          
   }  
   

       if(document.getElementById('vcountry').value == "") {
  document.getElementById('vcountry').style.background = "#CCCCCC";
    alert('You must must indicate your country');
    return false;          
   }  


      if(document.getElementById('vtel1').value == "") {
  document.getElementById('vtel1').style.background = "#CCCCCC";
    alert('You must supply a contact number');
    return false; 
   }    

 
    if(document.getElementById('vemail').value == 'yourname@yourdomain.com') {
 document.getElementById('vemail').style.background = "#CCCCCC";
         alert('You need to type your email address into the text box');
           return false;
        }   
  // check add format
     var act = chk(document.getElementById('vemail').value);
     if(act != true) {  
          document.getElementById('vemail').style.background = "#CCCCCC";
         alert('You need to type your email address into the text box');
           return false;
       }
        
   
  if(document.getElementById('venqtype').value == "0") {
  document.getElementById('venqtype').style.background = "#CCCCCC";
    alert('You must make a selection from the menu');
    return false;
   }       
  
  
  if(document.getElementById('vtperiod').value == "0") {
    document.getElementById('vtperiod').style.background = "#CCCCCC";
    alert('You must make a selection from the menu');
         return false;
    }
 
  
  if(document.getElementById('vreferer').value == "") {
    document.getElementById('vreferer').style.background = "#CCCCCC";
    alert('Please indicate where you heard about Bite!');
         return false;
    }
    
   
  if(document.getElementById('vcurrsw').value == "0") {
    document.getElementById('vcurrsw').style.background = "#CCCCCC";
    alert('You must make a selection from the menu');
         return false;
    }
 
   
    if (document.getElementById('vcurrsw').value=="Other" )   {
 if (document.getElementById('vswhistoryother').value < 5 )   { 
 alert("You must enter an alternative description of the SW you use!");
  document.getElementById('vswhistoryother').style.background = "#CCCCCC";
 return false;
}
}
    
      
  if(document.getElementById('vnumsystms').value == "0") {
    document.getElementById('vnumsystms').style.background = "#CCCCCC";
    alert('You must make a selection from the menu');
         return false;
    }  
    

    if(document.getElementById('vmsg').value == "enter your text here") {
    document.getElementById('vmsg').style.background = "silver";
      alert('Please provide some indication of what you would like to know!');
         return false;
    }
 
 
  if(document.getElementById('vmsg').value == "") {
    document.getElementById('vmsg').style.background = "silver";
      alert('Please provide some indication of what you would like to know!');
         return false;
    }
   
document.mailfrm.action = "mail_form_exec.asp";
document.mailfrm.submit();
} 


function chk(str){
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
    var reg1 = new RegExp(reg1str);
    var reg2 = new RegExp(reg2str);
    if (!reg1.test(str) && reg2.test(str)) {
      return true;
    }

    return false;
  }
    if(str.indexOf("@") >= 0){
         return true;
    
 } 
 }


 function checkswhistory(f) {	
if (f=="Other")	{
	document.getElementById('div_vswhistoryothertable').style.display="block";
	//show(true,'div_vswhistory')
	//show(true,'div_vswhistorytxt')
  pointout("vswhistoryother");  
	} 	else	{
	document.getElementById('div_vswhistoryothertable').style.display="none";
	//show(false,'div_vswhistory')
	//show(false,'div_vswhistorytxt')
		} 
} 

function checkpostcode(a) {	
		if (document.getElementById('vpstcode').value !="")	{
	var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-Z]{2}/i;	
/* tests to see if string is in correct UK style postcode: AL1 1AB, BM1 5YZ etc. */
	if (postcodeRegEx.test(a)) {
/*	formats a VALID postcode nicely: AB120XY -> AB1 0XY */
		var postcodeRegEx = /(^[A-Z]{1,2}[0-9]{1,2})([0-9][A-Z]{2}$)/i;
		cleaned = a.replace(postcodeRegEx,"$1 $2");
		document.getElementById('vpstcode').value = cleaned;
		setwhite("vpstcode");
		document.getElementById('div_postcodetable').style.display="none";
		return false;
	} else {
		
		if (document.getElementById('nonuk').checked){
			//alert("Non UK post code!");
			} else {
			alert("invalid UK post code!");
			document.getElementById('div_postcodetable').style.display="block";
			show(true,'div_postcodetxt')
			show(true,'div_postcodevalue')
		 document.getElementById('vpstcode').style.background = "#CCCCCC";
		return false;
			}
	}	
		} 
}


function pointout(p)
{
document.getElementById(p).style.background = "#B0C4DE";
document.getElementById(p).focus();
return false;
}

function setwhite(q){
	if (document.getElementById(q).value !="")	{
   document.getElementById(q).style.background = "white";
	} 
}

// quick browser tests
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

function show(sw,obj) {
	// show/hide the divisions
	//show(true,'div3')
	//show(false,'div3')
	if (sw && (ie4 || ie5) ) document.getElementById(obj).style.visibility = 'visible';
	if (!sw && (ie4 || ie5) ) document.getElementById(obj).style.visibility = 'hidden';
	if (sw && ns4) document.layers[obj].visibility = 'visible';
	if (!sw && ns4) document.layers[obj].visibility = 'hidden';
}


function togglea() {
tags = document.getElementsByTagName('tr');
for (i = 0; i < tags.length; i++) {
if (tags[i].attributes.id.value.substr(0,3) == 'div') {
tags[i].style.display = (tags[i].style.display == "none")?"":"none"; // show or hide it
}
}
}


function toggleb(obj){
var objId = document.getElementById(obj);
objId.style.display = (objId.style.display == "none")?"":"none"; // show or hide it
}



