var ARSP = Aris.extend({
	pageReady: function () {
		forEach( document.getElementsByTagName('a'), this.popUpSafe );
	},
	inputFocus: function(input) {
		if (input.getAttribute('oldval') == null){
			input.setAttribute('oldval',this.value);
			input.value = '';
		} else {
			input.select();
		}
	},
	inputBlur: function(input) {
		if (input.value == '')
			input.value = input.getAttribute('tbkeywords');
	}, 
	popUpSafe: function(a) {
		var _onSite = /(aristotle\.net)|(\barkansasstateparks\.com)|(arkansasstateparks\.findlocation\.com)|(javascript:)|(localhost)/i;
		var _files = /\.(pdf|doc)/i;
		var _rels = /external|print|sendtofriend/i;
		if ( a.href.length > 0 && (!_onSite.test(a.href) || _files.test(a.href) || _rels.test(a.rel) )) {
			Event.add(a,'click', function(e) {
				if ( Aris.popWin(this.href) ); {
					Event.preventDefault(e);
					return false;
				}
			});	
		}
		else if ((a.rel.indexOf(':') > 0 || a.target) && !a.href.match(/arkansasstateparks\.findlocation\.com/i)) {
			Event.add(a,'click', function(e) {
				var args = (this.rel||this.target).split(':') ;
				if ( Aris.popWin(this.href,args[0],args[1],args[2]) ) {
					Event.preventDefault(e);
					return false;
				}
			});
		}
	},
	openVideoWindow: function(video, h, w) {
		Aris.popWin('/video-tours/video-win.aspx?video_str=' + video, 'VIDEO', w, h);
	},
	openIpixWindow: function(ipix) {
		Aris.popWin('/park-finder/ipix_win.aspx?ipix_str=' + ipix, 'IPIX', 500, 400);
	}
});
var OpenVideoWindow = ARSP.openVideoWindow;
var OpenIpixWindow = ARSP.openIpixWindow;

//Show/hide script for use on hiking trails section
var hikingdivs = new Array("easytrails", "moderatetrails", "strenuoustrails");

function showHide(num) {
	if (document.getElementById) {
		for (var i=0; i<hikingdivs.length; i++) {
			document.getElementById(hikingdivs[i]).style.display = 'none';
			document.getElementById(hikingdivs[i] + "tab").className = 'tabOff';
		}
		document.getElementById(hikingdivs[num]).style.display = 'block';
		document.getElementById(hikingdivs[num] + "tab").className = 'tabOn';
	}
}

function initDropDowns(ddList) {
	var dds = ddList.getElementsByTagName("dd");
	var hideSelectBoxes = document.getElementsByTagName("select");
	var hideObject = document.getElementById('hideObject');
	var hideObject2 = document.getElementById('hideObject2');
	var hideObject3 = document.getElementById('hideObject3');
	
	// JDR 20070812	fix for errors thrown on main page nav
	if (hideSelectBoxes.length==0) 
		hideSelectBoxes=null;
	
	for(i = 0; i < dds.length; i++) {
		dds[i].onmouseover = function()
		{
		    if (this.className != "")
		    {
		        this.className = this.className + " ddHover";
		    }
		    else
		    {
		        this.className = "ddHover";
		    }
			if (hideObject != null) 
				document.getElementById('hideObject').style.visibility = 'hidden';
			if (hideSelectBoxes != null)
			{
			    for (var hidecount = 0; hidecount <= hideSelectBoxes.length; hidecount++)
			    {
			        hideSelectBoxes[hidecount].style.visibility = 'hidden';
			    }
			}
		};
		dds[i].onmouseout = function()
		{ 
		    this.className = this.className.replace(/ *ddHover/i,""); 
			if (hideObject != null)
				document.getElementById('hideObject').style.visibility = 'visible';
			if (hideSelectBoxes != null)
			{
			    for (var hidecount = 0; hidecount <= hideSelectBoxes.length; hidecount++)
			    {
			        hideSelectBoxes[hidecount].style.visibility = 'visible';
			    }
			}
		};
	}
}

function clearText(formField)
{
	if(formField.value == formField.attributes.getNamedItem("initialText").value)
		formField.value = "";
}
function fillText(formField)
{
	if(formField.value == "")
		formField.value = formField.attributes.getNamedItem("initialText").value;
}