function setFocus(value) {
	radio_button = document.form3.intlocation
	for(counter=0;counter<radio_button.length;counter++) {
		if(radio_button[counter].value == value) {
			radio_button[counter].checked = true;
		}
	}

}


function setColor_seller(field, bgColour) {
    if (field.style) field.style.backgroundColor = bgColour;
}

function radio_value(radio_button){
	
	for (counter = 0; counter < radio_button.length; counter++){
		if(radio_button[counter].checked)
			return radio_button[counter].value;
	}

	return 0;
}

function select_check(select_field, emptyValue) {

        for (counter = 0; counter < select_field.length; counter++){
                if (select_field[counter].selected && select_field[counter].value != emptyValue)
                        return true;
        }
        return false;

}

function ValidateSellerSearch() {
	var errors = '';
	var numErrors = 0;
	var bgColorError = "#FFCCCC";
  	var bgColorDefault = "#FFFFFF";
	
	var objElements = document.form3.elements;
	for(j=0;j<objElements.length;j++) {
	  if (objElements[j].type != 'button' && objElements[j].type != 'submit' && objElements[j].type != 'reset')
	   setColor_seller(objElements[j], bgColorDefault);
	}

	if (radio_value(document.form3.intlocation) == 2 && !select_check(document.form3.intstate, 0)) {
		errors += '- The state field needs to be completed.\n';
		numErrors++;
		setColor_seller(document.form3.intstate, bgColorError);  
	}
	if (radio_value(document.form3.intlocation) == 3 && !select_check(document.form3.intregionid, 0)) {
		errors += '- The reigon field needs to be completed.\n';
		numErrors++;
		setColor_seller(document.form3.intregionid, bgColorError);  
	}
	if (radio_value(document.form3.intlocation) == 4 && isEmpty(document.form3.strpostcode.value)) {
		errors += '- The postcode field needs to be completed.\n';
		numErrors++;
		setColor_seller(document.form3.strpostcode, bgColorError);  
	}

	if (numErrors) {
		errors = 'The form was not submitted due to the following problem' + ((numErrors > 1) ? 's' : '') + ':\n' + errors + 'Please fix ' + ((numErrors > 1) ? 'these' : 'this') + ' problem' + ((numErrors > 1) ? 's' : '') + ' and resubmit the form.';
		alert(errors);
		return false;
	}
	return true;
}

function ValidateKeywordSearch() {
	var errors = '';
	var numErrors = 0;
	var bgColorError = "#FFCCCC";
  	var bgColorDefault = "#FFFFFF";
	
	var objElements = document.form4.elements;
	for(j=0;j<objElements.length;j++) {
	  if (objElements[j].type != 'button' && objElements[j].type != 'submit' && objElements[j].type != 'reset')
	   setColor_seller(objElements[j], bgColorDefault);
	}

	if (document.form4.strkeyword.value == '') {
		errors += '- The keyword field needs to be completed.\n';
		numErrors++;
		setColor_seller(document.form4.strkeyword, bgColorError); 
	}
	if (numErrors) {
		errors = 'The form was not submitted due to the following problem' + ((numErrors > 1) ? 's' : '') + ':\n' + errors + 'Please fix ' + ((numErrors > 1) ? 'these' : 'this') + ' problem' + ((numErrors > 1) ? 's' : '') + ' and resubmit the form.';
		alert(errors);
		return false;
	}
	return true;
}