/* GLOBAL SCRIPTS */

// Function to safely register multiple functions with the onLoad browser event
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') window.onload = func;
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// Shortcut getID function
function $(ee) {
	return document.getElementById(ee);
}

// Shortuct to innerHTML
function getHtml(elmId) {
	return $( elmId ).innerHTML;
}

// Modifier for innerHTML
function setHtml(elmId, strContent) {
	$( elmId ).innerHTML = strContent;
}

function closeWindow() {
	close();
}

// This is the implementation of SimpleSwap
// by Jehiah Czebotar
// Version 1.1 - June 10, 2005
// Distributed under Creative Commons
//
// Include this script on your page
// then make image rollovers simple like:
// <img src="/images/ss_img.gif" oversrc="/images/ss_img_over.gif">
//
// http://jehiah.com/archive/simple-swap
// 
function SimpleSwap(el,which) {
	el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup() {
	var x = document.getElementsByTagName("img");
	for (var i=0;i<x.length;i++) {
		var oversrc = x[i].getAttribute("oversrc");
    	if (!oversrc) continue;
	    // preload image
    	// comment the next two lines to disable image pre-loading
	    x[i].oversrc_img = new Image();
	    x[i].oversrc_img.src=oversrc;
    	// set event handlers
	    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    	x[i].onmouseout = new Function("SimpleSwap(this);");
	    // save original src
    	x[i].setAttribute("origsrc",x[i].src);
	}
}
//// FOR INPUT-IMAGE tags
function SimpleSwapSetupFormImages() {
	var x = document.getElementsByTagName("input");
	for (var i=0;i<x.length;i++) {
		if (x[i].type == "image") {
			var oversrc = x[i].getAttribute("oversrc");
			if (!oversrc) continue;     
			// preload image
			// comment the next two lines to disable image pre-loading
			x[i].oversrc_img = new Image();
			x[i].oversrc_img.src=oversrc;
			// set event handlers
			x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
			x[i].onmouseout = new Function("SimpleSwap(this);");
			// save original src
			x[i].setAttribute("origsrc",x[i].src);
		}
	}
}

addLoadEvent(SimpleSwapSetup);
addLoadEvent(SimpleSwapSetupFormImages);
// End SimpleSwap

// Dynamic implementation of oversrc attribute for SimpleSwap
function setOverSrc(imgObj) {
	var _imgSrcPrefix = imgObj.src.substring( 0,imgObj.src.lastIndexOf('.') );
	var _imgSrcSuffix = imgObj.src.substring( imgObj.src.lastIndexOf('.') );
	imgObj.setAttribute("oversrc",_imgSrcPrefix + '_on' + _imgSrcSuffix);
}
// End Dynamic implementation of oversrc attribute


// Function for Flash app to call to change the height of the embedded Flash stage.
// This version requires that the container have an id=ufoContainer
// And the embedded movie have an id=myUFO
function changeHeight(newHeight) {
	document.getElementById("myUFO").height = newHeight;
	document.getElementById("myUFO").style.height = newHeight +"px";
	document.getElementById("ufoContainer").height = newHeight;
	document.getElementById("ufoContainer").style.height = newHeight +"px";
	document.getElementById("container").height = newHeight;
	document.getElementById("container").style.height = newHeight +"px";
};

