
var QPop; if (!QPop) QPop = {};

QPop.ASYNCH_URL = "qpopper/qpop_asynchs.php";
QPop.RESPONSE_ROOT_NODE = 'QPopResponse';

/**********************************************************************
	Determine properties of user browser
***********************************************************************/
QPop.BrowserSniff = function() {
	var b = navigator.appName.toString();
	var up = navigator.platform.toString();
	var ua = navigator.userAgent.toString();

	this.mozilla = this.ie = this.opera = this.safari = false;
	var re_opera = /Opera.([0-9\.]*)/i;
	var re_msie = /MSIE.([0-9\.]*)/i;
	var re_gecko = /gecko/i;
	var re_safari = /(applewebkit|safari)\/([\d\.]*)/i;
	var r = false;

	if ( (r = ua.match(re_opera))) {
		this.opera = true;
		this.version = parseFloat(r[1]);
	} else if ( (r = ua.match(re_msie))) {
		this.ie = true;
		this.version = parseFloat(r[1]);
	} else if ( (r = ua.match(re_safari))) {
		this.safari = true;
		this.version = parseFloat(r[2]);
	} else if (ua.match(re_gecko)) {
		var re_gecko_version = /rv:\s*([0-9\.]+)/i;
		r = ua.match(re_gecko_version);
		this.mozilla = true;
		this.version = parseFloat(r[1]);
	}
	this.windows = this.mac = this.linux = false;

	this.Platform = ua.match(/windows/i) ? "windows" :
					(ua.match(/linux/i) ? "linux" :
					(ua.match(/mac/i) ? "mac" :
					ua.match(/unix/i) ? "unix" : "unknown"));
	this[this.Platform] = true;
	this.v = this.version;

	if (this.safari && this.mac && this.mozilla) {
		this.mozilla = false;
	}
};

//grab the browser sniffer once
QPop.is = new QPop.BrowserSniff();

/*******************************************************************************
* Assign handler to specified element event
*
* @param element control DOM element receiving the handler
* @param eventType string Defined event name such as 'click' or 'mouseover'
* @param handler function The function to run when event fires
* @param capture bool Whether to capture event when fired, defaults to false
* @return nothing
********************************************************************************/
QPop.addEventListener = function(element, eventType, handler, capture) {
	if (!capture) capture = false;
	
	try {
		if (element.addEventListener) {
			element.addEventListener(eventType, handler, capture);
		}
		else if (element.attachEvent) {
			element.attachEvent('on' + eventType, handler);
		}
	}
	catch (e) {}
};

/*******************************************************************************
* Gets an instantiated XMLHttpRequest
* 
* @return XMLHttpRequest or an ActiveXObject that works as well
********************************************************************************/
QPop.newRequest = function() {
	var req = false;
	try {
		req = new XMLHttpRequest();
		req.getterarg = true;
	}
	catch (trymicrosoft) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			req.getterarg = false;
		}
		catch (othermicrosoft) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
				req.getterarg = false;
			}
			catch (failed) {
			}
		}
  }
	return req;
};

/*******************************************************************************
* Gets an element by id, browser independent
*
* @param ele string Name of element to retrieve
* @return control The found control, or null on not found
********************************************************************************/
QPop.getElement = function(ele) {
	if (document.getElementById) {
		return document.getElementById(ele);
	}
	else if (document.all) {
		return window.document.all[ele];
	}
	else if (document.layers) {
		return window.document.layers[ele];
	}
	return null;

};

QPop.AddArg = function(currurl, arg) {
	if (currurl.indexOf('?') != -1) {
		return currurl + "&" + arg;
	}
	return currurl + '?' + arg;
};

