
<!-- //

/**
 *	util.js
 *
 *	@author: gg@seso.at
 */


/*******************************************************************************
	LOGGER
*******************************************************************************/
 
function log (msg, clear) {
	
	/*
	var logger = document.getElementById('logger');
	
	if (!logger) {
		
		logger = document.createElement('DIV');
		logger.id = 'logger';
		logger.className = 'logger';
		
		document.getElementsByTagName('BODY')[0].appendChild(logger);
		
		logger = document.getElementById('logger');
	}
	
	if (clear === true) logger.innerHTML = '';
	
	logger.innerHTML += msg+'<br>';
	*/
	
	// alert(msg);
}

function printError(e) {
 	
 	var r = "";

 	r += "<h1>"+e.name+"</h1>";
 	r += "<p>"+e.fileName + " ["+e.lineNumber+"]</p>";
 	r += "<p><b>"+e.message+"</b></p>";
 	r += "<pre>"+e.stack+"</pre><hr>";
 	
 	return r;
}



/*******************************************************************************
	UTIL
*******************************************************************************/

function util() {
	
	var self = this;

	this.init = function() {
		
		try {
		
			for (u in this) {
	
				if (u != 'init' && self[u]['init'])
					eval('util.'+u+'.init();');
			}
		}
		
		catch(e) {

			log(printError(e));
		}
	}
};




/*******************************************************************************
	DATA
*******************************************************************************/

var A1data = {};

	A1data.lightBox = [];
	A1data.lightBox['property'] = {};


/**
 * PROPERTIES 
 * do not change this section!
 * 
 */
A1data.lightBox['property'].container = "a1";
A1data.lightBox['property'].prefix = "lightBox_"; 
A1data.lightBox['property'].speed = 35; 
A1data.lightBox['property'].frames = 15;



/**
 * DEFAULT CONFIGURATION
 * 
 * the default-values of the lightBox-configuration
 * you can overwrite this values for every lightBox individually.
 * 
 */
A1data.lightBox['property'].config = [];

/**
 * size
 * 
 * defines the width of the lightBox.
  * 
 * @permitted values: 'small' ||?'medium' ||?'large'
 * 
 */
A1data.lightBox['property'].config['size'] = 'medium';

/**
 * contentHeight
 * 
 * defines height of the contentLayer in px.
 * set false: the height is depending on the content
 * 
 * @permitted values: false || {Int}
 * 
 */
A1data.lightBox['property'].config['contentHeight'] = 450;

/**
 * bgLayer
 * 
 * defines if the lightBox has a background-layer. 
  * 
 * @permitted values: true || false
 * 
 */
A1data.lightBox['property'].config['bgLayer'] = true;

/**
 * hasDesign
 * 
 * defines if the lightBox has a design - means, glow, header, edges
 * 
 * @permitted values: true || false
 * 
 */
A1data.lightBox['property'].config['hasDesign'] = false;

/**
 * closeable
 * 
 * defines if the lightBox has a closeIcon
  * 
 * @permitted values: true || false
 * 
 */
A1data.lightBox['property'].config['closeable'] = true;

/**
 * dragable
 * 
 * defines if the lightBox is dragable, otherwise it will be fixed at the viewport.
 * this config will not take affect in IE6 - default is false.
 * 
 * @permitted values: true || false
 * 
 */
A1data.lightBox['property'].config['dragable'] = false;

/**
 * vertical align
 * 
 * defines the vertical position of the lightBox in the viewport
  * 
 * @permitted values: 'center' || 'top' || 'bottom'
 * 
 */
A1data.lightBox['property'].config['vAlign'] = 'center';

/**
 * horizontal align
 * 
 * defines the horizontal position of the lightBox in the viewport
  * 
 * @permitted values: 'center' || 'left' || 'right'
 * 
 */
A1data.lightBox['property'].config['hAlign'] = 'center';

/**
 * fade
 * 
 * defines if the lightBox fades in an out.
 * 
 * @permitted values: true || false
 * 
 */
A1data.lightBox['property'].config['fade'] = true;

/**
 * slide
 * 
 * defines the direction from which the lightBox slides into the viewport.
 * set false to disable this animation.
 * 
 * @permitted values: false || 'left' || 'right' || 'top' || 'bottom'
 * 
 */
