if (!YAHOO.lightBox){
	YAHOO.namespace ("YAHOO.lightBox");
}
YAHOO.lightBox.start = function(){
	// config object
	var config = {};
	// shortcuts
	var $dom = YAHOO.util.Dom;
	// dom elements and collections
	var containers = {};
	var displays = {};
	var imgs = null;
	// storage objects / arrays
	var boxes = {};
	var active = {};
	var request;
	var loaded = {};
	var events = {};
	var configs = {};
	var configDefault = {};

	// public
	return{
		init: function(){
			// set up custom events
			events.onMetaChange = new YAHOO.util.CustomEvent("metaChange", this, true, 1);
			events.onLoad = new YAHOO.util.CustomEvent("load", this, true, 1);
			this.defaultConfig();
			this.create();
		},
		defaultConfig: function(){
			// first create default config object
			var containers = null;
			configDefault = {
				display:{
					gallery:true,
					slideshow:false,
					timer:5000
				},
				transitions:{
					fade:0.6,
					size:0.6
				},
				window:{
					modal:true,
					dragable:false
				},
				easing:{
					global:YAHOO.util.Easing.easeBothStrong
				},
				// no default connections
				position:{
					placement: "absolute"
				}// no default slideshow setting
			};
			if (!YAHOO.lightBox.config){
				containers = $dom.getElementsByClassName("lightBoxContainer", "div");
				YAHOO.lightBox.config = {};
				for (var i = 0; i < containers.length; i++){
					containers[i].setAttribute("id", "lightBoxContainer_" + i);
					YAHOO.lightBox.config["lightBoxContainer_" + i] = configDefault;
				}
			}
		},
		create: function(cont){/************* should be private */
			var box;
			if (!cont){
				containers = $dom.getElementsByClassName("lightBoxContainer", "div");
				for (var j = 0; j < containers.length; j++){
					if (containers[j].getElementsByTagName("img").length){
						//containers[j].setAttribute("id", "lightBoxContainer_" + j);
						this.configImage(containers[j], j);
					}
				}
			}
			else{
				this.configImage($dom.get(cont));
			}
		},
		configImage: function(container, index){/************* should be private */
			active[container.getAttribute("id")] = null; // set default active
			imgs = $dom.getElementsByClassName("lightBox", "img", container);
			loaded[container.getAttribute("id")] = {};
			boxes[container.getAttribute("id")] = [];
			displays[container.getAttribute("id")] = null;
			configs[container.getAttribute("id")] = container.getAttribute("id");
			for (var i in imgs){
				if (imgs.hasOwnProperty(i)){
					if (!loaded[container.getAttribute("id")]["lightBoxThumb_" + i]){
						imgs[i].setAttribute("id", "lightBoxThumb_" + i); // assign unique id
						imgs[i].index = i; // custom attribute for index
						box = new YAHOO.lightBox.image(imgs[i]);
						boxes[container.getAttribute("id")].push(box);
						loaded[container.getAttribute("id")][imgs[i].getAttribute("id")] = true;
					}
				}
			}
		},
		openDisplay: function(cont, index){
			var index = index ? index : 0;
			try{
			boxes[cont][index].open();
			}catch(e){} // temp, need to have the display object check for active display
		},
		next: function(id){
			try{
				this.getDisplay(id).onnext();
			}catch(e){} // temp, need to have the display object check for active display
		},
		prev: function(id){
			try{
			this.getDisplay(id).onprev();
			}catch(e){} // temp, need to have the display object check for active display
		},
		close: function(id){
			try{
			this.getDisplay(id).onclose();
			}catch(e){} // temp, need to have the display object check for active display
		},
		load: function(id){
			var config = YAHOO.lightBox.config[id];
			var callBack = config.connections.callBack ? config.connections.callBack : void(0);
			var callBack = {
				success: this.readPhotos,
				failure: this.handleFail,
				caller: this,
				callBack: callBack,
				cont: id
			};
			request = YAHOO.util.Connect.asyncRequest('GET', config.connections.url, callBack);
		},
		readPhotos: function(data){/************* should be private */
			var photo = {};
			//if (YAHOO.lightBox.config.connections.type == "XML"){
				var photoNodes = data.responseXML.getElementsByTagName("photo");
				for (var i = 0; i < photoNodes.length; i++){
					photo.src = photoNodes[i].getElementsByTagName("src")[0].firstChild.nodeValue;
					photo.longdesc = photoNodes[i].getElementsByTagName("longdesc")[0].firstChild.nodeValue;
					if (photoNodes[i].getElementsByTagName("title")[0].firstChild){
						photo.title = photoNodes[i].getElementsByTagName("title")[0].firstChild.nodeValue;
					}
					else{
						photo.title = "";
					}
					if (photoNodes[i].getElementsByTagName("alt")[0].firstChild){
						photo.alt = photoNodes[i].getElementsByTagName("alt")[0].firstChild.nodeValue;
					}
					else{
						photo.alt = "";
					}
					this.caller.createPhoto(photo, this.cont);
				}
			//}
			//else{
				// need JSON decoder
			//}
			this.caller.create(this.cont);
			this.caller.events("onMetaChange").fire();
			this.callBack();
			//ww=window.open("","");
			//ww.document.write(document.body.innerHTML);
		},
		createPhoto: function (photo, cont){ /************* should be private */
			var anchor = document.createElement("a");
			var dom = document.createElement("img");
			var loadContainer = cont ? $dom.get(cont) : $dom.getElementsByClassName("lightBoxContainer", "div")[0];

			anchor.setAttribute("href", "javascript:;");
			$dom.setStyle(anchor, "display", "none");
			dom.setAttribute("src", photo.src);
			//dom.setAttribute("longdesc", photo.longdesc);
			dom.longdesc = photo.longdesc;
			//alert(dom.longdesc);
			dom.setAttribute("title", photo.title);
			dom.setAttribute("alt", photo.alt);
			$dom.addClass(dom, "lightBox");
			anchor.appendChild(dom);
			loadContainer.appendChild(anchor);
		},
		handleFail: function(){/************* should be private */
			alert("fail!");
		},
		setActive: function(cont, box){
			active[cont] = box;
		},
		getActive: function(cont){
			return active[cont];
		},
		getDisplay: function(id){
			return displays[id];
		},
		setDisplay: function(id, display){
			displays[id] = display;
		},
		getCont: function(node){
			return $dom.getAncestorByClassName(node, "lightBoxContainer").getAttribute("id");
		},
		events: function(evt){
			return events[evt];
		}
	} // end return
}();
// instance classes
YAHOO.lightBox.image = function(dom){
	// config object
	var config = {};
	// shortcuts
	var $dom = YAHOO.util.Dom;
	var $evt = YAHOO.util.Event;

	init();

	//public
	this.getDom = getDom;
	function getDom(){
		return dom;
	}
	this.open = open;
	function open(){
		onclick();
	}
	// private
	function init(){
		setEvents();
	}
	function setEvents(){
		$evt.on(dom, "click", onclick, dom, true);
	}
	function onclick(e){
		if (!YAHOO.lightBox.start.getActive(YAHOO.lightBox.start.getCont(dom))){
			//display = new YAHOO.lightBox.display(box);
			YAHOO.lightBox.start.setDisplay(YAHOO.lightBox.start.getCont(dom), new YAHOO.lightBox.display(dom));
		}
		YAHOO.lightBox.start.setActive(YAHOO.lightBox.start.getCont(dom), dom);
		YAHOO.lightBox.start.getDisplay(YAHOO.lightBox.start.getCont(dom)).load();
		YAHOO.util.Event.preventDefault(e);
	}
};
YAHOO.lightBox.display = function(dom){
	// config object
	var config = {};
	// shortcuts
	var $dom = YAHOO.util.Dom;
	var $evt = YAHOO.util.Event;
	// dom elements and collections
	var display = null;
	var header = null;
	var title = null;
	var closeBtn = null;
	var image = null;
	var details = null;
	var desc = null;
	var count = null;
	var nav = null;
	var nextBtn = null;
	var prevBtn = null;
	var mask = null;
	var loader = null;
	var dragObj = null;
	var pager = null;
	// storage objects / arrays
	var hasLoaded = false;
	var orgBodyOverflow = $dom.getStyle(document.body, "overflow");
	var pagingBtns = [];
	var interval = null;

	init();

	// public
	this.load = load;
	function load(){
		var box = YAHOO.lightBox.start.getActive(YAHOO.lightBox.start.getCont(dom));
		var src;
		$dom.setStyle(title, "visibility", "hidden");
		$dom.setStyle(details, "visibility", "hidden");
		$dom.setStyle(image, "visibility", "hidden");
		$dom.setStyle(display, "z-index", YAHOO.lightBox.newZ++);
		setText(title, "title");
		setText(desc, "alt");
		displayLoadingOn();
		if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].window.modal){
			//$dom.setStyle(document.body, "overflow", "hidden");
		}
		if (box.longdesc == undefined){
			src = box.getAttribute("longdesc");
		}
		else{
			src = box.longdesc;
		}
		image.src = src;
	}
	this.onnext = onnext;
	function onnext(){
		if (!disabled(nextBtn)){
			YAHOO.lightBox.start.setActive(YAHOO.lightBox.start.getCont(dom), getNextBox());
			load();
			setEvents();
			updateCount();
		}
	}
	this.onprev = onprev;
	function onprev(){
		if (!disabled(prevBtn)){
			YAHOO.lightBox.start.setActive(YAHOO.lightBox.start.getCont(dom), getPrevBox());
			load();
			setEvents();
			updateCount();
		}
	}
	this.onclose = onclose;
	function onclose(){
		var anim, attributes;
		YAHOO.lightBox.start.setActive(YAHOO.lightBox.start.getCont(dom), null);
		attributes = {
			opacity: { from: 1, to: 0 },
			height: { to: 0 }
		};
		anim = new YAHOO.util.Anim(display, attributes, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].transitions.fade, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].easing.global);
		anim.animate();
		anim.onComplete.subscribe(function(){
			$dom.setStyle(display, "display", "none");
			$dom.setStyle(mask, "display", "none");
			if (interval)
				stopSlideshow();
			//$dom.setStyle(document.body, "overflow", orgBodyOverflow);
		});
	}
	this.middle = middle;
	function middle(){
		// not sure what to do here yet
	}
	this.startSlideshow = startSlideshow;
	function startSlideshow(){
		var which = YAHOO.lightBox.start.getCont(dom);
		var intervalStr = "YAHOO.lightBox.start.getDisplay('" + which + "').onnext()";
		interval = setInterval(intervalStr, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].display.timer);
	}
	this.stopSlideshow = stopSlideshow;
	function stopSlideshow(){
		clearInterval(interval);
	}
	// private
	function init(){
		create();
		if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].window.dragable){
			dragObj = new YAHOO.lightBox.DDOnTop(display.getAttribute("id"));
			dragObj.setHandleElId(title.getAttribute("id"));
			$dom.setStyle(title, "cursor", "move");
		}
		setEvents();
	}
	function create(){
		display = document.createElement("div");
		displayInner = document.createElement("div");
		header = document.createElement("div");
		title = document.createElement("h1");
		closeBtn = document.createElement("a");
		image = document.createElement("img");
		details = document.createElement("div");
		desc = document.createElement("div");
		count = document.createElement("div");
		nav = document.createElement("div");
		pager = document.createElement("div");
		nextBtn = document.createElement("a");
		prevBtn = document.createElement("a");
		mask = document.createElement("div");
		loader = document.createElement("div");
		// add to the dom
		display.appendChild(displayInner);
		displayInner.appendChild(header);
		header.appendChild(title);
		displayInner.appendChild(closeBtn);
		displayInner.appendChild(image);
		displayInner.appendChild(details);
		details.appendChild(desc);
		details.appendChild(count);
		displayInner.appendChild(nav);
		nav.appendChild(pager);
		nav.appendChild(nextBtn);
		nav.appendChild(prevBtn);
		document.body.appendChild(mask);
		document.body.appendChild(loader);
		if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].position.placement == "absolute"){ // split for absolute vs relative pathing
			document.body.appendChild(display);
		}
		else{
			//document.body.appendChild(display);
			$dom.get(YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].position.container).appendChild(display);
			$dom.setStyle(display, "position", "relative");
			$dom.setStyle(display, "margin-top", "0px");
			$dom.setStyle(display, "margin-left", "0px");
			$dom.setStyle(display, "top", "0px");
			$dom.setStyle(display, "left", "0px");
			$dom.replaceClass(display, "lightBoxShowCase", "lightBoxShowCaseRel");
		}
		// config
		configDisplay();
	}
	function setEvents(){
		if (!$evt.getListeners(nextBtn, "click")){
			$evt.on(image, "load", onload, image, true);
			$evt.on(nextBtn, "click", onnext, nextBtn, false);
			$evt.on(prevBtn, "click", onprev, prevBtn, false);
			$evt.on(closeBtn, "click", onclose, closeBtn, false);

			if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].window.dragable){
				$evt.on(display, "mousedown", dragObj.startDrag, dragObj, true);
			}

			$evt.on(nextBtn, "focus", doblur);
			$evt.on(prevBtn, "focus", doblur);
			$evt.on(closeBtn, "focus", doblur);
			$evt.on(window, "resize", middle);
			$evt.on(document.body, "scroll", middle);
			YAHOO.lightBox.start.events("onMetaChange").subscribe(metaUpdate);
			//YAHOO.lightBox.start.events("onLoad").subscribe(loadUpdate);
			// set event for configuring the pagination
			if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].controls){
				if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].controls.paging){
					YAHOO.lightBox.start.events("onLoad").subscribe(configPaging);
				}
			}
			// set event for starting the slideshow timer
			if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].display.slideshow){
				if (!hasLoaded)
					startSlideshow();
			}
		}
	}
	function configDisplay(){
		$dom.setStyle(display, "display", "none");
		//$dom.setStyle(display, "z-index", YAHOO.lightBox.newZ++);
		$dom.addClass(display, "lightBoxShowCase");
		$dom.addClass(display, "lightBoxShowCaseInner");
		display.setAttribute("id", $dom.generateId());
		title.setAttribute("id", $dom.generateId());
		$dom.addClass(image, "lightBoxZoom");
		$dom.addClass(header, "lightBoxHeader");
		$dom.addClass(details, "lightBoxDetails");
		$dom.addClass(desc, "lightBoxDesc");
		$dom.addClass(count, "lightBoxCount");
		$dom.addClass(nav, "lightBoxNav");
		$dom.addClass(pager, "lightBoxPager");

		createBtn("nextBtn", nextBtn);
		createBtn("prevBtn", prevBtn);
		createBtn("closeBtn", closeBtn);

		$dom.addClass(mask, "lightBoxMask");
		$dom.setStyle(mask, "z-index", 900);
		$dom.addClass(loader, "lightBoxLoader");
		//$dom.setStyle(loader, "z-index", YAHOO.lightBox.newZ); // set this on show
	}
	function configPaging(){
		var index = getBoxIndex();
		var amount = getBoxsAmount();
		var maxShown = YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].controls.pagingButtons;
		var buffer = Math.round(maxShown / 2);
		var shown,cindex;

		shown = (amount > maxShown) ? maxShown : amount ;
		if (index - buffer <= 0){
			buffer = index;
		}
		// add paging links
		if (pagingBtns.length == 0){
			for (var i = 0; i < shown; i++){
				cindex = ((i + 1) + (index - buffer));
				if (cindex <= amount){
					pagingBtns.push(document.createElement("a"));
					pager.appendChild(pagingBtns[i]);
					$dom.addClass(pagingBtns[i], "pagingBtn");
					pagingBtns[i].innerHTML = cindex;
					pagingBtns[i].setAttribute("href", "javascript:;");
					pagingBtns[i].onclick = page;
					if (cindex == (index + 1)){
						$dom.addClass(pagingBtns[i], "activePage");
					}
				}
			}
		}
		else{
			for (var i = 0; i < shown; i++){
				cindex = ((i + 1) + (index - buffer));
				$dom.setStyle(pagingBtns[i], "display", "inline");
				if (cindex <= amount){
					pagingBtns[i].innerHTML = cindex;
					$dom.removeClass(pagingBtns[i], "activePage");
					if (cindex == (index + 1)){
						$dom.addClass(pagingBtns[i], "activePage");
					}
				}
				else
					$dom.setStyle(pagingBtns[i], "display", "none");
			}
		}
	}
	function page(){
		var index = parseInt(this.innerHTML, 10);
		var container = YAHOO.lightBox.start.getCont(dom);
		var next = $dom.get(container).getElementsByTagName("a")[index - 1];
		YAHOO.lightBox.start.setActive(YAHOO.lightBox.start.getCont(dom), $dom.getFirstChild(next));
		load();
		setEvents();
		updateCount();
	}
	function metaUpdate(){
		// updates the display view to refrlect meta changes
		enable(nextBtn);
		updateCount();
	}
	function loadUpdate(){
		// not implemented yet
	}
	function createBtn(str, el){
		el.setAttribute("href", "javascript:;");
		if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].display.gallery || str == "closeBtn"){
			$dom.addClass(el, "lightBox-" + str);
		}
		else{
			$dom.addClass(el, "lightBox-noNav");
		}
	}
	function updateCount(){
		count.innerHTML = "Photo: " + (getBoxIndex() + 1) + " of " + getBoxsAmount();
	}
	function doblur(){
		this.blur();
	}
	function displayLoadingOn(){
		$dom.setStyle(loader, "display", "block");
		if (hasLoaded){
			var top = Number(display.offsetTop);
			var left = Number(display.offsetLeft);
			var offsetWidth =  (display.offsetWidth / 2) - (loader.offsetWidth / 2);
			var offsetHeight =  (display.offsetHeight / 2) - (loader.offsetHeight / 2);
		}
		else{
			var top = Number((($dom.getViewportHeight() / 2) + document.documentElement.scrollTop));
			var left = Number(($dom.getViewportWidth() / 2));
			var offsetWidth =  retNumeric(-Number(loader.offsetWidth)) / 2;
			var offsetHeight =  retNumeric(-Number(loader.offsetHeight)) / 2;
		}
		$dom.setStyle(loader, "top", top + offsetHeight + "px");
		$dom.setStyle(loader, "left", left + offsetWidth + "px");
		$dom.setStyle(loader, "z-index", YAHOO.lightBox.newZ++);
	}
	function displayLoadingOff(){
		//$dom.addClass(display, "loaderOverride"); // deprecated
		$dom.setStyle(loader, "display", "none");
	}
	function onload(){
		var imgWidth,imgHeight,headerHeight,detailsHeight,countHeight,navHeight,displayHeight,displayWidth,displayPadding,
			displayMargins,adjustedWidth,adjustedHeight,marginTop,marginLeft,anim1,anim2,descHeight,displayInnerPadding,
			displayInnerMargins,displayInnerExtraTB,displayInnerExtraLR;
		// display
		$dom.setStyle(image, "visibility", "visible");
		$dom.setStyle(image, "opacity", 0);
		if (hasLoaded) {
			$dom.setStyle(display, "opacity", 1);
		}
		else{
			$dom.setStyle(display, "opacity", 0);
		}
		$dom.setStyle(display, "display", "block");
		if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].window.modal){
			var maskHeight = (document.body.offsetHeight > $dom.getViewportHeight()) ? document.body.offsetHeight : $dom.getViewportHeight();
			$dom.setStyle(mask, "display", "block");
			$dom.setStyle(mask, "height", maskHeight + "px");
		}
		// positioning: WARNING, lightbox positioning uses negative margins. there is no need to set margins on the slidebox container anyway.
		imgWidth = getElTotalWidth(image);
		imgHeight = getElTotalHeight(image);
		headerHeight = getElTotalHeight(header);
		detailsHeight = getElTotalHeight(details);
		descHeight = getElTotalHeight(desc);
		countHeight = getElTotalHeight(count);
		navHeight = getElTotalHeight(nav);
		displayHeight = getElTotalHeight(display);
		displayWidth = getElTotalWidth(display);
		displayPadding = getPadding(display);
		displayMargins = getMargins(display);
		displayInnerPadding = getPadding(displayInner);
		displayInnerMargins = getMargins(displayInner);

		displayInnerExtraTB = (displayInnerPadding.top + displayInnerPadding.bottom) + (displayInnerMargins.top + displayInnerMargins.bottom);
		displayInnerExtraLR = (displayInnerPadding.left + displayInnerPadding.right) + (displayInnerMargins.left + displayInnerMargins.right);
		//alert(displayInnerExtraTB + " - " +displayInnerExtraLR);
		adjustedWidth = imgWidth + (displayPadding.left + displayPadding.right) + displayInnerExtraLR; // exclude margins
		adjustedHeight = imgHeight + (headerHeight + descHeight + countHeight + navHeight) + (displayPadding.top + displayPadding.bottom) + displayInnerExtraTB; // exclude margins
		//if (!hasLoaded) { adjustedHeight = adjustedHeight + (countHeight * 2); } // weird bug, do not understand this yet
		marginTop = ((adjustedHeight / 2) - (document.documentElement.scrollTop)) * -1;
		marginLeft = (adjustedWidth / 2) * -1;
		
		
		if (YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].position.placement == "absolute"){ // split to stop margin adjustments
			$dom.setStyle(display, "top", "50%");
			
			// mdprok 071207 min-width added to inline stylesheet
			var attributes1 = {
				"marginTop": { to: marginTop },
				"marginLeft": { to: marginLeft },
				"width": { to:  adjustedWidth},
				"min-width": { to:  380},
				"height": {to: adjustedHeight}
			};
		}
		else{
			var attributes1 = {
				"width": { to:  adjustedWidth},
				"min-width": { to:  380},
				"height": {to: adjustedHeight}
			};
		}
		anim1 = new YAHOO.util.Anim(display, attributes1, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].transitions.size, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].easing.global);
		anim1.animate();
		anim1.onComplete.subscribe(function(){
			$dom.setStyle(title, "visibility", "visible");
			$dom.setStyle(details, "visibility", "visible");
			//dump($dom.getStyle(display, "top"));
		});
		// enable disable
		if (getBoxIndex() == (getBoxsAmount() - 1))
			disable(nextBtn);
		else
			enable(nextBtn);
		//
		if (getBoxIndex() < 1)
			disable(prevBtn);
		else
			enable(prevBtn);
		// display : set in a call back for the last animation sequence
		attributes2 = {
			opacity: { to: 1 }
		};
		anim2 = new YAHOO.util.Anim(image, attributes2, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].transitions.fade, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].easing.global);
		anim2.animate();

		if (!hasLoaded) {
			anim1.onComplete.subscribe(function(){
				var attributes = {
					opacity: { to: 1 }
				};
				var anim = new YAHOO.util.Anim(display, attributes, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].transitions.fade, YAHOO.lightBox.config[YAHOO.lightBox.start.getCont(dom)].easing.global);
				anim.animate();
			});
		}
		displayLoadingOff();
		updateCount();
		hasLoaded = true;
		// annouce loaded
		YAHOO.lightBox.start.events("onLoad").fire();
	}
	function getElTotalHeight(el){
		var height = el.offsetHeight;
		height = height + retNumeric(Number($dom.getStyle(el, "padding-top").replace("px","")));
		height = height + retNumeric(Number($dom.getStyle(el, "padding-bottom").replace("px","")));
		height = height + retNumeric(Number($dom.getStyle(el, "margin-top").replace("px","")));
		height = height + retNumeric(Number($dom.getStyle(el, "margin-bottom").replace("px","")));
		return height;
	}
	function getElTotalWidth(el){
		var width = el.offsetWidth;
		width = width + retNumeric(Number($dom.getStyle(el, "padding-left").replace("px","")));
		width = width + retNumeric(Number($dom.getStyle(el, "padding-right").replace("px","")));
		width = width + retNumeric(Number($dom.getStyle(el, "margin-left").replace("px","")));
		width = width + retNumeric(Number($dom.getStyle(el, "margin-right").replace("px","")));
		return width;
	}
	function getMargins(el){
		var margins = {};
		margins.left = retNumeric(Number($dom.getStyle(el, "margin-left").replace("px","")));
		margins.right = retNumeric(Number($dom.getStyle(el, "margin-right").replace("px","")));
		margins.top = retNumeric(Number($dom.getStyle(el, "margin-top").replace("px","")));
		margins.bottom = retNumeric(Number($dom.getStyle(el, "margin-bottom").replace("px","")));
		return margins;
	}
	function getPadding(el){
		var padding = {};
		padding.left = retNumeric(Number($dom.getStyle(el, "padding-left").replace("px","")));
		padding.right = retNumeric(Number($dom.getStyle(el, "padding-right").replace("px","")));
		padding.top = retNumeric(Number($dom.getStyle(el, "padding-top").replace("px","")));
		padding.bottom = retNumeric(Number($dom.getStyle(el, "padding-bottom").replace("px","")));
		return padding;
	}
	function retNumeric(n){
		if (isFinite(n))
			return n;
		else
			return 0;
	}
	function setText(el, att){
		var box = YAHOO.lightBox.start.getActive(YAHOO.lightBox.start.getCont(dom));
		el.innerHTML = "";
		$dom.setStyle(el, "display", "none");
		if (box.getAttribute(att).length){
			el.innerHTML = box.getAttribute(att);
			$dom.setStyle(el, "display", "block");
		}
		// condition for title (always leave the title bar for dragging)
		else{
			if (el.tagName.toLowerCase() == "h1"){
				el.innerHTML = "&nbsp;";
				$dom.setStyle(el, "display", "block");
			}
		}
	}
	function getNextBox(){
		// TODO: check if its the last item
		try{
			var box = YAHOO.lightBox.start.getActive(YAHOO.lightBox.start.getCont(dom));
			var sibA = $dom.getNextSibling(box.parentNode);
			return $dom.getFirstChild(sibA);
		}
		catch(e){
			return null;
		}
	}
	function getPrevBox(){
		// TODO: check if its the last item
		try{
			var box = YAHOO.lightBox.start.getActive(YAHOO.lightBox.start.getCont(dom));
			var sibA = $dom.getPreviousSibling(box.parentNode);
			return $dom.getFirstChild(sibA);
		}
		catch(e){
			return null;
		}
	}
	function disable(btn){
		$dom.addClass(btn, "disabled");
	}
	function enable(btn){
		$dom.removeClass(btn, "disabled");
	}
	function disabled(btn){
		if ($dom.hasClass(btn, "disabled"))
			return true;
		else
			return false;
	}
	function getBoxIndex(){
		var box = YAHOO.lightBox.start.getActive(YAHOO.lightBox.start.getCont(dom));
		return parseInt(box.index);
	}
	function getBoxsAmount(){
		var box = YAHOO.lightBox.start.getActive(YAHOO.lightBox.start.getCont(dom));
		return $dom.getAncestorByTagName(box, "div").getElementsByTagName("a").length;
	}
}

// Our custom drag and drop implementation, extending YAHOO.util.DD
YAHOO.lightBox.newZ = 999;
YAHOO.lightBox.DDOnTop = function(id, sGroup, config) {
    YAHOO.lightBox.DDOnTop.superclass.constructor.apply(this, arguments);
};
YAHOO.extend(YAHOO.lightBox.DDOnTop, YAHOO.util.DD, {
    origZ: 0,
    startDrag: function(x, y) {
        var style = this.getEl().style;
        this.origZ = style.zIndex;
        style.zIndex = YAHOO.lightBox.newZ++;
    },
    endDrag: function(e) {
        //this.getEl().style.zIndex = this.origZ;
    }
});


YAHOO.util.Event.onDOMReady(YAHOO.lightBox.start.init, YAHOO.lightBox.start, YAHOO.lightBox.start);