function init() {
	addRollovers( Array('ro_tridea','ro_free','ro_give','ro_trp','ro_map','ro_gal','ro_wea','ro_trn','ro_med','ro_trv','ro_scr','ro_gui','ro_nav1','ro_nav2','ro_nav3','ro_nav4','ro_nav5','ro_nav6','ro_nav7','ro_nav8','ro_nav9','ro_nav10'),getRollSrcAlt);
	PopUpSafe(document.getElementsByTagName('a'));
	initFlash();
}
addEvent(window,'load',init);

function initFlash() {
	if ( !document.getElementById || typeof(FlashObject) == 'undefined')  return;
	myFlash = new FlashObject("/images/mp/tsusa_mp_flash1a.swf", "mflash", "578", "354", 8, "#5A4872");
	myFlash.addParam("WMODE","Transparent");
	myFlash.write("mpflash");
	myFlash2 = new FlashObject("/images/mp/tsusa_mp_flash2a.swf", "mflash2", "362", "100", 8, "#DACBA2");
	myFlash2.addParam("WMODE","Transparent");
	myFlash2.write("flash_bar");
}

function PopUpSafe(els) {
	for (var i = 0; i < els.length; i++) {
	//add event only to those <A>'s with appropriate "rel" attribute
		if (els[i].rel.indexOf("external") >= 0 ) {
			//els[i].target = '_blank';
			els[i].onclick = function() { return PopWin(this.href,'new'); }
		}
		else if (els[i].rel.indexOf(':') >= 0) {
			els[i].onclick = function() { args = this.rel.split(':'); return PopWin(this.href,args[0],args[1],args[2]); }
		}
	}// for
}// PopUpSafe()
function sizeFromRel(obj) {
 args = this.rel.split(':');
 return PopWin(this.href,args[0],args[1],args[2]);
}

//ROLLOVER RELATED
///////////////////////////
var over = new Array();
var out = new Array();
function addRollovers(idArr,func) {
	var imgs, a;
	if (!func) func = getRollSrc;
	if (!document.images) return;

	for (i = 0; i < idArr.length; i++) {
		imgs = getObj(idArr[i]);
		if (!imgs) continue;
		a = imgs.parentNode;
		if (a && a.tagName == 'A'){
			over[i] = new Image();
			out[i] = new Image();
			over[i].src = func(imgs.src,"gif",1);
			out[i].src = imgs.src;
			imgs.setAttribute('ro_index',i);
			a.onmouseover = function() { this.childNodes[0].src = over[this.childNodes[0].getAttribute('ro_index')].src; }
			a.onfocus = function() { this.childNodes[0].src = over[this.childNodes[0].getAttribute('ro_index')].src; }
			a.onmouseout = function() { this.childNodes[0].src = out[this.childNodes[0].getAttribute('ro_index')].src; }
			a.onblur = function() { this.childNodes[0].src = out[this.childNodes[0].getAttribute('ro_index')].src; }
		}
	}
}
function getRollSrc(src, ext, hover) {
	return (hover) ? src.replace('a.'+ext,'b.'+ext) : src.replace('b.'+ext,'a.'+ext);
}
function getRollSrcAlt(src, ext, hover) {
	return (hover) ? src.replace('.'+ext,'_m.'+ext) : src.replace('_m.'+ext,'.'+ext);
}

//GENERAL PURPOSE FUNCTIONS
///////////////////////////

var wini; //Reference to a window
function PopWin(url, name, width, height) {
	var s;
	if (width || height) {
		h = (height) ? height : 600;
		w = (width) ? width : 800;
		lp = (screen.width) ? (screen.width-w)/2 : 0;
		tp = (screen.height) ? (screen.height-h)/2 : 0;
		sc = (name == 'gallery') ? 'no' : 'yes';
		s = 'height='+ h +',width='+ w +',top='+tp+',left='+lp+',scrollbars='+sc+',resizable';
	}
	else s = '';
	wini = window.open(url,name,s);
	if (wini) wini.focus();
	return ( !wini )
}// PopWin()

function addEvent(obj,evType,fn){
	if(obj.addEventListener){
		obj.addEventListener(evType,fn,false);
	}
	else if(obj.attachEvent){
		var r=obj.attachEvent("on"+evType,fn);
	}
	else{
		if ( typeof( obj['on'+evType] ) == 'function' ) {
			var last = obj['on'+evType] ;
			obj['on'+evType] = null;
			obj['on'+evType] = function() { last(); fn(); };
		}
		else obj['on'+evType] = fn;
	}
}

function getObj(name) {
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
		if(this.obj) 
			this.style = document.getElementById(name).style;
  }
  else if (document.all) {
		this.obj = document.all[name];
		if(this.obj)
			this.style = document.all[name].style;
  }
  else if (document.layers) {
   	this.obj = document.layers[name];
		if(this.obj)
	   	this.style = document.layers[name];
  }
	return this.obj; //secondary functionality returns reference to obj
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

//****************************
//** FROM: somewhere. Seen these functions elsewhere too many times to properly credit
//***************************
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}


// HELP POP WINDOW
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=425,height=330,left = 440,top = 312');");
}