/*******************************************************************************
* QPop.Popbox constructor
*
* @param element string Name of element to retrieve
* @return control The found control, or null on not found
********************************************************************************/
QPop.Popbox = function(element, scriptid) {
	this.element = QPop.getElement(element);
	//alert("got element");
	
	if (!this.element) {
		alert("receiver box: " + element + " not found in page");
		return;
	}
	
	//kill any left-over shadow layer
	var tshad = QPop.getElement('qpop_shadow_' + this.element.id);
	if (tshad) this.element.parentNode.removeChild(tshad);
	
	//move me to the top of the stack
	//this.element.style.zIndex = 999;
	
	if (scriptid == null) scriptid = 0;
	
	if (typeof document.getElementById == 'undefined' || 
		(navigator.vendor == 'Apple Computer, Inc.' && typeof window.XMLHttpRequest == 'undefined') || 
		(QPop.is.ie && typeof document.uniqueID == 'undefined')) {
		// bail on older unsupported browsers
		return;
	}
	
	this.parms = [];
	
	this.ScriptID = scriptid;
	
	this.WantsShadow = false;
	this.WantsCopyright = false;

	//set up, position and show your popup element
	if (this.element) {
		//alert("got element");
		//clear element on open
		this.element.innerHTML = '';
		this.element.style.zIndex = 100;
		
		//add closer button
		var closer = new QPop.Popbox.CloseButton();
		this.element.appendChild(closer.element);
		
		var self = this;
		QPop.addEventListener(closer.element, 'click', function(e){self.ClosePopbox();}, false);
		
		//add content box
		var contentbox = document.createElement('div');
		//contentbox.style.zIndex = 2;
		this.element.appendChild(contentbox);
		this.receiverBox = contentbox;
		
		//center, position, fill (with prompt), and show Popbox
		this.CenterHorizontally();
		this.PositionTop(40);
		this.FillWith("getting image...");
		this.MakeVisible();
	}
	
};

/*******************************************************************************
* Add drop shadow around this element
*
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.AddShadow = function() {
	//kill any pre-existing shadow layer
	var tshad = QPop.getElement('qpop_shadow_' + this.element.id);
	if (tshad) this.element.parentNode.removeChild(tshad);
	
	var shadow = new QPop.DropShadow(this.element);
	this.element.parentNode.appendChild(shadow.shadowBox());
	this.shadowlayer = shadow.element;
};

/*******************************************************************************
* Add copyright on top of content
*
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.AddCopyright = function() {
	var year = new Date();
	year = year.getFullYear();
	var copy = '&copy; TuskegeeTopGun.com';
	
	var copybox = document.createElement('div');
	copybox.className = 'bigimgcopy';
	copybox.innerHTML = copy;

	var copybk = document.createElement('div');
	copybk.className = 'bigimgcopybk';
	copybk.innerHTML = copy;
	this.receiverBox.appendChild(copybk);

	this.receiverBox.appendChild(copybox);
	this.copylayer = copybox;
};


/*******************************************************************************
* Center this Popbox horizontally
*
* @param wide int Width to use for centering, gets it from offsetWidth if not supplied
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.CenterHorizontally = function(wide) {
	if (!wide) {
		wide = this.element.offsetWidth;
		//wide = 200;
	}
	
	var winW = 630;
	
	if (document.body.clientWidth) {
		winW = document.body.clientWidth;
	}
	else if (window.innerWidth) {
		winW = window.innerWidth;
	}
	
	this.element.style.left = ((winW / 2) - (wide / 2)) + "px";

};

/*******************************************************************************
* Position this Popbox the specified pixels from top of visible screen area
*
* @param topoff int Offset from top in pixels, defaults to 10 if not supplied
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.PositionTop = function(topoff) {
	if (topoff == null) topoff = 10;
	
	var ScrollTop = document.body.scrollTop;
 
	if (ScrollTop == 0) {
		if (window.pageYOffset) 
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	
	this.element.style.top = (ScrollTop + topoff) + "px";
	
};

/*******************************************************************************
* Fills my receiver with supplied HTML content
*
* @param content string Formed HTML code to fill box
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.FillWith = function(content) {
	this.receiverBox.innerHTML = content;
};

/*******************************************************************************
* Makes me visible
*
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.MakeVisible = function() {
	this.element.style.display = "block";
};

/*******************************************************************************
* Adds supplied name/value to my params list
*
* @param name string Name of parameter
* @param value string Value of parameter
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.AddParameter = function(name, value) {
	//alert("adding parameter");
	this.parms.push([name, value]);
};

/*******************************************************************************
* Launches an asynch filler and fills my receiver with the results
*
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.FillAsynchronously = function() {
	//set up URL
	var url = QPop.ASYNCH_URL;
	
	url = QPop.AddArg(url, 'scriptid=' + this.ScriptID);
	
	//alert("filling asynchronously");
	//make args out of my parameters
	for (var i = 0; i < this.parms.length; i++) {
		url = QPop.AddArg(url, this.parms[i][0] + "=" + this.parms[i][1]);
	}
	
	var filler = new QPop.Popbox.AsynchFiller(url);
	
	var self = this;
	
	filler.handle_success = function(resp){self.fillWithResponse(resp);};
	
	filler.send();
	
};

/*******************************************************************************
* Launches an asynch filler and fills my receiver with the results
*
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.fillWithImage = function(imgpath) {
	//set up URL
	var imgtag = '<img src="' + imgpath + '" width="" height="" alt="" style="" />';
	
	this.fillWithResponse(imgtag);
	
};

/*******************************************************************************
* Handles asynchronous filler response
*
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.fillWithResponse = function(response) {
	//alert("filling with response");
	this.FillWith(response);
	//re-center it after filling
	this.CenterHorizontally();
	if (this.WantsShadow) {
		this.AddShadow();
	}
	if (this.WantsCopyright) {
		this.AddCopyright();
	}
};

/*******************************************************************************
* Clears and hides me
*
* @return nothing
********************************************************************************/
QPop.Popbox.prototype.ClosePopbox = function() {
	this.element.innerHTML = "";
	this.element.style.display = "none";
	if (this.shadowlayer) {
		this.element.parentNode.removeChild(this.shadowlayer);
	}
};



