var fx_config = new Array();
fx_config['images'] = new Array();
fx_config['images']['constraint'] = new Array;
fx_config['images']['zoom'] = new Array;

/* config area */
fx_config['images']['constraint']['mini'] 		= 100;
fx_config['images']['constraint']['thumb'] 		= 175;
fx_config['images']['constraint']['fullsize'] 		= 390;
fx_config['images']['constraint']['zoom'] 		= 800;
fx_config['images']['constraint']['constrainBy'] 	= 'w';		// width (w) or height (h)

fx_config['images']['zoom']['step']			= 7;		// number pixels to jump with each expand/contract
fx_config['images']['zoom']['speed']			= 1;		// delay in milliseconds between jumps
fx_config['images']['zoom']['runout']			= 1000;		// maximum number of iterations to expand
fx_config['images']['zoom']['tween']			= 10;		// positive number tweens out
/* end config area */

var defaultSpeed = 20;

/* transitions */
function slideIn(obj, speed) {
	if(!obj.style.top) obj.style.top = obj.offsetHeight*-1;
	if(speed==undefined)	speed = defaultSpeed;
	obj.style.display='block';
	obj.style.visiblity='visible';
	obj.style.top = (parseFloat(obj.style.top)+speed)+'px';
	if(parseInt(obj.style.top) <= 0) {
		setTimeout('slideIn($("'+obj.id+'"));', 50);
	} else	obj.style.top = 0;
} 
function slideOut(obj, speed) {
	if(!obj.style.top) obj.style.top = 0;
	if(speed==undefined)	speed = defaultSpeed;
	obj.style.display='block';
	obj.style.visiblity='visible';
	obj.style.top = (parseFloat(obj.style.top)-speed)+'px';
	if(parseInt(obj.style.top) > obj.offsetHeight*-1) {
		setTimeout('slideOut($("'+obj.id+'"));', 50);
	} else	obj.style.top = obj.offsetHeight*-1;
}

var curGrowObj = false;
function grow(obj, to, speed) {
	if(obj) curGrowObj = obj;
	if(obj.style.height=='') obj.style.height = obj.offsetHeight+'px';

	if(speed==undefined)	speed = defaultSpeed*1.5;
	obj.style.height = (parseFloat(obj.style.height)+speed)+'px';
	if(parseInt(obj.style.height) < to) {
		setTimeout('grow(curGrowObj, '+to+', '+(speed*.9)+');', 50);
	} else	{
		obj.style.height = to+'px';
	}
} 
function shrink(obj, to, speed) {
	if(to==undefined)	
		to = 0;
	if(!obj.id)	
		obj.id = 'shrnk|'+Math.round(Math.random()*10000000000);
	if(obj.style.height) 
		obj.style.height = obj.offsetHeight+'px';
	to = parseInt(to);
	speed = parseInt(speed);

	if(speed==undefined)	speed = defaultSpeed;
	obj.style.overflow='hidden';
	obj.style.visiblity='visible';
	obj.style.height = (parseFloat(obj.style.height)-speed)+'px';
	if(parseInt(obj.style.height) > (speed+to)) { 
		setTimeout('shrink($("'+obj.id+'"),'+to+','+speed+');', 50);
	} else	{
		obj.style.height = to+'px';
	}
}

