//Timer
Object.extend(PeriodicalExecuter.prototype, {
     initialize: function(callback, frequency) {
         this.callback = callback;
         this.frequency = frequency;
         this.currentlyExecuting = false;
         this.timer = null;
         //this.start();
     },
 
     isAlive: function() {
        return (this.timer != null) ? true : false;
     },
     
     start: function() {
         if(this.timer == null)
            this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
     },
     
     stop: function() {
        this.pause();
     },
 
     pause: function() {
         clearInterval(this.timer);
         this.timer = null;
     },
 
     reset: function() {
        this.pause();
        this.start();
     },
     
     setFrequency: function(f) {
         this.frequency = f;
         if (this.timer != null) {
             this.reset();
         }
     }
 });
 
 //Cookies
 var Cookies = {
  setCookie: function(name, value, daysToExpire, path, domain, secure) {
    var expire = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    var x = escape(name) + '=' + escape(value || '') + expire + 
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");

    return (document.cookie = x);
  },
  getCookie: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  deleteCookie: function(name) {
    var cookie = Cookies.getCookie(name) || true;
    Cookies.setCookie(name, '', -1);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookies.setCookie('_test', '1');
    return (Cookies.deleteCookie('_test') === '1');
  }
};

//DOM ready
Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;

    if (this._timer)  clearInterval(this._timer);
    
    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDOMReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);
      
      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);
        
        /*@cc_on @*/
        /*@if (@_win32)
            document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady(); 
            };
        /*@end @*/
        
        if (/WebKit/i.test(navigator.userAgent)) { 
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady(); 
          }, 10);
        }
        
        Event.observe(window, 'load', domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});

//Events
Event.Publisher = Class.create();
Object.extend( Event.Publisher, {
	_ls_event_targets: null,
	
	getEventTarget: function( event_name ) {
		if ( ! this._ls_event_targets )
			this._ls_event_targets = new Array();
		
		if ( ! this._ls_event_targets[ event_name ] )
			document.body.appendChild( this._ls_event_targets[ event_name ] = document.createElement( 'A' ) );
		
		return this._ls_event_targets[ event_name ];
	},
	
	addEventListener: function( event_name, callback_func, capturing ) {
		var targ = this.getEventTarget( event_name );
		
		Event.observe( targ, 'click', callback_func, capturing );
	},
	
	removeEventListener: function( event_name, callback_func, capturing ) {
		var targ = this.getEventTarget( event_name );
		
		Event.stopObserving( targ, 'click', callback_func, capturing );
	},
	
	dispatchEvent: function( event_name, data, can_bubble, cancelable ) {
		var targ = this.getEventTarget( event_name );
		var event_data = { event_name: event_name, event_target: this, data: ( typeof( data ) == 'undefined' ) ? null : data };
		
		Event.create( targ, event_data, can_bubble, cancelable, true );
	}
} );

Event.Listener = Class.create();
Object.extend( Event.Listener, {
	_listens: null,
	
	getEventHandlerName: function( event_name ) {
		var onEvent_name = event_name.split( /[ _]/ ).join( '-' ).camelize();
		
		return "on" + onEvent_name.charAt( 0 ).toUpperCase() + onEvent_name.substr( 1 );
	},
	
	listenForEvent: function( event_source, event_name, use_capture, onEvent_name ) {
		if ( ! onEvent_name )
			onEvent_name = this.getEventHandlerName( event_name );
		
		if ( ! this._listens ) this._listens = new Array();
		
		var cb = this[ onEvent_name ].bindAsEventListener( this );
		this._listens.push( [ event_source, event_name, use_capture, onEvent_name, cb ] )
		
		event_source.addEventListener( event_name, cb, use_capture );
	},
	
	stopListeningForEvent: function( event_source, event_name, use_capture, onEvent_name ) {
		if ( ! this._listens ) return false;
		
		if ( ! onEvent_name )
			onEvent_name = this.getEventHandlerName( event_name );
		
		var ix_item;
		var ls = this._listens.detect( function( val, ix ) {
			if ( ( val[ 0 ] == event_source ) && ( val[ 1 ] == event_name ) && ( val[ 2 ] == use_capture ) && ( val[ 3 ] == onEvent_name ) ) {
				ix_item = ix;
				return true;
			}
		} );
		
		if ( ix_item ) {
			this._listens.splice( ix_item, 1 );
			
			event_source.removeEventListener( event_name, ls[ 4 ], use_capture );
			
			return true;
		}
		
		return false;
	}
} );

