// ### Adds Load Listener to the window.onload event handler.
//     Used in conjuction with attachEventListener function.
function addLoadListener(fn){if(typeof window.addEventListener!='undefined'){window.addEventListener('load',fn,false);}else if (typeof document.addEventListener != 'undefined'){document.addEventListener('load',fn,false);}else if(typeof window.attachEvent!='undefined'){window.attachEvent('onload',fn);}else{return false;}return true;}
// ### Attaches an Event Listener to a valid document event type
function attachEventListener(target, eventType, functionRef, capture){if(typeof target.addEventListener!="undefined"){target.addEventListener(eventType,functionRef,capture);}else if(typeof target.attachEvent!="undefined"){target.attachEvent("on"+eventType,functionRef);}else{return false;}return true;}

// ### Generic GetHTML Object Function
function getObj(oId){var d=document,i,el;el=d.getElementById?d.getElementById(oId):d.all?d.all[oId]?d[oId]:d[oId]:null;if(!el){if(d.forms.length>0){for(i=0; !el && i<d.forms.length; i++){el=d.forms[i][oId];}}}return el;}
// ### Get Rendered HTML Width / Height of an object
// ### Adds Load Listener to the window.onload event handler.
//     Used in conjuction with attachEventListener function.
function addLoadListener(fn){if(typeof window.addEventListener!='undefined'){window.addEventListener('load',fn,false);}else if (typeof document.addEventListener != 'undefined'){document.addEventListener('load',fn,false);}else if(typeof window.attachEvent!='undefined'){window.attachEvent('onload',fn);}else{return false;}return true;}
// ### Attaches an Event Listener to a valid document event type
function attachEventListener(target, eventType, functionRef, capture){if(typeof target.addEventListener!="undefined"){target.addEventListener(eventType,functionRef,capture);}else if(typeof target.attachEvent!="undefined"){target.attachEvent("on"+eventType,functionRef);}else{return false;}return true;}

// ### Generic GetHTML Object Function
function getObj(oId){var d=document,i,el;el=d.getElementById?d.getElementById(oId):d.all?d.all[oId]?d[oId]:d[oId]:null;if(!el){if(d.forms.length>0){for(i=0; !el && i<d.forms.length; i++){el=d.forms[i][oId];}}}return el;}
// ### Get Rendered HTML Width / Height of an object
function getObjWH(obj){if(obj.offsetWidth&&obj.offsetHeight){return [obj.offsetWidth,obj.offsetHeight];}}

// ### Create Instance of a Flash Object inside an HTML container object via script_
//	   Bypasses "Click to Activate Control" message in IE
// ### Usage: <script type="text/javascript">var oFlash=new insertFlashObject(['oContainerId','id','url','w','h','wmode']);</script>
// ### Notes: 'wmode' is an optional override and is not required when creating a new insertFlashObject call...simply end the array after 'h'...example: var oFlash=new insertFlashObject(['oContainerId','id','url','w','h']);
function insertFlashObject(args){
	var oContainerId=args[0]; //id of html element that will contain the new flash object
	var id	 		=args[1]; //id assigned to new flash object
	var url	 		=args[2]; //url of flash object
	var w	 		=args[3]; //width of flash object
	var h	 		=args[4]; //height of flash object
	var wmode		=args[5]?args[5]:'transparent'; //window mode of flash object (transparent, window)
	if(oContainerId.length>0)var oFlashContainer=getObj(oContainerId);
	if(oFlashContainer&&url){
		var oStartTag  = '<object type="application/x-shockwave-flash" id="'+id+'" data="'+url+'" width="'+w+'" height="'+h+'">'
		var strParams  = '<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+url+'" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="autoStart" value="true" /><param name="WMode" value="'+wmode+'" />';
		var oEndTag = '</object>';
		oFlashContainer.innerHTML=oStartTag+strParams+oEndTag;
	}
}

function launch(url,args){
	var oWin=null;
	var w=args[0]?args[0]:400;
	var h=args[1]?args[1]:250;
	var s=args[2]?args[2]:'no';
	var r=args[3]?args[3]:'no';
	var aw=screen.availWidth,ah=screen.availHeight,x=(aw-w)/2,y=(ah-h)/2;
	oWin=window.open(url,'win','width='+w+',height='+h+',left='+x+',top='+y+',scrollbars='+s+',resizable='+r);
	oWin.window.focus();
}