/*******************************************************************************
* QPop.Popbox.CloseButton constructor
*
* @return CloseButton 
********************************************************************************/
QPop.Popbox.CloseButton = function() {
	this.init();
};

	QPop.Popbox.CloseButton.prototype.init = function() {
		this.element = document.createElement('div');
		
		this.element.style.position = "absolute";
		this.element.style.right = "6px";
		this.element.style.top = "6px";
		this.element.style.backgroundColor = "#cb450c";
		this.element.style.color = "#ffffff";
		this.element.style.fontWeight = "bold";
		this.element.style.paddingLeft = "3px";
		this.element.style.paddingRight = "3px";
		this.element.style.paddingBottom = "2px";
		this.element.style.fontFamily = "verdana, arial, helvetica";
		this.element.style.fontSize = "8pt";
		this.element.style.border = "solid 1px #712606";
		this.element.style.cursor = "pointer";
		this.element.title = "click to close window";
		//this.element.style.zIndex = 999;
		this.element.innerHTML = "X";
		
		var self = this;
		QPop.addEventListener(this.element, 'mouseover', function(e){self.mouseOver(e);}, false);
		QPop.addEventListener(this.element, 'mouseout', function(e){self.mouseOut(e);}, false);

	};

	/*******************************************************************************
	* MouseOver handler for this button
	*
	* @return nothing
	********************************************************************************/
	QPop.Popbox.CloseButton.prototype.mouseOver = function(e) {
		this.element.style.backgroundColor = "#f7966c";
		this.element.style.borderColor = "#f25613";
	};

	/*******************************************************************************
	* MouseOut handler for this button
	*
	* @return nothing
	********************************************************************************/
	QPop.Popbox.CloseButton.prototype.mouseOut = function(e) {
		this.element.style.backgroundColor = "#cb450c";
		this.element.style.borderColor = "#712606";
	};

/***** end CloseButton virtual class *************************************************/



