
//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

//PAUL'S ADDITION TO CAPTURE IMG SRC
/*
// NOT NEEDED -- WILL HAVE CORY PUT IN LRG IMAGE DIMENSIONS INSTEAD
if (document.getElementById("content-artistpics")) {
	var aArray = document.getElementById("content-artistpics").getElementsByTagName("A");
	for(i=0;i<aArray.length;i++) {
		src = aArray[i].getElementsByTagName("img")[0].getAttribute("src");
		width = aArray[i].getElementsByTagName("img")[0].getAttribute("width");
		height = aArray[i].getElementsByTagName("img")[0].getAttribute("height");
		aArray[i].onclick = function() {
			srcInit = this.getElementsByTagName("img")[0].getAttribute("src").split(".");
			src = srcInit[0] + "_lg." + srcInit[1];
			src = srcInit[0] + "." + srcInit[1];
			width = this.getElementsByTagName("img")[0].getAttribute("width");
			height = this.getElementsByTagName("img")[0].getAttribute("height");
			imgPreview(src,width+60,height+60);
		}
	}
}
*/

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("imgPreview").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("imgPreview").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("imgPreview").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("imgPreview").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("imgPreviewContent").style.display="none" //extra
tempx=parseInt(document.getElementById("imgPreview").style.left)
tempy=parseInt(document.getElementById("imgPreview").style.top)

dragapproved=true
document.getElementById("imgPreview").onmousemove=drag_drop
}

function imgPreview(url,width,height,title){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
width = (!width) ? 750 : width;
height = (!height) ? 400 : height;
document.getElementById("imgPreview").style.display='block';
document.getElementById("imgPreview").style.width=initialwidth=width+"px"
//document.getElementById("imgPreview").style.height=initialheight=height+"px"
//document.getElementById("imgPreview").style.left="30px"
//document.getElementById("imgPreview").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("imgPreview").style.left = ns6 ? (window.innerWidth/2)-(width/2)+"px" : (iecompattest().clientWidth/2)-(width/2) + "px"
document.getElementById("imgPreview").style.top = ns6 ? window.pageYOffset*1 + ((window.innerHeight/2) - (height/2)) + "px" : iecompattest().scrollTop*1 + ((iecompattest().clientHeight/2) - (height/2)) + "px"
//document.getElementById("cframe").src=url
var rExpSQuote = /'/gi
var rExpDQuote = /"/gi
var caption = (title != "<br />") ? "<br><div id=\"imgPreviewTitle\">"+title+"</div>" : ""
layout1 = "<table cellpadding=0 cellspacing=0 border=0 width=100% height=100%><tr><td align=center valign=middle class=\"imgPreviewTd\"><img src='"+url+"'>"+caption+"</td></tr></table>";
layout2 = "<table cellpadding=0 cellspacing=0 border=0 width=100% height=100%><tr><td align=center valign=middle class=\"imgPreviewTd\"><img src='"+url+"'></td><td align=center valign=middle style=\"background-color:#fff\">"+caption+"</td></tr></table>";
document.getElementById("imgPreviewContent").innerHTML = layout2;
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("imgPreview").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("imgPreview").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("imgPreview").style.width=initialwidth
document.getElementById("imgPreview").style.height=initialheight
}
document.getElementById("imgPreview").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("imgPreview").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("imgPreview").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("imgPreview").onmousemove=null;
document.getElementById("imgPreviewContent").style.display="" //extra
}

function toggleClose() {
	if (document.getElementById("imgPreviewClose")) {
		if (document.getElementById("imgPreviewClose").style.display == "none") {
			document.getElementById("imgPreviewClose").style.display == "block"
		} else {
			document.getElementById("imgPreviewClose").style.display == "none";
		}
	}
}
