var isIE = document.all ? true : false;
var misc = new Array();
var popup = false;
function openWin(file, width, height) {
	if(!width)	width = 100;
	if(!height)	height = 100;
        x = (screen.width / 2) - (width / 2) - 150;
        y = (screen.height / 2) - (height / 2) - 150;
        var i = Math.round(100*Math.random());
	var win = window.open(file, i,'close=no,width='+width+',height='+height+',top='+y+',left='+x+',top=1,resizable=yes,status=no,scrollbars=yes');
	popup = win;
        return win;
}
function init_dd(dropset) {
	dropset = removeBlankChildren(dropset);
	for(var x=0; x<dropset.childNodes.length; x++) {
		removeBlankChildren(dropset.childNodes[x]);
		dropset.childNodes[x].onmouseover=function() { over(this); };
		dropset.childNodes[x].onmouseout=function() { out(this); };
	}
}
var dropped = false;
function over(obj) {
	var header, drop;
	if(dropped)	out($(dropped).parentNode);	// remove other drop

	/* add bg in */
	if(!obj.initialized) {
		/* obj is holder for both header and menu */
		obj.header = obj.firstChild;		// first child is header
		obj.drop = obj.lastChild;		// next child is drop
		if(!obj.drop.firstChild) {		// empty
			obj.onmouseover=function(){;};
			obj.onmouseout=function(){;};
			return;	
		}

		/* create somewhat opaque bg */
		obj.bg = document.createElement('div');
		obj.bg.style.position='absolute';
		obj.bg.className = 'subNavBg';
		obj.insertBefore(obj.bg, obj.drop);

		obj.initialized = true;	// set initialized to true so it doesn't need to do this again
	}

	//obj.onmouseover = function() { if(!dropped) over(this.parentNode); };
	/* show & align drop */
	obj.drop.style.visibility='visible';
	obj.drop.style.display='block';

	/* bg pattern for drop */
	obj.bg.style.visibility='visible';

	//obj.drop.style.left=(Left(obj.header) - Left('header'))+'px';
	obj.drop.style.left=(Left(obj.header) - Left('mainNavContainer')-5)+'px';

	/* move over if too far right */
	if((Left(obj.drop) + obj.drop.offsetWidth) > Left(obj.parentNode) + obj.parentNode.offsetWidth) {
		//obj.drop.style.left = (Left(obj.parentNode) + obj.parentNode.offsetWidth - obj.drop.offsetWidth-Left('header'))+'px';
		//obj.bg.style.left = (Left(obj.parentNode) + obj.parentNode.offsetWidth - obj.drop.offsetWidth-Left('header'))+'px';
		obj.drop.style.left = (Left(obj.parentNode) + obj.parentNode.offsetWidth - obj.drop.offsetWidth-Left('mainNavContainer'))+'px';
		obj.bg.style.left = (Left(obj.parentNode) + obj.parentNode.offsetWidth - obj.drop.offsetWidth-Left('mainNavContainer'))+'px';
	}

	obj.drop.style.top=Top(obj.header)+obj.header.offsetHeight-28+'px';

	obj.header.className=obj.header.className+'  hover'; 

	/* resize bg */
	obj.bg.style.width = obj.drop.offsetWidth+'px';	// must be done post showing of drop so that width/height can calc
	obj.bg.style.height = obj.drop.offsetHeight+'px';
}
function out(obj) {
	dropped = false;
	obj.header.className = obj.header.className.replace('hover','');
	obj.drop.style.visibility='hidden';
	obj.bg.style.visibility='hidden';
}
function draw(at_obj, url, sep_win, w, h) {
	var top = Top(at_obj);
	var left = Left(at_obj);
	var popin = $('popin');
	if(!popin) {
		var tmp_div = document.createElement('div');
		tmp_div.setAttribute('id','popin');
		popin = document.body.appendChild(tmp_div);
		popin.innerHTML = "<div id='popin_top'><a href='javascript:popout();'><img border=1 src='images/ui/x.gif'></div></a><div id='popin_content'></div><div id='popin_bottom'></div>";
	}

	popin.style.display = 'none';
	popin.className = "popin";
	popin.style.left = left+'px';
	if(((parseInt(at_obj.offsetHeight)-window.scrollY + top + h) > window.innerHeight) && (top > h)) // display above
		popin.style.top = (top - h- parseInt(at_obj.offsetHeight))+'px';
	else	popin.style.top = (parseInt(at_obj.offsetHeight) + top)+'px';
	popin.style.display = 'block';
	$('popin_content').style.width = w+'px';
	$('popin_content').style.height = '0px';
	rolldown('popin_content', h);
	if(sep_win) {
		$('popin_content').innerHTML = "<iframe width=100% height=100% frameborder=2 src='"+url+"'></iframe>";
	} else {
		$('popin_content').innerHTML = "<iframe width=0 height=0 frameborder=0 src='/components/load.php?targ=popin_content&url="+url+"'></iframe>";
	}
}
function popout() {
	rollup('popin_content', "$('popin').style.display='none';");
}