var unique_counter = 0;
var currentlyFading = Array();
var _fadeInterval = 80;
function fade_in(obj, speed, to) {
	if(!obj || !obj.style)	return;
	if(!speed || (speed==undefined))	speed = .2;
	if(to==undefined) 			to = 1;
	if(!obj.id) obj.id = 'anonymous|'+(unique_counter++);


	if(!obj.style.opacity) {
		obj.style.opacity=0;
		obj.style.filter='alpha(opacity=0)';
	}
	obj.style.opacity = parseFloat(obj.style.opacity)+speed;
	obj.style.filter='alpha(opacity='+(parseFloat(obj.style.opacity)*100)+')';
	if(obj.style.opacity >= to) {
		obj.style.filter='alpha(opacity='+(to*100)+')';
		obj.style.opacity=to;
		currentlyFading[obj.id] = false;
	} else {
		currentlyFading[obj.id] = true;
		setTimeout('fade_in($("'+obj.id+'"),'+speed+','+to+');', _fadeInterval);
	}
} 
function fade_out(obj, removeAfter, speed) {
	if(removeAfter==undefined)	removeAfter = 0;
	if(speed==undefined)		speed = .1;
	if(obj == null)	{
		remove(obj);
		return;
	}

	if(!obj.style.opacity || (obj.style.opacity==undefined)) {
		obj.style.opacity=1;
		obj.style.filter='alpha(opacity=100)';
	}
	if(!obj.id) obj.id = 'anonymous|'+(unique_counter++);
	obj.style.opacity = parseFloat(obj.style.opacity)-speed;
	obj.style.filter='alpha(opacity='+(parseFloat(obj.style.opacity)*100)+')';
	if(obj.style.opacity <= 0) {
		if(removeAfter)	remove(obj);
		return;
	} else {
		setTimeout('fade_out($("'+obj.id+'"),'+(removeAfter?1:0)+', '+speed+');', 50);
	}
}
function scrollUp(obj, to, speed, lastAt) {
	if(!obj.scrollTop || (obj.scrollTop==undefined)) obj.scrollTop=0;

	if(!obj.id) obj.id = 'anonymous|'+(unique_counter++);
	obj.scrollTop = obj.scrollTop - speed;

	if(lastAt && (obj.scrollTop >= lastAt))	return;

	if(obj.scrollTop <= to) {
		obj.scrollTop = to;
		return;
	} else {
		setTimeout('scrollUp($("'+obj.id+'"),'+to+','+speed+','+obj.scrollTop+');', 50);
	}
}
function scrollDown(obj, to, speed, lastAt) {
	if(!obj.scrollTop || (obj.scrollTop==undefined)) obj.scrollTop=0;

	if(!obj.id) obj.id = 'anonymous|'+(unique_counter++);
	obj.scrollTop = obj.scrollTop + speed;

	if(lastAt && (obj.scrollTop <= lastAt))	return;

	if((obj.scrollTop >= to) || (obj.scrollTop==obj.scrollHeight)) {
		obj.scrollTop = to;
		return;
	} else {
		setTimeout('scrollDown($("'+obj.id+'"),'+to+','+speed+','+obj.scrollTop+');', 50);
	}
}