/*******************************************************************************
* Constructor for asynch filler object
*
* @param url string URL and all args for get request
* @return CloseButton 
********************************************************************************/
QPop.Popbox.AsynchFiller = function(url) {
	
	this.handle_success = null;
	
	//get request object from stack
	var req = QPop.newRequest();
	
	if (!req) { alert("Could not create request object"); return; }
	
	//force new page response
	url = QPop.AddArg(url, this.RandomKey());
	
	//set it up for GET operation
	req.open("GET", url, true);
	req.onreadystatechange = function() {
		try {
			if (req.readyState == 4) {
				if (req.status == 200) {
					//retrieve response
					var resp = req.responseText;
					//call success handler
					req.handle_success(resp);
				}
				else {
					//alert("Error in asynchGetRequest. Status code: " + req.status + " URL: " + url);
				}
			}
		}
		catch(e) {
			alert("Communication error. Probably temporary, try again. " 
				+ e.message 
				+ " name: " + e.name 
				+ " url: " + url 
				+ " status: " + req.status);
		}
	}
	this.send = function() {
		req.handle_success = this.handle_success;
		if (req.getterarg) { //not sure I need this
			req.send(null);
		}
		else {
			req.send();
		}
	};
};

/*******************************************************************************
* Generate random argument to ensure fresh pages and images
*
* @return CloseButton 
********************************************************************************/
QPop.Popbox.AsynchFiller.prototype.RandomKey = function() {
	return "RandomKey=" + Math.random() * Date.parse(new Date());
};



/*******************************************************************************
* Constructor for FormPoster object
*
* @param element string Name of element to manage
* @return FormPoster object
********************************************************************************/
QPop.FormPoster = function(element) {
	this.init(element);
};

QPop.FormPoster.prototype.init = function(element, scriptid) {
	this.element = QPop.getElement(element);
	
	if (scriptid == null) scriptid = '104';
	this.ScriptID = scriptid;
	
	if (this.element) {
		//add results dump div
		var tbox = document.createElement('div');
		tbox.style.display = "none";
		tbox.style.border = "solid 1px #5117e8";
		tbox.style.padding = "4px";
		tbox.style.marginTop = "8px";
		this.element.appendChild(tbox);
		this.errdump = tbox;
		
		//prototype contains function if necessary
		if(!QPop.is.ie) {
			// define a simple function that comes standard in IE to determine
			// if a node is within another node
			this.element.contains = function(testNode) {
				// this refers to the list item
				if(testNode == null)
					return false;

				if(testNode == this)
					return true;
				else
					return this.contains(testNode.parentNode);
			};
		}

		
		//find the first form within element
		var myforms = this.element.getElementsByTagName('form');
		this.theForm = (myforms.length > 0 ? myforms[0] : null);
		
		var self = this;
		
		//find the cancel button and add my closer handler
		var cancelbutt = QPop.getElement("qpopcancel");
		if (cancelbutt) 
			QPop.addEventListener(cancelbutt, 'click', function(e){self.ClosePop();}, false);
		
		//find the submit button and add my submit handler
		var submitbutt = QPop.getElement("qpopsubmit");
		if (submitbutt) {
			QPop.addEventListener(submitbutt, 'click', function(e){self.SendPost();}, false);
			this.submitter = submitbutt;
			this.submitter.disabled = false;
		}
		else {
			//if there's no submit button in the box, re-hide myself
			window.setTimeout(function(){self.ClosePop();}, 2000);
		}
	}

};

/*******************************************************************************
* Asynchronously send the form to specified URL and script ID
*
* @return void
********************************************************************************/
QPop.FormPoster.prototype.SendPost = function() {
	
	//get new request object
	var req = QPop.newRequest();
	
	if (!req) { alert("Could not create request object"); return; }
	
	var url = QPop.ASYNCH_URL;
	url = QPop.AddArg(url, 'scriptid=' + this.ScriptID);

	req.open("POST", url, true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

	var self = this;
	
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			window.clearInterval(self.waiter);
			
			if (req.status == 200) {
				if (req.getResponseHeader("Content-Type") != 'text/xml') {
					self.handleErrorResponse(req.responseText);
				}
				else {
					self.handleXmlResponse(req.responseXML);
				}
			}
			else if (req.status == 404) {
				alert("Request URL does not exist");
			}
			else {
				alert("Error: status code is " + req.status);
			}
		}
	};
	
	req.send(this.getChkRequestBody());
	
	//set myself up in stand-by mode
	this.errdump.innerHTML = "sending message...";
	this.errdump.style.borderColor = "#5117e8";
	this.errdump.style.display = "block";
	
	this.submitter.disabled = true;
	
	this.startWaiter(function(){self.checkForCompletion();});
	
};

