                 		
		function checkemail(){
			var testresults;			
			var str=document.charting_form.email.value;
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (filter.test(str))
				testresults=true
			else				
				testresults=false				
			return (testresults)			
			}
			
			
			 function ValidateForm(){
                	
                	//now verify the form fields               	
			                                                
                        //make sure that the email field is not blank.
                        if (document.charting_form.email.value.length == 0)  {
                                //it isn't so show the user an alert and go to that field
                                alert ("Please enter your email");
                                document.charting_form.email.focus();
                                //and return false so the form doesn't get submitted
                                
                                return false;
                        }
                        
                        //make sure the email address is formatted properly
                        if (checkemail()==false)
                        {
                        	alert ("Please check your email address, it is not valid");
                        	document.charting_form.email.focus();
                        	//and return false so the form doesn't get submitted
                                
                                return false;
                        }
                        
                         //make sure that the account has been entered, and it must be 8 digits
			                   if (document.charting_form.account.value.length < 8)  {
				                 //it isn't so show the user an alert and go to that field
				                 		alert ("Please enter your 8 digit account number");
														document.charting_form.account.focus();
														//and return false so the form doesn't get submitted

														return false;
												}
                        
                        //everything checks out, submit the form
                        return true;
                }


function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}

function displayItem(key){
if(queryString(key)=='false') 
{
document.write("you didn't enter a ?name=value querystring item.");
}else{
document.write(queryString(key));
}
}

if (queryString('brand') != 'false')
{
	document.charting_form.brand.value = queryString('brand')	
}