Object.extend( Event, {
	create: function( event_data, can_bubble, cancelable, fl_dispatch, target ) {
		var event;
		
		if ( document.createEvent ) {  // gecko, safari
			if ( ! can_bubble ) can_bubble = false;
			if ( ! cancelable ) cancelable = false;
			
			if ( /Konqueror|Safari|KHTML/.test( navigator.userAgent ) ) {
				event = document.createEvent( 'HTMLEvents' )
				
				event.initEvent( 'click', can_bubble, cancelable );
			}
			else {  // gecko uses MouseEvents
				event = document.createEvent( 'MouseEvents' )
				
				event.initMouseEvent( "click", can_bubble, cancelable,
				                      window, 0, 0, 0, 0, 0,
				                      false, false, false, false, 0, null );
			}
		}
		else {  // msie
			event = document.createEventObject();
			event.event_type = 'click';
		}
		
		event.event_data = event_data;
		
		if ( fl_dispatch )
			Event.dispatch( target, event );
		
		return event;
	},
	
	dispatch: function( target, event ) {
		if ( document.createEvent )
			return target.dispatchEvent( event );
		else
			return target.fireEvent( ( typeof( event.event_type ) != "undefined" ) ? event.event_type : 'onclick', event );
	}
} );

//Other
var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 0 && navigator.userAgent.indexOf('Mac') < 0 ? 1 : 0;
var isIEMac = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Mac') > -1 ? 1 : 0;
var isMac = navigator.userAgent.toLowerCase().indexOf('mac') > -1 ? 1 : 0;
var isWin = navigator.userAgent.toLowerCase().indexOf('win') > -1 ? 1 : 0;
var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0;
var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0;
var isSa = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') > 1 ? 1 : 0;
var isFF = navigator.userAgent.indexOf("Firefox/") > -1 ? 1 : 0;
var isNS47 = (navigator.appName=="Netscape"&&parseFloat(navigator.appVersion)>=4.7) ? 1 : 0;
var isDHTML = (document.getElementById || document.all || document.layers);

function isWinXPAndNewer()
{
    var v = false;
    var i = navigator.userAgent.indexOf('Windows NT');
    if(i > -1)
    {
        var l = navigator.userAgent.length;
        var s;
        for(var j=i; i<navigator.userAgent.length; j++)
        {
            s = navigator.userAgent.substring(j, j+1);
            if(s == ";" || s == ")")
            {
                if(parseFloat(navigator.userAgent.substring(i+11,j)) >= 5.1)
                {
                    v = true;
                }
                break;
            }
        }
    }
    return v;
}

