function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
		func();
		}
	}
}

// declare count outside this function
function faqSelect(id) {
	for (i = 1; i<=count; i++) {
		// check divs for display/hide
		var answer = 'answer'+(i);
		aStyle = findDOM(answer,1);
		var question = 'faq'+(i);
		qStyle = findDOM(question);
		if(i==id) {
			aStyle.display="inline";
			qStyle.className='selected';
		} else {
			aStyle.display="none";
			qStyle.removeAttribute('class');
			qStyle.removeAttribute('className');
		}
	}
}

// show/hide supported phones by manufacturer
// declare brands outside this function
function brandSelect(id) {
	for (i = 0; i<brands.length; i++) {
		// check divs for display/hide
		var show = brands[i];
		showStyle = findDOM(show,1);
		if(show==id) {
			showStyle.display="inline";
		} else {
			showStyle.display="none";
		}
	}
}

// Author: Matt Kruse <matt@mattkruse.com> http://www.mattkruse.com/
var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}

// highlight fields with errors
// define errors array outside this function
function errorHilite() {
	for (i = 0; i<fields.length; i++) {
		// check fields for error highlighting
		var errfield = fields[i];
		errStyle = findDOM(errfield,1);
		errStyle.backgroundColor="#EBD8D8";
		errStyle.borderColor="#D6B8B8";
		errStyle.color="#660000";
	}
}

// pop-up window
function popWin(content) {
	mywindow = window.open(
	'includes/'+content+'.php',content,'width=342,height=340,location=no,directories=no,resizable,titlebar=no,toolbar=no,scrollbars=no,alwaysRaised=yes'
	);
}

// function to submit selections to browser
function OnChange(dropdown,baseURL)
{
	var myindex = dropdown.selectedIndex
	//var baseURL= "?id=70&pg="
	top.location.href = baseURL + dropdown.options[myindex].value;
	return true;
}