A1data.lightBox['property'].config['slide'] = false;


A1data.lightBox['property'].config['printBtn'] = false;





/**
 *  the following settings only take affect while loadBehavior is set to 4 (FlashLayer).
 *  in that case all parmeters need to be set valid, otherwise the lightbox will not open.
 */

/**
 * beginDate
 *
 * @permitted values: null ||�GMT-String
 * 
 */
A1data.lightBox['property'].config['beginDate'] = null;

/**
 * endDate
 *
 * @permitted values: null ||�GMT-String
 * 
 */
A1data.lightBox['property'].config['endDate'] = null;

/**
 * timeout (days)
 *
 * @permitted values: Int-Value (>=0)
 * 
 */
A1data.lightBox['property'].config['timeout'] = 0;

/**
 * flashVer
 *
 * @permitted values: Int-Value (>=0)
 * 
 */
A1data.lightBox['property'].config['flashVer'] = 8;


/**
 * eventhandlers: onClose & onOpen 
 * 
 * @permitted values: action-const ||�eval-String
 * 
 */
A1data.lightBox['property'].config['onOpen'] = null;
A1data.lightBox['property'].config['onClose'] = null;


A1data.lightBox['property'].config['autoClose'] = null;




/*******************************************************************************
	LIGHT-BOX
*******************************************************************************/