function nothing() {	return;	}
var drop_stepper = 4;
var roll_dir = false;
var orig_overflow;
function rolldown(i, h, post, initiated) {
	if(roll_dir != 'up') {
		roll_dir = 'down';
		var w = $(i);
		if(!initiated || (initiated == undefined)) {
			orig_overflow = w.style.overflow;
			w.style.overflow='hidden';
		}
		if(parseInt(w.offsetHeight) < h) {
			w.style.height = parseInt(w.offsetHeight) + drop_stepper+'px';
			setTimeout('rolldown("'+i+'",'+h+',\''+post+'\',1);', 10);
			return;
		} else {
			roll_dir = false;
			//w.style.height = h;
			setTimeout(replace(post, '`', '\\\''),1);
			w.style.overflow=orig_overflow;
		}
	}
}
function rollup(i, post, initiated) {
	if(roll_dir != 'down') {
		roll_dir = 'up';
		var obj = $(i);
		if(parseInt(obj.style.height) > drop_stepper) {
			obj.style.height = parseInt(obj.offsetHeight) - drop_stepper+'px';
			setTimeout('rollup("'+i+'","'+post+'");', 10);
			return;
		} else {
			roll_dir = false;
			obj.style.height = 0+'px';
			obj.style.display='none';
			eval(post);
		}
	}
}
function $(i) {
	return document.getElementById(i);
}
function replace(string,text,by) {
	if(!string)	return '';
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;
	if(string.indexOf) {
		var i = string.indexOf(text);
		if ((!i) && (text != string.substring(0,txtLength))) return string;
		if (i == -1) return string;
		var newstr = string.substring(0,i) + by;
		if (i+txtLength < strLength)	newstr += replace(string.substring(i+txtLength,strLength),text,by);
		return newstr;
	}
}

function Left(obj) {
	if(obj) {
		var x = eval(obj).offsetLeft;
		elem = eval(obj).offsetParent;
		while (elem != null) {
			x += elem.offsetLeft;
			elem = elem.offsetParent;
		}
		return x;
	}
}
function Top(obj) {
	y = eval(obj).offsetTop;
	elem = eval(obj).offsetParent;
	while (elem != null) {
		y += parseFloat(elem.offsetTop);
		elem = elem.offsetParent;
	}
	return y;
}
function getScrollY() {	return isIE ? document.documentElement.scrollTop  : window.pageYOffset; }
function getScrollX() {	return isIE ? document.documentElement.scrollLeft : window.pageXOffset; }

function getWinWidth() {	return isIE ? document.body.offsetWidth : window.innerWidth; }
function getWinHeight() {	return isIE ? document.body.offsetHeight : window.innerHeight; }
function getFullWinWidth() {	return isIE ? document.body.offsetWidth : document.body.clientWidth; }
function getFullWinHeight() {	return isIE ? document.body.offsetHeight : document.body.clientHeight; }
function getScrollHeight() {	return isIE ? document.body.scrollTop : window.pageYOffset; }

