var _article;
var _showingItem = false;
function showGalleryItem(obj, table, className) {
	if(table==undefined)	table = 'CMS_Multimedia';
	if(_article || (_article!=undefined)) 	remove(_article);

	var initHeight = obj.offsetHeight;
	_article = document.createElement('div');
	_article.style.position = 'absolute';
	_article.style.top = (Top($('copy'))+1)+'px';
	_article.style.left = Left($('copy'))+'px';
	_article.style.width = $('copy').offsetWidth+'px';
	_article.style.height = $('copy').offsetHeight+'px';

	_article.style.zIndex=999;
	_article.className = 'article transparent '+((className!=undefined) ? className : '');
	_article.id = '_article';

	document.body.appendChild(_article);

	var xml = load('/boss/bossCMS.php?getFields&table='+table+'&id='+obj.id+'&0=id&1=image&2=copy&3=label&4=date&5=subheading');
	var img = ParseXML(xml, Array('image'));
	var copy = unescape(ParseXML(xml, Array('copy')));
	var label = unescape(ParseXML(xml, Array('label')));
	var subheading = unescape(ParseXML(xml, Array('subheading')));
	var dtAry = ParseXML(xml, Array('date')).substring(0,10).split('-');
	var dt = months[parseInt(dtAry[1])-1]+' '+dtAry[2]+', '+dtAry[0];
	//alert('month: '+dt.substring(4,2)+"\nday: "+dt.substring(6,2)+"\nyear: "+dt.substring(0,4));
	if(table=='CMS')	dt = '';
	_article.innerHTML = 	
			'<div class="left">'
			     +'<div style="position:absolute;" id="leftImg">'+(img?'<img src="'+img.replace('.jpg','.f.jpg').replace('.JPG','.f.JPG')+'" />':'')+'</div>'
			     +'<div style="position:absolute;">'
			       +'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="360" height="86" id="h2" align="middle">'
			       +'<param name="movie" value="/i/swf/headingTemplate.swf?c=1&'+(dt?'d='+dt:'')+'&s='+subheading+'&l='+label+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" />     '
			       +'<embed src="/i/swf/headingTemplate.swf?c=1&'+(dt?'d='+dt:'')+'&s='+subheading+'&l='+label+'" quality="high" wmode="transparent" width="360" height="86" name="h2" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
			       +'</object>'
			    +'</div>'
			+'</div>'
			+'<div class="right">'
				+'<div class="closeButton"><a href="javascript:closeGalleryItem($(\''+obj.id+'\'),\''+initHeight+'\');">&times; close</a></div>'
				+'<div class="rightCopy">'+copy+'</div>'
			+'</div>';

	fade_out(obj);
	grow(obj, $('copy').offsetHeight, 45);		// expand this holder
	if($('copy').scrollTop < Top(obj)-Top($('copy')))
		scrollDown($('copy'), Top(obj)-Top($('copy')),10);
	else	scrollUp($('copy'), Top(obj)-Top($('copy')),10);

	setTimeout('fade_in(_article);', 100);
	showingItem = true;
}
function showSlideshow(obj, table) {
	if(table==undefined)	table = 'CMS_Multimedia';
	if(_article || (_article!=undefined)) 	remove(_article);

	var initHeight = obj.offsetHeight;
	_article = document.createElement('div');
	_article.style.position = 'absolute';
	_article.style.top = (Top($('copy'))+1)+'px';
	_article.style.left = Left($('copy'))+'px';
	_article.style.width = $('copy').offsetWidth+'px';
	_article.style.height = $('copy').offsetHeight+'px';

	_article.style.zIndex=999;
	_article.className = 'article transparent slideshow';
	_article.id = '_article';

	document.body.appendChild(_article);

	var xml = load('/boss/bossCMS.php?getFields&table='+table+'&id='+obj.id+'&0=id&1=image&2=copy&3=label&4=date&5=subheading');
	var img = ParseXML(xml, Array('image'));
	var copy = unescape(ParseXML(xml, Array('copy')));
	var label = unescape(ParseXML(xml, Array('label')));
	var subheading = unescape(ParseXML(xml, Array('subheading')));
	var dtAry = ParseXML(xml, Array('date')).substring(0,10).split('-');
	var dt = months[parseInt(dtAry[1])-1]+' '+dtAry[2]+', '+dtAry[0];
	if(table=='CMS')	dt = '';
	_article.innerHTML = 	
			'<div class="left">'
			     +'<div style="position:absolute;">'+(img?'<img src="'+img.replace('.jpg','.f.jpg').replace('.JPG','.f.JPG')+'" />':'')+'</div>'
			     +'<div style="position:absolute;">'
			       +'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="360" height="86" id="h2" align="middle">'
			       +'<param name="movie" value="/i/swf/headingTemplate.swf?c=1&'+(dt?'d='+dt:'')+'&s='+subheading+'&l='+label+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" />     '
			       +'<embed src="/i/swf/headingTemplate.swf?c=1&'+(dt?'d='+dt:'')+'&s='+subheading+'&l='+label+'" quality="high" wmode="transparent" width="360" height="86" name="h2" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
			       +'</object>'
			    +'</div>'
			+'</div>'
			+'<div class="right">'
				+'<div class="closeButton"><a href="javascript:closeGalleryItem($(\''+obj.id+'\'),\''+initHeight+'\');">&times; close</a></div>'
				+'<div class="rightCopy">'+copy+'</div>'
			+'</div>';

	fade_out(obj);
	grow(obj, $('copy').offsetHeight, 45);		// expand this holder
	if($('copy').scrollTop < Top(obj)-Top($('copy')))
		scrollDown($('copy'), Top(obj)-Top($('copy')),10);
	else	scrollUp($('copy'), Top(obj)-Top($('copy')),10);

	setTimeout('fade_in(_article);', 100);
	showingItem = true;
}
function showBioItem(obj, table) {
	if(table==undefined)	table = 'CMS_Bios';
	if(_article || (_article!=undefined)) 	remove(_article);

	var initHeight = obj.offsetHeight;
	_article = document.createElement('div');
	_article.style.position = 'absolute';
	_article.style.top = (Top($('copy'))+1)+'px';
	_article.style.left = Left($('copy'))+'px';
	_article.style.width = $('copy').offsetWidth+'px';
	_article.style.height = $('copy').offsetHeight+'px';

	_article.style.zIndex=999;
	_article.className = 'article transparent';
	_article.id = '_article';

	document.body.appendChild(_article);

	var xml = load('/boss/bossCMS.php?getFields&table='+table+'&id='+obj.id+'&0=id&1=image_big&2=copy&3=label&4=position');
	var img = ParseXML(xml, Array('image_big'));
	var copy = unescape(ParseXML(xml, Array('copy')));
	var label = unescape(ParseXML(xml, Array('label')));
	var position = unescape(ParseXML(xml, Array('position')));
	_article.innerHTML = 	
			'<div class="left">'
			     +'<div style="position:absolute;">'+(img?'<img src="'+img.replace('.jpg','.f.jpg').replace('.JPG','.f.JPG')+'" />':'')+'</div>'
			+'</div>'
			+'<div class="right">'
				+'<div class="closeButton"><a href="javascript:scrollUp($(\'copy\'), 0); closeGalleryItem($(\''+obj.id+'\'),\''+initHeight+'\');">&times; close</a></div>'
				+'<div class="rightCopy">'
				       +'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="300" height="17" id="h2" align="middle">'
				       +'<param name="movie" value="/i/swf/h2_ext.swf?a=left&c=575d64&t='+label+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" />     '
				       +'<embed src="/i/swf/h2_ext.swf?a=left&c=575d64&t='+label+'" quality="high" wmode="transparent" width="300" height="17" name="h2" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
				       +'</object><br />'
					+copy
				+'</div>'
			+'</div>';

	fade_out(obj);
	/*
	grow(obj, $('copy').offsetHeight, 45);		// expand this holder
	if($('copy').scrollTop < Top(obj)-Top($('copy')))
		scrollDown($('copy'), Top(obj)-Top($('copy')),10);
	else	scrollUp($('copy'), Top(obj)-Top($('copy')),10);
	*/

	setTimeout('fade_in(_article,.2);', 100);
	showingItem = true;
}