/*******************************************************************************
* Set up and initiate form waiter
*
* @param handler function Function to run each tick
* @return void
********************************************************************************/
QPop.FormPoster.prototype.startWaiter = function(handler) {
	this.waited = 0;
	this.waiter = window.setInterval(handler, 1000);
};

/*******************************************************************************
* Waiter tick function
*
* @return void
********************************************************************************/
QPop.FormPoster.prototype.checkForCompletion = function() {
	this.waited++;
	this.errdump.innerHTML += '.';
	if (this.waited > 30) {
		//turn the submit button back on
		this.submitter.disabled = false;
		
		//re-style, add error message, and show dumpbox
		this.errdump.style.borderColor = '#8d28b9';
		this.errdump.innerHTML = 'Timeout exceeded waiting for response from server.<br />Try your request again or click cancel to abort.';
		window.clearInterval(this.waiter);
	}
};

/*******************************************************************************
* Handles XML response from form submission
*
* @param resXml XMLDoc XML returned by form post
* @return void
********************************************************************************/
QPop.FormPoster.prototype.handleXmlResponse = function(resXml) {
	//parse results
	var res = new QPop.FormPoster.ResultXmlParser(resXml);
	
	if (res.ResultCode == "0") {
		this.element.innerHTML = "Your message regarding '" + res.Painting + "' has been sent!";
		
		var self = this;
		window.setTimeout(function(){self.ClosePop();}, 5000);
	}
	else {
		//turn the submit button back on
		this.submitter.disabled = false;
		
		//re-style, add error message, and show dumpbox
		this.errdump.style.borderColor = "#ff0000";
		this.errdump.innerHTML = '<div style="font-size: 8pt; margin-bottom: 4px;">response code received: ' + res.ResultCode + '</div>';
		this.errdump.innerHTML += res.ErrorMessage;
		this.errdump.style.display = "block";
	}

};

/*******************************************************************************
* Handler for error response from form post
*
* @param resText string Text returned by form post
* @return void
********************************************************************************/
QPop.FormPoster.prototype.handleErrorResponse = function(resText) {
	//re-style, add error message, and show dumpbox
	this.errdump.style.borderColor = "#ff0000";
	this.errdump.innerHTML = '<div style="font-size: 8pt; margin-bottom: 4px;">server-side error: </div>';
	this.errdump.innerHTML += resText;
	this.errdump.style.display = "block";

	//turn the submit button back on
	this.submitter.disabled = false;
	
};

/*******************************************************************************
* Parses XMLDoc and returns object with properties for every node in XML
*
* @param xdoc XMLDoc XML to parse
* @return void
********************************************************************************/
QPop.FormPoster.ResultXmlParser = function(xdoc) {
	var root = xdoc.getElementsByTagName(QPop.RESPONSE_ROOT_NODE)[0];
	if (!root) {
		this.ResultCode = "-9";
		this.ErrorMessage = "No QPop root node found in response XML";
		this.ErrorMessage += "<br />returned xdoc: " + xdoc;
		return;
	}
	for (var i = 0; i < root.childNodes.length; i++) {
		//all child nodes become properties of this parser (this is so cool!)
		try {
			if (root.childNodes[i].childNodes.length == 0) {
				this[root.childNodes[i].nodeName] = '';
			}
			else {
				this[root.childNodes[i].nodeName] = root.childNodes[i].childNodes[0].nodeValue;
			}
		}
		catch(e) {
			this.ResultCode = "-11";
			this.ErrorMessage = "Error evaluating response XML";
			this.ErrorMessage += "<br />at child node: " + root.childNodes[i].nodeName;
			this.ErrorMessage += "<br />msg: " + e.message;
			return;
		
		}
	}
};

