var savedFieldVals = new Array();
var selInfo = new Array();
var dispDivs = new Array();

var sgi_ord=Math.random()*10000000000000000;
var sgi_tile=1;

function displayAd(target, w, h) {
	var sourceScript = document.getElementById(target);
	var sourceParent = sourceScript.parentNode;
	var testFRAME = document.createElement("iframe");
	testFRAME.id = 'ad'+sgi_tile+'FRAME';
	testFRAME.src = 'http://ad.doubleclick.net/adi/sgi.unearthedoutdoors/home;id=sg697796;ch=oe;vc=comm;vc=mtn;vc=outd;vc=trav;sp=camp;sp=fish;sp=hk;zn=home;pos=aflb;dcopt=ist;sz='+w+'x'+h+';tile=1;ord='+sgi_ord+'?';
	sourceParent.insertBefore(testFRAME,sourceScript);
	sgi_tile++;
}

function upgradeBrowser(){
	if (confirm('It seems basic JavaScript dosen\t work in your web browser. Please upgrade your browser or disable JavaScript.'))
			top.location.replace('http://www.spreadfirefox.com/?q=affiliates&id=80581&t=70');
}

document.write = function(str){
	var moz = !window.opera && !/Apple/.test(navigator.vendor);
	if ( str.match(/^<\//) )
		return;
	if ( !window.opera )
		str = str.replace(/&(?![#a-z0-9]+;)/g, "&amp;");
	str = str.replace(/<([a-z]+)(.*[^\/])>$/, "<$1$2></$1>");
	if ( !moz )
		str = str.replace(/(<[a-z]+)/g, "$1 xmlns='http://www.w3.org/1999/xhtml'");
	if(document.createElementNS){
		var div = document.createElementNS("http://www.w3.org/1999/xhtml", "div")
	} else {
		var div = document.createElement("div");
		div.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
	}
	div.innerHTML = str;
	var pos;
	if ( !moz ) {
		pos = document.getElementsByTagName("*");
		pos = pos[pos.length - 1];
	} else {
		pos = document;
		while ( pos.lastChild && pos.lastChild.nodeType == 1 )
			pos = pos.lastChild;
	}
	var nodes = div.childNodes;
	while ( nodes.length )
		pos.parentNode.appendChild( nodes[0] );
};

function chkHide(sel_num){
	if (!document.getElementById) {
		upgradeBrowser();
		return;
	}
	
	var thisSelInfo = selInfo[sel_num];
	
	var selector = document.getElementById(thisSelInfo[0]);
	var div_box = document.getElementById(thisSelInfo[2]);
	
	var field = null;
	
	if(selector.options[selector.selectedIndex].value == "hide_div"){
		div_box.style.display="none";
		selInfo[sel_num][3] = true;
		for(fieldI = 0; fieldI < thisSelInfo[4].length; fieldI++){
			swapInField(sel_num, fieldI, document.getElementById(thisSelInfo[4][fieldI][0]), thisSelInfo[4][fieldI][1]);
		}
	} else if(thisSelInfo[3] == true) {
		for(fieldI = 0; fieldI < thisSelInfo[4].length; fieldI++){
			if(thisSelInfo[4][fieldI][2]){
				field = document.getElementById(thisSelInfo[4][fieldI][0]);
				if(field.options){
					field.selectedIndex = selInfo[sel_num][4][fieldI][2];
				} else {
					field.value = thisSelInfo[4][fieldI][2];
				}
			}
		}
		div_box.style.display="block";
		selInfo[sel_num][3] = false;
	}
}

function swapInField(fieldSetNum, fieldNum, field, newVal){
	
	if(savedFieldVals[fieldSetNum] == null){
		savedFieldVals[fieldSetNum] = new Array();
	}
	
	if(savedFieldVals[fieldSetNum][fieldNum] == null){
		savedFieldVals[fieldSetNum][fieldNum] = new Array();
	}

	if(field.options){
		for(var optionI = 0; optionI < field.length; optionI++){
			if(newVal == field.options[optionI].value){
				savedFieldVals[fieldSetNum][fieldNum] = field.selectedIndex;
				field.selectedIndex = optionI;
				return;
			}
		}
	} else {
		savedFieldVals[fieldSetNum][fieldNum] = field.value;
		field.value = newVal;
	}
}

function initAllSelectors(){
	
	if(!selInfo){
		return;
	}
	
	if(!document.getElementById){
		upgradeBrowser();
		return;
	}
	
	for(initI = 0; initI < selInfo.length; initI++){
		dispDiv(selInfo[initI][1]);
		chkHide(initI);
	}
}

function disableFormButtons(form){
	for(i = 0; i < form.elements.length; i++){
		if(form.elements[i].type == "submit"){
			form.elements[i].value=" Loading... ";
			form.elements[i].disabled=true;
		}
		form.elements[i].style.cursor = "wait";
	}
	return true;
}

function subForm(form){
	form.style.cursor = "wait";
	return disableFormButtons(form);
}

/*Automatically generated; File must be saved as UTF-8*/
function initCountryProvDOL(dol){
	dol.forValue("0").addOptionsTextValue("Please select a country", "");
	dol.forValue("1").addOptionsTextValue("Select one...","","Alabama","AL","Alaska","AK","American Samoa","AS","Arizona","AZ","Arkansas","AR","Armed Forces Americas","AA","Armed Forces Europe","AE","Armed Forces Pacific","AP","California","CA","Colorado","CO","Connecticut","CT","Delaware","DE","District of Columbia","DC","Federated Micronesia","FM","Florida","FL","Georgia","GA","Guam","GU","Hawaii","HI","Idaho","ID","Illinois","IL","Indiana","IN","Iowa","IA","Kansas","KS","Kentucky","KY","Louisiana","LA","Maine","ME","Marshall Islands","MH","Maryland","MD","Massachusetts","MA","Michigan","MI","Minnesota","MN","Mississippi","MS","Missouri","MO","Montana","MT","N. Mariana Islands","MP","Nebraska","NE","Nevada","NV","New Hampshire","NH","New Jersey","NJ","New Mexico","NM","New York","NY","North Carolina","NC","North Dakota","ND","Ohio","OH","Oklahoma","OK","Oregon","OR","Palau","PW","Pennsylvania","PA","Puerto Rico","PR","Rhode Island","RI","South Carolina","SC","South Dakota","SD","Tennessee","TN","Texas","TX","Virgin Islands","VI","Utah","UT","Vermont","VT","Virginia","VA","Washington","WA","West Virginia","WV","Wisconsin","WI","Wyoming","WY");
	dol.forValue("2").addOptionsTextValue("Select one...","","Alberta","AB","British Columbia","BC","Manitoba","MB","New Brunswick","NB","Newfoundland","NF","Northwest Territories","NT","Nova Scotia","NS","Nunavut","NU","Ontario","ON","Prince Edward Island","PE","Quebec","QC","Saskatchewan","SK","Yukon","YT");
	dol.forValue("3").addOptionsTextValue("Select one...","","Aguascalientes","AGS","Baja California Norte","BCN","Baja California Sur","BCS","Campeche","CAM","Chiapas","CHIS","Chihuahua","CHIH","Coahuila","COAH","Colima","COL","Distrito Federal","DF","Durango","DGO","Guanajuato","GTO","Guerrero","GRO","Hidalgo","HGO","Jalisco","JAL","México (Estado de)","MEX","Michoacán","MICH","Morelos","MOR","Nayarit","NAY","Nuevo León","NL","Oaxaca","OAX","Puebla","PUE","Querétaro","QRO","Quintana Roo","QROO","San Luis Potosí","SLP","Sinaloa","SIN","Sonora","SON","Tabasco","TAB","Tamaulipas","TAMPS","Tlaxcala","TLAX","Veracruz","VER","Yucatán","YUC","Zacatecas","ZAC");
}

function chngIdImg(idField, imageId, type){
	if (!document.getElementById) {
		upgradeBrowser();
		return;
	}
	
	document.getElementById(imageId).src = "/dynimgs/id_lookup.php?type_id="+type+"_"+(idField.value);
}

function dispDiv(divId){
	document.getElementById(divId).style.display = "block";
}

function dispAllDivs(){
	
	if(!dispDivs){
		return;
	}
	
	for(divI = 0; divI < dispDivs.length; divI++){
		dispDiv(dispDivs[divI]);
	}
}

function makePopUp(url){
	window.open(url,'NewWindow','width=640, height=480, toolbar=no, menubar=no, scrollbars=yes, resizeable=yes').focus();
	return false;
}