/* functionality */
var _lightboxObj = false;
var _lightboxTopOffset = 0;
var _lightboxBodyPadding = 0;
var _lightboxConstrainWidth = 800;	// pixels
var _lightboxConstrainHeight = .8;	// percentage of window
function lightbox(src, width, type, className, height) {
	if(className==undefined)	className = '';
	if(_lightboxObj) {
		_lightboxObj.closeButton.onclick();
       		if(src==undefined)	return;
	}
	if(type==undefined)	type = 'img';
	var scrollTop = isNaN(window.pageYOffset) ? document.body.scrollTop : window.pageYOffset;
	var scrollLeft = isNaN(window.pageXOffset) ? document.body.scrollLeft : window.pageXOffset;
	var closeButtonLeftOffset = 0;

	document.body.className = document.body.className+' lightboxActive';

	/* lightbox container */
	_lightboxObj = document.createElement('div');
	_lightboxObj.id = 'lightbox';
	_lightboxObj.className = className;
	_lightboxObj.style.position = 'absolute';
	_lightboxObj.style.top = '0px';
	_lightboxObj.style.left = '0px';
	_lightboxObj.style.width='100%';
	_lightboxObj.style.zIndex='9';

	_lightboxObj.style.height=getFullWinHeight()+'px';
	document.body.appendChild(_lightboxObj);

	/* create background */
	var bg = document.createElement('div');
	bg.style.position = 'absolute';
	bg.style.top = getScrollHeight()+'px';
	window.onscroll = function() { 
		var scrollTop = getScrollHeight();
		_lightboxObj.bg.style.top = scrollTop+'px'; 
		_lightboxObj.container.style.top = scrollTop+(getWinHeight()/2-(width?width:_lightboxObj.container.offsetHeight)/2 + _lightboxTopOffset)+'px'; 
		_lightboxObj.closeButton.style.top = scrollTop+(getWinHeight()/2-(height?height:lbContainer.offsetHeight)/2 + _lightboxTopOffset )+2+'px';
	};
	bg.style.left = '0px';
	bg.style.width='100%';

	bg.style.height='100%';
	bg.className = 'lightboxBG';
	bg.onclick = function() { this.closeButton.onclick(); };
	//bg.style.opacity=.7;
	//bg.style.filter='alpha(opacity=70)';

	_lightboxObj.bg = bg;
	_lightboxObj.appendChild(bg);

	/* setup img width */
	if(type=='img') {
		_lightboxObj.className = _lightboxObj.className +' blackbox';
		var imgXML = load('/boss/getImageInfo.php?src='+src);
		var imgProps = new Array();
		if(ParseXML(imgXML, Array('response','w'))) {
			imgProps['w'] = ParseXML(imgXML, Array('response','w'));		// size is appropriate
			imgProps['h'] = ParseXML(imgXML, Array('response','h'));
                        if(imgProps['h'] > (getWinHeight()*_lightboxConstrainHeight)) {		// size needs to be adjusted
				height = imgProps['h'];
				imgProps['h'] = getWinHeight()*_lightboxConstrainHeight;	// recalc height
				imgProps['w'] = imgProps['h']/height * imgProps['w'];		// recalc width
			}
			if(imgProps['w']>_lightboxConstrainWidth) {
				var oldWidth = imgProps['w'];
				imgProps['w'] = _lightboxConstrainWidth;
				imgProps['h'] = imgProps['w']/oldWidth * imgProps['h'];
			}
			height = imgProps['h'];
			width = imgProps['w'];
		} else	imgProps['w'] = 450;
	}

	/* create container */
	var lbContainer = document.createElement('div');					// create container
	lbContainer.className = 'lightboxContainer';
	lbContainer.style.position = 'absolute';

	width = (width/1) + (_lightboxBodyPadding*2);
	height = (height/1) + _lightboxBodyPadding*2;

	lbContainer.style.width = (width+(_lightboxBodyPadding/2))+'px';
	if(isNaN(height))	height = 400;
	lbContainer.style.height = (height+_lightboxBodyPadding/2)+'px';
	lbContainer.style.overflow = 'hidden';
	_lightboxObj.container = lbContainer;
	_lightboxObj.appendChild(lbContainer);
	lbContainer.style.visiblity = 'hidden';
	
	_lightboxObj.style.opacity = .4;
	_lightboxObj.style.filter='alpha(opacity=40)';

	/* setup html */
	if(type=='img') {
		var dv = document.createElement('img');
		dv.src = src;
		dv.style.opacity = .4;
		dv.style.filter='alpha(opacity=40)';
		dv.style.width = imgProps['w']+'px';
		dv.style.height = (imgProps['h']!=undefined) ? imgProps['h']+'px' : 'auto';
		dv.lb = _lightboxObj;
		dv.className = 'lightboxBody img';
		dv.onload = function() { 		// onload modify sizing
			if(dv.offsetHeight > (getWinHeight()*_lightboxConstrainHeight)) {	// adjust if larger than 90% of screen
				dv.style.width = 'auto';
				dv.style.height = Math.round(getWinHeight()*_lightboxConstrainHeight)+'px';
			}
			fade_in(this);
			this.lb.container.style.left = (parseInt(getWinWidth()/2)-(this.width/2) + _lightboxBodyPadding/2)+'px'; 
			this.lb.closeButton.style.top = Top(this.lb.closeButton)+'px';
			this.lb.closeButton.style.left = Left(this.lb.container)+this.lb.container.offsetWidth-this.lb.closeButton.offsetWidth-1+'px';

			dv.style.opacity = '1';
			dv.style.filter='alpha(opacity=100)';
		};
		if(isIE) setTimeout('fade_in(_lightboxObj.img);',500);
		_lightboxObj.img = dv;
		lbContainer.appendChild(dv);
	} else if(type == 'obj') {			// load from an html node obj
		var dv = document.createElement('div');
		dv.appendChild(src);
		dv.className = 'lightboxBody';
		lbContainer.appendChild(dv);
		lbContainer.style.height = (height!=undefined ? height : dv.offsetHeight)+'px';
		lbContainer.style.width = dv.offsetWidth+'px';
		var clrDiv = document.createElement('div');
		clrDiv.style.clear='both';
		lbContainer.appendChild(clrDiv);
		if(dv.offsetHeight > (getWinHeight()*.9)) {			// adjust if larger than 90% of screen
			dv.style.height = Math.round(getWinHeight()*.9)+'px';
			lbContainer.style.height = Math.round(getWinHeight()*.9)+40+'px';	
		}
	} else {					// load from a url
		var html = load(src);
		var dv = document.createElement('div');
		dv.innerHTML = html;
		dv.className = 'lightboxBody';
		dv.style.width = (width-40)+'px';
		lbContainer.appendChild(dv);
		lbContainer.style.height = (height!=undefined ? height : dv.offsetHeight)+'px';
		lbContainer.style.height = '0px';
		if(dv.offsetHeight > (getWinHeight()*.9)) {
			dv.style.height = Math.round(getWinHeight()*.9)+'px';	// adjust if larger than 70% of screen
		}
		lbContainer.style.height = dv.offsetHeight+'px';
	}
	lbContainer.style.left = (parseInt(getWinWidth()/2)-(width?width:lbContainer.offsetWidth)/2)+(_lightboxBodyPadding/2)+'px';
	lbContainer.style.top = scrollTop+(getWinHeight()/2-(height?height:lbContainer.offsetHeight)/2 + _lightboxTopOffset)+'px';

	/* create close button */
	_lightboxObj.closeButton = document.createElement('div');
	_lightboxObj.closeButton.innerHTML = 'close &times;';
	_lightboxObj.closeButton.style.top = scrollTop+(getWinHeight()/2-(height?height:lbContainer.offsetHeight)/2 + _lightboxTopOffset)+1+'px';
	setTimeout('_lightboxObj.container.style.top="'+_lightboxObj.closeButton.style.top+'";', 500);	// ie fix 

	_lightboxObj.closeButton.style.cursor='pointer';
	_lightboxObj.closeButton.style.position = 'absolute';
	_lightboxObj.closeButton.className = 'lightboxButton';
	_lightboxObj.appendChild(_lightboxObj.closeButton);
	_lightboxObj.closeButton.style.left = Left(lbContainer)+lbContainer.offsetWidth-_lightboxObj.closeButton.offsetWidth-closeButtonLeftOffset+'px';
	_lightboxObj.closeButton.onclick=function() { this.parentNode.parentNode.removeChild(this.parentNode); _lightboxObj=false; document.body.className=document.body.className.replace('lightboxActive',''); };
	if(type=='img') _lightboxObj.closeButton.style.visible = 'hidden';

	bg.closeButton = _lightboxObj.closeButton;

	fade_in(_lightboxObj);

	return _lightboxObj;
}
var _loading;
function setLoad(dv, isLoading) {
	if(_loading) {
		_loading.parentNode.removeChild(_loading);	// remove old
		_loading=false;
	}
	if(isLoading) {
		_loading = document.createElement('div');
		_loading.className = 'load';
		_loading.style.left = Left(dv)+'px';
		_loading.style.top = Top(dv)+'px';
		_loading.style.width = dv.offsetWidth+'px';
		_loading.style.height = dv.offsetHeight+'px';
		_loading.style.zIndex = 99;
		document.body.appendChild(_loading);
	}
}
function showLoad(dv) {	return setLoad(dv); }			// alias for setLoad function