util.prototype.lightBox = {
	
	
	// action-consts - used for onOpen & onClose
	
	DELETE_CONTENT : "var d = cache.box.getElementsByTagName('DIV'); d[d.length-1].innerHTML='';",
	RESET_CONTENT : "cache.box.getElementsByTagName('DIV')[0].innerHTML = cache.fallback;",
	

	cache : [],
	property : A1data.lightBox['property'],
	activeBox : null,
	dragInfo : [],
	ajax : null,
	
	
	
	setProperty : function(key, value) {
		
		this.property[key] = value;		
	},

	
	add : function(dataId, linkId, loadBehavior, config) {
		
		var box = {};
			box.dataId = dataId;
			box.linkId = linkId;
			box.loadBehavior = (loadBehavior) ? loadBehavior : 0;
			box.config = (config) ? config : null;
			
		this.cache.push(box);
	},
	
	
	multibleAdd : function(id, linkList, config) {
		
		var box = {};
			box.dataId = id;
			box.linkId = linkList;
			box.loadBehavior = 0;
			box.config = (config) ? config : null;
			
		this.cache.push(box);		
	},
	
		
	
	parseFlashVars : function(vars) {
		
		var v = '{';
	
		vars = vars.split('&');
		
		for (var i=0; i<vars.length; i++) {
		
			
			k = vars[i].split('=');
			
			v += k[0]+":'"+k[1]+"'";
			
			if (i < vars.length-1) v += ',';
		}
		
		v += '}';
	
		return v;
	},

		
	init : function() {

		if (this.cache.length > 0) {
			
			// this.ajax = new util.ajax();

			// container
			
			var divs = document.getElementsByTagName('DIV');
			
			 for (var i=0; i<divs.length; i++) {
			 
			 	if (divs[i].className == this.property.container) {
			 		
			 		var d = document.createElement('DIV');
			 			d.className = "lightBoxContainer";
			 			
			 		divs[i].appendChild(d);
			 		this.property.container = d;
			 		break;
			 	}
			 }

			 // bgLayer
			
			util.lightBox.cache[-1] = {};
			util.lightBox.cache[-1].box = util.lightBox.createBgLayer();

			// cache
			
			for (var i=0; i<this.cache.length; i++) {

				var cache = util.lightBox.cache[i];
				
				// decorate links
				
				if (cache.linkId && typeof cache.linkId == 'object' && cache.linkId.length) {
					
					for (var j=0; j<cache.linkId.length; j++) {
						
						var a = document.getElementById(cache.linkId[j]);
						
						if (!cache.config) cache.config = [];
						cache.config.onClose = util.lightBox.RESET_CONTENT;		
						cache.config.onOpen = 'FETCH_HREFS';			
						
						a.setAttribute('id', i);

						if (env.isIE) {
					
							a.attachEvent("onclick", util.lightBox.open);
						}
								
						else {

							a.addEventListener("click", util.lightBox.open, false);
						}
					}
				}
				
				else {

					if (cache.linkId && cache.loadBehavior == 0) {
					
						var a = document.getElementById(cache.linkId);

						if (a) {
							
							a.setAttribute('id', i);
	
							if (env.isIE) {
	
								a.attachEvent("onclick", util.lightBox.open);
							}
									
							else {
								
								a.addEventListener("click", util.lightBox.open, false);
							}
						}
					}
				}

				// load config
				
				var dataSet = A1data.lightBox[cache.dataId];
				
				if (!cache.config) cache.config = [];
				
				for (conf in util.lightBox.property.config) {

					if (cache.config[conf] == undefined) {

						cache.config[conf] = (dataSet && dataSet.config && dataSet.config[conf]!=undefined) ? dataSet.config[conf] : util.lightBox.property.config[conf];
					}
				}
				
				if (env.browser == 'ie6') cache.config['dragable'] = false;

				cache.followAction = [];
				cache.followTimeout = [];

		
				// load content

				var dataDiv = document.getElementById(cache.dataId);
				
				if (a) var ajaxTarget = a.getAttribute('href');
				
				if (cache.loadBehavior > 0 && cache.linkId) {
					
					ajaxTarget = cache.linkId;
				}
				
				if (dataSet && dataSet.content) {
					
					cache.content = dataSet.content;
					util.lightBox.createBox(i, false);
				}
				
				else if (dataDiv) {
					
					cache.content = dataDiv.innerHTML;
					dataDiv.parentNode.removeChild(dataDiv);
					util.lightBox.createBox(i, false);
				}
				
				else if (ajaxTarget) {

					util.lightBox.ajax.sendRequest(ajaxTarget, null, "util.lightBox.createBox("+i+", true);", 0);
				}
				
				else log("could not load data - no source detected: " + i);

			
			} // end for

		} // end if

	},
	

	createBgLayer : function() {

		var bg = document.createElement('DIV');
			bg.id = "lightBoxBgLayer";

		util.lightBox.property.container.appendChild(bg);
		
		return bg;
	},

	
	createBox : function(cid, ajaxResponse) {

		var cache = util.lightBox.cache[cid];

		if (ajaxResponse == true) {

			cache.content = util.lightBox.ajax.getResponse();
		}

		var s = (cache.config.size) ?  cache.config.size : 'medium';

		// box
		
		var box = document.createElement('DIV');
			box.id = this.property['prefix'] + this.cache[cid].dataId;
			box.className = 'lightBox ' + s;
		
		if (cache.config['hasDesign'] == true) {

			// header
			
			var header = document.createElement('DIV');
				header.className = 'header';
				
			box.appendChild(header);
	
			// content
			
			var content = document.createElement('DIV');
				content.className = 'content';
				
			box.appendChild(content);
				
			// footer
			
			var footer = document.createElement('DIV');
				footer.className = 'footer';
				
			box.appendChild(footer);
		}
	
		// layers
		
		var contentLayer = document.createElement('DIV');
			contentLayer.className = 'contentLayer';
			
		if (cache.config['hasDesign'] == false) contentLayer.className += ' noLayout';
		
		var innerLayer = document.createElement('DIV');
			innerLayer.innerHTML = cache.content;
			//innerLayer.style.backgroundColor='#ff0000';
		
		// print-button
		
		if (cache.config['printBtn'] == true) {
			
			var pLink = document.createElement('A');
				pLink.href = "javascript:window.print();";
				pLink.title = "Drucken";
			
			var btn = document.createElement('IMG');
				btn.width = 73;
				btn.height = 18;
				btn.src = "../imgs/global/btn_drucken.png";
				btn.alt = "Drucken"
				btn.className = "printBtn";

				pLink.appendChild(btn);
			
			innerLayer.appendChild(pLink);
		}

		// scroller	
		
		if (cache.config.contentHeight) {

			innerLayer.className = "innerLayer";
			
			var h2 = innerLayer.getElementsByTagName('H2')[0];
		
			if (h2) {

				contentLayer.appendChild(h2);
			}
			
			var scrollLayer = document.createElement('DIV');
				scrollLayer.style.height = cache.config.contentHeight + 'px';
				scrollLayer.className = "scrollLayer";
				
			scrollLayer.appendChild(innerLayer);
			
			contentLayer.appendChild(scrollLayer);
		}
		
		else {
			
			contentLayer.appendChild(innerLayer);
		}

		box.appendChild(contentLayer);

		// closeIcon

		if (cache.config.closeable == true) {
			
			var cl = document.createElement('SPAN');
				cl.className = 'closeIcon';
				cl.title = 'close';
				cl.innerHTML = " ";
				
				if (cache.config.closeable == true) {
	
					if (env.isIE) {
					
						cl.attachEvent("onclick", util.lightBox.close);
					}
					
					else {
						
						cl.addEventListener("click", util.lightBox.close, false);
					}
				}

			box.appendChild(cl);
		}

		util.lightBox.property.container.appendChild(box);

		cache.box = box;
		
	
		// check loadBehavior
		
		if (cache.loadBehavior > 0) {

			var cName = util.lightBox.getCookieName(cid);
			
			var found = false;
			
			var cookies = document.cookie.split('; ');
			
			for (var j=0; j<cookies.length; j++) {
				
				if (cookies[j] == cName) {
					
					found = true;
					break;
				}
			}
			
			switch (cache.loadBehavior) {

				case 1:	// Emergency

					if (found == false) {
						
						util.lightBox.open(cid, false);
						document.cookie = cName;
					}
					break;
				
				case 2:	// Survey
				
					if (found == false) {
						
						util.lightBox.open(cid, false);
					}
					break;
				
				case 3:	// Penetrant
				
					util.lightBox.open(cid, false);
					break;
				
				default:
					log("unkown loadBehavior: " + cache.loadBehavior);
					break;
			}
			
		} // end loadBehavior
	},
	
	
		
	
	getCookieName : function(cid, value) {
		
		if (!value) value = 1;
		
		return "a1_"+util.lightBox.property.prefix+util.lightBox.cache[cid].dataId+"="+value;
	},
	
	
	
	getCacheId : function(dataId) {
		
		var cid = null;
		
		var cache = util.lightBox.cache;
		
		for (var i=0; i<cache.length; i++) {
			
			if (cache[i].dataId == dataId) {
				
				cid = i;
				break;
			}
		}
		
		return cid;
	},

	
	switchBox : function(dataId) {
		
		var cid = util.lightBox.getCacheId(dataId);
		
		util.lightBox.cache[util.lightBox.activeBox].followAction.push("util.lightBox.open("+cid+");");
		util.lightBox.cache[util.lightBox.activeBox].followTimeout.push(0);

		util.lightBox.close();
	},
	
	
	resize : function() {
		
		var cid = util.lightBox.activeBox;
		
		if (cid != null && cid >= 0) {
		
			var cache = util.lightBox.cache[cid];
			
			// bgLayer
			
			if (cache.config.bgLayer) {
	
				var html = document.getElementsByTagName('HTML')[0],
					
					h = html.scrollHeight,
					w = html.scrollWidth;
					
					if (env.browser == 'safari') {
						
						h = document.body.scrollHeight;
					}
		
				util.lightBox.cache[-1].box.style.height = h + 'px';
				util.lightBox.cache[-1].box.style.width = w + 'px';
			}
			
			// adapt height

			cache.box.style.display = 'block';

			var cl = cache.box.getElementsByTagName('DIV')[3];
		
			if (cl) {
			
				var h = (cl.style.height) ? cl.style.height.split('px')[0] : cl.offsetHeight;
					h -= (cache.config.size == 'small') ? 15 : 45;
	
				//cache.box.getElementsByTagName('DIV')[1].style.height = h +'px';
			}
			
			else {
				
				var h = cache.box.getElementsByTagName('DIV')[1].offsetHeight;
				
				if (env.isIE && cache.config.hasDesign == false) h += 35;
				
				cache.box.style.height = (h+32) +'px';
			}


			// dimensions

			var body = document.getElementsByTagName('BODY')[0];
						
			if (!cache.config.boxHeight) {

				cache.config.boxHeight = cache.box.offsetHeight;
			}
			
			if (!cache.config.boxWidth) {
				
				cache.config.boxWidth = cache.box.offsetWidth;
			}

			if (!cache.config.boxTop) {

				cache.config.boxTop = (body.scrollHeight - cache.config.boxHeight) / 2;
			}
			
			if (!cache.config.boxLeft) {
				
				cache.config.boxLeft = (body.scrollWidth - cache.config.boxWidth) / 2;
			}
						
			var t = cache.config.boxTop;
			var l = cache.config.boxLeft;
			
			if (env.browser == 'ie6') {

				t += document.documentElement.scrollTop;
			}
			
			if (cache.config.vAlign == 'top') t -= (t/3)*2;
				else if (cache.config.vAlign == 'bottom') t += (t/3)*2;
			
			if (cache.config.hAlign == 'left') l -= (l/3)*2;
				else if (cache.config.hAlign == 'right') l += (l/3)*2;
			
			cache.box.style.top = Math.floor(t) + 'px';
			cache.box.style.left = Math.floor(l) + 'px';
		}
	},


	open : function(e, gref, force) {
		
		if (!gref) gref = null;
		if (!force) gref = force;

		
		var cid;
		
		if (typeof e == 'number') {
			
			cid = e;
		}

		else if (e) {
			
			if (env.isIE) e.returnValue = false;
				else e.preventDefault();

			e = (e.srcElement) ? e.srcElement : e.target;
			cid = e.getAttribute('id');
			if (!cid) cid = e.parentNode.getAttribute('id');
			var gref = e.parentNode.getAttribute('href');
			e.blur();
		}
		
		if (util.lightBox.activeBox == null) {

			util.lightBox.activeBox = cid;
			
			var cache = util.lightBox.cache[cid],
				spd = util.lightBox.property.speed;
						
			// resize

			util.lightBox.resize();
			
			if (env.browser != 'ie6') {
				
				window.onresize = util.lightBox.resize;
			}
			

			// bgLayer

			if (cache.config.bgLayer == true) {

				// closeable
				
				if (cache.config.closeable == true) {
	
					if (env.isIE) {
					
						util.lightBox.cache[-1].box.attachEvent("onclick", util.lightBox.close);
					}
					
					else {
						
						util.lightBox.cache[-1].box.addEventListener("click", util.lightBox.close, false);
					}
				}
				
				util.lightBox.cache[-1].box.style.display = 'block';
				
				// fadeIn bg
				
				if (cache.config.fade == true) {

					util.lightBox.fadeIn(-1, (spd/2), 8);	
				}
				
				else util.lightBox.finish(-1, 1, 8);
			}

			// dragable
			
			if (cache.config.dragable == true) {
				
				var head = cache.box.getElementsByTagName('DIV')[0];
				
				head.onmousedown = util.lightBox.startDrag;
				head.style.cursor = 'move';

				util.lightBox.initDrag();
			}
			
			var anm = false;
			
			// fadeIn
			
			if (cache.config.fade == true) {

				util.lightBox.fadeIn(cid, spd);
				anm = true;
			}

			// slideIn
			
			if (cache.config.slide !== false) {
				
				util.lightBox.slideIn(cid, spd);
				anm = true;
			}
			
			if (anm === false) util.lightBox.finish(cid, 1);
			
			
			// check autoClose
				
			if (cache.config.autoClose !== null) {

				cache.followAction.push("util.lightBox.close();");
				cache.followTimeout.push(cache.config.autoClose * 1000);
			}
			
			
			// onOpen eventhandler
			
			if (cache.config.onOpen !== null || force != null) {

				cache.fallback = cache.box.getElementsByTagName('DIV')[0].innerHTML;

				if ((cache.config.onOpen == 'FETCH_HREFS' && gref) || force != null) {
						
					var h = gref.split('?');
					var v = util.lightBox.parseFlashVars(h[1]);

					cache.followAction.push("swfobject.embedSWF('"+h[0]+"', 'videoContainer', '445', '382', '9.0.0', '../swf/expressInstall.swf', "+v+", {wmode:'transparent',allowFullScreen:true})");
				}
				
				else {
					
					cache.followAction.push(cache.config.onOpen);
				}	

				cache.followTimeout.push(0);
			}
			

			// hide selects
			
			if (env.browser == 'ie6') {
				
				var selects = document.getElementsByTagName('SELECT');
				
				for (var s=0; s<selects.length; s++) {
					
					selects[s].style.visibility = 'hidden';
				}
			}
			
			document.onkeyup = util.lightBox.catchKeyEvent;
		}

	},


	close : function(e) {

		var commit = false;
		
		if (e === true) {
			
			commit = true;
		}

		else if (e) {
			
			if (env.isIE) e.returnValue = false;
				else e.preventDefault();
		}
		
		var cid = util.lightBox.activeBox;
		
		if (cid != null) {

			var cache = util.lightBox.cache[cid];
			
			if (cache.config.onClose !== null) {
				
				try {
				
					eval(cache.config.onClose);
				}
				
				catch (e) {}
			}
			
			// remove document-handlers
			
			document.onmousemove = null;
			document.onmouseup = null;
			
			var spd = util.lightBox.property.speed;

			// remove ddLayer
			
			if (cache.config.dragable == true) {
				
				cache.box.getElementsByTagName('DIV')[0].onmousedown = null;
			}
			
			// bgLayer
			
			if (cache.config.bgLayer == true) {

				if (env.isIE) {
				
					util.lightBox.cache[-1].box.detachEvent("onclick", util.lightBox.close);
				}
				
				else {
					
					util.lightBox.cache[-1].box.removeEventListener("click", util.lightBox.close, false);
				}
			
			
				if (cache.config.fade == true) {
					
					util.lightBox.fadeOut(-1, (spd/2), 8);
				}
				else util.lightBox.finish(-1, 0, 0);
			}

			// fadeOut
			
			var anm = false;

			if (cache.config.fade == true) {

				util.lightBox.fadeOut(cid, spd);
				anm = true;
			}
			
			// slideOut
			
			if (cache.config.slide !== false) {
				
				util.lightBox.slideOut(cid, spd);
				anm = true;
			}
			
			if (anm === false) util.lightBox.finish(cid, 0);

			// check loadBehavior
				
			if (cache.loadBehavior == 2 && commit == true) {

				document.cookie = util.lightBox.getCookieName(cid);
			}
			
			window.onresize = null;
			
			// show selects
			
			if (env.browser == 'ie6') {
				
				var selects = document.getElementsByTagName('SELECT');
				
				for (var s=0; s<selects.length; s++) {
					
					selects[s].style.visibility = 'visible';
				}
			}
			
			document.onkeyup = null;
		}
	},
	
	
	catchKeyEvent : function(e) {
		
		if (!e) e = window.event;
		
		var key = (e.keyCode) ? e.keyCode : e.which;
		
		if (key == 32) util.lightBox.close();	// space
	},

	
	
	/* DRAG & DROP */
	
	initDrag : function() {

		util.lightBox.stopDrag();

		document.onmousemove = util.lightBox.drag;
		document.onmouseup = util.lightBox.stopDrag;
	},
	
	drag: function(e) {

		util.lightBox.dragInfo['px'] = document.all ? window.event.clientX : e.pageX;
 		util.lightBox.dragInfo['py'] = document.all ? window.event.clientY : e.pageY;
		
		if (util.lightBox.dragInfo['obj'] != null) {
		    
		    var l = (util.lightBox.dragInfo['px'] - util.lightBox.dragInfo['dx']);
		    var t = (util.lightBox.dragInfo['py'] - util.lightBox.dragInfo['dy']);
			
			if (t<0) t = 0;
			else if (t>util.lightBox.dragInfo['maxH']) t = util.lightBox.dragInfo['maxH'];
				
			util.lightBox.dragInfo['obj'].style.top = t + "px";

			if (l<0) l = 0;
			else if (l>util.lightBox.dragInfo['maxW']) l = util.lightBox.dragInfo['maxW'];
				
			util.lightBox.dragInfo['obj'].style.left = l + "px";
		}
	},
	
	startDrag : function() {
		
		if (util.lightBox.activeBox != null) {
		
			util.lightBox.cache[util.lightBox.activeBox].box.style.right = 'auto';
			util.lightBox.cache[util.lightBox.activeBox].box.style.bottom = 'auto';
			
			var body = document.getElementsByTagName('BODY')[0];
				
			util.lightBox.dragInfo['maxH'] = body.scrollHeight - util.lightBox.cache[util.lightBox.activeBox].config.boxHeight;
			util.lightBox.dragInfo['maxW'] = body.scrollWidth - util.lightBox.cache[util.lightBox.activeBox].config.boxWidth;
	
			util.lightBox.dragInfo['obj'] = util.lightBox.cache[util.lightBox.activeBox].box;
			util.lightBox.dragInfo['dx'] = util.lightBox.dragInfo['px'] - util.lightBox.dragInfo['obj'].offsetLeft;
			util.lightBox.dragInfo['dy'] = util.lightBox.dragInfo['py'] - util.lightBox.dragInfo['obj'].offsetTop;
		}
	},

	stopDrag : function() {

		util.lightBox.dragInfo['obj'] = null;
		util.lightBox.dragInfo['dx'] = 0;
		util.lightBox.dragInfo['dy'] = 0;
		util.lightBox.dragInfo['px'] = 0;
		util.lightBox.dragInfo['py'] = 0;
	},



	/* FADE */
	
	finish : function(cid, typ, op) {

		var cache = util.lightBox.cache[cid];
		
		// position
		
		var body = document.getElementsByTagName('BODY')[0];

		if (cache.box.style.top == 'auto') {
			
			cache.box.style.top = cache.box.offsetTop + 'px';
		}
		
		if (cache.box.style.left == 'auto') {
			
			cache.box.style.left = cache.box.offsetLeft + 'px';
		}
		
		cache.box.style.right = 'auto';
		cache.box.style.bottom = 'auto';

		// opacity

		if (typ === 1) {
			
			if (!op) op = 10;
			
			cache.box.style.display = 'block';
			
			if (env.isIE) cache.box.style.filter = "alpha(opacity:"+(op*10)+");";
				else cache.box.style.opacity = (op/10);
				
			util.lightBox.activeBox = cid;
		}
		
		else {
			
			cache.box.style.display = 'none';
			
			if (env.isIE) cache.box.style.filter = "alpha(opacity:0);";
				else cache.box.style.opacity = 0;
				
			if (cid >= 0) util.lightBox.activeBox = null;
		}

		// follow action

		if (cid > -1 && cache.followAction.length > 0) {

			for (var j=0; j<cache.followAction.length; j++) {

				if (!cache.followTimeout[j]) cache.followTimeout[j] = 0;
				
				setTimeout(cache.followAction[j], cache.followTimeout[j]);
			}
			
			cache.followAction = [];
			cache.followTimeout = [];
		}
		
		if (env.isIE) body.style.overflowY = 'auto';
	},
	
	
	fadeIn : function(cid, intv, lim) {
		
		lim = (!lim) ? 10 : lim;
		
		var cache = util.lightBox.cache[cid];
		
			cache.opacity = 0;
			
		if (env.isIE) cache.box.style.filter = "alpha(opacity:0);";
			else cache.box.style.opacity = 0;

		if (cache.fadeAction == null)
			cache.fadeAction = setInterval("util.lightBox.fadeInStep("+cid+","+lim+");", intv);
	},
	
	
	fadeInStep: function(cid, lim) {

		var cache = util.lightBox.cache[cid];

			cache.opacity += (env.isIE) ? 2 : 1;

		if (env.isIE) cache.box.style.filter = "alpha(opacity:"+(cache.opacity*10)+");";
			else cache.box.style.opacity = (cache.opacity/10);

		if (cache.opacity > lim) {
			
			clearInterval(cache.fadeAction);
			cache.fadeAction = null;

			var op = (cid == -1) ? 8 : 0;

			util.lightBox.finish(cid, 1, op);
		}
	},
	
	
	fadeOut : function(cid, intv, lim) {
		
		lim = (!lim) ? 10 : lim;
		
		var cache = util.lightBox.cache[cid];
			
			cache.opacity = lim;
			
		if (env.isIE) cache.box.style.filter = "alpha(opacity:"+(cache.opacity*10)+");";
			else cache.box.style.opacity = (cache.opacity/10);

		if (cache.fadeAction == null)
			cache.fadeAction = setInterval("util.lightBox.fadeOutStep("+cid+");", intv);
	},
	
	
	fadeOutStep: function(cid) {

		var cache = util.lightBox.cache[cid];

			cache.opacity -= (env.isIE) ? 2 : 1;

		if (env.isIE) cache.box.style.filter = "alpha(opacity:"+(cache.opacity*10)+");";
			else cache.box.style.opacity = (cache.opacity/10);
		
		if (cache.opacity < 0) {
			
			clearInterval(cache.fadeAction);
			cache.fadeAction = null;
			util.lightBox.finish(cid, 0);
		}
	},
	
	
	/* SLIDE */
	
	slideIn : function(cid, intv) {
		
		var cache = util.lightBox.cache[cid],
		
			body = document.getElementsByTagName('BODY')[0],
		
			t = parseInt(cache.box.style.top.split('px')[0]),
			l = parseInt(cache.box.style.left.split('px')[0]),

			w = cache.config.boxWidth,
			h = cache.config.boxHeight;
			
		if (env.isIE) body.style.overflowY = 'hidden';

		switch (cache.config.slide) {
			
			case 'top':
				cache.lim = t;
				cache.dist = h + t;
				cache.start = (0-h);
				cache.box.style.bottom = 'auto';
				break;
				
			case 'bottom':
				b = parseInt(body.scrollHeight - t - h);
				cache.lim = b;
				cache.dist = h + b;
				cache.start = (0-h);
				cache.box.style.top = 'auto';
				break;

			case 'left':
				cache.lim = l;
				cache.dist = w + l;
				cache.start = (0-w);
				cache.box.style.right = 'auto';
				break;
				
			case 'right':
				r = parseInt(body.scrollWidth - l - w);
				cache.lim = r;
				cache.dist = w + r;
				cache.start = (0-w);
				cache.box.style.left = 'auto';
				break;
				
			default: break;
		}
		
		if (cache.config.fade !== true) {

			if (env.isIE) cache.box.style.filter = "alpha(opacity:100);";
				else cache.box.style.opacity = 1;
		}
		
		cache.typ = 1;
		cache.step = 0;
		cache.box.style[cache.config.slide] = cache.start + 'px';

		if (cache.slideAction == null)
			cache.slideAction = setInterval("util.lightBox.slideStep("+cid+");", intv);
	},
	
	
	slideOut : function(cid, intv) {
		
		var cache = util.lightBox.cache[cid],
		
			body = document.getElementsByTagName('BODY')[0],
		
			t = parseInt(cache.box.style.top.split('px')[0]),
			l = parseInt(cache.box.style.left.split('px')[0]),

			w = cache.config.boxWidth,
			h = cache.config.boxHeight;
		
		switch (cache.config.slide) {
			
			case 'top':
				cache.lim = (0-h);
				cache.dist = h + t;
				cache.start = t;
				cache.box.style.bottom = 'auto';
				break;
				
			case 'bottom':
				
				bh = (env.browser == 'safari') ? html.scrollHeight : body.scrollHeight;
				b = parseInt(bh - cache.box.offsetTop - h);
				cache.lim = (0-h);
				cache.dist = h + b;
				cache.start = b;
				cache.box.style.top = 'auto';
				break;
						
			case 'left':
				cache.lim = (0-w);
				cache.dist = w + l;
				cache.start = l;
				cache.box.style.right = 'auto';
				break;
			
			case 'right': 
				r = parseInt(body.scrollWidth - cache.box.offsetLeft - w);
				cache.lim = (0-w);
				cache.dist = w + r;
				cache.start = r;
				cache.box.style.left = 'auto';
				break;
				
			default: break;
		}
		
		cache.typ = 0;
		cache.step = 0;
		cache.box.style[cache.config.slide] = cache.start + 'px';

		if (cache.slideAction == null)
			cache.slideAction = setInterval("util.lightBox.slideStep("+cid+");", intv);
	},


	slideStep : function(cid) {

		var cache = util.lightBox.cache[cid];
		
		cache.step++;

		if (cache.step <= util.lightBox.property.frames) {
			
			pos = Math.ceil(cache.dist * Math.sin(cache.step * 1.5 / util.lightBox.property.frames));
			
			if (cache.typ === 1) pos = cache.start + pos;
				else pos = cache.start - pos;

			cache.box.style[cache.config['slide']] = pos + 'px';
		}
		
		else {

			clearInterval(cache.slideAction);
			cache.slideAction = null;
			
			cache.box.style[cache.config['slide']] = cache.lim + 'px';

			util.lightBox.finish(cid, cache.typ);
		}
	}


}

var util = new util();


// -->