function debug(elem) {
	var properties = "<HEAD><link href='/styles/sections.css' rel='stylesheet' type='text/css'></HEAD><BODY><TABLE WIDTH='100%'><TR><TH>Element<TH>Document<TH>Window</TR><TD VALIGn=TOP>";
	for(var e in elem) 
		properties += '<LI>'+e + ": " + elem[e]+"</LI>\n";
	properties += "<TD VALIGn=TOP>";
	for(var e in document) 
		properties += '<LI>'+e+(document.e ? ' = '+document.e : '')+"</LI>\n";
	properties += "<TD VALIGn=TOP>";
	for(e in window) 
		properties += '<LI>'+e;
	properties += "</TR></TABLE></BODY>";

	var newwindow=window.open('','name','height=700,width=750,scrollbars=yes,scroll=yes');
	var tmp = newwindow.document;
	tmp.write(properties);
}

/* admin functions */
function is_numeric(val) {
	var valid = '1234567890';
	for(var x in val) {
		if(valid.indexOf(val[x]) == -1) {
			return false;
		}
	}
	return true;
}
function Pad(num,intPlaces) {
    var str = String(num);
    var intLength = str.length;
    var intDifference = intPlaces-intLength;
    while (intDifference>0) {
	str = "0"+str;
	intDifference--;
    }
    return str;
}

