function forceCategoryAndDescription(form) {
	var myForm = document.categoryForm;
	// Category
	var mySelectList = myForm.category;
	var mySelectedIndex= mySelectList.selectedIndex;
	chosenItem = mySelectList.options[mySelectedIndex].value;
	if(chosenItem == "*") {
		alert("Choose a category.");
		mySelectList.focus();
		return false;
	}
	if(chosenItem == "") {
		alert("Choose a category.");
		mySelectList.focus();
		return false;
	}
	// end of category check
	// Description
	if ( myForm.description.value.length <= 9 ) {
		alert("Make your description 10 characters or longer.");
		myForm.description.focus();
		return false;
	}
return true;
}
function isDefaultKey(form) {
	var myForm = window.document.premiumSearchForm;
	var matchFound = false;
	if(myForm.textToFind.value) { // if the user has entered something into the textToFind box
		while(matchFound != "true" ) { // as long as there are no matches
			for (var i = 0; i < myForm.primaryField.length ;i++ ) {
				if(myForm.primaryField[i].checked) {
					matchFound = "true";
				}else{
					matchFound = "false";
				}
			}			
		}	
	} // if a value has been entered
	if(matchFound == "false") {
		alert("You entered Text To Find.\nPlease choose a company or keyword search.");
		return false;
	}
return true;
}
function isKey(form) {
	var myForm = window.document.premiumSearchForm;
	for (var i = 0;i < myForm.primaryField.length ;i++ ) {
		return i;
	}
	if(myForm.primaryField[i].checked) {
				alert("There is a checked value");
				return false;
	}
return true;
}
// browser detection - load css file
function loadCSSFile() {
  	/* this script determines the user browser and loads an appropriate external cascading style sheet.
	   If the browser is an Internet Explorer browser then an IE compatible external css file is loaded.
	   If the browser is a Netscape browser then a Netscape compatible external css file is loaded.
	   If the browser is an Opera browser then an an Internet Explorer compatible external css file is loaded.
	   If the browser is anything else no css file is loaded.
	   You can add more browser types by adding another case and a related css file. Based on an analysis 
	   of website traffic most surfers use recent browser versions. You can add specific versioning if you want
	   but the traffic that will use it will be negligible.
	   Richard Creech info@dreamriver.com http://www.dreamriver.com
	*/
/*	var cssFileName = "";
	var browser = navigator.appName;
	switch(browser) {
		case "Microsoft Internet Explorer":
			cssFileName = "yellow.css";
			//cssFileName = "netscape.css";
			break;
		case "Netscape":
			cssFileName = "netscape.css";
			break;
		case "Opera":
			cssFileName = "yellow.css";		
			break;	
		default:
			/* if there is no switch(browser) match then no css file is loaded */
/*	}  */ 
	cssFileName = "yellow.css"; 
	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssFileName + "\">");
  }



// phpYellow javascript by Dreamriver.com
// Credit: This function by dreamriver.com
function validateLoginForm(form) {
	var myForm = document.loginForm;
	var admin = "DDB";
// Password
	if ( myForm.subpass.value.length < 1) {
		alert("You MUST enter a password.");
		myForm.subpass.focus();
		return false;
	}
	if ( myForm.subpass.value == admin ){
		return true;
	}

	if ( myForm.subpass.value != myForm.password.value ){
		alert("You entered the WRONG password. ");
		myForm.subpass.focus();
		return false;
	}
	//alert("This is before return true");
return true;
}
function test(form) {
	var myForm = document.loginForm;
		alert("You entered the WRONG password.");
		myForm.subpass.focus();
		return false;
		}