function scrollLayer(id, amount, time)
{
	var clipTop, clipBottom, topper;
	
	if (!isDHTML) 
		return;
		
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function getQueryString(params) {
	var variablePairs = new Array();
	for (var name in params) { 
    	if(name != "removeItems")
    	{
    		variablePairs.push(name + "=" + escape(params[name])); 
    	}
	}
	return (variablePairs.length > 0) ? variablePairs.join("&"):false;
}
	
// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}
function writeLayer(ID,parentID,sText)
{ 
	if (document.layers) 
	{ 
		var oLayer; 
		if(parentID)
		{ 
			oLayer = eval('document.' + parentID + '.document.' + ID + '.document'); 
		}
		else
		{ 
			oLayer = document.layers[ID].document; 
		} 
		oLayer.open(); 
		oLayer.write(sText); 
		oLayer.close(); 
	}
	else
	{
		var o = findObj(ID);
		if(o != null)
		{
			o.innerHTML = sText;
		}
	}
}

//OTHER
/*
a 
defines the action you want the function to perform. 
o 
the object in question. 
c1 
the name of the first class 
c2 
the name of the second class 
Possible actions are:

swap 
replaces class c1 with class c2 in object o. 
add 
adds class c1 to the object o. 
remove 
removes class c1 from the object o. 
check 
test if class c1 is already applied to object o and returns true or false. 
*/
function jscss(a,o,c1,c2)
{
  switch (a){
    case 'swap':
      o.className=!jscss('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
    break;
    case 'add':
      if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
    break;
    case 'remove':
      var rep=o.className.match(' '+c1)?' '+c1:c1;
      o.className=o.className.replace(rep,'');
    break;
    case 'check':
      return new RegExp('\\b'+c1+'\\b').test(o.className);
    break;
  }
}

function setFullScreen()
{
	try
	{
	    window.moveTo(0,0);
		if(document.all) 
		{ 
  			window.resizeTo(screen.availWidth,screen.availHeight); 
		} 
		else if(document.layers || document.getElementById) 
		{ 
  			if(window.outerHeight < self.screen.availHeight || window.outerWidth < self.screen.availWidth)
			{ 
				window.outerHeight = self.screen.availHeight; 
				window.outerWidth = self.screen.availWidth; 
			} 
		}
	}
	catch(ex)
	{
	}
}

function calcTime(date1, date2)
{
	var diff  = new Date();
	var timediff = 0;
	
	diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

	timediff = diff.getTime();

	var weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
	timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

	var days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
	timediff -= days * (1000 * 60 * 60 * 24);

	var hours = Math.floor(timediff / (1000 * 60 * 60)); 
	timediff -= hours * (1000 * 60 * 60);

	var mins = Math.floor(timediff / (1000 * 60)); 
	timediff -= mins * (1000 * 60);

	var secs = Math.floor(timediff / 1000); 
	timediff -= secs * 1000;
}

function detectRealPlayer()
{
	var mpInfo = {
		installed: false,
		scriptable: false,
		type: null,
		versionInfo: null
	};
	//var rp = "rmocx.RealPlayer G2 Control.1";
	var rp1 = "RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)";
	var rp2 = "rmocx.RealPlayer G2 Control";
	if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1) || window.GeckoActiveXObject)
	{
		//alert("RP activex");
		var player = createActiveXObject(rp1);
		if(player != null)
		{
			//alert("Real player not installed");
			mpInfo.installed = true;
			mpInfo.scriptable = true;
			mpInfo.type = "ActiveX";
			mpInfo.versionInfo = player.GetVersionInfo();
			
			return mpInfo;
		}
		else
		{
		    player = createActiveXObject(rp2);
		    if(player != null)
		    {
		        mpInfo.installed = true;
			    mpInfo.scriptable = true;
			    mpInfo.type = "ActiveX";
			    mpInfo.versionInfo = "6";
			    
			    return mpInfo;
		    }
		    else if(navigator.plugins != null)
		    {
			    //alert("Real Player Plugin with ActiveX");
			    var plugin;
			    var numPlugins = navigator.plugins.length;
			    for (var i = 0; i < numPlugins; i++)
			    {
  				    plugin = navigator.plugins[i];
  				    if (plugin.name.indexOf("RealPlayer") > -1)
  				    {
    				    //alert("You have the RealPlayer Plug-in installed!");
    				    mpInfo.installed = true;
					    mpInfo.scriptable = true;
					    mpInfo.versionInfo = "G2";
    				    break;
  				    }
			    }
			    
			    return mpInfo;
		    }
		    else
		    {
		        return mpInfo;
		    }
		}
	}
	else if(navigator.mimeTypes)
	{
	    var plugin;
		var numPlugins = navigator.plugins.length;
	    for (var i = 0; i < numPlugins; i++)
	    {
		    plugin = navigator.plugins[i];
		    if (plugin.name.indexOf("RealPlayer") > -1)
		    {
			    //alert("You have the RealPlayer Plug-in installed!");
			    mpInfo.installed = true;
			    mpInfo.scriptable = true;
			    mpInfo.versionInfo = "G2";
			    mpInfo.type = "NetscapePlugin";
			    break;
		    }
	    }
	    
	    return mpInfo;
	}
	else
	{
	    return mpInfo;
	}
}
function detectWMP()
{
	var mpInfo = {
		installed: false,
		scriptable: false,
		type: null,
		versionInfo: 6.4
	};
	
	var player = null;
	var wmp64 = "MediaPlayer.MediaPlayer.1";
	var wmp7 = "WMPlayer.OCX.7";
	if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1))
	{
		mpInfo.type = "ActiveX";
		player = createActiveXObject(wmp7);
		if(player)
		{
			mpInfo.installed = true;
			mpInfo.scriptable = true;
			mpInfo.versionInfo = player.versionInfo;
		}
		else
		{
			player = createActiveXObject(wmp64);
			if(player)
			{
				mpInfo.installed = true;
				mpInfo.scriptable = true;
				mpInfo.versionInfo = 6.4;
			}
		}
	}
    else if(window.GeckoActiveXObject)
    {
      // Netscape 7.1 object instantiation --use of GeckoActiveXObject
      //wmp7+
      player = createActiveXObject("{6BF52A52-394A-11d3-B153-00C04F79FAA6}");
      if(player != null)
      {
        mpInfo.type = "GekkoActiveX";
		mpInfo.installed = true;
		mpInfo.scriptable = true;
		mpInfo.versionInfo = player.versionInfo;
      }
      else
      {
        player = createActiveXObject("{22D6F312-B0F6-11D0-94AB-0080C74C7E95}");
        if(player != null)
        {
            mpInfo.type = "GekkoActiveX";
		    mpInfo.installed = true;
		    mpInfo.scriptable = true;
		    mpInfo.versionInfo = 6.4;
        }
        else
        {
            mpInfo = detectWMPPlugin();
        }
      }
    }
    else if(navigator.mimeTypes)
    {
        // Plugin architecture, such as in Netscape 4x - 7.02 and Opera browsers
        mpInfo = detectWMPPlugin();
    }
	
	return mpInfo;
}
function detectWMPPlugin()
{
    var mpInfo = {
		installed: false,
		scriptable: false,
		type: null,
		versionInfo: 6.4
	};
	
    // Plugin architecture, such as in Netscape 4x - 7.02 and Opera browsers
    if(typeof(navigator.plugins) != undefined)
	{
	    for (var i = 0; i < navigator.plugins.length; i++) 
		{
			if (navigator.plugins[i].name.indexOf("Windows Media Player") > -1)
			{
			    if(navigator.plugins[i].name.indexOf("Firefox Plugin") > -1)
			    {
				    mpInfo.installed = true;
				    mpInfo.scriptable = true;
				    mpInfo.type = "GekkoPlugin";
				    mpInfo.versionInfo = 7.0;
			    }
			    else
			    {
				    mpInfo.installed = true;
				    mpInfo.scriptable = false;
				    mpInfo.type = "Applet";
				    mpInfo.versionInfo = 7.0;
			    }			
				break;
			}
		}
	}
	else if(typeof(navigator.mimetypes) != undefined)
	{
	    player = navigator.mimeTypes['application/x-mplayer2'].enabledPlugin;
	    if(player)
	    {	
		    mpInfo.installed = true;
		    mpInfo.type = "Plugin";
		    mpInfo.versionInfo = 6.4;
	    }
	}
	return mpInfo;
}
function createActiveXObject(id)
{
  var error;
  var control = null;

  try
  {
    if (window.ActiveXObject)
    {
      control = new ActiveXObject(id);
    }
    else if (window.GeckoActiveXObject)
    {
      control = new GeckoActiveXObject(id);
    }
  }
  catch (error)
  {
    ;
  }
  return control;
}

