var appVersion = navigator.appVersion;
var ie4 = (document.all) ? true : false;
var ie5 = ( navigator.appVersion.indexOf("MSIE 5") != -1 );
var ns4 = ( document.layers) ? true : false;
var ns6 = ( (navigator.appName.indexOf("Netscape") != -1) && parseInt(navigator.appVersion) >= 5 );
var mac = ( navigator.userAgent.indexOf("Mac") != -1) ? true : false;
var gek = ( navigator.userAgent.indexOf("Gecko") != -1 );
var sf01 = ( navigator.userAgent.indexOf("KHTML") != -1);
var sf12 = ( parseInt(navigator.appVersion.replace(/.*AppleWebKit\//i, "")) >= 124 ) ;

if (ns4) { window.onresize=fixMe; }
if (ns4) { origWidth = innerWidth; origHeight = innerHeight; }
function fixMe() { if (innerWidth != origWidth || innerHeight != origHeight) self.location.reload(); }

function imgComplete( img ) { return ( img.complete ); }
function sfImgComplete( img ) { return ( img.width > 0 ); }
function ieRedrawWindow() { window.resizeBy( 0, 1 ); window.resizeBy( 0, -1 ); }
function redrawWindow() { }

if ( mac && ie5 ) Array.prototype.push = function() {
	redrawWindow = ieRedrawWindow;

	var thisArray = this, x;
	for ( x=0; x < arguments.length; x++ ) {
		thisArray[ thisArray.length ] = arguments[x];
	}
	return thisArray.length;
}

if ( sf01 || sf12 ) imgComplete = sfImgComplete;


var urlValueOf = new Array(), queryDataArray = location.search.substr(1).split(/\&|;|\&;/);
for ( var x=0; x < queryDataArray.length; x++ ) {
	var thisQueryVariable = queryDataArray[x].split("=");
	urlValueOf[ thisQueryVariable[0] ] = new Object();
	urlValueOf[ thisQueryVariable[0] ] = thisQueryVariable[1];
}


function nsD(elementName, w){ w = (w) ? w : top; return w.document.layers[elementName]; }
function nsShow(element, w) { d(element, w).display = "block"; }
function nsHide(element, w) { d(element, w).display = "none"; }
function nsClip(element, t, r, b, l)  {
	var obj = d(element);
	obj.clip.top = t;
	obj.clip.right = r;
	obj.clip.bottom = b;
	obj.clip.left = l;
}

function mozD(elementName, w) { w = (w) ? w : self; return w.document.getElementById(elementName); }
function mozShow(elementID, w)  { w = (w) ? w : self; d(elementID, w).style.display = "block"; }
function mozHide(elementID, w)  { w = (w) ? w : self; d(elementID, w).style.display = "none"; }
function mozvShow(elementID, w)  { w = (w) ? w : self; d(elementID, w).style.visibility = "visible"; }
function mozvHide(elementID, w)  { w = (w) ? w : self; d(elementID, w).style.visibility = "hidden"; }
function mozClip(elementID, t, r, b, l)  { w = (w) ? w : self; d(elementID, w).style.clip = "rect(" + t + "," + r + "," + b + "," + l + ")"; }
function mozSetOpacity(element, alpha) { element.style.MozOpacity = alpha; }
function w3cSetOpacity(element, alpha) { element.style.opacity = alpha; }
function ieSetOpacity(element, alpha) { element.style.filter = "Alpha(Opacity=" + alpha*100 + ")"; }
function fakeSetOpacity(element, alpha) { if ( alpha > 0 ) Show(element); else Hide(element); }
function macIe_bindEvent( element, event, func ) { eval( 'element.on' + event + ' = '+ func ); }
function ie_bindEvent( element, event, func ) {	element.attachEvent( 'on' + event, function(e) { return func( e, element)} ); }
function w3_bindEvent( element, event, func ) {	element.addEventListener(event, function(e) { return func( e, element ) }, false ); }
function macIeShow(element, w)  { w = (w) ? w : self; element.style.visibility = "visible"; }
function macIeHide(element, w)  { w = (w) ? w : self; element.style.visibility = "hidden"; }

function getTarget(e) {
	e = e || window.event;
	var targ = e.target || e.srcElement;
	return targ;
}

var d, Show, Hide, Clip, setOpacity, bindEvent;
if ( ns4 ) {
	d = nsD,
	Show = nsShow;
	Hide = nsHide;
	Clip = nsClip;
}
else {
	d = mozD;
	vShow = mozvShow;
	vHide = mozvHide;
	Show = mozShow;
	Hide = mozHide;
	Clip = mozClip;
	bindEvent = w3_bindEvent;

	if ( (mac && ie4) || (sf01 && !sf12) ) setOpacity = fakeSetOpacity;
	else if ( !mac && ie4 ) {
		bindEvent = ie_bindEvent;
		setOpacity = ieSetOpacity;
	}
	else if ( sf12 ) setOpacity = w3cSetOpacity;
	else if ( ns6 ) setOpacity = mozSetOpacity;
	if ( mac && ie4 ) {
		bindEvent = macIe_bindEvent;
		Hide = macIeHide;
		Show = macIeShow;
	}
}

function Swap( oldID, newID, w ) {
	Hide( oldID, w );
	Show( newID, w );
	return newID;
}


/**************************************************************
	F A D I N G    F U N C T I O N S
**************************************************************/
var rate = 80,
	smoothFade = [ 0, 0.15, 0.3090169943749475, .435, 0.5877852522924731, .69, 0.8090169943749475, .875, 0.9510565162951535, .975, .9999999999999 ],
	fadeSteps = [ 0, 0.3090169943749475, 0.5877852522924731, 0.8090169943749475, 0.9510565162951535, .9999999 ],
	quickFade = [ 0, .33, .66, .9999 ],
	cutsOnly = [ 0, .9999 ],
	fadeObj = new Array();
function FadeObj(element, ramp)
{
	this.style = element.style;
	this.buffer = 0;		//	buffers events during fades to address after the fade
	this.idle = true;		// to ignore events while a fade is in progress
	this.timerCache = null;
	this.ramp = ( ramp ) ? ramp : fadeSteps;
	this.f = this.ramp.length;
	this.HTMLelement = element;
	this.id = element.id;
	FadeObj.prototype.fade = function()		//	determines whether to fade up or down
	{
		var thisObj = this;
		if ( thisObj.idle )
		{
			thisObj.idle = false;
			if (thisObj.f > 0) thisObj.fadeDown();
			else thisObj.fadeUp();
		}
		else thisObj.buffer++;
	}

	FadeObj.prototype.fadeUp = function()
	{
		var thisObj = this;
		if ( thisObj.f == 0 )
			thisObj.performance.startTimeIndex = new Date().getTime();
		var x = thisObj.f+1;
		if ( x < thisObj.ramp.length )
		{
			thisObj.f++;
			setOpacity(thisObj.HTMLelement, thisObj.ramp[x]);
			thisObj.timerCache = setTimeout(function() {thisObj.fadeUp() }, rate);
		}
		else
		{
			thisObj.f = thisObj.ramp.length;
			if ( thisObj.performance.adaptive )
				thisObj.callibrate();
	
			thisObj.callBack();
			if ( thisObj.buffer > 0 )
			{
				thisObj.buffer--;
				thisObj.idle = true;
				thisObj.fade();
			}
			else thisObj.idle = true;
		}
	}
	
	FadeObj.prototype.fadeDown = function()
	{
		var thisObj = this;
		if ( thisObj.f == 0 )
			thisObj.performance.startTimeIndex = new Date().getTime();
		var x = thisObj.f-2;
		if ( x > -1 )
		{
			thisObj.f--;
			setOpacity(thisObj.HTMLelement, thisObj.ramp[x]);
			thisObj.timerCache = setTimeout(function() { thisObj.fadeDown() }, rate);
		}
		else
		{
			thisObj.f = 0;
			if ( thisObj.performance.adaptive )
				thisObj.callibrate();
	
			thisObj.callBack();
			if ( thisObj.buffer > 0 )
			{
				thisObj.buffer--;
				thisObj.idle = true;
				thisObj.fade();
			}
			else thisObj.idle = true;
		}
	}

	FadeObj.prototype.snapOff = function() { setOpacity(this, 0); this.f = 0; };
	FadeObj.prototype.snapOn = function() { setOpacity(this, .9999); this.f = ramp.length; };
	FadeObj.prototype.callBack = function() {};

	// setOpacity is depricated and only for backward compatibility
	FadeObj.prototype.setOpacity = function() { setOpacity(this, 0); this.f = 0; };

	// Benchmarking variables
	var performance = new Object();
	performance.adaptive = false;								// flag to dynamically select opacity ramps for optimum performance
	performance.referenceTime = ( this.ramp.length-2 ) * rate;	// ideal time required to complete fade in milliseconds
	performance.startTimeIndex = 0;
	performance.stopTimeIndex = 0;
	performance.actualTime = 0;
	performance.benchmark = 0;

	this.performance = performance;
	FadeObj.prototype.callibrate = function()
	{
		var thisObj = this;
			thisObj.performance.stopTimeIndex = new Date().getTime();
			thisObj.performance.actualTime = thisObj.performance.stopTimeIndex - thisObj.performance.startTimeIndex;
			thisObj.performance.benchmark = thisObj.performance.actualTime / thisObj.performance.referenceTime;
			if ( thisObj.performance.benchmark > 3 )
			{
				thisObj.ramp = fadeSteps;
				thisObj.performance.referenceTime = ( thisObj.ramp.length-2 ) * rate;
			}
			else if ( thisObj.performance.benchmark > 6 )
			{
				thisObj.ramp = quickFade;
				thisObj.performance.referenceTime = ( thisObj.ramp.length-2 ) * rate;
			}
			else if ( thisObj.performance.benchmark > 12 )
			{
				thisObj.ramp = cutsOnly;
				thisObj.performance.referenceTime = ( thisObj.ramp.length-2 ) * rate;
			}
	}

	fadeObj[this.id] = this;
	return this;
}

/**************************************************************
	S L I D E S H O W    F U N C T I O N S
**************************************************************/
var slideShowObj = new Array();
function SlideshowObject( containerElement, frameElements, delay, initialDelay, fadeRamp )
{
	var thisObj = new Object();
	thisObj.slides = d( containerElement ).getElementsByTagName( frameElements );
	thisObj.delay = delay * 1000;
	thisObj.initialDelay = ( initialDelay ) ? initialDelay * 1000 : 0;
	thisObj.ramp = ( fadeRamp ) ? fadeRamp : fadeSteps;
	thisObj.cycleFrames = [];
	thisObj.currentSlide = 0;

	for ( x=0; x < thisObj.slides.length; x++ )
	{
		thisObj.cycleFrames.push( new FadeObj( thisObj.slides[x], thisObj.ramp ) );
		redrawWindow();						// prevents MacIE from clearing top & left values
		thisObj.cycleFrames[x].performance.adaptive = true;
		thisObj.cycleFrames[x].snapOff();
	}
	thisObj.rotateSlide = function() { rotateSlide( containerElement ) };
	thisObj.cycleFrames[0].fadeUp();
	slideShowObj[ containerElement ] = thisObj;
	setTimeout( 'slideShowObj["' + containerElement + '"].rotateSlide()', slideShowObj[ containerElement ].initialDelay );
	return slideShowObj[ containerElement ];
}

function rotateSlide( slideShowID )
{
	var nextFrame, prevFrame,
		thisSlideShowObj = slideShowObj[ slideShowID ];
	prevFrame = thisSlideShowObj.currentSlide;
	thisSlideShowObj.currentSlide++;
	nextFrame = thisSlideShowObj.currentSlide;
	if ( thisSlideShowObj.currentSlide == thisSlideShowObj.cycleFrames.length )
	{
		thisSlideShowObj.currentSlide = 0;
		nextFrame = 0;
		thisSlideShowObj.cycleFrames[ prevFrame ].fade()	// just fade down the last slide in the list to reveal the first one
	}
	else if ( thisSlideShowObj.currentSlide == 1 )
		thisSlideShowObj.cycleFrames[ nextFrame ].fade();	// don't fade out the first slide in the list
	else
	{
		thisSlideShowObj.cycleFrames[ nextFrame ].callBack = function() { thisSlideShowObj.cycleFrames[ prevFrame ].snapOff(); }		// set callBack to hide previous slide when fade is complete
		thisSlideShowObj.cycleFrames[ nextFrame ].fade();
	}

//window.status = 'length: ' + thisSlideShowObj.cycleFrames.length + ', prev: ' + prevFrame + ', next: ' + nextFrame + ', curr: ' + thisSlideShowObj.currentSlide + ', id: ' + thisSlideShowObj.cycleFrames[ prevFrame ].id;
	setTimeout( 'slideShowObj["' + slideShowID + '"].rotateSlide()', thisSlideShowObj.delay );
}

/**************************************************************
	S C R O L L B A R    F U N C T I O N S
**************************************************************/
var sThumb, scrollableContent, scrollableWindow, sWell, sWellHeight, sWellDist, scrollPaneIncr, scrollTimer, scrollIncrement = 20, scrollDelay = 50;

/* Initialize elements for scrolling: container, contents, scrollbar, well, and shuttle */
function initScrollbar( scrollableElementID, scrollContainerID, containerWidth, containerHeight ) {
	sThumb = d("scrollThumbShell");

	scrollableContent = d( scrollableElementID );
	scrollableContent.style.width = containerWidth - 20 + 'px';

	scrollableWindow = d( scrollContainerID );
	scrollableWindow.style.height = containerHeight + 'px';

	bindEvent( top.window, "keypress", keyboardEvents );
	bindEvent( window, "keypress", keyboardEvents );
	bindEvent( window, "DOMMouseScroll", getMouseWheel );
	bindEvent( top.window, "mousewheel", getMouseWheel );
	bindEvent( document, "mousewheel", getMouseWheel );

	sWellHeight = containerHeight - 32;
	d("scrollWell").style.height = sWellHeight + 'px';

	sThumbHeight = ( containerHeight >= scrollableContent.clientHeight ) ? sWellHeight : containerHeight / scrollableContent.clientHeight * sWellHeight;
	sWellDist = sWellHeight - sThumbHeight;
	sWinDist = scrollableContent.clientHeight - containerHeight;

	d("scrollThumb").style.height = sThumbHeight + "px";
}

function getMouseWheel(event) {
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		if (window.opera) delta = -delta;
	}
	else if (event.detail) {
		delta = -event.detail/3;
	}
	scrollPage(delta*15);
}

function scrollPage( distance ) {
	if ( distance < 0 ) moveDown( -distance );
	else moveUp( distance );
}

function keyboardEvents(event) {
	var upArrowCode, upArrowCode, pageUpCode, pageDownCode, homeCode, endCode;
	if ( sf01 || sf12 ) {
		upArrowCode = 63232;
		downArrowCode = 63233;
		pageUpCode = 63276;
		pageDownCode =63277;
		homeCode = 63273;
		endCode = 63275;
	}
	else {
		upArrowCode = 38;
		downArrowCode = 40;
		pageUpCode = 33;
		pageDownCode = 34;
		homeCode = 36;
		endCode = 35;
	}
	
	switch( event.keyCode ) {
		case upArrowCode:
			moveUp();
			break;
		case downArrowCode:
			moveDown();
			break;
		case pageUpCode:
			moveUp( sWellHeight );
			break;
		case pageDownCode:
			moveDown( sWellHeight );
			break;
		case homeCode:
			moveUp( sWinDist );
			break;
		case endCode:
			moveDown( 99999999 );
			break;
	}
}

function moveUp( page ) {
	if ( sThumb.offsetTop >= 0 ) {
		var increment = ( page ) ? page : scrollIncrement;
			newPaneTop = ( scrollableContent.offsetTop + increment > 0 ) ? 0 : scrollableContent.offsetTop + increment,
			newThumbTop = 1-newPaneTop/sWinDist * sWellDist;

		sThumb.style.top = newThumbTop + "px";
		scrollableContent.style.top = newPaneTop + "px";
		redrawWindow();
	}
	else stopScrolling();
}

function moveDown( page ) {
	if ( sThumb.offsetTop < sWellDist ) {
		var increment = ( page ) ? page : scrollIncrement;
			newPaneTop =  ( scrollableContent.offsetTop - increment < sWinDist * -1 ) ? 0 - sWinDist : scrollableContent.offsetTop - increment,
			newThumbTop = 1-newPaneTop/sWinDist * sWellDist;

		sThumb.style.top = newThumbTop + "px";
		scrollableContent.style.top = newPaneTop + "px";
		redrawWindow();
	}
	else stopScrolling();
}

function scrollUp() { scrollTimer = setInterval( "moveUp()", scrollDelay ); }
function scrollDown() { scrollTimer = setInterval( "moveDown()", scrollDelay ); }
function stopScrolling() { clearTimeout( scrollTimer ); }

var mouseDown = false, offsetY;

function setMouseOffset( event ) {
	offsetY = event.clientY - sThumb.offsetTop - 1;
	mouseDown=true;
}

function dragPane( event ) {
	var coordY = event.clientY, newThumbY;
	if ( coordY - offsetY < 0 ) newThumbY = 0;
	else if ( coordY - offsetY > sWellDist ) newThumbY = sWellDist;
	else newThumbY = coordY - offsetY;
	if ( mouseDown == true ) {
		sThumb.style.top = newThumbY + "px";
		scrollableContent.style.top = Math.round(0 - newThumbY / sWellDist * sWinDist ) + "px";
		redrawWindow();
	}
}

/**************************************************************
	H O V E R I N G    F U N C T I O N S
**************************************************************/
var mouseX, mouseY,
	midPointX,								//	Midpoint where hovering changes direction
	midPointY,
	nonHoverThrottle = 400,					//	Throttle setting that generates no movement
	initialHoverThrottle = 5,				//	Higher values produce slower motion
	hoverThrottle = initialHoverThrottle,
	hoverTimeout,
	captureMouse;

function W3captureMouse(event) {
	mouseX = event.clientX;
	mouseY = event.clientY;
}

function SFcaptureMouse(event) {
	mouseX = event.clientX - window.scrollX;
	mouseY = event.clientY - window.scrollY;
}

captureMouse = ( sf01 || sf12 ) ? SFcaptureMouse : W3captureMouse;

function initHover( axis ) {
	if ( axis == "x" ) setInterval( 'hoverRailX()', 50 );
	else if ( axis == "y" ) setInterval( 'hoverRailY()', 50 );
	else {
		setInterval( 'hoverRailX()', 50 );
		setInterval( 'hoverRailY()', 50 );
	}
	setHoverMidPoints();
	bindEvent( self, 'resize', setHoverMidPoints );
}

function setHoverMidPoints() {
	if ( ie4 ) {
		midPointX = document.body.clientWidth/2;
		midPointY = document.body.clientHeight/2;
	}
	else {
		midPointX = self.innerWidth/2;
		midPointY = self.innerHeight/2;
	}
//window.status = midPointX;
}

/* startHover & stopHover gradually accellerate & decellerate hovering */
function startHover() {
	clearTimeout( hoverTimeout );
	hoverThrottle = initialHoverThrottle;
}

function hoverRailX() { window.scrollBy( ( mouseX - midPointX )/ hoverThrottle, 0 ); }
function hoverRailY() { window.scrollBy( ( 0, mouseY - midPointY )/ hoverThrottle ); }

if ( mac && ie4 ) {
	startHover = initHover = setHoverMidPoints = function() {}
}

function stopHover() {
	if (  hoverThrottle < nonHoverThrottle ) {
		hoverThrottle = hoverThrottle + 10;
		hoverTimeout = setTimeout( 'stopHover()', 100 );
	}
}



/**************************************************************
	Parses hidden data contained in hidden span tags
	and returns an array of the data:
		ID's are used as entry IDs
		classNames are used as field names
**************************************************************/
function parseHTMLData( data ) {
	var DataObject = [], thisEntry;
	DataObject.fields = [];
	for ( var x=0; x < data.getElementsByTagName('div').length; x++ ) {
		thisEntry = data.getElementsByTagName('div')[x];
		thisObject = new Object();
		thisObject.id = thisEntry.id.substr(1);
		DataObject.fields = [ 'id' ];

		for ( var y=0; y < thisEntry.getElementsByTagName('span').length; y++ ) {
			var	thisVaiable = thisEntry.getElementsByTagName('span')[y],
				thisKey = thisVaiable.className,
				thisValue = thisVaiable.innerHTML;
			eval( "thisObject." + thisKey + " = thisValue " );

			if ( DataObject.fields.toString().indexOf( thisKey ) == -1 ) DataObject.fields.push( thisKey );
		}
		DataObject.push( thisObject );
	}
	return DataObject;
}


function HTMLtemplate( middle, first, last ) {
	this.middle = middle;
	this.first = ( first ) ? first : middle;
	this.last = ( last ) ? last : middle;
}

/* Returns a template populated with data */
function buildContent( template, data, debug ) {
	var out = '', thisChunk, thisField, thisToken;

	// Populate first item using first template
	thisChunk = template.first;
	for ( var y=0; y < data.fields.length; y++ ) {
		thisField = data.fields[y];
		thisToken = new RegExp('@@' + data.fields[y] + '@@', 'gi');
		thisChunk = thisChunk.replace( thisToken, eval( 'data[0].' + thisField ) );
	}
	thisChunk = thisChunk.replace( /@@index@@/gi, '0' );
	out += thisChunk;

	// Populate 2nd thru last-1 item using middle template
	for ( var x=1; x < data.length-1; x++ ) {
		thisChunk = template.middle;
		for ( var y=0; y < data.fields.length; y++ ) {
			thisField = data.fields[y];
			thisToken = new RegExp('@@' + data.fields[y] + '@@', 'gi');
			thisChunk = thisChunk.replace( thisToken, eval( 'data[x].' + thisField ) );
		}
		thisChunk = thisChunk.replace( /@@index@@/gi, x );
		out += thisChunk;
	}

	// Populate last item using last template
	thisChunk = template.last;
	for ( var y=0; y < data.fields.length; y++ ) {
		thisField = data.fields[y];
		thisToken = new RegExp('@@' + data.fields[y] + '@@', 'gi');
		thisChunk = thisChunk.replace( thisToken, eval( 'data[ data.length-1].' + thisField ) );
	}
	thisChunk = thisChunk.replace( /@@index@@/gi, data.length-1 );
	out += thisChunk;

	if ( debug ) Debug( out, true );
	return out;
}

function newWin( url, name, options ) {
	var newWin = window.open( url, name, options );
}

/* Sets a Cookie with the given name and value.
	name       Name of the cookie
	value      Value of the cookie
	[expires]  Expiration date of the cookie (default: end of current session)
	[path]     Path where the cookie is valid (default: path of calling document)
	[domain]   Domain where the cookie is valid
					(default: domain of calling document)
	[secure]   Boolean value indicating if the cookie transmission requires a
					secure transmission
*/
function setCookie(name, value, path, expires, domain, secure) {
	document.cookie = 
		name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

function clearCookie ( name ) {
	var cookie_date = new Date ();			// current date & time
	cookie_date.setTime ( cookie_date.getTime() - 1 );
	document.cookie = name += "=; expires=" + cookie_date.toGMTString();
}

var Months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
	Days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ];
function showDateTime( showDate )
{
	var currentDate = new Date(),
		prettyTime,
		minutes;

	if ( showDate )
		prettyTime = '<span class="weekday">' + Days[ currentDate.getDay() ] + '</span>' + Months[ currentDate.getMonth() ] + ' ' + currentDate.getDate() + ', ' + currentDate.getFullYear();
	else
	{
		// Pad the minute if less than 10
		minutes = ( currentDate.getMinutes() < 10 ) ? '0' + currentDate.getMinutes() : currentDate.getMinutes();

		if ( currentDate.getHours() > 12 )
			prettyTime = currentDate.getHours() - 12 + ':' + minutes + ' <span class="ampm">pm</span>';
		else
			prettyTime = currentDate.getHours() + ':' + minutes + ' <span class="ampm">am</span>';
	}
	return prettyTime;
}

function generateQTcode( container, src, w , h )
{
var mov_container = ( container ) ? container : 'movie',
	mov_src = ( src ) ? src : ( '/av/' + urlValueOf['src'] ),
	mov_w = ( w ) ? w : ( ( urlValueOf['w'] ) ? urlValueOf['w'] : 320 ) ,
	mov_h = ( h ) ? h : ( parseInt( ( urlValueOf['h'] ) ? urlValueOf['h'] : 240 ) + 16 );
	mov_delay = parseInt( urlValueOf['delay'] ),
	 out = 
		  '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="' + mov_w + '" height="' + mov_h + '" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
		+ '\n	<param name="src" value="' + mov_src + '">'
		+ '\n	<param name="controller" value="true">'
		+ '\n	<param name="target" value="myself">'
		+ '\n	<param name="autoplay" value="false">'
		+ '\n	<param name="bgcolor" value="black">'
		+ '\n	<param name="pluginspage" value="http://www.apple.com/quicktime/download/">'
		+ '\n<embed onmouseup="window.close()" autoplay="false" width="' + mov_w + '" height="' + mov_h + '" controller="true" target="myself" src="' + mov_src + '" bgcolor="black" border="0" pluginspage="http://www.apple.com/quicktime/download/indext.html"></embed>\r</object>';
	d(mov_container).innerHTML = out;
//Debug( out );
}

function Debug(str,code) {
	var str_debug = "";
	if ( code ) {
		str_debug += '<body marginheight="0" marginwidth="0">\n\n';
		str_debug += str;
	}
	else {
		str_debug += '<html><body marginheight="0" style="white-space: pre;font-family: Monaco,Courier;font-size:9px;">\n\n';
		str_debug += str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
	}
	str_debug += "\n\n</body></html>";
	var win_debug = window.open();
	win_debug.document.write(str_debug);
}