function Mask(id, mask) {
	var sections = mask.split(/[^#]/g);
	var delimiters = mask.replace(/[#]/g, '');
	var start  = document.getElementById(id).value.replace(/[^a-z0-9A-Z*%^ ]/g, '');
	var result = '';
	var place = 0;
	for(var i in sections) {
		if(place+sections[i].length > start.length) {
			document.getElementById(id).value = result.concat(start.substring(place));
			return;
		}
		if(start.substring(place, place+(sections[i].length) != undefined))
			result = result.concat(start.substring(place, place+(sections[i].length))+delimiters.charAt(i));
		place += sections[i].length;
	}
	document.getElementById(id).value = result.concat(start.substring(place));
}

function getQueryParams() {
	var loc = window.location.toString();
	var str = loc.substring(loc.indexOf('?'));
	var ary = str.split('&');
	var toReturn = new Array();
	for(var x in ary) {
		var tmp = ary[x].split('=');
		toReturn[tmp[0]] = tmp[1];
	}
	return toReturn;
}

function view(src,obj) {
	if($('image_viewer')) {
		document.body.removeChild($('image_viewer'));
	}
	if(!src)	return;
	var tmp = document.createElement('div');
	tmp.setAttribute('id','image_viewer');
	var viewer = document.body.appendChild(tmp);
	viewer.className = 'floater';
	viewer.style.height = '200px';
	viewer.style.width = '200px';
	viewer.style.top = Top(obj)+10+'px';
	viewer.style.left = Left(obj)+'px';
	viewer.style.overflow = 'auto';
	viewer.innerHTML = '<img src="'+src+'"></div>';
}
function removeBlankChildren(rent) {
	for(var x=0; x<rent.childNodes.length; x++) {
		if(rent.childNodes[x] && rent.childNodes[x].nodeName == '#text' && rent.childNodes[x].innnerHTML == undefined) {
			//if(rent.className==nav_listing nav1) 
			rent.removeChild(rent.childNodes[x]);
		}
		if(rent.childNodes[x] && rent.childNodes[x].nodeName == '#comment') 
			rent.removeChild(rent.childNodes[x]);
	}
	return rent;
}


/* obstrucated */
function ParseXML(XML,Tag_Label){if(typeof(Tag_Label)=='string')Tag_Label=new Array(Tag_Label);XML=replace(XML,'\n',"\\\r");var tmp=new Array();iterations=0;for(var index in Tag_Label){var aN=Tag_Label[index];aN=replace(aN,'|',"->");var regEx=new RegExp("<"+aN+".*?>(.*?)</"+aN+">","i");if(XML){tmp=XML.match(regEx);if(tmp){XML=(tmp[2]&&(tmp[2]!=undefined))?tmp[2]:tmp[1];iterations++;}}}return(iterations==Tag_Label.length)?XML:'';};function EatXML(XML,Tag_Label){if(typeof(Tag_Label)=='string')Tag_Label=new Array(Tag_Label);unsafe=Array("\n","  ");XML=XML.replace(unsafe,"");for(var index in Tag_Label){var aN=Tag_Label[index];var regEx=new RegExp("<"+aN+".*?>(.*?)</"+aN+">","i");XML=XML.replace(regEx,'');}return XML;};function load(url,params,post,aU){if(url.indexOf('?')== -1)url=url+'?';if(params&&(params!=undefined)){for(var i in params){url+=i+'='+params[i]+'&'}}if(typeof window.ActiveXObject!='undefined')requestObj=new ActiveXObject("Microsoft.XMLHTTP");else requestObj=new XMLHttpRequest();if(url.indexOf('?')== -1)url=url+'?_inline';else url=rtrim(url,'&')+'&_inline';if(post==undefined)post=true;requestObj.open(post?'POST':"GET",url,false);requestObj.send(null);if(aU){var x=window.open(url);}return requestObj.responseText;};
function ltrim(toTrim,ac){if(!ac||ac==undefined)ac="\\s";ac=ac||"\\s";return toTrim.replace(new RegExp("^["+ac+"]+","g"),"");};function rtrim(toTrim,ac){if(!ac||ac==undefined)ac="\\s";return toTrim.replace(new RegExp("["+ac+"]+$","g"),"");};function trim(toTrim,ac){return rtrim(ltrim(toTrim,ac),ac);};function ParseFirstXML(XML){var regEx=new RegExp("<(.*?)>(.*?)</\\1>");var tmp=XML.match(regEx);var ary=new Array();if(tmp){tmp.shift();return tmp;}else return false;};



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 unique_counter = 0;
function fade_in(obj) {
	if(!obj.style.opacity)	obj.style.opacity=0;
	obj.style.display='block';
	obj.style.opacity = parseFloat(obj.style.opacity)+.1;
	obj.style.filter='alpha(opacity='+(parseFloat(obj.style.opacity)*100)+')';
	if(obj.style.opacity >= 1) {
		obj.style.filter='alpha(opacity=100)';
		return;
	} else {
		setTimeout('fade_in($("'+obj.id+'"));', 50);
	}
} function fade_out(obj) {
	obj.style.opacity = parseFloat(obj.style.opacity)-.1;
	obj.style.filter='alpha(opacity='+(parseFloat(obj.style.opacity)*100)+')';
	if(obj.style.opacity <= 0) {
		obj.style.display='none';
		return;
	} else {
		setTimeout('fade_out($("'+obj.id+'"));', 50);
	}
}

function lightbox(src) {
	imgProps = imageProperties(src);
	/* resize if neccesary */
	if(imgProps['w'] > parseInt(getWinWidth())-30) {
		imgProps['h'] = parseInt(getWinWidth()-30)/imgProps['w']*imgProps['h'];
		imgProps['w'] = getWinWidth()-30;
	} if(imgProps['h'] > parseInt(getWinHeight())-30) {
		imgProps['w'] = parseInt(getWinHeight()-30)/imgProps['h']*imgProps['w'];
		imgProps['h'] = getWinHeight()-30;
	}

	/* lightbox container */
	var lb = document.createElement('div');
	lb.id = 'lightbox';
	lb.style.position = 'absolute';
	lb.style.top = '0px';
	lb.style.left = '0px';
	lb.style.width='100%';
	lb.style.height=getFullWinHeight()+'px';
	document.body.appendChild(lb);


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

	/* create image container */
	var imgContainer = document.createElement('div');
	imgContainer.className = 'lightboxImgContainer';
	imgContainer.style.position = 'absolute';
	imgContainer.style.left = (parseInt(getWinWidth()/2)-imgProps['w']/2)+'px';
	imgContainer.style.top = (parseInt(getWinHeight()/2)-imgProps['h']/2)+getScrollHeight()+'px';
	imgContainer.style.width = imgProps['w']+'px';
	imgContainer.style.height = imgProps['h']+'px';
	lb.appendChild(imgContainer);

	/* create close button */
	var closeButton = document.createElement('div');
	closeButton.innerHTML = 'close &times;';
	closeButton.style.cursor='pointer';
	closeButton.style.position = 'absolute';
	closeButton.className = 'lightboxButton';
	lb.appendChild(closeButton);
	closeButton.style.left = Left(imgContainer)+imgContainer.offsetWidth-closeButton.offsetWidth+'px';
	closeButton.style.top = (parseInt(getWinHeight()/2)-imgProps['h']/2)-closeButton.offsetHeight+getScrollHeight()+'px';
	closeButton.onclick=function() { this.parentNode.parentNode.removeChild(this.parentNode); };

	var img = document.createElement('img');
	img.src = src;
	img.style.width = imgProps['w']+'px';
	img.style.height = imgProps['h']+'px';
	imgContainer.appendChild(img);
}

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;
}

var slideshowAry = new Array();
var slideshowInterval = false;
var slideshowCounter = false;
function slideshowAdd(obj) {	slideshowAry[slideshowAry.length] = obj;	}
function slideshowStart(intvl, randomOrder) {
	if(slideshowInterval)	clearInterval(slideshowInterval);
	if(randomOrder)	slideshowCounter = Math.round(Math.random()*slideshowAry.length);
	slideshowNext();						// start right away
	slideshowInterval = setInterval('slideshowNext()',intvl*1000);	// set following to run at intvl (secs)
} function slideshowNext() {
	if(slideshowAry[slideshowCounter-1]) 	slideshowAry[slideshowCounter-1].className = slideshowAry[slideshowCounter-1].className.replace('high','');
	if((slideshowAry.length < slideshowCounter) || !slideshowAry[slideshowCounter])	slideshowCounter=0;
	slideshowAry[slideshowCounter].onclick();
	slideshowAry[slideshowCounter].className += ' high';
	slideshowCounter++;
} function slideshowStop() {
	if(slideshowInterval) {
		clearInterval(slideshowInterval);
		if(slideshowAry[slideshowCounter-1])    slideshowAry[slideshowCounter-1].className = slideshowAry[slideshowCounter].className.replace('high','');
	}
}



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);
}



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;
			}
			if(center) {
/*
				if(!targ.style.marginLeft)	targ.style.marginLeft = 0;
				else	targ.style.marginLeft = parseInt(targ.style.marginLeft) - (speed)+'px';
				if(!targ.style.marginTop)	targ.style.marginTop = 0;
				else	targ.style.marginTop = parseInt(targ.style.marginTop) - otherStep+'px';
*/
			}
			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']);
	}
}