function getMediaFormat(url)
{
	var format = null;
	if(url != null)
	{
		var ext = url.substring(url.lastIndexOf("."));
		switch(ext)
		{
			case ".wmv":
			case ".wma":
			case ".asx":
			case ".asf":
			{
				format = "WindowsMedia";
				break;
			}
			case ".rm":
			case ".smi":
			{
				format = "RealMedia";
				break;
			}
			case ".swf":
			case ".flv":
			{
				format = "Flash";
				break;
			}
		}
	}
	return format;
}
function getMediaPlayerFromUrl(url)
{
	var x = null;
	if(url != null)
	{
		var ext = url.substring(url.lastIndexOf("."));
		switch(ext)
		{
			case ".wmv":
			case ".wma":
			case ".asx":
			case ".asf":
			{
				x = "wmp";
				break;
			}
			case ".rm":
			case ".smi":
			{
				x = "rp";
				break;
			}
			case ".swf":
			case ".flv":
			{
				x = "fp";
				break;
			}
		}
	}
	return x;
}

function toSeconds(time)
{
	//hh:mm:ss or mm:ss
	var h = 0;
	var m = 0;
	var s = 0;
	var t = time.split(":");
	if(t.length == 3)
	{
		if(t[0].substring(0,1) == "0")
		{
			t[0] = t[0].substring(1);
		}
		h = parseInt(t[0]);
		
		if(t[1].substring(0,1) == "0")
		{
			t[1] = t[1].substring(1);
		}
		m = parseInt(t[1]);
		
		if(t[2].substring(0,1) == "0")
		{
			t[2] = t[2].substring(1);
		}
		s = parseInt(t[2]);
	}
	else if(t.length == 2)
	{
		if(t[0].length > 1 && t[0].substring(0,1) == "0")
		{
			t[0] = t[0].substring(1);
		}
		m = parseInt(t[0]);
		
		if(t[1].substring(0,1) == "0")
		{
			t[1] = t[1].substring(1);
		}
		s = parseInt(t[1]);
	}
	
	return h*3600+m*60+s;
}
	