function closeGalleryItem(obj, initHeight) {
	fade_in(obj);					// fade back in initial article teaser
	shrink(_article, initHeight, 20);		// shrink article along with
	shrink(obj, initHeight-1, 20);			// shrinking the teaser area
	setTimeout('fade_out(_article, true, .2);',500);	// fade out overlay
	setTimeout('_showingItem=false;', 600);

	if(window['ss']) {
		window['ss'].stop();
		window['ss'].overrideStop = true;
	}
}
function showListItem(obj) {
	var initHeight = obj.offsetHeight;

	obj.className = obj.className.replace('open','')+' open';
	grow(obj, $('copy').offsetHeight, 45);				// expand object to full height
	if($('copy').scrollTop < Top(obj)-Top($('copy')))		// scroll to item
		scrollDown($('copy'), Top(obj)-Top($('copy')),10);
	else    scrollUp($('copy'), Top(obj)-Top($('copy')),10);

	removeBlankChildren(obj);
	obj.childNodes[obj.childNodes.length-1].style.overflowY = 'scroll';
	$('copy').style.overflowY='hidden';				// hide copy scroll bar
	
	obj.onclick = function() {
		shrink(this, initHeight, 45);				// shrink obj back down
		this.childNodes[this.childNodes.length-1].style.overflowY = 'hidden';
		$('copy').style.overflowY = 'auto';
		this.onclick = function() { showListItem(this); };
		this.className = this.className.replace('open','');
		remove(obj.close);
	}
	var close = document.createElement('div');
	close.className = 'closeButton transparent';
	close.style.marginLeft='840px';
	close.innerHTML = '<a href="javascript:$(\''+obj.id+'\').onclick();">&times; close</a>';
	obj.close = close;
	document.body.appendChild(close);
	close.style.position='absolute';
	close.style.top = '0px';
	close.style.top = Top($('copy'))+'px';
	close.style.left = '0px';
	close.style.left = (Left($('copy'))-20)+'px';
	fade_in(close);
}
