function checkform ( form )
{
  // see http://www.thesitewizard.com/archive/validation.shtml
  // for an explanation of this script and how to use it on your
  // own website

  // ** START **
  var status = false;

  if (form.nomis.value == ""){
    alert( "Please enter your name." );
    form.nomis.focus();
    return false ;
  }

  if (form.phone.value == "" && form.email.value == ""){
    alert( "Please enter at least an email address or a phone number." );
    form.email.focus();
    return false;
  }



  /*if (form.email.value == "" ) {
    alert( "Please enter your email address." );
    form.email.focus();
    return false ;
  }else{
*/
/*
Here is the breakdown of the regex:

^ = Matches the beginning of the string.

[A-Z0-9._%+-] = Bracket expression that will match any letter(A-Z), any number (0-9), dot (.), underscore (_), percent sign (%), plus(+), and minus (-).

+ = This will match the preceding element, in this case the bracket expression, 1 or more times. In summary the bracket expression with the (+) will match a person’s email alias.

@ = Match the (@) symbol in the email address.
[A-Z0-9.-] = Bracket expression that will match any letter(A-Z), any number (0-9), dot (.), and minus (-).

+ = This will match the preceding element, in this case the bracket expression, 1 or more times.

\. = The dot (.) in this case is matched and it is escaped with the backslash (\) because the dot by itself is used to match any single character when used in a regex (when it is outside of a bracket expression).

[A-Z] = Bracket expression that will match any letter(A-Z).

{2,4} = Matches the preceding element at least 2 times and not more than 4 times. In summary the bracket expression with the ({2,4}) will match the top-level domain name such as com, net, or info.
*/

     var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (form.email.value != "" && form.email.value.search(emailRegEx) == -1) {
        alert("Please enter a valid email address.");
	form.email.focus();
	return false;
     }
  //}

  if (form.message.value == ""){
    alert( "Please enter your message." );
    form.message.focus();
    return false ;
  }

 // finally do the captcha check...
// see http://www.archreality.com/contact
  if (jcap()){
    return true;
  }else{
   return false;
  }
  // ** END **
  return true ;
}

function clearInputValue(aControl){
	aControl.value="";
}

function checkEmailAddress(aControl){
}

function popupopen(mylink, windowname)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	href=mylink;
	else
	href=mylink.href;
	m_popupwindow=window.open(href, windowname, 'width=800,height=600,fullscreen,resizable=yes,scrollbars=yes');
	return false;
}

function InsertByTag(tagid, htmltoinsert) {
/*p id='para'>
	Welcome to the site <b id='browseroutput'>dude</b>
</p> 
 <input type="button" onclick="javascript:return InsertByTag('browseroutput','<b>test</b>')" value="Change Text"/>
*/

	var x=document.getElementById(tagid);
	x.innerHTML=htmltoinsert;
	return true;
}


function showbrowser(tagId){

try {
	var html='nav='+navigator.appName + '<br/>';
	var agent=navigator.userAgent.toLowerCase();	
	var is_iphone =  (agent.indexOf('iphone')!=-1);
	if (is_iphone) {
	  html+='you are using an IPhone<br/>';
	}

	html=html+'browser codename=' + navigator.appCodeName + '<br/>';
	html=html+'browser=' + navigator.appName + '<br/>';
	html=html+'version=' + navigator.appVersion+ '<br/>';


	html=html+'cookies enabled=' + navigator.cookieEnabled + '<br/>';
	html=html+'default lang=' + navigator.language + '<br/>';

	var arLen=navigator.mimeTypes.length;
	for ( var i=0, len=arLen; i<len; ++i ){
		html=html+'MimeType='+navigator.mimeTypes[i].type+'<br/>';
	}
	
	html=html+'platform='+navigator.platform+'<br/>';

	arLen=navigator.plugins.length;
	for ( var j=0, len=arLen; j<len; ++j ){
		html=html+'PlugIn name='+navigator.plugins[j].name + ' type=' + navigator.plugins[j].type +'<br/>';
	}
	
	html=html+'os lang=' + navigator.systemLanguage + '<br/>';
	html=html+'useragent=' + navigator.userAgent + '<br/>';
	html=html+'userlang=' + navigator.userLanguage + '<br/>';

	InsertByTag(tagId,html);
  } catch (e) {
	alert("Oops!@* Tell Mark something when wrong using this page\nException:" + e.name +" Message:" + e.message);
	return false;
  }

  return true;
}
/*	
	

	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
	var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	if (ffversion>=3)
	document.write("You're using FF 3.x or above")
	else if (ffversion>=2)
	document.write("You're using FF 2.x")
	else if (ffversion>=1)
	document.write("You're using FF 1.x")
	}
	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	if (ieversion>=8)
	document.write("You're using IE8 or above")
	else if (ieversion>=7)
	document.write("You're using IE7.x")
	else if (ieversion>=6)
	document.write("You're using IE6.x")
	else if (ieversion>=5)
	document.write("You're using IE5.x")
	}
	
	if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);
	var oprversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	if (oprversion>=10)
	document.write("You're using Opera 10.x or above")
	else if (oprversion>=9)
	document.write("You're using Opera 9.x")
	else if (oprversion>=8)
	document.write("You're using Opera 8.x")
	else if (oprversion>=7)
	document.write("You're using Opera 7.x")
	else
	document.write("n/a")
	}
	
	return true;
}
*/