var galleryPos = -1;
var galleryInterval = false;
var page = 0;
function loadGalleryItem(id, type, onAuto) {
	if($('commentForm'))	closeComment();
	if(type==undefined)	type = 'images';

	if(onAuto) {
	       	if(!data[id+1]) id = 1;
	} else 	if(galleryInterval)	clearInterval(galleryInterval);

	if($('img|'+galleryPos)) $('img|'+galleryPos).className = $('img|'+galleryPos).className.replace('high','');
	galleryPos = id;

	if(!data[galleryPos]) {		// bad request
		var params = getQueryParams();
		params['p'] = 0;
		var loc = window.location.toString();
		var gotoLoc = window.location.toString().substring(0,window.location.toString().indexOf('?'));
		for(var x in params)	gotoLoc += x+((params[x]!=undefined) ? '='+params[x]:'')+'&';
		window.location = gotoLoc;
	} else if(id==0) {		// goto previous page
		var params = getQueryParams();
		params['jump'] = true;
		params['p'] = page-1;
		params['jump'] = 1;
		var loc = window.location.toString();
		var gotoLoc = window.location.toString().substring(0,window.location.toString().indexOf('?'));
		for(var x in params)	gotoLoc += x+((params[x]!=undefined) ? '='+params[x]:'')+'&';
		window.location = gotoLoc;
	} else if(!$('img|'+id)) {	// goto next page
		var params = getQueryParams();
		params['p'] = page+1;
		params['jump'] = 0;
		var loc = window.location.toString();
		var gotoLoc = window.location.toString().substring(0,window.location.toString().indexOf('?'));
		for(var x in params)	gotoLoc += x+((params[x]!=undefined) ? '='+params[x]:'')+'&';
		window.location = gotoLoc;
	} else {
		if($('previous')) {
			if(data[id-1]) {
				$('previous').style.visibility = 'visible';
				$('previous').firstChild.src = data[id-1]['image'].replace('.jpg','.t.jpg');
			} else  $('previous').style.visibility = 'hidden';
		}
		if($('next')) {
			if(data[id+1]) {
				$('next').style.visibility = 'visible';
				$('next').firstChild.src = data[id+1]['image'].replace('.jpg','.t.jpg');
			} else  $('next').style.visibility = 'hidden';
		}

		/* load image and data */
		if(type=='images') {
			$('mainViewerImg').src = data[id]['image'].replace('.jpg','.f.jpg');
		} else if(type=='videos') {
			$('mainVideoHolder').innerHTML = generateEmbedCode('flv',data[id]['link'],$('mainVideoHolder').offsetWidth,$('mainVideoHolder').offsetHeight);
		}
		if($('img|'+id)) $('img|'+id).className = $('img|'+id).className+' high';

		for(x in data[id]) {
			if($(x))	$(x).innerHTML = data[id][x];
		}

		loadComments(type,data[id]['i'],$('commentsHolder'),4,0,Array($('pgNav_top'),$('pgNav_bottom')));
	}
}
function loadComments(table,id,target,limit, pg, navs) {
	if(limit==undefined)	limit = 4;
	if(pg==undefined)	pg = 0;

	var aryStr = '';
	for(var x in navs)	aryStr += "$('"+navs[x].id+"'),";
	aryStr = 'Array('+aryStr.substring(0,aryStr.length-1)+')';

	var dat = load('/boss/dynamic.php?fetch=comments&t='+table+'&i='+id+'&l='+limit+'&p='+pg);
	if($('imgComments'))	$('imgComments').innerHTML = ParseXML(dat, Array('totalRows'));;
	target.innerHTML = '';
	var row = '';

	var x = 0;
	while(row = ParseXML(dat, Array('row'))) {
		//alert(row+'::'+"\n\n"+dat);x++;
		dat = replace(dat, "\n","");
		dat = replace(dat, "\r","");
		target.innerHTML += '<div class="resultsRow"><h4 class="headline">'+ParseXML(row,Array('Username'))+' | '+ParseXML(row,Array('date'))+'</h4>'+ParseXML(row,Array('Body'))+'</div>';
		dat = EatXML(dat, Array('row'));
		x++;
		if(x>10) return;
	}
	var totalRows = ParseXML(dat, Array('totalRows'));
	var pagination= pg ? '<img onclick="loadComments(\''+table+'\',\''+id+'\',$(\''+target.id+'\'),\''+limit+'\','+(pg-1)+', '+aryStr+');" src="/images/ui/gallery/leftBtn.gif" border=0 />':'';

	for(var x=0; x<totalRows/limit; x++) pagination += '<span '+(x==pg?'class="high" ':'')+'onclick="loadComments(\''+table+'\',\''+id+'\',$(\''+target.id+'\'),\''+limit+'\','+x+','+aryStr+');">'+(x<8?'0':'')+(x+1)+'</span>';

	pagination += (pg+1<Math.ceil(totalRows/limit)) ? '<img onclick="loadComments(\''+table+'\',\''+id+'\',$(\''+target.id+'\'),\''+limit+'\','+(pg+1)+', '+aryStr+');" src="/images/ui/gallery/rightBtn.gif" border=0 />':'';

	for(var x in navs)	navs[x].innerHTML = '<div class="pageNav">'+pagination+'</div>';
	
}


function generateEmbedCode(type,src,w,h) {
	var code = '';
	var rand = Math.random(0,100000);
	src = 'http://girls.boss32.com'+src;
	if(w==undefined) w='330';
	if(h==undefined) h='290';
	w = Math.round(w);
	h = Math.round(h);
	switch(type) {
		case 'flv':
			code = '<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="'+w+'" height="'+h+'" id="videoViewer" align="middle">'+
				'<param name="allowScriptAccess" value="sameDomain" />'+
				'<param name="vSrc"="'+src+'" />'+
				'<param name="FlashVars" value="vSrc='+src+'" />'+
				'<param name="wmode" value="transparent" />'+
				'<param name="allowFullScreen" value="true" />'+
				'<param name="movie" value="/images/flash/viewer.swf?vSrc='+src+'&'+rand+'" /><param name="quality" value="high" /><embed src="/images/flash/viewer.swf?'+src+'" &'+rand+'" FlashVars="vSrc='+src+'" 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;
	}
	//var debugWin = window.open();
	//debugWin.document.write(code);
	return code;
}