/*
Javascript Fixed Popup With Transparent Edges

Required:
Jquery

Control(s):
show
hide
destroy

.slideshowBorder{
	position: absolute;
	z-index: 1002;
	font-size: 1px;
}

.slideshowContent{
	position: relative;
	z-index: 1003;
	top: 15px;
	left: 15px;
	background-color: #fff;
}

.overlay{
	position:absolute;
	z-index:1000;
	top:0;
	left:0;
	height:100%;
	width:100%;
	background:#000000;
	opacity:0;
	filter:alpha(opacity=0);
}
*/
function popupWindow(id, width, height){
	this.id = id;
	this.width = width;
	this.height = height;
	
	this.build = popupWindow_build;
	this.build = this.build();
	
	this.show = popupWindow_show;
	this.hide = popupWindow_hide;
	this.destroy = popupWindow_destroy;
}

function popupWindow_build(){
	var frame = '<div id="'+(this.id)+'Popup" style="visibility: hidden; position: absolute; z-index: 1001; top:100px; left:100px;" align="center">'
					+'<div class="'+(this.id)+'Content" style="position: relative; z-index: 1003; width: '+(this.width)+'px;	height: '+(this.height)+'px; top: 15px; left: 15px; background:url(/images/popup/popupGradientBG.jpg);"></div>'
					+'<div class="'+(this.id)+'Border '+(this.id)+'width" style="background: transparent url(/sdata/img/popup/t.png) repeat-x scroll 0px 0px; top: 0px; left: 15px; width: '+(this.width)+'px; height: 15px;"></div>'
					+'<div class="'+(this.id)+'Border '+(this.id)+'width '+(this.id)+'top" style="background: transparent url(/sdata/img/popup/b.png) repeat-x scroll 0px 0px; top: '+(this.height+15)+'px; left: 15px; width: '+(this.width)+'px; height: 15px;"></div>'
					+'<div class="'+(this.id)+'Border '+(this.id)+'height" style="background: transparent url(/sdata/img/popup/l.png) repeat-y scroll 0px 0px; top: 15px; left: 0px;  width: 15px; height: '+(this.height)+'px;"></div>'
					+'<div class="'+(this.id)+'Border '+(this.id)+'left '+(this.id)+'height" style="background: transparent url(/sdata/img/popup/r.png) repeat-y scroll 0px 0px; top: 15px; left: '+(this.width+15)+'px; width: 15px; height: '+(this.height)+'px;"></div>'
					+'<div class="'+(this.id)+'Border '+(this.id)+'left" style="background: transparent url(/sdata/img/popup/tr.png) no-repeat scroll 0px 0px; top: 0px; left: '+(this.width+15)+'px; width: 15px; height: 15px;"></div>'
					+'<div class="'+(this.id)+'Border" style="background: transparent url(/sdata/img/popup/tl.png) no-repeat scroll 0px 0px; top: 0px; left: 0px; width: 15px; height: 15px;"></div>'
					+'<div class="'+(this.id)+'Border '+(this.id)+'left '+(this.id)+'top" style="background: transparent url(/sdata/img/popup/br.png) no-repeat scroll 0px 0px; top: '+(this.height+15)+'px; left: '+(this.width+15)+'px; width: 15px; height: 15px;"></div>'
					+'<div class="'+(this.id)+'Border '+(this.id)+'top" style="background: transparent url(/sdata/img/popup/bl.png) no-repeat scroll 0px 0px; top: '+(this.height+15)+'px; left: 0px; width: 15px; height: 15px;"></div>'
				+'</div>';
	var build = $j("body").append(frame);
	
	if(build){return true;}else{return false;}
}

function popupWindow_show(){
	popupWindow_addOverlay();
	$j("#"+(this.id)+"Popup").css({
		"top":(($j(window).height() / 2) - (this.height / 2) + $j(window).scrollTop() -15),
		"left":(($j(window).width() / 2) - (this.width / 2) + $j(window).scrollLeft() -15)
	});
	$j('.overlay').css("height", $j(document).height());
	$j('.overlay').css("width", screen.width);
	$j('#'+this.id+'Popup').css('visibility','visible');
	popupWindow_captureResize(this.id, this.width, this.height);
}

function popupWindow_addOverlay(){
	$j("body").append('<div id="overlay" class="overlay"></div>').css({"overflow":"hidden"});
	$j("html").css({"overflow":"hidden"});
	$j(".overlay").css({"opacity":"0.6"}, "linear");
}

function popupWindow_captureResize(id, width, height){
	window.onresize = function(){
		if(document.all){
			window.resizeEnd = (window.resizeEnd ==null)?(new Object()):window.resizeEnd;
			clearTimeout(window.resizeEnd);
			window.resizeEnd = setTimeout(popupWindow_onResizeEnd(id, width, height),1);
		}
		else{
			popupWindow_onResizeEnd(id, width, height);
		}
	}
}

function popupWindow_onResizeEnd(id, width, height){
	$j("#"+(id)+"Popup").css({
		"top":(($j(window).height() / 2) - (height / 2) + $j(window).scrollTop() -15),
		"left":(($j(window).width() / 2) - (width / 2) + $j(window).scrollLeft() -15)
	});
}

function popupWindow_hide(){
	$j(window).unbind('resize');
	$j("#"+(this.id)+"Popup").css("visibility", "hidden");
	$j("."+(this.id)+"Content").html('');
	popupWindow_removeOverlay();
}

function popupWindow_removeOverlay(){
	$j("body").css({"overflow":"auto"});
	$j("html").css({"overflow":"auto"});
	$j(".overlay").remove();
}

function popupWindow_destroy(){
	var destroy = $j("."+this.id+"Popup, ."+this.id+"Content, "+this.id+"Border").remove();
	if(destroy){return true;}else{return false;}
}