function isClass(object, className) {
	return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
}

function getElementsWithClassName(elementName,className) {
	var allElements = document.getElementsByTagName(elementName);
	var elemColl = new Array();
	for (i = 0; i< allElements.length; i++) {
		if (isClass(allElements[i], className)) {
			elemColl[elemColl.length] = allElements[i];
		}
	}
	return elemColl;
}

function getElementsByClassName(obj,className) {
	var allElements = obj.childNodes;
	var elemColl = new Array();
	for (var i = 0; i< allElements.length; i++) {
		if (allElements[i].className == className) 
		{
			elemColl[elemColl.length] = allElements[i];
		}
	}
	return elemColl;
}

function getChildElementsByName(object, name)
{
	//alert(name);
	name = name ? name.toLowerCase() : "div";
	var o = object.childNodes;
	var c = new Array();
	if(o != null)
	{
		for(var i=0; i<o.length;i++)
		{
			if(o[i].nodeName.toLowerCase() == name)
			{
				c.push(o[i]);
			}
		}
	}
	return c;
}

function getMaxHeight(o)
{
	var h = o.offsetHeight;
	var c = o.childNodes.firstChild;
	for(var i=0; i<o.childNodes.length; i++)
	{
		if(o.childNodes[i].offsetHeight > h)
			h = o.childNodes[i].offsetHeight;
	}
	return h;
}

function getStyle(el, style) {
	if(!document.getElementById) 
		return;
    var value = el.style[toCamelCase(style)];
    if(!value)
    {
        if(document.defaultView)
        {
            value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
        }
        else if(el.currentStyle)
        {
            value = el.currentStyle[toCamelCase(style)];
        }
     }
     return value;
}

/** toCamelCase(input)
 * Converts string input to a camel cased version of itself.
 * For example:
 * toCamelCase("z-index"); // returns zIndex
 * toCamelCase("border-bottom-style"); // returns borderBottomStyle.
 */
function toCamelCase( sInput ) {
    var oStringList = sInput.split('-');
    if(oStringList.length == 1)    
        return oStringList[0];
    var ret = sInput.indexOf("-") == 0 ? 
    	oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
    for(var i = 1, len = oStringList.length; i < len; i++){
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1);
    }
    return ret;
}

// file: pagequery_api.js
// javascript query string parsing utils
// pass location.search to the constructor: var page = new PageQuery(location.search)
// get values like: var myValue = page.getValue("param1") etc.
// djohnson@ibsys.com {{djohnson}}
// you may use this file as you wish but please keep this header with it thanks

function PageQuery(q) {
	q = q ? q : location.search;
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return null;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}

// Implement function.apply for browsers which don't support it natively
// Courtesy of Aaron Boodman - http://youngpup.net
if (!Function.prototype.apply) {
      Function.prototype.apply = function(oScope, args) {
		    var sarg = [];
		    var rtrn, call;
		
		    if (!oScope) oScope = window;
		    if (!args) args = [];
		
		    for (var i = 0; i < args.length; i++) {
		            sarg[i] = "args["+i+"]";
		    }
		
		    call = "oScope.__applyTemp__(" + sarg.join(",") + ");";
		
		    oScope.__applyTemp__ = this;
		    rtrn = eval(call);
		    oScope.__applyTemp__ = null;
		    return rtrn;
      }
}

/*
 * FlashObject embed
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.1.0 - 03-31-2005
 *
 * writes the embed code for a flash movie, includes plugin detection
 *
 * Usage:
 *
 *	myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
 *	myFlash.write("objId");
 *
 * for best practices, see:
 *  http://blog.deconcept.com/2005/03/31/proper-flash-embedding-flashobject-best-practices/
 *
 */

var FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver;
	this.align = "middle";

	this.params = new Object();
	this.variables = new Object();

	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.bypassTxt = "<p>Already have Macromedia Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
	
	this.color = (c != null)?c:"#ffffff";
	
	//default params
	this.addParam('bgcolor', this.color);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
	
	this.installedVersion = getFlashVersion();
	if(this.installedVersion < this.version)
	{
	    var updateMessage = "To see this webcast you need to update your flash player. Would you like to download Adobe flash player now?";
		var yes = confirm(updateMessage);
		if(yes)
		{
			window.location.href = "http://www.adobe.com/products/flashplayer/";
		}
	}
}

var FOP = FlashObject.prototype;

FOP.addParam = function(name, value) { this.params[name] = value.toString(); }

FOP.getParams = function() { return this.params; }

FOP.getParam = function(name) { return this.params[name]; }

FOP.addVariable = function(name, value) { this.variables[name] = value; }

FOP.getVariable = function(name) { return this.variables[name]; }

FOP.getVariables = function() { return this.variables; }

FOP.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '\n\t\t<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    return (paramTags == "") ? false:paramTags;
}

FOP.getHTML = function() {
	//alert(navigator.userAgent);
	var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 0 && navigator.userAgent.indexOf('Mac') < 0 ? 1 : 0;
	var isIEMac = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Mac') > -1 ? 1 : 0;
	var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0;
	var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0;
	var isSa = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') > 1 ? 1 : 0;
	
	var flashHTML = "";
	if(isIE && !isIEMac)
	{
		flashHTML += '\n\t<object id="'+this.id+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=' + this.version + ',0,0,0" width="' + this.width + '" height="' + this.height + '" align="' + this.align + '">';
		flashHTML += '\n\t\t<param name="movie" value="' + this.swf + '" />';
		if (this.getParamTags()) {
			flashHTML += this.getParamTags();
		}
		if (this.getVariablePairs() != null) {
			flashHTML += '\n\t\t<param name="flashVars" value="' + this.getVariablePairs() + '" />';
		}
		flashHTML += '\n\t</object>\n';
	}
	else{
		//fix for safari, ignoring parameter tags
		if(isSa && this.getVariablePairs() != null){
			this.swf = this.swf + "?" + this.getVariablePairs();
		}
		
		flashHTML += '\n\t<object id="' + this.id + '" data="' + this.swf + '" type="application/x-shockwave-flash" width="' + this.width + '" height="' + this.height + '" align="' + this.align + '">';
		
		for (var param in this.getParams()) {
			flashHTML += '\n\t\t<param name="' + param + '" value="' + this.getParam(param) + '" />';
		}
		
		//tell flash to use getURL
		//this.addVariable("usefs", "0");
		if (this.getVariablePairs() != null) {
			flashHTML += '\n\t\t<param name="flashVars" value="' + this.getVariablePairs() + '" />';
		}
		flashHTML += '\n\t\t<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />';
		flashHTML += '\n\t</object>\n';
	}
	//alert(flashHTML);
  return flashHTML;	
}

FOP.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) { 
    	variablePairs.push(name + "=" + escape(this.getVariable(name))); 
    }
    return (variablePairs.length > 0) ? variablePairs.join("&"):false;
}

FOP.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) 
		{
			var o = document.getElementById(elementId);
			if(o != null)
			{
			    o.innerHTML = this.getHTML();
			}
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else if (this.altTxt) {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}

//detection functions
function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			var y = x.description;
			var z = 1;
			for(var i=y.indexOf('.'); i>0; i--){
			    if(y.charAt(i) == ' '){
			        z = i+1;
			        break;
			    }
			}
			flashversion = parseInt(y.substring(z, y.indexOf('.')));
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	return (getFlashVersion() >= ver) ? true:false; }

//get value of query string param
function getQueryParamValue(param) {
	var q = document.location.search || document.location.href.split("#")[1];
	if (q) {
		var detectIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", detectIndex) > -1) ? q.indexOf("&", detectIndex) : q.length;
		if (q.length > 1 && detectIndex > -1) {
			return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
		} else {
			return "";
		}
	}
}

//add Array.push if needed
if(Array.prototype.push == null)
{
	Array.prototype.push = function(item) { this[this.length] = item; return this.length; }
}
