// JavaScript Document
ie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
firefox = ((navigator.appName == "Mozilla"));
safari=((navigator.appName == "Netscape"));
function checkDealerForm(theForm) {
	var problem=false;

	if (checkBlank(theForm.name.value)==false) {
		toggle('errName');
		problem=true;
	}
	if (checkBlank(theForm.businessName.value)==false) {
		toggle('errBusiness');
		problem=true;
	}
	if (checkBlank(theForm.location.value)==false) {
		toggle('errLocation');
	problem=true;
	}	
	if (checkBlank(theForm.tel.value)==false) {
		toggle('errTel');
	problem=true;
	}	
	if (checkBlank(theForm.email.value)==false) {
		toggle('errEmail1');
		problem=true;
	}	else {
		if(checkEmail(theForm.email.value)==false) {
			toggle('errEmail2');
			problem=true;
		}
	}
	
	if (checkBlank(theForm.activity.value)==false) {
		toggle('errActivity');
	problem=true;
	}		
	if (problem==true) {
		return false;
	} else {
			return true;
	}
}
function resetDealer() {
	toggleOff('errName');
	toggleOff('errBusiness');
	toggleOff('errLocation');
	toggleOff('errTel');
	toggleOff('errEmail1');
	toggleOff('errEmail2');
	toggleOff('errActivity');
}

function checkBlank(theField) {
	if ((theField.length==0) || (theField==null)) {
	  return false;
	} 
}
function checkEmail(email) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(email)) {
		return true;
	} else{
		return false;
	}
}
function toggleOff(targetId) {
  if (ie4){
  		target = document.all( targetId );
  			if (target.style.display == ""){
  				target.style.display = "none";
  			}
  	} else {
		target = document.getElementById(targetId);
  			if (target.style.display == ""){
  				target.style.display = "none";
  			}
	}		
}

function toggle( targetId ){
  if (ie4){
  		target = document.all( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	} else {
		target = document.getElementById(targetId);
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
	}		
}