/* misc */
function setCSS(fileTitle, selector, prop, val) {
	var rulesVar = document.styleSheets[0].cssRules ? 'cssRules' : 'rules';
	var file = false;
	var styleSheets = document.styleSheets;
	var x,y,z;
	for(file in styleSheets) {
		if(styleSheets[file].title==fileTitle) {	// found file
			var rules = styleSheets[file][rulesVar];
			for(x in rules) {
				if(rules[x].selectorText == selector) {
					rules[x].style[prop] = val;
					return;
				}
			}
		}
	}
}
function loadCSS(file) {
	var headID = document.getElementsByTagName("head")[0];         
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = '/css/'+file;
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
	return cssNode;
}


function imageProperties(src) {	
	src = replace(replace(src,'&','%26'),' ','%20');
	var xml = load('/boss/getImageInfo.php?src='+src); 
	var ary = new Array();
	ary['w'] = ParseXML(xml,Array('response','w'));
	ary['h'] = ParseXML(xml,Array('response','h'));
	return ary;
}

function mouseoverZoom(targ, constrainTo) {
	// attach zoom fx
	targ.zoom = document.createElement('div');
	targ.zoom.className = 'float imgZoom';
	targ.zoom.image = document.createElement('img');
	targ.zoom.image.id = (targ.id!='' && targ.id!=undefined) ? targ.id+'|zoom_img' : '_'+(unique_counter++);
	document.body.appendChild(targ.zoom);
	targ.zoom.appendChild(targ.zoom.image);
	targ.zoom.image.src = targ.src;
	if(targ.preloaded) {
		targ.zoom.image.src = targ.preloaded.src;
	} else {
		if((constrainTo==undefined) || (constrainTo < fx_config['images']['constraint']['fullsize']))	// use fullsize
			targ.zoom.image.src = targ.src.replace('.t.jpg', '.f.jpg').replace('.m.jpg','.f.jpg');
		else 	targ.zoom.image.src = targ.src.replace('.t.jpg', '.z.jpg').replace('.m.jpg','.z.jpg').replace('.f.jpg','.z.jpg');
	}
	targ.zoom.image.onmouseout = function(e) {	if (!e) var e = window.event; mouseoutZoom(e.target?e.target:e.fromElement);	}

	targ.zoom.display='block';
	targ.zoom.style.width=targ.offsetWidth+'px';
	targ.zoom.style.height=targ.offsetHeight+'px';
	targ.zoom.image.style.width=targ.offsetWidth+'px';
	targ.zoom.image.style.height=targ.offsetHeight+'px';
	targ.zoom.style.top = Top(targ)+'px';
	targ.zoom.style.left = Left(targ)+'px';
	targ.zoom.onclick=function(event) {	if(!event)	event=this.event;Popup('/boss/displayImage.php?w=600&src='+event.target.src,620,500);	};

	var w = 0;
	var h = 0;
	if(fx_config['images']['constraint']['constrainBy'] == 'w') {
		w = constrainTo ? constrainTo : fx_config['images']['constraint']['fullsize'];
		var ratio = targ.offsetWidth / w;
		h = targ.offsetHeight / ratio;
	} else {
		h = constrainTo ? constrainTo : fx_config['images']['constraint']['fullsize'];
		var ratio = targ.offsetHeight / h;
		w = targ.offsetWidth * ratio;
	}
	expandImage(targ.zoom.image, Math.round(w), Math.round(h), true);
} function mouseoutZoom(targ) {
	targ.parentNode.parentNode.removeChild(targ.parentNode);
}