// VALIDATE THE STANDARD FORM used for insert and edit of contact listings
// Credit: This function by dreamriver.com
function validate(form) {

	var myForm = document.forms[0];

	// Email
	if ( myForm.email.value.length < 6) {
		alert("You MUST submit a valid email address.");
		myForm.email.focus();
		return false;
		// needs better validation
	}

	// Password
	if ( myForm.password.value.length < 1) {
		alert("You MUST enter a password.");
		myForm.password.focus();
		return false;
	}

	// start of county
	// this has problems, so it is commented out - look at category processing for correct option handling
	/*
	var mycountyList = myForm.county;
	var mySelectedcountyIndex= mycountyList.selectedIndex;
	if( mycountyList.options[mySelectedcountyIndex].value ) {
		countyItem = mycountyList.options[mySelectedcountyIndex].value;
	}else{ // if it is null then give it a value to satisfy javascript
		countyItem = "*";
	}
	if(countyItem == "*") {
		alert("Choose a county.");
		mycountyList.focus();
		return false;
	}
	if(countyItem == "") {
		alert("Choose a county.");
		mycountyList.focus();
		return false;
	}
	// end of county
	*/

	// start of Website
	if( myForm.website.value.length >= 1 ) {
		if ( myForm.website.value.substring(0,7) != "http://" ) {
			alert("You must enter a clickable link.\nThe link must begin with 'http://'");
			myForm.website.focus();
			return false;
		}
	}
	// end of Website
	// paste below this line






	// paste above this line
/* 
	HOW TO MAKE DATA REQUIRED
	To require certain data to be entered by the user:
		1. save this file as yellowORIGINAL.js
		2. open yellow.js in your html editor
		3. find the data below: example: locate the // Phone section
		4. copy the phone section from the // start of ... to the // end of ... 
		5. paste the phone section in above where it says "paste below this line"
		6. save this file yellow.js and upload to your web server
		7. test by adding a new record
		8. [OPTIONAL] color code [red] the new fields you require in the file registerForm.php
*/
/*
	// start of firstname
	if ( myForm.firstname.value.length < 2) {
		alert("You MUST enter a first name.");
		myForm.firstname.focus();
		return false;
	}
	// end of firstname

	// start of lastname
	if ( myForm.lastname.value.length < 2) {
		alert("You MUST enter a last name.");
		myForm.lastname.focus();
		return false;
	}
	// end of lastname
*/
	// start of Company
	if ( myForm.company.value.length < 3) {
		alert("You MUST enter a company name.");
		myForm.company.focus();
		return false;
	}
	// end of Company

	// start of Phone
	if ( myForm.phone.value.length < 7 ) {
		alert("Your phone number must be at least 7 numbers or longer.\nEnter 7 spaces if not applicable.");
		myForm.phone.focus()
		return false;
		// needs validation for a number value, but allowing hyphens or dots
	}
	// end of Phone
/*	
	// start of Fax
	if ( myForm.fax.value.length < 7 ) {
		alert("Your fax number must be at least 7 numbers or longer.");
		myForm.fax.focus()
		return false;
	}
	// end of Fax
	
	// start of Street Address
	if ( myForm.address.value.length < 6 ) {
		alert("Your street address appears invalid.\nEnter 6 spaces if not applicable.");
		myForm.address.focus()
		return false;
	}
	// end of Street Address

	// start of City
	if ( myForm.city.value.length < 3 ) {
		alert("The city appears invalid.\nEnter 3 spaces if not applicable.");
		myForm.city.focus()
		return false;
	}
	// end of City

	// start of ZIP or Postal code
	if ( myForm.postalcode.value.length < 5 ) {
		alert("Your ZIP or postal code must contain at least 5 characters.\nEnter 5 spaces if not applicable.");
		myForm.postalcode.focus()
		return false;
	}
	// end of ZIP or Postal Code

	// start of county
	var mycountyList = myForm.county;
	var mySelectedcountyIndex= mycountyList.selectedIndex;
	countyItem = mycountyList.options[mySelectedcountyIndex].value;
	if(countyItem == "*") {
		alert("Choose a county.");
		mycountyList.focus();
		return false;
	}
	if(countyItem == "") {
		alert("Choose a county.");
		mycountyList.focus();
		return false;
	}
	// end of county

	// start of Website
	if( myForm.website.value.length > 1) {
		if ( myForm.website.value.substring(0,7) != "http://" ) {
			alert("You must enter a clickable link.\nThe link must begin with 'http://'");
			myForm.website.focus();
			return false;
		}
	}
	// end of Website
*/
	return true
}


