function RolloverImage(img)
{
	var tempArr = img.src.split('.gif');
	var name = tempArr[0];
	
	if (name.indexOf('_on') == -1) {		
		// store the on and off images			
		img.rollOn = name + "_on.gif";
		img.rollOut = name + ".gif";
		
		Event.observe(img, 'mouseover', function(e) { doRollOver(); });
		Event.observe(img, 'mouseout', function(e) { doRollOut(); });

		// called on rollover
		function doRollOver() { img.src = img.rollOn; }
	
		// called on rollout
		function doRollOut() { img.src = img.rollOut; }
	}
}

function show_submission_form(e)
{
	$$('.submission_form').each(function(form){
		Effect.toggle(form);
	});
}

function flash_track(options)
{
	options = $H(options);
	try {
		var s = s_gi(s_account);
		s.linkTrackVars = options.keys().join(',');
		s.linkTrackEvents = options.get('events');
		s.events = options.unset('events');
		options.each(function(opt){
			eval('s.' + opt.key + '="' + opt.value + '";');
		});
		s.t();		
	} catch(err) {}
	return true;
}

Event.observe(window, 'load', function(){ 

	// Hack textile to open links in new windows
	$$('a.external').each(function(link) {
		link.observe('click', function(e) {
			window.open(e.target.href);
			e.preventDefault();
			return false;
		});
	});

	// Initialize the Jump Nav
	var jump_nav = $('jump_nav');
	if (jump_nav) {
		jump_nav.observe('change', function(e){
			Effect.ScrollTo($F(e.target), {duration: '0.5'});
			Event.stop(e);
		});
	}
	
	// Initialize the rollovers
	$$('#nav img', '.rollover').each(function(img){
		new RolloverImage(img);
	});
	
	// Initialize the hinted forms
	var inputs = $$('.hint');
	inputs.each(function(input){
		if (input.value.blank()) { input.value = input.readAttribute('rel') };
		Event.observe(input, 'focus', function(e) { if (this.value == this.readAttribute('rel')) { this.clear(); } });
		Event.observe(input, 'blur', function(e) { if (this.value.length < 2) { this.value = this.readAttribute('rel'); } });
		Event.observe(input.up('form'), 'submit', function(e) {
			$(this).select('.hint').each(function(input){
				if (input.readAttribute('rel') == input.value) {
					input.clear();
				}
			});
		});
	});
	
	// Initialize the submission forms
	if (!$('errorExplanation')) {
		var forms = $$('.submission_form');
		forms.each(function(form){
			form.hide();
		});
	}
	
	// Initialize the search tip
	new Tip('search_tips', "Use whatever information you have. You can type in the street, the city, zip or a part of town (like downtown Cincinnati). You can even try a location, such as a university or stadium.", {
		title: "Search Tips",
		style: 'protoblue',
		fixed: true,
		closeButton: true,
		showOn: 'click',
		hideOn: { element: 'closeButton', event: 'click'},
		stem: 'topRight',
		hook: { target: 'bottomRight', tip: 'topRight' },
		width: '190',
		viewport: true
	});

});