var popinContainer=false;
function Popin(obj, width) {
	if(popinContainer && popinContainer!=undefined)	{
		popinContainer.parentNode.removeChild(popinContainer);
		popinContainer = false;
	}

	var scrollTop = isNaN(window.pageYOffset) ? document.body.scrollTop : window.pageYOffset;
	var scrollLeft = isNaN(window.pageXOffset) ? document.body.scrollLeft : window.pageXOffset;

	if(!obj)	return;
	popinContainer = document.createElement('div');
	document.body.appendChild(popinContainer);

	/* create background */
	var popinBG = document.createElement('div');
	popinBG.className = 'popinBG';
	popinBG.style.position = 'absolute';
	popinBG.style.top = scrollTop+'px';
	popinBG.style.left = '0px';
	popinBG.style.width='100%';
	popinBG.style.height=getFullWinHeight()+'px';
	popinContainer.appendChild(popinBG);
	popinBG.onclick = function() {	popinContainer.parentNode.removeChild(popinContainer); popinContainer=false; };

	/* create popin container */
	var popin = document.createElement('div');
	popin.className='popin';
	popin.appendChild(obj);
	popin.style.position = 'absolute';
	popinContainer.appendChild(popin);
	popinContainer.pop=popin;

	popin.className = 'popinContainer';
	if(width && (width!=undefined)) popin.style.width = width+'px';
	popin.style.left = (parseInt(getWinWidth()/2)-popin.offsetWidth/2)+'px';
	popin.style.top = (scrollTop+145)+'px';
	//popin.style.top = (parseInt(getWinHeight()/2)-popin.offsetHeight/2)+getScrollHeight()+'px';

	return popinContainer;
}