/*******************************************************************************
* Assembles this element's form into url argument
*
* @return string Encoded argument string
********************************************************************************/
QPop.FormPoster.prototype.getChkRequestBody = function() {
	var p = [];
	var nChkcode = function(n,v) {
		return encodeURIComponent(n) + '=' + encodeURIComponent(v);
	};
	
	for (var i = this.theForm.elements.length-1; i >= 0; i--) {
		var fld = this.theForm.elements[i];
		switch (fld.type) {
			case "button": case "submit": case "reset": break;
			case "checkbox": case "radio": if (!fld.checked) break;
			default:
				if ("select" == fld.tagName.toLowerCase())
					p.push(nChkcode(fld.name, fld.options[fld.selectedIndex].value));
				else p.push(nChkcode(fld.name, fld.value));
		}
	}
	return p.join('&');	
};

/*******************************************************************************
* Closes this popup window
*
* @return void
********************************************************************************/
QPop.FormPoster.prototype.ClosePop = function() {
	try {
		//lose the errdump if it's still here
		if (this.element.contains(this.errdump)) {
			this.element.removeChild(this.errdump);
		}
		window.clearInterval(this.waiter);
	}
	catch(e) {alert("couldn't remove dump");}
	//hide myself
	this.element.style.display = "none";
};

/*******************************************************************************
* Opens this popup window
*
* @return void
********************************************************************************/
QPop.FormPoster.prototype.Show = function() {
	this.element.style.display = "block";
};

/*******************************************************************************
* QPop Drop Shadow object
*
* @return void
********************************************************************************/
QPop.DropShadow = function(ele) {
	this.parentpop = ele;
	
	this.element = document.createElement('div');
	this.element.id = 'qpop_shadow_' + this.parentpop.id;
	
	//shadow.style.zIndex = parentpop.style.zIndex - 1;
	///alert('z-index: ' + shadow.style.zIndex);
	
	//this.shadoff = 50;
	
	this.topOff = 10;
	this.leftOff = 20;
	this.rightOff = 30;
	this.bottomOff = 40;
	
	//this.shadowBox = shadow;
};

