
function validateValues(what) {

// validate myradiobuttons

  var myOption = 1;

  var radioNames = new Object();
  var selectNames= new Object();
  var contactNames=new Object();
  var firstCounter = 0;
  var secondCounter = 0;
  var thirdCounter = 0;
  	

  for (i=0; i<what.elements.length; i++) {
	var myType = what.elements[i].type;
	if(myType == 'radio'){	
		if(radioNames[what.elements[i].name])
		{
			//ok, already initialized
		}
		else
		{
			radioNames[what.elements[i].name]=-1;
		}
	    	if(what.elements[i].checked) {
	      		//ok
			radioNames[what.elements[i].name]=1;
	    	}
	}
        if(myType == 'select-one'){
                if(selectNames[what.elements[i].name])
                {
                        //ok, already initialized
                }
                else
                {
                        selectNames[what.elements[i].name]=-1;
                }
                if(
					(what.elements[i].value =='please.choose') 
					||
					(what.elements[i].value =='-please choose-') 
				){
                        ;
				}
				else
				{
                        selectNames[what.elements[i].name]=1;
						if(what.elements[i].value == 'first'){ firstCounter++;}
						if(what.elements[i].value == 'second'){ secondCounter++;}
						if(what.elements[i].value == 'third'){ thirdCounter++;}
                }
        }
        if(myType == 'text'){
                if(contactNames[what.elements[i].name])
                {
                        //ok,already initialized
                }
                else
                {
                        if(
                                (what.elements[i].name != 'address2')
								&&
								(what.elements[i].name != 'state_non_us')
                        )
                        {
                                contactNames[what.elements[i].name]=-1;
                        }
                }
                if(
                       (what.elements[i].name != 'address2')
					   &&
					   (what.elements[i].name != 'state_non_us')
                )
                {

                        if(what.elements[i].value =="") {
                                ;
                        }
                        else
                        {
                                contactNames[what.elements[i].name]=1;
                        }
                }
				if(what.elements[i].name == 'email')
				{
					var myString = what.elements[i].value;
					var inThere = myString.match(/@/g);
					if (inThere) {
 					  	// Yes, a match occurred.
					 	;
					}
					else {
  					 	// No match occurred.
						contactNames[what.elements[i].name]=-1;
					}

				}
        }

  }
  for (key in radioNames)
  {
    if( radioNames[key] == -1)
    {
  	myOption=-1;
    }
  }
  for (key in selectNames)
  {
    if( selectNames[key] == -1)
    {
        myOption=-1;
    }
  }
  for (key in contactNames)
  {
    if( contactNames[key] == -1)
    {
        myOption=-1;
    }
  }
  if(
  		(firstCounter != 1) || (secondCounter != 1) || (thirdCounter != 1)
   )
  {
  		alert("Please make a single choice for each of the top three rankings.");
		return false;
  }
  if (myOption == -1) {
    alert("Form has not been filled out completely.");
    return false;
  }
  else{
    return true;
  }	
}