function expandImage(targ,w,h,center, otherStep, speed, running) {
	if(speed == undefined)	speed = fx_config['images']['zoom']['step'];
	if(running == undefined)running = 0;
	if(center == undefined)	center = false;
	if(!targ) return;
	if(fx_config['images']['zoom']['tween']) {
		if(fx_config['images']['constraint']['constrainBy'] == 'w')
			speed = (targ.offsetWidth<fx_config['images']['zoom']['tween'] && speed>2) ? speed/.4 : speed;
		else	speed = (targ.offsetHeight<fx_config['images']['zoom']['tween'] && speed>2) ? speed/.4 : speed;
	}
	if((fx_config['images']['constraint']['constrainBy'] == 'w') && (targ.offsetWidth+speed > w)
	    ||(fx_config['images']['constraint']['constrainBy'] == 'h') && (targ.offsetHeight+speed > h)
	    ||((running++) > fx_config['images']['zoom']['runout'])) {
		targ.style.offsetWidth = w;
		targ.style.offsetHeight = h;
	} else {
		if(fx_config['images']['constraint']['constrainBy'] == 'w') {
			if(!otherStep || otherStep == undefined) {
				var ratio = targ.offsetWidth / targ.offsetHeight;
				otherStep = speed/ratio;
			}
			targ.style.width  = targ.offsetWidth+speed+'px';
			targ.style.height  = targ.offsetHeight+otherStep+'px';
		} else {
			targ.style.height = targ.offsetHeight+speed+'px';
		}
		setTimeout('expandImage($(\''+targ.id+'\'), '+w+','+h+', '+center+','+otherStep+','+speed+','+running+');', fx_config['images']['zoom']['speed']);
	}
}
function generateEmbedCode(type,src,w,h, autostart, transparent, paramAry) {
	var code = '';
	var rand = Math.random(0,100000);
	//src = 'http://girls.boss32.com'+src;
	src = ''+src;
	autostart = (!autostart || (autostart==undefined)) ? 0 : 1;
	transparent = (!transparent || (transparent==undefined)) ? 0 : 1;
	if(w==undefined)	w=467;
	if(h==undefined)	h=240;
	w = Math.round(w);
	h = Math.round(h);

	var paramXML = '';
	var paramStr = '';
	if(paramAry!=undefined) {
		for(var x in paramAry) {
			paramXML += '<param name="'+x+'" value="'+paramAry[x]+'" />';
			paramStr += x+'='+paramAry[x]+'&';
		}
	}

	switch(type) {
		case 'img':
			code = '<img onclick="lightbox(this.src);" src="'+src+'" />';
			break;
		case 'flv':
			code = '<object class="flv" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="'+w+'" height="'+h+'" id="videoViewer" align="middle">'+
				paramXML+
				'<param name="allowScriptAccess" value="sameDomain" />'+
				'<param name="vSrc"="'+src+'" />'+
				'<param name="FlashVars" value="vSrc='+src+'&'+paramStr+'" />'+
				'<param name="wmode" value="transparent" />'+
				'<param name="allowFullScreen" value="true" />'+
				'<param name="movie" value="/i/swf/videoPlayer.swf?autostart='+autostart+'&vSrc='+src+'&transparent='+transparent+'&'+rand+'&'+paramStr+'" /><param name="quality" value="high" /><embed src="/i/swf/videoPlayer.swf?autostart='+autostart+'&vSrc='+src+'" &transparent='+transparent+'&'+rand+'&'+paramStr+'" FlashVars="autostart='+autostart+'&vSrc='+src+'&'+paramStr+'" allowFullScreen="true" quality="high" wmode="transparent" width="'+w+'" height="'+h+'" name="videoViewer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
			'</object>';
			break;
		case 'swf':
			code = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="'+w+'" height="'+h+'" id="videoViewer" align="middle">'+
				paramXML+
				'<param name="allowScriptAccess" value="sameDomain" />'+
				'<param name="wmode" value="transparent" />'+
				'<param name="allowFullScreen" value="true" />'+
				'<param name="movie" value="'+src+'" /><param name="quality" value="high" /><embed src="'+src+'?&?'+paramStr+'" allowFullScreen="true" quality="high" wmode="transparent" width="'+w+'" height="'+h+'" name="videoViewer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
			'</object>';
			break;
	}
	return code;
}