/*******************************************************************************
* Assembles shadow layer based on current dimensions of parent box
*
* @return void
********************************************************************************/
QPop.DropShadow.prototype.shadowBox = function() {
	
	var parentbox = {
		top: this.parentpop.offsetTop,
		left: this.parentpop.offsetLeft,
		width: this.parentpop.offsetWidth,
		height: this.parentpop.offsetHeight
	};
	
	var shadwidth = (parentbox.width + this.leftOff + this.rightOff);
	var shadheight = (parentbox.height + this.topOff + this.bottomOff);
	var shadleft = (parentbox.left - this.leftOff);
	var shadtop = (parentbox.top - this.topOff);
	
	//var shadsrc = (shadwidth > shadheight) ? 'shad_warm_horiz2.png' : 'shad_warm_vert2.png';
	
	this.element.style.position = "absolute";

	this.element.style.left = shadleft + 'px';
	this.element.style.top = shadtop + 'px';
	this.element.style.width = shadwidth + 'px';
	this.element.style.height = shadheight + 'px';
		
	//this.element.style.backgroundColor = "#cb450c";
	
	var refreshkey = 'qsq';
	var shaddim = 45;
	var shaddir = '/qpopper/shadows/';
	
	//create the 8 sections
	var shad_tl = document.createElement('div');
	shad_tl.style.position = "absolute";
	shad_tl.style.left = '0px';
	shad_tl.style.top = '0px';
	shad_tl.style.backgroundImage = 'url(' + shaddir + 'shad_tl.png?' + refreshkey + ')';
	shad_tl.style.backgroundRepeat = 'no-repeat';
	shad_tl.style.width = shaddim + 'px';
	shad_tl.style.height = shaddim + 'px';

	this.element.appendChild(shad_tl);
	
	var shad_tr = document.createElement('div');
	shad_tr.style.position = "absolute";
	shad_tr.style.right = '0px';
	shad_tr.style.top = '0px';
	shad_tr.style.backgroundImage = 'url(' + shaddir + 'shad_tr.png?' + refreshkey + ')';
	shad_tr.style.backgroundRepeat = 'no-repeat';
	shad_tr.style.width = shaddim + 'px';
	shad_tr.style.height = shaddim + 'px';
	this.element.appendChild(shad_tr);
	
	var shad_bl = document.createElement('div');
	shad_bl.style.position = "absolute";
	shad_bl.style.left = '0px';
	shad_bl.style.bottom = '0px';
	shad_bl.style.backgroundImage = 'url(' + shaddir + 'shad_bl.png?' + refreshkey + ')';
	shad_bl.style.backgroundRepeat = 'no-repeat';
	shad_bl.style.width = shaddim + 'px';
	shad_bl.style.height = shaddim + 'px';
	this.element.appendChild(shad_bl);
	
	var shad_br = document.createElement('div');
	shad_br.style.position = "absolute";
	shad_br.style.right = '0px';
	shad_br.style.bottom = '0px';
	shad_br.style.backgroundImage = 'url(' + shaddir + 'shad_br.png?' + refreshkey + ')';
	shad_br.style.backgroundRepeat = 'no-repeat';
	shad_br.style.width = shaddim + 'px';
	shad_br.style.height = shaddim + 'px';
	this.element.appendChild(shad_br);
	
	var shad_bb = document.createElement('div');
	shad_bb.style.position = "absolute";
	shad_bb.style.left = shaddim + 'px';
	shad_bb.style.bottom = '0px';
	shad_bb.style.width = (shadwidth - (shaddim * 2)) + 'px';
	shad_bb.style.backgroundImage = 'url(' + shaddir + 'shad_bb.png?' + refreshkey + ')';
	shad_bb.style.backgroundRepeat = 'repeat-x';
	shad_bb.style.height = shaddim + 'px';
	this.element.appendChild(shad_bb);
	
	var shad_tt = document.createElement('div');
	shad_tt.style.position = "absolute";
	shad_tt.style.left = shaddim + 'px';
	shad_tt.style.top = '0px';
	shad_tt.style.width = (shadwidth - (shaddim * 2)) + 'px';
	shad_tt.style.backgroundImage = 'url(' + shaddir + 'shad_tt.png?' + refreshkey + ')';
	shad_tt.style.backgroundRepeat = 'repeat-x';
	shad_tt.style.height = shaddim + 'px';
	this.element.appendChild(shad_tt);
	
	var shad_ll = document.createElement('div');
	shad_ll.style.position = "absolute";
	shad_ll.style.left = '0px';
	shad_ll.style.top = shaddim + 'px';
	shad_ll.style.height = (shadheight - (shaddim * 2)) + 'px';
	shad_ll.style.backgroundImage = 'url(' + shaddir + 'shad_ll.png?' + refreshkey + ')';
	shad_ll.style.backgroundRepeat = 'repeat-y';
	shad_ll.style.width = shaddim + 'px';
	this.element.appendChild(shad_ll);
	
	var shad_rr = document.createElement('div');
	shad_rr.style.position = "absolute";
	shad_rr.style.right = '0px';
	shad_rr.style.top = shaddim + 'px';
	shad_rr.style.height = (shadheight - (shaddim * 2)) + 'px';
	shad_rr.style.backgroundImage = 'url(' + shaddir + 'shad_rr.png?' + refreshkey + ')';
	shad_rr.style.backgroundRepeat = 'repeat-y';
	shad_rr.style.width = shaddim + 'px';
	this.element.appendChild(shad_rr);
	
	return this.element;
};





/*************************************************************
* outside function that the images call
**************************************************************/
function popupLarge(imgpath) {
	//alert("got element");
	var newpop = new QPop.Popbox('bigimagebox', '201');
	
	newpop.AddParameter('img', imgpath);
	//newpop.AddParameter("scriptid", "600");
	newpop.WantsShadow = true;
	newpop.WantsCopyright = true;
	
	newpop.FillAsynchronously();
	
	//newpop.AddShadow();
}

/*************************************************************
* outside function that the inquire link calls
**************************************************************/
function showInquireForm() {
	var newinq = new QPop.FormPoster("inquirebox");
	newinq.Show();
}

function popShadowBox() {
	var newpop = new QPop.Popbox('shadtest', '333');
	newpop.FillWith("this is some longer text to fill this box with.<p>And a second paragraph to push out the height a bit.</p>");
	newpop.AddShadow();
}
