// Scriptaculous Slideshow scripts for "Sample Report" page
// Setup array for DIVs to be included in slideshow
var frames = new Array("slideshow1","slideshow2","slideshow3","slideshow4");
var cur_frame = 0;
var total_frames = frames.length - 1;

function next_slide() {
	new Effect.Fade(frames[cur_frame], { duration: 0.3, queue: "front" });
	if(cur_frame != total_frames) {
		cur_frame++;
	} else if(cur_frame == total_frames) {
		cur_frame = 0;
	}
	new Effect.Appear(frames[cur_frame], { duration: 0.3, delay: 0.32, queue: "end" });
}

function prev_slide() {
	new Effect.Fade(frames[cur_frame], { duration: 0.3, queue: "front" });
	if(cur_frame != 0) {
		cur_frame = cur_frame - 1;
	} else if(cur_frame == 0) {
		cur_frame = total_frames;
	}
	new Effect.Appear(frames[cur_frame], { duration: 0.3, delay: 0.32, queue: "end" });
}



// Generic Popup Script
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=500');");
}


// Open links in external window for XHTML 1.0 Strict compliancy
// To make a link open in external window add the "rel" attribute to the <a> tag
// and set its value to "external" example:
//     <a href="http://www.google.com" rel="external">Google</a>
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	var areas = document.getElementsByTagName("area");
	var forms = document.getElementsByTagName("form");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
	for (var x=0; x<areas.length; x++) {
		var area = areas[x];
		if (area.getAttribute("href") &&
		area.getAttribute("rel") == "external")
		area.target = "_blank";
	}
	for (var y=0; y<forms.length; y++) {
		var form = forms[y];
		if (form.getAttribute("rel") == "external")
		form.target = "_blank";
	}
}
window.onload = externalLinks;



// moo.FX Accordion Configuration
function init(){
	
	var stretchers = document.getElementsByClassName('stretcher'); //div that stretches
	var toggles = document.getElementsByClassName('display'); //h3s where I click on

	//accordion effect
	var myAccordion = new fx.Accordion(toggles, stretchers, {opacity: true, duration: 400});
	
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling'); //element.find is located in prototype.lite
		if (window.location.href.indexOf(h3.title) > 0) {
			myAccordion.showThisHideOpen(div);
			found = true;
		}
	});
	
	// Open one of the accordian elements by default. Change which one to open by adjust the stretchers
	// array element referenced (0 order starting).
	if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}




// Image rollover - for use please make sure image names follow the following name scheme:
// Idle Image:  image_i.gif
// Hover Image: image_o.gif
// File extension and anything before the _i. does not matter so long as it is consistent between
// the two states (e.g. "image_i.gif" and "hoverimage_o.gif" does not work)
// Usage:
// <img src="image_i.gif" alt="" onmouseover="rollOver(this)" onmouseout="rollOut(this)" />
var oldImage = "";
function rollOver(oImg) {
	oldImage = oImg.src;
	var newImage = oldImage.replace("_i.","_o.");
	oImg.src = newImage;
}
function rollOut(oImg) {
	oImg.src = oldImage;
}

// Replace input field with default value on blur if nothing was entered
// Usage: <input type="text" value="Default Value" onfocus="clearText(this)" onblur="replaceText(this)" />
function clearText(thefield) {
	if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
 
function replaceText(thefield) {
	if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

function LinkMessage(text)
{window.status=text;}
function KillMessage()
{window.status=" ";}