function switchInlineTab(active) {
	var holder = active.parentNode;
	for(var x in holder.childNodes)	
		holder.childNodes[x].className = holder.childNodes[x].className ? holder.childNodes[x].className.replace('active','') : '';
	active.className = active.className + ' active';
}
/* end misc functions */

/* glossary functions */
var definitionDV = false;
function def(obj, specificTo, overrideTerm, overrideWidth) {
	obj = (obj!=undefined)	? obj : false; 
	var term = overrideTerm ? overrideTerm : obj.innerHTML;
	var html = load('/boss/definition.php?s='+term+'&cat='+specificTo);

	return showMore(obj, html, overrideWidth);
}
var moreDV = false;
function showMore(anchorTo, html, overrideWidth) {
	if(moreDV) {
		moreDV.parentNode.removeChild(moreDV);
		moreDV = false;
	}
	if(anchorTo) {
		moreDV = document.createElement('div');
		moreDV.innerHTML = html;
		moreDV.className = 'more';
		if(overrideWidth) moreDV.style.width = overrideWidth+'px';
		moreDV.style.left='0px';
		document.body.appendChild(moreDV);

		moreDV.style.top=Top(anchorTo)-moreDV.offsetHeight+'px';
		var x = Left(anchorTo);
		if(x+moreDV.offsetWidth > getWinWidth())	x = getWinWidth()-moreDV.offsetWidth-10;
		moreDV.style.left=x+'px';
		fade_in(moreDV);
	}
}
/**/

/* map functions */
if(window.GIcon) {
	var defaultIcon = new GIcon(G_DEFAULT_ICON);

	var onlineIcon = new GIcon(defaultIcon);
	var iconSize = new GSize(20,34);
	onlineIcon.iconSize=iconSize;

	var offlineIcon = new GIcon(defaultIcon);
	var iconSize = new GSize(20,34);
	offlineIcon.iconSize=iconSize;
}

function plotAddress(map_obj, address, html, status, mapType, panning, point) {
	if (GBrowserIsCompatible()) {
		if(!map_obj.canvas)	map_obj.canvas = new GMap2(map_obj);

		geocoder = new GClientGeocoder();
		if(mapType==undefined) mapType=G_NORMAL_MAP;
		if(!point || point==undefined) {
			var bounds = geocoder.getLatLng(address,function(point) { 
							//map_obj.canvas.setZoom(13);
							map_obj.canvas.addControl(new GSmallMapControl());
							plotPoint(map_obj.canvas, point,address,html, status,false,panning);
							//map_obj.canvas.setMapType(mapType);
						} );
						map_obj.canvas.addControl(new GSmallMapControl());
						plotPoint(map_obj.canvas, point,address,html, status,false,panning);
		} else {
			map_obj.canvas.addControl(new GSmallMapControl());
			plotPoint(map_obj.canvas, point,address,html, status,false,panning);
		}
	}
	//return 
}
var lastPoint = false;
function plotAddresses(map_obj, ary, x, geocoder, holderTag,  latLong, recurse) {
	if(!map_obj.canvas)	map_obj.canvas = new GMap2(map_obj);
	if(geocoder==undefined) geocoder = new GClientGeocoder();
	var map = map_obj.canvas;

	var holder = false;
	if(!recurse && (holderTag != undefined)) {
		holder = mapMarkerHolders[holderTag];

		// clear old results
		var k;
		if(holder)for(k in holder) {
			map_obj.canvas.clearOverlays(holder[k]);
		}
		mapMarkerHolders[holderTag] = new Array();
		mapMarkerHTML[holderTag] = new Array();
		usedMarkers = new Array();
	}
	
	if(!x || x==undefined)	x = 0;
	if(!ary[x]) {
		return;
	}
	var tmp = ary[x].split('|');
	var address = tmp[0];
	var status = tmp[1];
	var html = tmp[2];
	var markerID = tmp[3];

	if(!markerID)	markerID = x;
	if((latLong!=undefined) && (latLong!=undefined)) {
		var latLongAry = address.split(',');
		if(latLongAry[0]*1 && latLongAry[1]*1) {
			var point = new GLatLng(latLongAry[0],latLongAry[1]);
			plotPoint(map_obj.canvas, point,markerID,html, status, holderTag);
			//map_obj.canvas.addControl(new GSmallMapControl());
			lastPoint = point;
		}
		if(ary[x++]) plotAddresses(map_obj, ary,x, geocoder, holderTag, latLong, true);
	}
}

