function goBack(){
	history.back();
}
function goBack2(){
	history.go(-2);
}
function reload(){
	history.go(0);
}
function imposeMaxLength(Object, maxLen)
{
	if (Object.value.length > maxLen){
		Object.value = Object.value.substring(0, maxLen);
	}
}
function clearSearchBox(){
	var e = document.getElementsByName('search_box')[0];
	e.value = "";
	e.setAttribute('id', 'SEARCH_BOX_CLICKED');
}

function processSearch(){
	if(validateSearch() == 0){
		document.adv_search_form.submit();
		return true;
	}
	return false;
}
function validateSearch(){
	var fields = new Object();
	fields.country = document.getElementById('country').value;
	fields.name = document.getElementById('name').value;
	fields.age = document.getElementById('age').value;
	fields.zip = document.getElementById('zip').value;
	fields.make = document.getElementById('make').value;
	fields.body = document.getElementById('body').value;
	fields.additional = document.getElementById('additional_kw').value;
	var zip_ok = fields.zip.search(/^\d{5}$/);
	var ad_ok = fields.additional.search(/\S+/); //needs to have non-space character in it somewhere

	var flag=0;
	
	for(var elt in fields){
		if(fields[elt] != ""){
			if(elt != "zip" && elt != "additional"){
				flag = 1;
			}
			if(elt == "zip" && zip_ok >= 0){
				flag = 1;
			}
			if(elt == "additional" && ad_ok >= 0){
				flag = 1;
			}
		}
	}
	
	if(flag == 0){
		alert("Please fill in one or more search fields.");
		return -1;
	}
	return 0;
}

function processContact(){
	if(validateContact() == 0){
		document.contact_form.submit();
		return true;
	}
	return false;
}
function validateContact(){
	var fields = new Object();
	fields.name = document.getElementById('viewer_name').value;
	fields.email = document.getElementById('viewer_email').value;
	fields.message = document.getElementById('viewer_message').value;
	
	var ok = fields.email.search(/^[a-zA-Z].*@.+\..{2,6}$/);
	
	if(ok != 0 || fields.name == "" || fields.message == "" || fields.email == ""){
		alert("Please complete entire form correctly.");
		return -1;
	}
	return 0;
}

function validatePostField(num, regex){
	
	return 0;
}


function showScript(fileName){
	newwindow=window.open(fileName,'Script','height=700,width=600,resizeable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus();}
}

function showSecurityCode(){
	newwindow=window.open('securitycode.html','Security Code','width=300,height=160,scrollbars=yes,resizable=yes,toolbar=no,status=no,menubar=no');
	if (window.focus) {newwindow.focus();}
}

function showTCUG(){
	newwindow=window.open('tcug.html','Terms','width=700,height=700,scrollbars=yes,resizable=yes,toolbar=no,status=no,menubar=yes');
	if (window.focus) {newwindow.focus();}
}

function linkRollover(elt){
	elt.firstChild.src="style/link_icon_rollover.gif";
}

function linkRolloff(elt){
	elt.firstChild.src="style/link_icon.gif";
}