function clearMap(map_obj) {
	var x,k;
	usedMarkers = Array();
	for(x in mapMarkers) 
		map_obj.canvas.clearOverlays(mapMarkerHolders[x]);
}
var usedMarkers = new Array();
var usedMarkersHTML = new Array();
var mapMarkerHolders = new Array();
var mapMarkerHTML = new Array();
var mapMarkers = new Array();
function plotPoint(map, point,id, html, status, holderTag, panning) {
	if(point) {
		/**/
		while(usedMarkers[point]) { 	// marker already placd in this spot
			var tmp = point;
			point = new GLatLng(parseFloat(point.y)+.0007, parseFloat(point.x)+.0007);
		}
		/**/
		usedMarkers[point] = true;
		mapMarkers[id] = new GMarker(point,(status==1) ? onlineIcon : offlineIcon);
		if(holderTag) {
			mapMarkerHolders[holderTag][id] = mapMarkers[id];
			mapMarkerHTML[holderTag][id] = html;
			//mapMarkerHolders[holderTag][mapMarkerHolders[holderTag].length] = mapMarkers[id];
		}
		mapMarkers[id].html = html;

		if(!map.isLoaded()) {
			map.setCenter(point, 7);
		} else if(panning) {
			map.panTo(point);
		}
		map.addOverlay(mapMarkers[id]);
		if(html) GEvent.addListener(mapMarkers[id], "click", function(){  this.openInfoWindow(this.html);}  );
	}
}
/* end map functions */

/* video generator functions */
var maxVideoW = 960;
var videoRatio = 320/240;
var videoRatio = 475/350;
//var videoRatio = 320/180;
function setupVideoPlayer(initialSrc, holderObj, autostart, w, h, rent, keywords) {
	if(!autostart || (autostart==undefined))	autostart = true;
	if(!w || (w==undefined) || !h || (h==undefined)) {	// set to max width
		if(!w || (w==undefined)) 
			w = (getWinWidth() > maxVideoW) ? maxVideoW : getWinWidth();
		h = w / videoRatio;
		if(h > getWinHeight()*.8) {	// greater than win height, set to max height
			h = getWinHeight()*.8;
			w = h * videoRatio;
		}
	}

	var mainDV = document.createElement('div');
	mainDV.style.overflow='hidden';
	mainDV.style.height=h+'px';
	mainDV.innerHTML = generateEmbedCode('flv', initialSrc, w, h, autostart);

	var previewsDV = document.createElement('div');
	previewsDV.className = 'videoPreviewHolder lightboxVideoPreviews';
	mainDV.appendChild(previewsDV);
	previewsDV.innerHTML = holderObj.innerHTML.replace('more videos...','');

	lightbox(mainDV, w+40, 'obj', 'blackbox', h+50);
}
/* end video generator functions */

/* setup preview over video / images */
function initPreview(icon, type) {
	switch(type) {
		case 'video':
			/*
			icon.preview = document.createElement('div');
			icon.preview.className = 'previewOverlay';
			icon.preview.style.top = Top(icon)+'px';
			icon.preview.style.left = Left(icon)+'px';
			icon.preview.style.width = icon.offsetWidth+'px';	// leave room for border
			icon.preview.style.height = icon.offsetHeight+'px';
			icon.preview.icon = icon;

			if(!icon.onclick) icon.onclick = function() { document.location.href=this.parentNode.href;	};
			icon.preview.onclick = function() { this.icon.onclick(); 	};
			icon.preview.onmouseout = function() { this.icon.onmouseout(); 	};
			icon.onmouseover = function() { this.preview.onmouseover(); 	};
			icon.onmouseout = function() { this.preview.onmouseout(); 	};
			icon.preview.onmouseover = function() { this.className = this.className.replace('over','')+' over';		
								this.style.top = Top(this.icon)+'px';
								this.style.left = Left(this.icon)+'px';
								this.style.height = this.icon.offsetHeight+'px';
								this.style.width = this.icon.offsetWidth+'px';
			};
			icon.preview.onmouseout = function() { this.className = this.className.replace('over','');			};
			document.body.appendChild(icon.preview);
			//debug(icon.preview);
			*/
			break;
		case 'image':
			break;
	}
}
