

CMS = new Object();
CMS.use_local = (typeof(JSON) == 'object' && typeof(localStorage) == 'object')? 1: 0;
CMS.CSS = [];
CMS.pLD = [];
CMS.rowMapKey = null;
CMS.includes = [];
CMS.includes['js'] = [];
CMS.includes['css'] = [];
CMS.INLINE_SCRIPTS = '';

STACKS = [];
PLI=[];

function distro_error(val){
	if(IS_DISTRO){
		alert("distro says:"+val);
	}
}

function mapsChange(iID,rIND,LsID){
	var lat = document.getElementById('lat'+LsID).value;
	var lng = document.getElementById('lng'+LsID).value;
	var center = lat+","+lng;

	var obj = {};
	obj.options = [];
	obj.options[0] = {};
	obj.options[0].value = center;
	obj.selectedIndex = 0;
	
	mapChange(2,1,rIND,obj);
	mapChange(3,2,rIND,obj);
}

function mapChange(mode,iID,rIND,obj){
	var modes = ['zoom','heading','center','location'];
	var map = document.getElementById('map-'+rIND+'-'+iID);
	var split = map.src.split("&");
	var newSrc = split[0];
	var val = obj.options[obj.selectedIndex].value;
	var key = modes[mode];
	for(var x in split){
		if(x == 0){continue;}
		var parts = split[x].split('=');
		if(parts[0] == key){
			newSrc += '&'+parts[0] + '=' + val;
		}else{
			newSrc += '&'+split[x];
		}
	}
	map.src = newSrc;
}

function mapsSave(iID,rIND,LsID){
	var rec_id = document.getElementById('record_id').value;
	var lat = document.getElementById('lat'+LsID).value;
	var lng = document.getElementById('lng'+LsID).value;

	top.document.getElementById('child-address-0-'+rec_id+'-lat').value = lat;
	top.document.getElementById('child-address-0-'+rec_id+'-long').value = lng;
	top.document.getElementById('child-address-0-'+rec_id+'-heading').value = document.getElementById('compassHeading').value;

	if((lat+0) != 0 && (lng+0) != 0){
		top.document.getElementById('child-address-0-'+rec_id+'-map_mode').selectedIndex = 1;
	}

	top.closeWindow(" ");
}

function setMapMarker(x,y){
	if(sMarkers[x][y].getAnimation() != null){
		sMarkers[x][y].setAnimation(null);
	}else{
		var id = 'map_canvas-'+x;
		var map = document.getElementById(id); // AR2-42075
		var offSet = getOffset(map,'top');
		var m = mapMarkers[x][y];
		top.scrollTo(0,offSet);
		gMap[x].setCenter(new google.maps.LatLng(m[0],m[1]));
		if(parseInt(m[4])){gMap[x].setZoom(m[4]);}
		sInfos[x][y].open(gMap[x],sMarkers[x][y]);
		sMarkers[x][y].setAnimation(google.maps.Animation.BOUNCE);
		setTimeout("sMarkers["+x+"]["+y+"].setAnimation(null);",5000);
	}
}

function social_link(a,b,c){

	// alert("a("+a+") b("+b+") c("+c+")");

	window.open(STACKS["SOCIAL"][a][b][c][0]);
}

function clear_login(obj,val){
	if(obj.value == val){obj.value="";}
}

function getScrollY(){
	return window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
}

function getViewportWidth(){
	return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
}

function getViewportHeight(){
	return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
}

function imgLoad(obj){
	obj.style.visibility = 'visible';
	obj.parentNode.style.backgroundImage = 'none';
}

var offsets = new Object();
offsets.x=-60;
offsets.y=20;
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
var relative_to_object = 0;
var tipobjInd = 0;
var tipobjMode = 0;
var tipobj=[];

function initHelp(){
	if(ie||ns6){
		tipobj[0]=document.all?document.all["dhtmltooltip"]:document.getElementById?document.getElementById("dhtmltooltip"):"";
		tipobj[1]=document.all?document.all["helptip"]:document.getElementById?document.getElementById("helptip"):"";
	}
}

function getOffset2(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function imgSwap(obj,target,scale){
	var img = document.getElementById(target);
	var src = obj.src;
	var ind = src.indexOf("?");
	if(ind > 0){
		src = src.substr(0,ind);	
	}
	src += "?w=" + scale;
	img.src = src;
}

function ddrivetip(thisObj,t,c,w,x2,y2,i,obj){

	tipobjMode=i;
	if(x2){offsets.x=x2;}
	if(y2){offsets.y=y2;}
	if(typeof w!="undefined"&&w){tipobj[i].style.width=w+"px";}
	if(typeof c!="undefined"&&c!=""){tipobj[i].style.backgroundColor=c;}
	if(ARW != null && ARW[0]){
		var id = thisObj.id.split("-");
		tipobjInd = id[1];
		if(ARW[id[1]]){
			var content = ARW[id[1]].title;
		}else{
			var content = t;
		}
	}else{
		var content = t;
	}

	if(tipobjMode==0){
		tipobj[i].innerHTML=content;
	}else{
		tipobj[i].childNodes[3].innerHTML=content;
	}

	relative_to_object=obj;
	enabletip=true;
	document.onmousemove=positiontip;
	return false;
}

function positiontip(e){
	i = tipobjMode;

	if(!enabletip){return}
	var B=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;
	var curX=(ns6)?e.pageX:event.x+B.scrollLeft;
	var curY=(ns6)?e.pageY:event.y+B.scrollTop;
	var re=ie&&!window.opera? B.clientWidth-event.clientX-offsets.x:window.innerWidth-e.clientX-offsets.x-20
	var be=ie&&!window.opera? B.clientHeight-event.clientY-offsets.y:window.innerHeight-e.clientY-offsets.y-20
	var le=(offsets.x<0)? offsets.x*(-1):-1000;
	if(re<tipobj[i].offsetWidth){
		tipobj[i].style.left=ie? B.scrollLeft+event.clientX-tipobj[i].offsetWidth+"px":window.pageXOffset+e.clientX-tipobj[i].offsetWidth+"px";
	}else if(curX<le){
		tipobj[i].style.left="5px";
	}else{
		tipobj[i].style.left=curX+offsets.x+"px";
	}

	if(typeof(relative_to_object) == 'object'){ // this was done to patch ishop at home calendar rollovers...
		var offTop = getOffset2(relative_to_object,"top");
		var offLeft = getOffset2(relative_to_object,"left");

		//document.getElementById('dashboard_message').innerHTML = offTop + " - " + offLeft;
		tipobj[i].style.position = 'absolute';
		tipobj[i].style.top=offTop+50+"px";				
		tipobj[i].style.left=(offLeft-50)+"px";		
		if(re<tipobj[i].offsetWidth){
			tipobj[i].style.left=ie? B.scrollLeft+event.clientX-tipobj[i].offsetWidth+"px":window.pageXOffset+e.clientX-tipobj[i].offsetWidth+"px";
		}else if(curX<le){
			tipobj[i].style.left="5px";
		}
	}else{
		tipobj[i].style.top=curY+offsets.y+"px"		
	}

	//	tipobj[i].style.top=curY+offsets.y+"px"
	tipobj[i].style.visibility="visible";
	//	alert(tipobj[i].style.top);
	//	alert(tipobj[i].style.left);
}

function hideddrivetip(i){
	if(ns6||ie){
		tipobjMode=i;
		enabletip=false;
		tipobj[i].style.visibility="hidden";
		tipobj[i].style.left="-1000px";
		tipobj[i].style.backgroundColor='';
		tipobj[i].style.width='';
	}
}

if(typeof(XMLHttpRequest) == "undefined"){
  XMLHttpRequest = function() {
    try{return new ActiveXObject("Msxml2.XMLHTTP.6.0");}catch(e){}
    try{return new ActiveXObject("Msxml2.XMLHTTP.3.0");}catch(e){}
    try{return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){}
    try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
  };
}

CART = new Object();

function slideCart(dir){
	CART.ramp++;
	var unit = CART.ramp + CART.ramp;
	if((CART.cartSlideLeft - unit) < 1){
		unit = CART.cartSlideLeft;
	}
	CART.cartSlideLeft = (CART.cartSlideLeft - unit);
	var leftOff = parseInt(CART.cartInner.style.left);
	CART.cartInner.style.left = (dir == 'R') ?(leftOff + unit) + 'px': (leftOff - unit) + 'px';
	if(CART.cartSlideLeft < 1){
		window.clearInterval(CART.interval);
		var string = (dir == 'R')? ['S','H','O','W','&nbsp;','C','A','R','T']: ['H','I','D','E','&nbsp;','C','A','R','T'];
		for(x in CART.cartButton.childNodes){
			CART.cartButton.childNodes[x].innerHTML = string[x];
		}
		if(dir == 'R'){CART.cart.style.zIndex = 1;}
		try{
			var req = new XMLHttpRequest();
			var command = (dir == 'R')? 'hide': 'show';
			req.open("GET",'index.php?trans=crt|'+command);
			req.send("");
		}catch(e){}
	}
}

function hide_cart(obj,w,h){
	window.clearInterval(CART.interval);
	CART.cart = document.getElementById("cartCon");
	CART.cartInner = document.getElementById("cartInnerCon");
	CART.cartButton = document.getElementById("cartButH");
	CART.leftOff = getOffset2(CART.cart,'left');
	CART.leftOffInner = getOffset2(CART.cartInner,'left');
	CART.cartSlideLeft = w;
	CART.ramp = 3;
	var dir = (CART.leftOff == CART.leftOffInner)? 'R': 'L';
	if(dir == 'L'){CART.cart.style.zIndex = 40;}
	CART.interval = window.setInterval('slideCart("'+dir+'");',5);
}

function setCartStyle(){
	var bottomMarker = document.getElementById('cartStretchMarker');
	var offSetT = getOffset2(bottomMarker,'top');
	if(offSetT > (jH-250)){
		document.getElementById('searchCon').style.position = 'absolute';
		document.getElementById('cartCon').style.position = 'absolute';		
	}
	return false;
}


// COMPATIBILITY IS AN ISSUE... I AM NOT MOVING OVER THE FRAME CONTROLLER UNTIL IT'S BETTER TESTED...

function framePrint(id){
	var item = document.getElementById(id);

	top[id].focus();
	top[id].print();	

	//item.focus();
	//item.print();
}


TICKERS=[];

function initTicker(i){
	var id = 'mMCPID-'+i+'-47';
	var ticker = document.getElementById(id);
	if(ticker.id == id){
		TICKERS[i]=[];
		TICKERS[i][0]=1;
		TICKERS[i][1]=ticker;
		setTimeout("moveTicker("+i+");",50);
	}
}

function switchTicker(i,status){
	try{
		TICKERS[i][0] = status;
	}catch(e){}
}

function moveTicker(i){
	if(TICKERS[i][0] == 1){
		ticker = TICKERS[i][1];
		var right_to_left = false;
		ticker.scrollLeft += (right_to_left)? -1: 1;
		if(right_to_left && ticker.scrollLeft <= 0){
			ticker.scrollLeft = ticker.scrollWidth - ticker.offsetWidth;
		}else if(!right_to_left && (ticker.scrollLeft >= (ticker.scrollWidth - ticker.offsetWidth))){
			ticker.scrollLeft = 0;
		}
	}
	setTimeout("moveTicker("+i+");",50);
}

function getOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function initSearch(){

	try{var s = document.getElementById("search"); if(s.value.replace(/^\s+|\s+$/g,"")=="" && jW > 1000 && ((document.documentElement.scrollTop || window.pageYOffset || 0) < 50)){s.focus();}}catch(e){}

}




//MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006 Valerio Proietti, <http://mad4milk.net>, MIT Style License.

var Class = function(properties){
	var klass = function(){
		for (var p in this){
			if (this[p]) this[p]._proto_ = this;
		}
		if (arguments[0] != 'noinit' && this.initialize) return this.initialize.apply(this, arguments);
	};
	klass.extend = this.extend;
	klass.implement = this.implement;
	klass.prototype = properties;
	return klass;
};

Class.empty = function(){};

Class.create = function(properties){
	return new Class(properties);
};

Class.prototype = {

	extend: function(properties){
		var pr0t0typ3 = new this('noinit');
		for (var property in properties){
			var previous = pr0t0typ3[property];
			var current = properties[property];
			if (previous && previous != current) current = previous.parentize(current) || current;
			pr0t0typ3[property] = current;
		}
		return new Class(pr0t0typ3);
	},

	implement: function(properties){
		for (var property in properties) this.prototype[property] = properties[property];
	}

};

Object.extend = function(){
	var args = arguments;
	if (args[1]) args = [args[0], args[1]];
	else args = [this, args[0]];
	for (var property in args[1]) args[0][property] = args[1][property];
	return args[0];
};

Object.Native = function(){
	for (var i = 0; i < arguments.length; i++) arguments[i].extend = Class.prototype.implement;
};

new Object.Native(Function, Array, String, Number);

Function.extend({

	parentize: function(current){
		var previous = this;
		return function(){
			this.parent = previous;
			return current.apply(this, arguments);
		};
	}

});

Function.extend({

	pass: function(args, bind){
		var fn = this;
		if ($type(args) != 'array') args = [args];
		return function(){
			return fn.apply(bind || fn._proto_ || fn, args);
		};
	},

	bind: function(bind){
		var fn = this;
		return function(){
			return fn.apply(bind, arguments);
		};
	},
	
	bindAsEventListener: function(bind){
		var fn = this;
		return function(event){
			fn.call(bind, event || window.event);
			return false;
		};
	},

	delay: function(ms, bind){
		return setTimeout(this.bind(bind || this._proto_ || this), ms);
	},

	periodical: function(ms, bind){
		return setInterval(this.bind(bind || this._proto_ || this), ms);
	}

});

function $clear(timer){
	clearTimeout(timer);
	clearInterval(timer);
	return null;
};

function $type(obj){
	if (!obj) return false;
	var type = false;
	if (obj instanceof Function) type = 'function';
	else if (obj.nodeName){
		if (obj.nodeType == 3 && !/\S/.test(obj.nodeValue)) type = 'textnode';
		else if (obj.nodeType == 1) type = 'element';
	}
	else if (obj instanceof Array) type = 'array';
	else if (typeof obj == 'object') type = 'object';
	else if (typeof obj == 'string') type = 'string';
	else if (typeof obj == 'number' && isFinite(obj)) type = 'number';
	return type;
};

var Chain = new Class({

	chain: function(fn){
		this.chains = this.chains || [];
		this.chains.push(fn);
		return this;
	},

	callChain: function(){
		if (this.chains && this.chains.length) this.chains.splice(0, 1)[0].delay(10, this);
	},

	clearChain: function(){
		this.chains = [];
	}

});

if (!Array.prototype.forEach){

	Array.prototype.forEach = function(fn, bind){
		for(var i = 0; i < this.length ; i++) fn.call(bind, this[i], i);
	};
}

Array.extend({

	each: Array.prototype.forEach,

	copy: function(){
		var newArray = [];
		for (var i = 0; i < this.length; i++) newArray.push(this[i]);
		return newArray;
	},

	remove: function(item){
		for (var i = 0; i < this.length; i++){
			if (this[i] == item) this.splice(i, 1);
		}
		return this;
	},

	test: function(item){
		for (var i = 0; i < this.length; i++){
			if (this[i] == item) return true;
		};
		return false;
	},

	extend: function(newArray){
		for (var i = 0; i < newArray.length; i++) this.push(newArray[i]);
		return this;
	},

	associate: function(keys){
		var newArray = [];
		for (var i =0; i < this.length; i++) newArray[keys[i]] = this[i];
		return newArray;
	}

});

function $A(array){
	return Array.prototype.copy.call(array);
};

String.extend({

	test: function(regex, params){
		return this.match(new RegExp(regex, params));
	},
	toInt: function(){
		return parseInt(this);
	},

	camelCase: function(){
		return this.replace(/-\D/gi, function(match){
			return match.charAt(match.length - 1).toUpperCase();
		});
	},
	capitalize: function(){
		return this.toLowerCase().replace(/\b[a-z]/g, function(match){
			return match.toUpperCase();
		});
	},

	trim: function(){
		return this.replace(/^\s*|\s*$/g, '');
	},

	clean: function(){
		return this.replace(/\s\s/g, ' ').trim();
	},

	rgbToHex: function(array){
		var rgb = this.test('([\\d]{1,3})', 'g');
		if (rgb[3] == 0) return 'transparent';
		var hex = [];
		for (var i = 0; i < 3; i++){
			var bit = (rgb[i]-0).toString(16);
			hex.push(bit.length == 1 ? '0'+bit : bit);
		}
		var hexText = '#'+hex.join('');
		if (array) return hex;
		else return hexText;
	},

	hexToRgb: function(array){
		var hex = this.test('^[#]{0,1}([\\w]{1,2})([\\w]{1,2})([\\w]{1,2})$');
		var rgb = [];
		for (var i = 1; i < hex.length; i++){
			if (hex[i].length == 1) hex[i] += hex[i];
			rgb.push(parseInt(hex[i], 16));
		}
		var rgbText = 'rgb('+rgb.join(',')+')';
		if (array) return rgb;
		else return rgbText;
	}

});

Number.extend({

	toInt: function(){
		return this;
	}

});

var Element = new Class({

	initialize: function(el){
		if ($type(el) == 'string') el = document.createElement(el);
		return $(el);
	},

	inject: function(el, where){
		el = $(el) || new Element(el);
		switch(where){
			case "before": $(el.parentNode).insertBefore(this, el); break;
			case "after": {
					if (!el.getNext()) $(el.parentNode).appendChild(this);
					else $(el.parentNode).insertBefore(this, el.getNext());
			} break;
			case "inside": el.appendChild(this); break;
		}
		return this;
	},

	injectBefore: function(el){
		return this.inject(el, 'before');
	},

	injectAfter: function(el){
		return this.inject(el, 'after');
	},

	injectInside: function(el){
		return this.inject(el, 'inside');
	},

	adopt: function(el){
		this.appendChild($(el) || new Element(el));
		return this;
	},

	remove: function(){
		this.parentNode.removeChild(this);
	},

	clone: function(contents){
		return $(this.cloneNode(contents || true));
	},

	replaceWith: function(el){
		var el = $(el) || new Element(el);
		this.parentNode.replaceChild(el, this);
		return el;
	},

	appendText: function(text){
		if (this.getTag() == 'style' && window.ActiveXObject) this.styleSheet.cssText = text;
		else this.appendChild(document.createTextNode(text));
		return this;
	},

	hasClass: function(className){
		return !!this.className.test("\\b"+className+"\\b");
	},

	addClass: function(className){
		if (!this.hasClass(className)) this.className = (this.className+' '+className.trim()).clean();
		return this;
	},

	removeClass: function(className){
		if (this.hasClass(className)) this.className = this.className.replace(className.trim(), '').clean();
		return this;
	},

	toggleClass: function(className){
		if (this.hasClass(className)) return this.removeClass(className);
		else return this.addClass(className);
	},

	setStyle: function(property, value){
		if (property == 'opacity') this.setOpacity(parseFloat(value));
		else this.style[property.camelCase()] = value;
		return this;
	},

	setStyles: function(source){
		if ($type(source) == 'object') {
			for (var property in source) this.setStyle(property, source[property]);
		} else if ($type(source) == 'string') {
			if (window.ActiveXObject) this.cssText = source;
			else this.setAttribute('style', source);
		}
		return this;
	},

	setOpacity: function(opacity){
		if (opacity == 0){
			if(this.style.visibility != "hidden") this.style.visibility = "hidden";
		} else {
			if(this.style.visibility != "visible") this.style.visibility = "visible";
		}
		if (window.ActiveXObject) this.style.filter = "alpha(opacity=" + opacity*100 + ")";
		this.style.opacity = opacity;
		return this;
	},

	getStyle: function(property){
		var proPerty = property.camelCase();
		var style = this.style[proPerty] || false;
		if (!style) {
			if (document.defaultView) style = document.defaultView.getComputedStyle(this,null).getPropertyValue(property);
			else if (this.currentStyle) style = this.currentStyle[proPerty];
		}
		if (style && ['color', 'backgroundColor', 'borderColor'].test(proPerty) && style.test('rgb')) style = style.rgbToHex();
		return style;
	},

	addEvent: function(action, fn){
		this[action+fn] = fn.bind(this);
		if (this.addEventListener) this.addEventListener(action, fn, false);
		else this.attachEvent('on'+action, this[action+fn]);
		var el = this;
		if (this != window) Unload.functions.push(function(){
			el.removeEvent(action, fn);
			el[action+fn] = null;
		});
		return this;
	},

	removeEvent: function(action, fn){
		if (this.removeEventListener) this.removeEventListener(action, fn, false);
		else this.detachEvent('on'+action, this[action+fn]);
		return this;
	},

	getBrother: function(what){
		var el = this[what+'Sibling'];
		while ($type(el) == 'textnode') el = el[what+'Sibling'];
		return $(el);
	},

	getPrevious: function(){
		return this.getBrother('previous');
	},

	getNext: function(){
		return this.getBrother('next');
	},

	getFirst: function(){
		var el = this.firstChild;
		while ($type(el) == 'textnode') el = el.nextSibling;
		return $(el);
	},

	getLast: function(){
		var el = this.lastChild;
		while ($type(el) == 'textnode')
		el = el.previousSibling;
		return $(el);
	},

	setProperty: function(property, value){
		var el = false;
		switch(property){
			case 'class': this.className = value; break;
			case 'style': this.setStyles(value); break;
			case 'name': if (window.ActiveXObject && this.getTag() == 'input'){
				el = $(document.createElement('<input name="'+value+'" />'));
				$A(this.attributes).each(function(attribute){
					if (attribute.name != 'name') el.setProperty(attribute.name, attribute.value);
				
				});
				if (this.parentNode) this.replaceWith(el);
			};
			default: this.setAttribute(property, value);
		}
		return el || this;
	},

	setProperties: function(source){
		for (var property in source) this.setProperty(property, source[property]);
		return this;
	},

	setHTML: function(html){
		this.innerHTML = html;
		return this;
	},

	getProperty: function(property){
		return this.getAttribute(property);
	},

	getTag: function(){
		return this.tagName.toLowerCase();
	},

	getOffset: function(what){
		what = what.capitalize();
		var el = this;
		var offset = 0;
		do {
			offset += el['offset'+what] || 0;
			el = el.offsetParent;
		} while (el);
		return offset;
	},

	getTop: function(){
		return this.getOffset('top');
	},

	getLeft: function(){
		return this.getOffset('left');
	},

	getValue: function(){
		var value = false;
		switch(this.getTag()){
			case 'select': value = this.getElementsByTagName('option')[this.selectedIndex].value; break;
			case 'input': if ( (this.checked && ['checkbox', 'radio'].test(this.type)) || (['hidden', 'text', 'password'].test(this.type)) ) 
				value = this.value; break;
			case 'textarea': value = this.value;
		}
		return value;
	}

});

new Object.Native(Element);

Element.extend({
	hasClassName: Element.prototype.hasClass,
	addClassName: Element.prototype.addClass,
	removeClassName: Element.prototype.removeClass,
	toggleClassName: Element.prototype.toggleClass
});

function $Element(el, method, args){
	if ($type(args) != 'array') args = [args];
	return Element.prototype[method].apply(el, args);
};

function $(el){
	if ($type(el) == 'string') el = document.getElementById(el);
	if ($type(el) == 'element'){
		if (!el.extend){
			Unload.elements.push(el);
			el.extend = Object.extend;
			el.extend(Element.prototype);
		}
		return el;
	} else return false;
};

window.addEvent = document.addEvent = Element.prototype.addEvent;
window.removeEvent = document.removeEvent = Element.prototype.removeEvent;

var Unload = {

	elements: [], functions: [], vars: [],

	unload: function(){
		Unload.functions.each(function(fn){
			fn();
		});
	
		window.removeEvent('unload', window.removeFunction);
	
		Unload.elements.each(function(el){
			for(var p in Element.prototype){
				window[p] = null;
				document[p] = null;
				el[p] = null;
			}
			el.extend = null;
		});
	}

};

window.removeFunction = Unload.unload;
window.addEvent('unload', window.removeFunction);
var Fx = fx = {};

Fx.Base = new Class({

	setOptions: function(options){
		this.options = Object.extend({
			onStart: Class.empty,
			onComplete: Class.empty,
			transition: Fx.Transitions.sineInOut,
			duration: 500,
			unit: 'px',
			wait: true,
			fps: 50
		}, options || {});
	},

	step: function(){
		var time = new Date().getTime();
		if (time < this.time + this.options.duration){
			this.cTime = time - this.time;
			this.setNow();
		} else {
			this.options.onComplete.pass(this.element, this).delay(10);
			this.clearTimer();
			this.callChain();
			this.now = this.to;
		}
		this.increase();
	},

	set: function(to){
		this.now = to;
		this.increase();
		return this;
	},

	setNow: function(){
		this.now = this.compute(this.from, this.to);
	},

	compute: function(from, to){
		return this.options.transition(this.cTime, from, (to - from), this.options.duration);
	},

	custom: function(from, to){
		if (!this.options.wait) this.clearTimer();
		if (this.timer) return;
		this.options.onStart.pass(this.element, this).delay(10);
		this.from = from;
		this.to = to;
		this.time = new Date().getTime();
		this.timer = this.step.periodical(Math.round(1000/this.options.fps), this);
		return this;
	},
	clearTimer: function(){
		this.timer = $clear(this.timer);
		return this;
	},

	setStyle: function(element, property, value){
		element.setStyle(property, value + this.options.unit);
	}

});

Fx.Base.implement(new Chain);

Fx.Style = Fx.Base.extend({

	initialize: function(el, property, options){
		this.element = $(el);
		this.setOptions(options);
		this.property = property.camelCase();
	},

	hide: function(){
		return this.set(0);
	},

	goTo: function(val){
		return this.custom(this.now || 0, val);
	},

	increase: function(){
		this.setStyle(this.element, this.property, this.now);
	}

});

Fx.Styles = Fx.Base.extend({

	initialize: function(el, options){
		this.element = $(el);
		this.setOptions(options);
		this.now = {};
	},

	setNow: function(){
		for (var p in this.from) this.now[p] = this.compute(this.from[p], this.to[p]);
	},

	custom: function(objFromTo){
		if (this.timer && this.options.wait) return;
		var from = {};
		var to = {};
		for (var p in objFromTo){
			from[p] = objFromTo[p][0];
			to[p] = objFromTo[p][1];
		}
		return this.parent(from, to);
	},

	increase: function(){
		for (var p in this.now) this.setStyle(this.element, p, this.now[p]);
	}

});

Element.extend({

	effect: function(property, options){
		return new Fx.Style(this, property, options);
	},

	effects: function(options){
		return new Fx.Styles(this, options);
	}

});

Fx.Transitions = {
	linear: function(t, b, c, d){
		return c*t/d + b;
	},
	sineInOut: function(t, b, c, d){
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	}

};

function $S(){
	var els = [];
	$A(arguments).each(function(sel){
		if ($type(sel) == 'string') els.extend(document.getElementsBySelector(sel));
		else if ($type(sel) == 'element') els.push($(sel));
	});
	return $Elements(els);
};

var $$ = $S;

function $E(selector, filter){
	return ($(filter) || document).getElement(selector);
};

function $ES(selector, filter){
	return ($(filter) || document).getElementsBySelector(selector);
};

function $Elements(elements){
	return Object.extend(elements, new Elements);
};

Element.extend({

	getElements: function(selector){
		var filters = [];
		selector.clean().split(' ').each(function(sel, i){
			var bits = sel.test('^(\\w*|\\*)(?:#(\\w+)|\\.(\\w+))?(?:\\[["\']?(\\w+)["\']?([\\*\\^\\$]?=)["\']?(\\w*)["\']?\\])?$');
			if (!bits) return;
			if (!bits[1]) bits[1] = '*';
			var param = bits.remove(bits[0]).associate(['tag', 'id', 'class', 'attribute', 'operator', 'value']);
			if (i == 0){
				if (param['id']){
					var el = this.getElementById(param['id']);
					if (!el || (param['tag'] != '*' && $(el).getTag() != param['tag'])) return false;
					filters = [el];
				} else {
					filters = $A(this.getElementsByTagName(param['tag']));
				}
			} else {
				if (param['id']) filters = $Elements(filters).filterById(param['id']);
				filters = $Elements(filters).filterByTagName(param['tag']);
			}
			if (param['class']) filters = $Elements(filters).filterByClassName(param['class']);
			if (param['attribute']) filters = $Elements(filters).filterByAttribute(param['attribute'], param['value'], param['operator']);

		}, this);
		filters.each(function(el){
			$(el);
		});
		return $Elements(filters);
	},

	getElement: function(selector){
		return this.getElementsBySelector(selector)[0];
	},

	getElementsBySelector: function(selector){
		var els = [];
		selector.split(',').each(function(sel){
			els.extend(this.getElements(sel));
		}, this);
		return $Elements(els);
	}

});

document.extend = Object.extend;

document.extend({
	getElementsByClassName: function(className){
		return document.getElements('.'+className);
	},
	getElement: Element.prototype.getElement,
	getElements: Element.prototype.getElements,
	getElementsBySelector: Element.prototype.getElementsBySelector

});

var Elements = new Class({

	action: function(actions){
		this.each(function(el){
			el = $(el);
			if (actions.initialize) actions.initialize.apply(el);
			for(var action in actions){
				var evt = false;
				if (action.test('^on[\\w]{1,}')) el[action] = actions[action];
				else if (evt = action.test('([\\w-]{1,})event$')) el.addEvent(evt[1], actions[action]);
			}
		});
	},

	//internal methods

	filterById: function(id){
		var found = [];
		this.each(function(el){
			if (el.id == id) found.push(el);
		});
		return found;
	},

	filterByClassName: function(className){
		var found = [];
		this.each(function(el){
			if ($Element(el, 'hasClass', className)) found.push(el);
		});
		return found;
	},

	filterByTagName: function(tagName){
		var found = [];
		this.each(function(el){
			found.extend($A(el.getElementsByTagName(tagName)));
		});
		return found;
	},

	filterByAttribute: function(name, value, operator){
		var found = [];
		this.each(function(el){
			var att = el.getAttribute(name);
			if(!att) return;
			if (!operator) return found.push(el);
		
			switch(operator){
				case '*=': if (att.test(value)) found.push(el); break;
				case '=': if (att == value) found.push(el); break;
				case '^=': if (att.test('^'+value)) found.push(el); break;
				case '$=': if (att.test(value+'$')) found.push(el);
			}

		});
		return found;
	}

});

new Object.Native(Elements);

var Ajax = ajax = new Class({

	setOptions: function(options){
		this.options = {
			method: 'post',
			postBody: null,
			async: true,
			onComplete: Class.empty,
			onStateChange: Class.empty,
			update: null,
			evalScripts: false
		};
		Object.extend(this.options, options || {});
	},

	initialize: function(url, options){
		this.setOptions(options);
		this.url = url;
		this.transport = this.getTransport();
	},

	request: function(){
		this.transport.open(this.options.method, this.url, this.options.async);
		this.transport.onreadystatechange = this.onStateChange.bind(this);
		if (this.options.method == 'post'){
			this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
		}
		switch($type(this.options.postBody)){
			case 'element': this.options.postBody = $(this.options.postBody).toQueryString(); break;
			case 'object': this.options.postBody = Object.toQueryString(this.options.postBody);
		}
		if($type(this.options.postBody) == 'string') this.transport.send(this.options.postBody);
		else this.transport.send(null);
		return this;
	},

	onStateChange: function(){
		this.options.onStateChange.delay(10, this);
		if (this.transport.readyState == 4 && this.transport.status == 200){
			if (this.options.update) $(this.options.update).setHTML(this.transport.responseText);
			this.options.onComplete.pass([this.transport.responseText, this.transport.responseXML], this).delay(20);
			if (this.options.evalScripts) this.evalScripts.delay(30, this);
			this.transport.onreadystatechange = Class.empty;
			this.callChain();
		}
	},

	evalScripts: function(){
		if(scripts = this.transport.responseText.match(/<script[^>]*?>[\S\s]*?<\/script>/g)){
			scripts.each(function(script){
				eval(script.replace(/^<script[^>]*?>/, '').replace(/<\/script>$/, ''));
			});
		}
	},

	getTransport: function(){
		if (window.XMLHttpRequest) return new XMLHttpRequest();
		else if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
	}

});

Ajax.implement(new Chain);

Object.toQueryString = function(source){
	var queryString = [];
	for (var property in source) queryString.push(encodeURIComponent(property)+'='+encodeURIComponent(source[property]));
	return queryString.join('&');
};

Element.extend({

	send: function(options){
		options = Object.extend(options, {postBody: this.toQueryString(), method: 'post'});
		return new Ajax(this.getProperty('action'), options).request();
	},

	toQueryString: function(){
		var queryString = [];
		$A(this.getElementsByTagName('*')).each(function(el){
			var name = $(el).name;
			var value = el.getValue();
			if (value && name) queryString.push(encodeURIComponent(name)+'='+encodeURIComponent(value));
		});
		return queryString.join('&');
	}

});
var Drag = {};

Drag.Base = new Class({

	setOptions: function(options){
		this.options = Object.extend({
			handle: false,
			unit: 'px', 
			onStart: Class.empty, 
			onComplete: Class.empty, 
			onDrag: Class.empty,
			xMax: false,
			xMin: false,
			yMax: false,
			yMin: false
		}, options || {});
	},

	initialize: function(el, xModifier, yModifier, options){
		this.setOptions(options);
		this.element = $(el);
		this.handle = $(this.options.handle) || this.element;
		if (xModifier) this.xp = xModifier.camelCase();
		if (yModifier) this.yp = yModifier.camelCase();
		this.handle.onmousedown = this.start.bind(this);
	},

	start: function(evt){
		evt = evt || window.event;
		this.startX = evt.clientX;
		this.startY = evt.clientY;
	
		this.handleX = this.startX - this.handle.getLeft();
		this.handleY = this.startY - this.handle.getTop();
	
		this.set(evt);
		this.options.onStart.pass(this.element, this).delay(10);
		document.onmousemove = this.drag.bind(this);
		document.onmouseup = this.end.bind(this);
		return false;
	},

	addStyles: function(x, y){
		if (this.xp){
			var stylex = this.element.getStyle(this.xp).toInt();
	
			var movex = function(val){
				this.element.setStyle(this.xp, val+this.options.unit);
			}.bind(this);
	
			if (this.options.xMax && stylex >= this.options.xMax){
				if (this.clientX <= this.handleX+this.handle.getLeft()) movex(stylex+x);
				if (stylex > this.options.xMax) movex(this.options.xMax);
			} else if(this.options.xMin && stylex <= this.options.xMin){
				if (this.clientX >= this.handleX+this.handle.getLeft()) movex(stylex+x);
				if (stylex < this.options.xMin) movex(this.options.xMin);
			} else movex(stylex+x);
		}
		if (this.yp){
			var styley = this.element.getStyle(this.yp).toInt();

			var movey = function(val){
				this.element.setStyle(this.yp, val+this.options.unit);
			}.bind(this);

			if (this.options.yMax && styley >= this.options.yMax){
				if (this.clientY <= this.handleY+this.handle.getTop()) movey(styley+y);
				if (styley > this.options.yMax) movey(this.options.yMax);
			} else if(this.options.yMin && styley <= this.options.yMin){
				if (this.clientY >= this.handleY+this.handle.getTop()) movey(styley+y);
				if (styley < this.options.yMin) movey(this.options.yMin);
			} else movey(styley+y);
		}
	},

	drag: function(evt){
		evt = evt || window.event;
		this.clientX = evt.clientX;
		this.clientY = evt.clientY;
		this.options.onDrag.pass(this.element, this).delay(5);
		this.addStyles((this.clientX-this.lastMouseX), (this.clientY-this.lastMouseY));
		this.set(evt);
		return false;
	},

	set: function(evt){
		this.lastMouseX = evt.clientX;
		this.lastMouseY = evt.clientY;
		return false;
	},

	end: function(){
		document.onmousemove = null;
		document.onmouseup = null;
		this.options.onComplete.pass(this.element, this).delay(10);
	}

});

Drag.Move = Drag.Base.extend({

	extendOptions: function(options){
		this.options = Object.extend(this.options || {}, Object.extend({
			onSnap: Class.empty,
			droppables: [],
			snapDistance: 8,
			snap: true,
			xModifier: 'left',
			yModifier: 'top',
			container: false
		}, options || {}));
	},

	initialize: function(el, options){
		this.extendOptions(options);
		this.container = $(this.options.container);
		this.parent(el, this.options.xModifier, this.options.yModifier, this.options);
	},

	start: function(evt){
		if (this.options.container) {
			var cont = $(this.options.container).getPosition();
			Object.extend(this.options, {
				xMax: cont.right-this.element.offsetWidth,
				xMin: cont.left,
				yMax: cont.bottom-this.element.offsetHeight,
				yMin: cont.top
			});
		}
		this.parent(evt);
		if (this.options.snap) document.onmousemove = this.checkAndDrag.bind(this);
		return false;
	},

	drag: function(evt){
		this.parent(evt);
		this.options.droppables.each(function(drop){
			if (this.checkAgainst(drop)){
				if (drop.onOver && !drop.dropping) drop.onOver.pass([this.element, this], drop).delay(10);
				drop.dropping = true;
			} else {
				if (drop.onLeave && drop.dropping) drop.onLeave.pass([this.element, this], drop).delay(10);
				drop.dropping = false;
			}
		}, this);
		return false;
	},

	checkAndDrag: function(evt){
		evt = evt || window.event;
		var distance = Math.round(Math.sqrt(Math.pow(evt.clientX - this.startX, 2)+Math.pow(evt.clientY - this.startY, 2)));
		if (distance > this.options.snapDistance){
			this.set(evt);
			this.options.onSnap.pass(this.element, this).delay(10);
			document.onmousemove = this.drag.bind(this);
			this.addStyles(-(this.startX-evt.clientX), -(this.startY-evt.clientY));
		}
		return false;
	},

	checkAgainst: function(el){
		x = this.clientX+Window.getScrollLeft();
		y = this.clientY+Window.getScrollTop();
		var el = $(el).getPosition();
		return (x > el.left && x < el.right && y < el.bottom && y > el.top);
	},

	end: function(){
		this.parent();
		this.options.droppables.each(function(drop){
			if (drop.onDrop && this.checkAgainst(drop)) drop.onDrop.pass([this.element, this], drop).delay(10);
		}, this);
	}

});

Element.extend({

	makeDraggable: function(options){
		return new Drag.Move(this, options);
	},

	makeResizable: function(options){
		return new Drag.Base(this, 'width', 'height', options);
	},

	getPosition: function(){
		var obj = {};
		obj.width = this.offsetWidth;
		obj.height = this.offsetHeight;
		obj.left = this.getLeft();
		obj.top = this.getTop();
		obj.right = obj.left + obj.width;
		obj.bottom = obj.top + obj.height;
		return obj;
	}

});

var Window = {

	disableImageCache: function(){
		if (window.ActiveXObject) document.execCommand("BackgroundImageCache", false, true);
	},

	extend: Object.extend,

	getWidth: function(){
		return window.innerWidth || document.documentElement.clientWidth || 0;
	},

	getHeight: function(){
		return window.innerHeight || document.documentElement.clientHeight || 0;
	},

	getScrollHeight: function(){
		return document.documentElement.scrollHeight;
	},

	getScrollWidth: function(){
		return document.documentElement.scrollWidth;
	},

	getScrollTop: function(){
		return document.documentElement.scrollTop || window.pageYOffset || 0;
	},

	getScrollLeft: function(){
		return document.documentElement.scrollLeft || window.pageXOffset || 0;
	},

	onDomReady: function(init){
		var state = document.readyState;
		if (state && document.childNodes && !document.all && !navigator.taintEnabled){ //khtml
			if (state.test(/loaded|complete/)) return init();
			else return Window.onDomReady.pass(init).delay(100);
		} else if (state && window.ActiveXObject){ //ie
			var script = $('_ie_ready_');
			if (!script) document.write("<script id='_ie_ready_' defer='true' src='://'></script>");
			$('_ie_ready_').addEvent('readystatechange', function(){
				if (this.readyState == 'complete') init();
			});
			return;
		} else { //others
			var myInit = function() {
				if (arguments.callee.done) return;
				arguments.callee.done = true;
				init();
			};
			window.addEvent("load", myInit);
			document.addEvent("DOMContentLoaded", myInit);
		}
	}

};

var Cookie = {

	set: function(key, value, duration){
		var date = new Date();
		date.setTime(date.getTime()+((duration || 365)*86400000));
		document.cookie = key+"="+value+"; expires="+date.toGMTString()+"; path=/";
	},

	get: function(key){
		var myValue, myVal;
		document.cookie.split(';').each(function(cookie){
			if(myVal = cookie.trim().test(key+'=(.*)')) myValue = myVal[1];
		});
		return myValue;
	},

	remove: function(key){
		this.set(key, '', -1);
	}

};

var Json = {

	toString: function(el){
		var string = [];
	
		var isArray = function(array){
			var string = [];
			array.each(function(ar){
				string.push(Json.toString(ar));
			});
			return string.join(',');
		};
	
		var isObject = function(object){
			var string = [];
			for (var property in object) string.push('"'+property+'":'+Json.toString(object[property]));
			return string.join(',');
		};
	
		switch($type(obj)){
			case 'number': string.push(obj); break;
			case 'string': string.push('"'+obj+'"'); break;
			case 'function': string.push(obj); break;
			case 'object': string.push('{'+isObject(obj)+'}'); break;
			case 'array': string.push('['+isArray(obj)+']');
		}
	
		return string.join(',');
	},

	evaluate: function(str){
		return eval('(' + str + ')');
	}

};

var Sortables = new Class({

	setOptions: function(options) {
		this.options = {
			handles: false,
			fxDuration: 250,
			fxTransition: Fx.Transitions.sineInOut,
			maxOpacity: 0.5,
			onComplete: Class.empty,
			onStart: Class.empty,
			contain: false
		};
		Object.extend(this.options, options || {});
	},

	initialize: function(elements, options){
		this.setOptions(options);
		this.options.handles = this.options.handles || elements;
		var trash = new Element('div').injectInside($(document.body));
		$A(elements).each(function(el, i){
			var copy = $(el).clone().setStyles({
				'position': 'absolute',
				'opacity': '0',
				'display': 'none'
			}).injectInside(trash);
			var elEffect = el.effect('opacity', {
				duration: this.options.fxDuration,
				wait: false,
				transition: this.options.fxTransition
			}).set(1);
			var copyEffects = copy.effects({
				duration: this.options.fxDuration,
				wait: false,
				transition: this.options.fxTransition,
				onComplete: function(){
					copy.setStyle('display', 'none');
				}
			});
			var yMax = false;
			var yMin = false;
			if (this.options.contain){
				yMax = $(el.parentNode).getTop()+el.parentNode.offsetHeight-el.offsetHeight;
				yMin = el.parentNode.getTop();
			}
			var dragger = new Drag.Move(copy, {
				handle: this.options.handles[i],
				yMax: yMax,
				yMin: yMin,
				xModifier: false,
				onStart: function(){
					this.options.onStart.bind(this).delay(10);
					copy.setHTML(el.innerHTML).setStyles({
						'display': 'block',
						'opacity': this.options.maxOpacity,
						'top': el.getTop()+'px',
						'left': el.getLeft()+'px'
					});
					elEffect.custom(elEffect.now, this.options.maxOpacity);
				}.bind(this),
				onComplete: function(){
					this.options.onComplete.bind(this).delay(10);
					copyEffects.custom({
						'opacity': [this.options.maxOpacity, 0],
						'top': [copy.getTop(), el.getTop()]
					});
					elEffect.custom(elEffect.now, 1);
				}.bind(this),
				onDrag: function(){
					if (el.getPrevious() && copy.getTop() < (el.getPrevious().getTop())) el.injectBefore(el.getPrevious());
					else if (el.getNext() && copy.getTop() > (el.getNext().getTop())) el.injectAfter(el.getNext());
				}
			});
		}, this);
	}

});

Fx.Scroll = Fx.Base.extend({

	initialize: function(el, options) {
		this.element = $(el);
		this.setOptions(options);
	},

	down: function(){
		return this.custom(this.element.scrollTop, this.element.scrollHeight-this.element.offsetHeight);
	},

	up: function(){
		return this.custom(this.element.scrollTop, 0);
	},

	increase: function(){
		this.element.scrollTop = this.now;
	}
});

Fx.Slide = Fx.Base.extend({

	initialize: function(el, options){
		this.element = $(el);
		this.wrapper = new Element('div').injectAfter(this.element).setStyle('overflow', 'hidden').adopt(this.element);
		this.setOptions(options);
		if (!this.options.mode) this.options.mode = 'vertical';
		this.now = [];
	},

	setNow: function(){
		[0,1].each(function(i){
			this.now[i] = this.compute(this.from[i], this.to[i]);
		}, this);
	},

	vertical: function(){
		this.margin = 'top';
		this.layout = 'height';
		this.startPosition = [this.element.scrollHeight, '0'];
		this.endPosition = ['0', -this.element.scrollHeight];
		return this;
	},

	horizontal: function(){
		this.margin = 'left';
		this.layout = 'width';
		this.startPosition = [this.element.scrollWidth, '0'];
		this.endPosition = ['0', -this.element.scrollWidth];
		return this;
	},

	hide: function(){
		this[this.options.mode]();
		this.wrapper.setStyle(this.layout, '0');
		this.element.setStyle('margin-'+this.margin, -this.element['scroll'+this.layout.capitalize()]+this.options.unit);
		return this;
	},

	show: function(){
		this[this.options.mode]();
		this.wrapper.setStyle(this.layout, this.element['scroll'+this.layout.capitalize()]+this.options.unit);
		this.element.setStyle('margin-'+this.margin, '0');
		return this;
	},

	toggle: function(mode){
		this[this.options.mode]();
		if (this.wrapper['offset'+this.layout.capitalize()] > 0) return this.custom(this.startPosition, this.endPosition);
		else return this.custom(this.endPosition, this.startPosition);
	},

	increase: function(){	
		this.wrapper.setStyle(this.layout, this.now[0]+this.options.unit);
		this.element.setStyle('margin-'+this.margin, this.now[1]+this.options.unit);
	}

});

Fx.Color = Fx.Base.extend({

	initialize: function(el, property, options){
		this.element = $(el);
		this.setOptions(options);
		this.property = property;
		this.now = [];
	},

	custom: function(from, to){
		return this.parent(from.hexToRgb(true), to.hexToRgb(true));
	},

	setNow: function(){
		[0,1,2].each(function(i){
			this.now[i] = Math.round(this.compute(this.from[i], this.to[i]));
		}, this);
	},

	increase: function(){
		this.element.setStyle(this.property, "rgb("+this.now[0]+","+this.now[1]+","+this.now[2]+")");
	},

	fromColor: function(color){
		return this.custom(color, this.element.getStyle(this.property));
	},

	toColor: function(color){
		return this.custom(this.element.getStyle(this.property), color);
	}

});

Fx.Height = Fx.Style.extend({

	initialize: function(el, options){
		this.parent(el, 'height', options);
		this.element.setStyle('overflow', 'hidden');
	},

	toggle: function(){
		if (this.element.offsetHeight > 0) return this.custom(this.element.offsetHeight, 0);
		else return this.custom(0, this.element.scrollHeight);
	},

	show: function(){
		return this.set(this.element.scrollHeight);
	}

});

Fx.Width = Fx.Style.extend({

	initialize: function(el, options){
		this.parent(el, 'width', options);
		this.element.setStyle('overflow', 'hidden');
		this.iniWidth = this.element.offsetWidth;
	},

	toggle: function(){
		if (this.element.offsetWidth > 0) return this.custom(this.element.offsetWidth, 0);
		else return this.custom(0, this.iniWidth);
	},

	show: function(){
		return this.set(this.iniWidth);
	}

});

Fx.Opacity = Fx.Style.extend({

	initialize: function(el, options){
		this.parent(el, 'opacity', options);
		this.now = 1;
	},

	toggle: function(){
		if (this.now > 0) return this.custom(1, 0);
		else return this.custom(0, 1);
	},

	show: function(){
		return this.set(1);
	}

});

Fx.Transitions = {
	linear: function(t, b, c, d){
		return c*t/d + b;
	},
	quadIn: function(t, b, c, d){
		return c*(t/=d)*t + b;
	},
	quadOut: function(t, b, c, d){
		return -c *(t/=d)*(t-2) + b;
	},
	quadInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	cubicIn: function(t, b, c, d){
		return c*(t/=d)*t*t + b;
	},
	cubicOut: function(t, b, c, d){
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	cubicInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	quartIn: function(t, b, c, d){
		return c*(t/=d)*t*t*t + b;
	},
	quartOut: function(t, b, c, d){
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	quartInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	quintIn: function(t, b, c, d){
		return c*(t/=d)*t*t*t*t + b;
	},
	quintOut: function(t, b, c, d){
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	quintInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	sineIn: function(t, b, c, d){
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	sineOut: function(t, b, c, d){
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	sineInOut: function(t, b, c, d){
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	expoIn: function(t, b, c, d){
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	expoOut: function(t, b, c, d){
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	expoInOut: function(t, b, c, d){
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	circIn: function(t, b, c, d){
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	circOut: function(t, b, c, d){
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	circInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	elasticIn: function(t, b, c, d, a, p){
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3; if (!a) a = 1;
		if (a < Math.abs(c)){ a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin(c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	elasticOut: function(t, b, c, d, a, p){
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3; if (!a) a = 1;
		if (a < Math.abs(c)){ a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin(c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	elasticInOut: function(t, b, c, d, a, p){
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5); if (!a) a = 1;
		if (a < Math.abs(c)){ a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin(c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	backIn: function(t, b, c, d, s){
		if (!s) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	backOut: function(t, b, c, d, s){
		if (!s) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	backInOut: function(t, b, c, d, s){
		if (!s) s = 1.70158;
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	bounceIn: function(t, b, c, d){
		return c - Fx.Transitions.bounceOut (d-t, 0, c, d) + b;
	},
	bounceOut: function(t, b, c, d){
		if ((t/=d) < (1/2.75)){
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)){
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)){
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	bounceInOut: function(t, b, c, d){
		if (t < d/2) return Fx.Transitions.bounceIn(t*2, 0, c, d) * .5 + b;
		return Fx.Transitions.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
	}

};

var Tips = new Class({

	setOptions: function(options){
		this.options = {
			transitionStart: Fx.Transitions.sineInOut,
			transitionEnd: Fx.Transitions.sineInOut,
			maxTitleChars: 30,
			fxDuration: 150,
			maxOpacity: 1,
			timeOut: 100,
			className: 'tooltip'
		}
		Object.extend(this.options, options || {});
	},

	initialize: function(elements, options){
		this.elements = elements;
		this.setOptions(options);
		this.toolTip = new Element('div').addClassName(this.options.className).setStyle('position', 'absolute').injectInside(document.body);
		this.toolTitle = new Element('H4').injectInside(this.toolTip);
		this.toolText = new Element('p').injectInside(this.toolTip);
		this.fx = new fx.Style(this.toolTip, 'opacity', {duration: this.options.fxDuration, wait: false}).hide();
		$A(elements).each(function(el){
			$(el).myText = el.title || false;
			if (el.myText) el.removeAttribute('title');
			if (el.href){
				if (el.href.test('http://')) el.myTitle = el.href.replace('http://', '');
				if (el.href.length > this.options.maxTitleChars) el.myTitle = el.href.substr(0,this.options.maxTitleChars-3)+"...";
			}
			if (el.myText && el.myText.test('::')){
				var dual = el.myText.split('::');
				el.myTitle = dual[0].trim();
				el.myText = dual[1].trim();
			} 
			el.onmouseover = function(){
				this.show(el);
				return false;
			}.bind(this);
			el.onmousemove = this.locate.bindAsEventListener(this);
			el.onmouseout = function(){
				this.timer = $clear(this.timer);
				this.disappear();
			}.bind(this);
		}, this);
	},

	show: function(el){
		this.toolTitle.innerHTML = el.myTitle;
		this.toolText.innerHTML = el.myText;
		this.timer = $clear(this.timer);
		this.fx.options.transition = this.options.transitionStart;
		this.timer = this.appear.delay(this.options.timeOut, this);
	},

	appear: function(){
		this.fx.custom(this.fx.now, this.options.maxOpacity);
	},

	locate: function(evt){
		var doc = document.documentElement;
		this.toolTip.setStyles({'top': evt.clientY + doc.scrollTop + 15 + 'px', 'left': evt.clientX + doc.scrollLeft - 30 + 'px'});
	},

	disappear: function(){
		this.fx.options.transition = this.options.transitionEnd;
		this.fx.custom(this.fx.now, 0);
	}

});

Fx.Elements = Fx.Base.extend({

	initialize: function(elements, options){
		this.elements = [];
		elements.each(function(el){
			this.elements.push($(el));
		}, this);
		this.setOptions(options);
		this.now = {};
	},

	setNow: function(){
		for (var i in this.from){
			var iFrom = this.from[i];
			var iTo = this.to[i];
			var iNow = this.now[i] = {};
			for (var p in iFrom) iNow[p] = this.compute(iFrom[p], iTo[p]);
		}
	},

	custom: function(objObjs){
		if (this.timer && this.options.wait) return;
		var from = {};
		var to = {};
		for (var i in objObjs){
			var iProps = objObjs[i];
			var iFrom = from[i] = {};
			var iTo = to[i] = {};
			for (var prop in iProps){
				iFrom[prop] = iProps[prop][0];
				iTo[prop] = iProps[prop][1];
			}
		}
		return this.parent(from, to);
	},

	increase: function(){
		for (var i in this.now){
			var iNow = this.now[i];
			for (var p in iNow) this.setStyle(this.elements[i.toInt()], p, iNow[p]);
		}
	}

});

Fx.Accordion = Fx.Elements.extend({

	extendOptions: function(options){
		Object.extend(this.options, Object.extend({
			start: 'open-first',
			startIndex: 0,
			fixedHeight: false,
			fixedWidth: false,
			alwaysHide: true,
			wait: false,
			onActive: Class.empty,
			onBackground: Class.empty,
			height: true,
			opacity: true,
			width: false
		}, options || {}));
	},

	initialize: function(togglers, elements, options){
		this.parent(elements, options);
		this.extendOptions(options);
		this.previousClick = 'nan';
		togglers.each(function(tog, i){
			$(tog).addEvent('click', function(){this.showThisHideOpen(i)}.bind(this));
		}, this);
		this.togglers = togglers;
		this.h = {}; this.w = {}; this.o = {};
		this.elements.each(function(el, i){
			this.now[i] = {};
			$(el).setStyles({'height': 0, 'overflow': 'hidden'});
		}, this);
		switch(this.options.start){
			case 'nothing': break;
			case 'first-open': this.elements[0].setStyle('height', this.elements[0].scrollHeight+this.options.unit); break;
			case 'open-first': this.showThisHideOpen(this.options.startIndex); break;
		}
	},

	hideThis: function(i){
		if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, 0]};
		if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, 0]};
		if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 1, 0]};
	},

	showThis: function(i){
		if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, this.options.fixedHeight || this.elements[i].scrollHeight]};
		if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, this.options.fixedWidth || this.elements[i].scrollWidth]};
		if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 0, 1]};
	},

	showThisHideOpen: function(iToShow){
		if (iToShow != this.previousClick || this.options.alwaysHide){
			this.previousClick = iToShow;
			var objObjs = {};
			var err = false;
			var madeInactive = false;
			this.elements.each(function(el, i){
				this.now[i] = this.now[i] || {};
				if (i != iToShow){
					this.hideThis(i);
				} else if (this.options.alwaysHide){
					if (el.offsetHeight == el.scrollHeight){
						this.hideThis(i);
						madeInactive = true;
					} else if (el.offsetHeight == 0){
						this.showThis(i);
					} else {
						err = true;
					}
				} else if (this.options.wait && this.timer){
					this.previousClick = 'nan';
					err = true;
				} else {
					this.showThis(i);
				}
				objObjs[i] = Object.extend(this.h, Object.extend(this.o, this.w));
			}, this);
			if (err) return;
			if (!madeInactive) this.options.onActive.call(this, this.togglers[iToShow], iToShow);
			this.togglers.each(function(tog, i){
				if (i != iToShow || madeInactive) this.options.onBackground.call(this, tog, i);
			}, this);
			return this.custom(objObjs);
		}
	}

});/*  Prototype JavaScript framework
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

//note: modified & stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
}

Object.extend = function(destination, source) {
	for (property in source) destination[property] = source[property];
	return destination;
}

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

Function.prototype.bindAsEventListener = function(object) {
var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;

	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}

if (!window.Element) var Element = new Object();

Object.extend(Element, {
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	hasClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var hasClass = false;
		element.className.split(' ').each(function(cn){
			if (cn == className) hasClass = true;
		});
		return hasClass;
	},

	addClassName: function(element, className) {
		element = $(element);
		Element.removeClassName(element, className);
		element.className += ' ' + className;
	},
  
	removeClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var newClassName = '';
		element.className.split(' ').each(function(cn, i){
			if (cn != className){
				if (i > 0) newClassName += ' ';
				newClassName += cn;
			}
		});
		element.className = newClassName;
	},

	cleanWhitespace: function(element) {
		element = $(element);
		$c(element.childNodes).each(function(node){
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node);
		});
	},

	find: function(element, what) {
		element = $(element)[what];
		while (element.nodeType != 1) element = element[what];
		return element;
	}
});

var Position = {
	cumulativeOffset: function(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
};

document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = [];
	$c(children).each(function(child){
		if (Element.hasClassName(child, className)) elements.push(child);
	});  
	return elements;
}



function $c(array){
	var nArray = [];
	for (var i=0;i<array.length;i++) nArray.push(array[i]);
	return nArray;
}

/*
moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
for more info (http://moofx.mad4milk.net).
Sunday, March 05, 2006
v 1.2.3
*/

var fx = new Object();
//base
fx.Base = function(){};
fx.Base.prototype = {
	setOptions: function(options) {
	this.options = {
		duration: 500,
		onComplete: '',
		transition: fx.sinoidal
	}
	Object.extend(this.options, options || {});
	},

	step: function() {
		var time  = (new Date).getTime();
		if (time >= this.options.duration+this.startTime) {
			this.now = this.to;
			clearInterval (this.timer);
			this.timer = null;
			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
		}
		else {
			var Tpos = (time - this.startTime) / (this.options.duration);
			this.now = this.options.transition(Tpos) * (this.to-this.from) + this.from;
		}
		this.increase();
	},

	custom: function(from, to) {
		if (this.timer != null) return;
		this.from = from;
		this.to = to;
		this.startTime = (new Date).getTime();
		this.timer = setInterval (this.step.bind(this), 13);
	},

	hide: function() {
		this.now = 0;
		this.increase();
	},

	clearTimer: function() {
		clearInterval(this.timer);
		this.timer = null;
	}
}

//stretchers
fx.Layout = Class.create();
fx.Layout.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.style.overflow = "hidden";
		this.iniWidth = this.el.offsetWidth;
		this.iniHeight = this.el.offsetHeight;
		this.setOptions(options);
	}
});

fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.height = this.now + "px";
	},

	toggle: function() {
		if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
		else this.custom(0, this.el.scrollHeight);
	}
});

fx.Width = Class.create();
Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.width = this.now + "px";
	},

	toggle: function(){
		if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0);
		else this.custom(0, this.iniWidth);
	}
});

//fader
fx.Opacity = Class.create();
fx.Opacity.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.now = 1;
		this.increase();
		this.setOptions(options);
	},

	increase: function() {
		if (this.now == 1 && (/Firefox/.test(navigator.userAgent))) this.now = 0.9999;
		this.setOpacity(this.now);
	},
	
	setOpacity: function(opacity) {
		if (opacity == 0 && this.el.style.visibility != "hidden") this.el.style.visibility = "hidden";
		else if (this.el.style.visibility != "visible") this.el.style.visibility = "visible";
		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + opacity*100 + ")";
		this.el.style.opacity = opacity;
	},

	toggle: function() {
		if (this.now > 0) this.custom(1, 0);
		else this.custom(0, 1);
	}
});

//transitions
fx.sinoidal = function(pos){
	return ((-Math.cos(pos*Math.PI)/2) + 0.5);
	//this transition is from script.aculo.us
}
fx.linear = function(pos){
	return pos;
}
fx.cubic = function(pos){
	return Math.pow(pos, 3);
}
fx.circ = function(pos){
	return Math.sqrt(pos);
}


//	Source edited from Lightbox v2.02
//	by Lokesh Dhakar - http://www.huddletogether.com

var fileLoadingImage = "./system/loading.gif";		
var fileBottomNavCloseImage = "./system/closelabel.gif";
var resizeSpeed = 6;	// controls the speed of the image resizing (1=slowest and 10=fastest)
var borderSize = 10;	//if you adjust the padding in the CSS, you will need to update this variable

var imageArray = new Array;
var activeImage;

if(resizeSpeed > 10){ resizeSpeed = 10;}
if(resizeSpeed < 1){ resizeSpeed = 1;}
resizeDuration = (11 - resizeSpeed) * 100;

Object.extend(Element, {
	hide: function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			element.style.display = 'none';
		}
	},
	show: function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			try{
				element.style.display = '';
			}catch(e){
				//alert('SHOW ERROR');
				//alert(objToString(element));
				//alert(e);
			}
		}
	},
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
		element.style.width = w +"px";
	},
	getHeight: function(element) {
		element = $(element);
		return element.offsetHeight;
	},
	setHeight: function(element,h) {
   		element = $(element);
		element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
		element.style.top = t +"px";
	},
	setSrc: function(element,src) {
		element = $(element);
		element.src = src; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});




var Lightbox = Class.create();
					
Lightbox.prototype = {

	initialize: function() {
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');

		this.LBID = (typeof(STACKS['LBID']) != 'undefined')? STACKS['LBID']: 0;

		// YOU ALWAYS GRAB THE SURFACE VIEW OF THE LANDING PAGE...
		// YOU CAN'T GRAB THE SURFACE VIEW OTHERWISE YOU LOSE THE ORIENTATION WITH THE 
		// YOU ONLY REINJECT NEW PAGE NODES IF WE GO DEEP INTO THE WINDOW STRUCTURES...

		// THIS IS TOTALLY WRONG...

		
		if(typeof(JSN) == 'object'){
			this.loadJSN = true;
		}else{
			// loop through all anchor tags
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				var relAttribute = String(anchor.getAttribute('rel')).toLowerCase();
				// use the string.match() method to catch 'lightbox' references in the rel attribute
				if (anchor.getAttribute('rev')){
					if(relAttribute.match('lightbox')){
						anchor.onclick = function () {myLightbox.start(this,'src'); return false;}
					}else if(relAttribute.match('jumpbox')){
						//anchor.onclick = function () {myLightbox.start(this,'href'); return false;}
					}
				}
			}
		}

		var objBody = document.getElementsByTagName("body").item(0);

		// ALL THESE ITEMS CAN ONLY BE CREATED ONE TIME
		// FOR NOW I JUST RE-INIT
		// ALL THESE ITEMS CAN ONLY BE CREATED ONE TIME
		// FOR NOW I JUST RE-INIT


		try{
			obj = document.getElementById("overlay");
			document.body.removeChild(obj);
		}catch(e){}

		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.onclick = function() { myLightbox.end(); return false; }
		objBody.appendChild(objOverlay);

		try{
			obj = document.getElementById("lightbox");
			document.body.removeChild(obj);
		}catch(e){}

		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objBody.appendChild(objLightbox);

		try{
			obj = document.getElementById("lightboxFloater");
			document.body.removeChild(obj);
		}catch(e){}

		var objLightboxFloater = document.createElement("div");
		objLightboxFloater.setAttribute('id','lightboxFloater');
		objLightbox.appendChild(objLightboxFloater);

		try{
			obj = document.getElementById("outerImageContainer");
			document.body.removeChild(obj);
		}catch(e){}

		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightboxFloater.appendChild(objOuterImageContainer);

		try{
			obj = document.getElementById("imageContainer");
			document.body.removeChild(obj);
		}catch(e){}

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);

		try{
			obj = document.getElementById("descRightContainer");
			document.body.removeChild(obj);
		}catch(e){}

		var descRightContainer = document.createElement("div");
		descRightContainer.setAttribute('id','descRightContainer');
		objImageContainer.appendChild(descRightContainer);

		try{
			obj = document.getElementById("pageContainer");
			document.body.removeChild(obj);
		}catch(e){}

		var objPageContainer = document.createElement("div");
		objPageContainer.setAttribute('id','pageContainer');
		objOuterImageContainer.appendChild(objPageContainer);		

		try{
			obj = document.getElementById("pageContainerSlug");
			document.body.removeChild(obj);
		}catch(e){}

		var objPageContainerSlug = document.createElement("div");
		objPageContainerSlug.setAttribute('id','pageContainerSlug');
		objPageContainer.appendChild(objPageContainerSlug);			

		try{
			obj = document.getElementById("lightboxImage");
			document.body.removeChild(obj);
		}catch(e){}

		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);

		try{
			obj = document.getElementById("hoverNav");
			document.body.removeChild(obj);
		}catch(e){}
	
		var objHoverNav = document.createElement("div");
		objHoverNav.setAttribute('id','hoverNav');
		objImageContainer.appendChild(objHoverNav);

		try{
			obj = document.getElementById("prevLink");
			document.body.removeChild(obj);
		}catch(e){}

		var objPrevLink = document.createElement("a");
		objPrevLink.setAttribute('id','prevLink');
		objPrevLink.setAttribute('href','#');
		objHoverNav.appendChild(objPrevLink);

		try{
			obj = document.getElementById("nextLink");
			document.body.removeChild(obj);
		}catch(e){}
		
		var objNextLink = document.createElement("a");
		objNextLink.setAttribute('id','nextLink');
		objNextLink.setAttribute('href','#');
		objHoverNav.appendChild(objNextLink);

		try{
			obj = document.getElementById("loading");
			document.body.removeChild(obj);
		}catch(e){}
	
		var objLoading = document.createElement("div");
		objLoading.setAttribute('id','loading');
		objOuterImageContainer.appendChild(objLoading);

		try{
			obj = document.getElementById("loadingLink");
			document.body.removeChild(obj);
		}catch(e){}

		var objLoadingLink = document.createElement("a");
		objLoadingLink.setAttribute('id','loadingLink');
		objLoadingLink.setAttribute('href','#');
		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
		objLoading.appendChild(objLoadingLink);
	
		var objLoadingImage = document.createElement("img");
		objLoadingImage.setAttribute('src', fileLoadingImage);
		objLoadingLink.appendChild(objLoadingImage);

		try{
			obj = document.getElementById("imageDataContainer");
			document.body.removeChild(obj);
		}catch(e){}

		var objImageDataContainer = document.createElement("div");
		objImageDataContainer.setAttribute('id','imageDataContainer');
		objImageDataContainer.className = 'clearfix';
		objLightboxFloater.appendChild(objImageDataContainer);

		try{
			obj = document.getElementById("imageData");
			document.body.removeChild(obj);
		}catch(e){}

		var objImageData = document.createElement("div");
		objImageData.setAttribute('id','imageData');
		objImageDataContainer.appendChild(objImageData);

		try{
			obj = document.getElementById("imageDetails");
			document.body.removeChild(obj);
		}catch(e){}
	
		var objImageDetails = document.createElement("div");
		objImageDetails.setAttribute('id','imageDetails');
		objImageData.appendChild(objImageDetails);
	
		this.objImageDetails = objImageDetails;

		try{
			obj = document.getElementById("caption");
			document.body.removeChild(obj);
		}catch(e){}
	
		var objCaption = document.createElement("span");
		objCaption.setAttribute('id','caption');
		objImageDetails.appendChild(objCaption);

		this.objCaption = objCaption;

		try{
			obj = document.getElementById("numberDisplay");
			document.body.removeChild(obj);
		}catch(e){}
	
		var objNumberDisplay = document.createElement("span");
		objNumberDisplay.setAttribute('id','numberDisplay');
		objImageDetails.appendChild(objNumberDisplay);

		try{
			obj = document.getElementById("bottomNav");
			document.body.removeChild(obj);
		}catch(e){}

		var objBottomNav = document.createElement("div");
		objBottomNav.setAttribute('id','bottomNav');
		objImageData.appendChild(objBottomNav);

		try{
			obj = document.getElementById("bottomNavClose");
			document.body.removeChild(obj);
		}catch(e){}

		var objBottomNavCloseLink = document.createElement("a");
		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
		objBottomNavCloseLink.setAttribute('href','#');
		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
		objBottomNav.appendChild(objBottomNavCloseLink);
		
		overlayEffect = new fx.Opacity(objOverlay, { duration: 300 });
		overlayEffect.hide();
		
		overlayEffectPage	= new fx.Opacity(objPageContainer, { duration: 900 });
		overlayEffectPage.hide();

		imageDescEffect = new fx.Opacity(descRightContainer, { duration: 350, onComplete: function() {}});
		imageDescEffect.hide();
		
		imageEffect = new fx.Opacity(objLightboxImage, { duration: 350, onComplete: function() { imageDetailsEffect.custom(0,1); }});
		imageEffect.hide();
		
		imageDetailsEffect = new fx.Opacity('imageDataContainer', { duration: 400, onComplete: function() { navEffect.custom(0,1); }}); 
		imageDetailsEffect.hide();
		
		navEffect = new fx.Opacity('hoverNav', { duration: 100 });
		navEffect.hide();
	},

	// this entire function has to be reworked to acomodate normal div elements...
	// where are we getting our dimensions from???
	// essentially... everything passed into this box will mix the lightbox initialization phase...
	// so...
	// we need special hooks... either that or we need to reinitialize the lightbox on each load and we cn do that through the requestController...
	// we will know our next previous due to the initialization process... so there will be no problems there...


	start: function(imageLink,version,c,p) {	

		if(myLightbox.is_open){
			getPane(imageLink,1,c,p);
			return;
		}

		hideSelectBoxes();
		var arrayPageSize = getPageSize();
		Element.setHeight('overlay', arrayPageSize[1]);
		overlayEffectPage.custom(0,0);
		overlayEffectPage.transition = 0;
		overlayEffect.custom(0,0.8);
		imageArray = [];
		imageNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');
		if(this.loadJSN){
			Element.hide('imageContainer');
			// find the node... we need the variables passed through onclick to reference the categories...
			imageArray.push(new Array(imageLink.getAttribute('rev'), imageLink.getAttribute('title') , 'href' , c , p));		
		}else if((imageLink.getAttribute('rel') == 'lightbox')){
			imageArray.push(new Array(imageLink.getAttribute('rev'), imageLink.getAttribute('title')));			
		}else{
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('rev') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
					imageArray.push(new Array(anchor.getAttribute('rev'), anchor.getAttribute('title'), version));
				}
			}
			for(i = 1; i < imageArray.length; i++){
				if(imageArray[i][0] == imageArray[i-1][0]){
					imageArray.splice(i,1);
				}
			}
			while(imageArray[imageNum][0] != imageLink.getAttribute('rev')) { imageNum++;}
		}

		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);

		//Element.setTop('lightbox', lightboxTop); // -------------------------------------------------------------------------------- SET TOP !!!!!!!!!!!!!!
		Element.show('lightbox');

		// maybe you've gone too deep... I mean... why are you cahnging the image if it's already loaded...
		this.changeImage(imageNum);
	},


	hideElements: function(){
		overlayEffectPage.custom(1,0);
		overlayEffectPage.transition = 1;
	},


	changeImage: function(imageNum) {
		activeImage = imageNum;	// update global var
		Element.hide('lightboxImage');
		imageDescEffect.hide();
		
		Element.show('loading');
		imageDetailsEffect.hide();
		imageEffect.hide();
		navEffect.hide();
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('numberDisplay');

		mode = imageArray[activeImage][2];

		if(mode == 'href'){
			if(PANES.i != 'home'){ // this is set to the PAGE=HOME variable...
				hidePane(PANES.i);				
			}
			myLightbox.resizeImageContainer(600,400,imageArray[activeImage][2]);
			getPane(imageArray[activeImage][0],1,imageArray[activeImage][3],imageArray[activeImage][4]);
		}else{
			imgPreloader = new Image();
			imgPreloader.onload=function(){

				Element.setSrc('lightboxImage', imageArray[activeImage][0]);
				resizeMode = 0;
				if(typeof(STACKS["LBPR"]) != 'undefined'){
					resizeMode = STACKS["LBPR"];
				}
				
				// IMAGE RESIZING MODES...
				var spaceCaptionBottom = (this.LBID == 1 || this.LBID == 2)? 350: 150;
				var maxHeightWin = getViewportHeight() - spaceCaptionBottom;
				var maxHeightImg = imgPreloader.height;
				
				if(maxHeightImg > maxHeightWin){
					framedHeight = maxHeightWin;
					var ratio = framedHeight / maxHeightImg;
					framedWidth = (ratio < 1)? parseInt(imgPreloader.width * ratio): imgPreloader.width;
					//if(!resizeMode){
						Element.setHeight('lightboxImage', framedHeight);
						Element.setWidth('lightboxImage', framedWidth);
					//}
				}else{
					framedHeight = maxHeightImg;
					framedWidth = imgPreloader.width;
					//if(!resizeMode){
						Element.setHeight('lightboxImage', framedHeight);
						Element.setWidth('lightboxImage', framedWidth);
					//}
				}

				myLightbox.resizeImageContainer(framedWidth, framedHeight);
			}
			imgPreloader.src = imageArray[activeImage][0];
		}
	},

	resizeImageContainer: function( imgWidth, imgHeight, page) {

		this.resizeImageContainerFLAG = 1;
		this.wCur = Element.getWidth('outerImageContainer');
		this.hCur = Element.getHeight('outerImageContainer');
		var spaceCaptionRight = (this.LBID == 3 || this.LBID == 4)? 250: 0;

		wDiff = (this.wCur - borderSize * 2) - imgWidth;
		hDiff = (this.hCur - borderSize * 2) - imgHeight;
		reHeight = new fx.Height('outerImageContainer', { duration: resizeDuration });
		reHeight.custom(Element.getHeight('outerImageContainer'),imgHeight+(borderSize*2)); 
		reWidth = new fx.Width('outerImageContainer', { duration: resizeDuration, onComplete: function() { imageEffect.custom(0,1);imageDescEffect.custom(0,1);myLightbox.resizeImageContainerFLAG =0; }});
		reWidth.custom(Element.getWidth('outerImageContainer'),imgWidth+(borderSize*2)+spaceCaptionRight);

		if((hDiff == 0) && (wDiff == 0)){
			if (navigator.appVersion.indexOf("MSIE")!=-1){ dopause(250); } else { dopause(100);} 
		}

		if(typeof(page) !== 'undefined' && page == 'href'){
			Element.setHeight('pageContainer', imgHeight);
		}

		Element.setHeight('prevLink', imgHeight);
		Element.setHeight('nextLink', imgHeight);		
		Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2) + spaceCaptionRight);
		Element.setWidth( 'hoverNav', imgWidth + (borderSize * 2));

		if(typeof(page) !== 'undefined'){
			//this.showPage();
		}else{
			this.showImage();
		}
	},

	// sometimes we are firing the lightbox before it has a chance to finsih it's transition.... we need safty locks to block repetitive calls...

	showPage: function(){
		myLightbox.is_open = true;
		
		if(!myLightbox.resizeImageContainerFLAG){
			if(PANES.hook == 1 && overlayEffectPage.transition == 1){
				//alert('transition is active...');
				overlayEffectPage.transition = 0;
				setTimeout("myLightbox.showPage();",1000);
				return;
			}
			Element.hide('loading');
			Element.show('lightboxImage');
			Element.show('caption');
			overlayEffectPage.custom(0,1);
			PANES[PANES.i].style.display = 'block';
			PANES[PANES.i].style.overflow = 'hidden';
			PANES['containers'][1].scrollTop = '0';
		}else{
			setTimeout("myLightbox.showPage();",1000);
			return;
		}
		var clone = PANES[PANES.i].cloneNode(true);
		PANES['containers'][PANES.hook].replaceChild(clone,PANES['containers'][PANES.hook].firstChild);
		PANES[PANES.i].style.display = 'none';
		if(this.loadJSN){
			var c = PANES.c;
			this.objCaption.innerHTML = '';
			if(typeof(JSN[PANES.c]) !== 'undefined'){
				var l = JSN[PANES.c].length;			
				for(x in JSN[c]){	
					var anchor = document.createElement("A");
					anchor.setAttribute('href',JST[x][1]);
					var sect = ('page_id='+x).toString();		
					anchor.setAttribute('rev',sect);
					anchor.setAttribute('rel','jumpbox[catalogue]');				
					anchor.onclick = function(){getPane(this.rev,1,c,x);return false;}				
					anchor.innerHTML = JST[x][0];
					this.objCaption.appendChild(anchor);
				}
			}else{ // happens with a single page node...
				//alert('defined');
			}
		}
	},

	updatePageDetails: function(){

	},
	
	showImage: function(){
		Element.hide('loading');
		Element.show('lightboxImage');
		myLightbox.updateDetails(); 
		this.preloadNeighborImages();
	},

	updateDetails: function() {

		Element.show('caption');
		var str = '';

		if(!this.LBID){
			str += imageArray[activeImage][1];
			Element.setInnerHTML( 'caption', str);
			Element.hide('descRightContainer');	
		}else if(this.LBID == 1 || this.LBID == 2){
			str += imageArray[activeImage][1];
			try{
				var desc = STACKS["LBD"][imageArray[activeImage][0]].toString();
				str += '<br>' + desc.replace(/&quot;/g, '"');
			}catch(e){distro_error("LBD"+e);}
			Element.setInnerHTML( 'caption', str);
			Element.hide('descRightContainer');	
		}else if(this.LBID == 3 || this.LBID == 4){
			Element.setInnerHTML( 'caption', str);
			str += imageArray[activeImage][1];
			try{
				var desc = STACKS["LBD"][imageArray[activeImage][0]].toString();
				str += '<br><br>' + desc.replace(/&quot;/g, '"');
			}catch(e){distro_error("LBD"+e);}		
			Element.setWidth('descRightContainer',225);
			Element.setInnerHTML( 'descRightContainer', str);
			Element.show('descRightContainer');	
		}
		
		if(imageArray.length > 1){
			Element.show('numberDisplay');
			Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length);
		}

		myLightbox.updateNav();
	},

	updateNav: function() {

		if(activeImage != 0){
			Element.show('prevLink');
			document.getElementById('prevLink').onclick = function() {
				myLightbox.changeImage(activeImage - 1); return false;
			}
		}

		if(activeImage != (imageArray.length - 1)){
			Element.show('nextLink');
			document.getElementById('nextLink').onclick = function() {
				myLightbox.changeImage(activeImage + 1); return false;
			}
		}
		
		//this.enableKeyboardNav();
	},

	EnableKeyboardNav: function() {
		document.onkeydown = this.keyboardAction; 
	},

	disableKeyboardNav: function() {
		document.onkeydown = '';
	},

	keyboardAction: function(e) {
		if (e == null) { // ie
			keycode = event.keyCode;
		} else { // mozilla
			keycode = e.which;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c')){	// close lightbox
			myLightbox.end();
		} else if(key == 'p'){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if(key == 'n'){	// display next image
			if(activeImage != (imageArray.length - 1)){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage + 1);
			}
		}
	},

	preloadNeighborImages: function(){

		if((imageArray.length - 1) > activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = imageArray[activeImage + 1][0];
		}
		if(activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = imageArray[activeImage - 1][0];
		}
	
	},

	end: function() {
		myLightbox.is_open = false;
		this.disableKeyboardNav();
		Element.hide('lightbox');
		Element.hide('caption');
		imageDescEffect.toggle();
		imageEffect.toggle();
		overlayEffect.custom(0.8,0);
		overlayEffectPage.custom(1,0);
		showSelectBoxes();
	}
}

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;

	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
		yScroll = document.body.clientHeight;

	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	//alert('yScroll'+yScroll);
	//alert('windowHeight'+windowHeight);
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}


	//alert('pageHeight'+pageHeight);

	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){
	}
}

function listenKey () {	document.onkeypress = getKey; }

// LOOKS LIKE IE WILL NOT SET THE SELECTED OPTION IF THE SELECT BOX IS NOT ON SCREEN>>>> A CARRY OVER FROM TH LAME MISTAKE BACK IN IE 6... ( STILL NOT FIXED EITHER )

function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	var l = selects.length;
	for(i = 0; i != selects.length; i++){
		try{selects[i].style.visibility = "visible";}catch(e){break;}
	}
}

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}


function dopause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}


function initLightbox() { myLightbox = new Lightbox(); }var cssdropdown={aa:250,ab:false,ac:1,dmo:null,ie:document.all,ff:document.getElementById&&!document.all,st:undefined,bc:0,g:function(w,ot){var to=(ot=="left")?w.offsetLeft:w.offsetTop;
var p=w.offsetParent;return to=(ot=="left")? to+p.offsetLeft:to+p.offsetTop;},se:function(){if(this.bc<parseInt(this.dmo.offsetHeight)){this.bc+=10+(this.bc/10);
this.dmo.style.clip="rect(0 auto "+this.bc+"px 0)";}else{return;
}this.st=setTimeout("cssdropdown.se()",10);},sh:function(obj,e){if(this.ie||this.ff){this.dmo.style.left=this.dmo.style.top="-500px"}
if(e.type=="click"&&obj.visibility==hidden||e.type=="mouseover"){if(this.ac==1){if(typeof this.st!="undefined"){clearTimeout(this.st);}obj.clip="rect(0 auto 0 0)";
this.bc=0;this.se();}obj.visibility="visible";
}else if(e.type=="click"){obj.visibility="hidden";
}else if(e.type=="focus"){obj.visibility="visible";
}},iec:function(){return(document.cm&&document.cm!="BackCompat")?document.documentElement:document.body;
},ce:function(obj,w){var ed=0;
if(w=="rightedge"){var we=this.ie&&!window.opera?this.iec().scrollLeft+this.iec().clientWidth-15:window.pageXOffset+window.innerWidth-15;
this.dmo.cm=this.dmo.offsetWidth;
if (we-this.dmo.x < this.dmo.cm){ed=this.dmo.cm-obj.offsetWidth;
}}else{var te=this.ie && !window.opera? this.iec().scrollTop:window.pageYOffset;
var we=this.ie && !window.opera? this.iec().scrollTop+this.iec().clientHeight-15:window.pageYOffset+window.innerHeight-18;
this.dmo.cm=this.dmo.offsetHeight;
if (we-this.dmo.y < this.dmo.cm){ed=this.dmo.cm+obj.offsetHeight;
if((this.dmo.y-te)<this.dmo.cm);
ed=this.dmo.y+obj.offsetHeight-te;
}}return ed;
},di:function(obj,e,did){if(this.dmo!=null){this.dmo.style.visibility="hidden";
}this.ch();
if(this.ie||this.ff){obj.onmouseout=function(){cssdropdown.dhm()};

this.dmo=document.getElementById(did);
obj.onmousedown=function(){setTimeout("cssdropdown.dmo.style.visibility='hidden';",50);return !cssdropdown.ab;};

this.dmo.onmouseover=function(){cssdropdown.ch()};
this.dmo.onmouseout=function(e){cssdropdown.dh(e)};
this.dmo.onclick=function(){cssdropdown.dhm()};
this.sh(this.dmo.style, e);
this.dmo.x=this.g(obj.parentNode,"left");
this.dmo.y=(typeof DDMFIXEDOFFSETHEIGHT == "undefined")?this.g(obj,"top"):this.g(obj.parentNode.parentNode,"top");
this.dmo.style.left=this.dmo.x-this.ce(obj,"rightedge")+"px";
var chromemenuT = document.getElementById("chromemenu");
var bottomEdgeTest = this.ce(obj,"bottomedge");
var topPos = (typeof DDMFIXEDTOP == "undefined")? chromemenuT.offsetTop:DDMFIXEDTOP;
var offSetHeight = (typeof DDMFIXEDOFFSETHEIGHT == "undefined")? obj.offsetHeight: DDMFIXEDOFFSETHEIGHT;
this.dmo.style.top=topPos+obj.offsetTop+offSetHeight+1+"px";
/* PUT BOTTOM TEST <--- BACK FOR SNAP TO TOP if(bottomEdgeTest != 0){this.dmo.style.left = parseInt(this.dmo.style.left) + 150 + "px";}*/
}},cff:function(a,b){while(b.parentNode){if((b=b.parentNode)==a){return true;
}}return false;
},dh:function(e){var evtobj=window.event?window.event:e;
if(this.ie&&!this.dmo.contains(evtobj.toElement)){this.dhm();
}else if (this.ff&&e.currentTarget!= evtobj.relatedTarget&& !this.cff(evtobj.currentTarget,evtobj.relatedTarget)){this.dhm();
}},dhm:function(){this.delayhide=setTimeout("cssdropdown.dmo.style.visibility='hidden';",this.aa);
},ch:function(){if (this.delayhide!="undefined"){clearTimeout(this.delayhide);
}},startchrome:function(){for(var ids=0;
ids<arguments.length;
ids++){var mi=document.getElementById(arguments[ids]).getElementsByTagName("a");
for(var i=0;i<mi.length; i++){if(mi[i].getAttribute("rel")){
mi[i].onfocus=function(e){var event=typeof e!="undefined"?e:window.event;
cssdropdown.di(this,event,this.getAttribute("rel"));
}
mi[i].onmouseover=function(e){var event=typeof e!="undefined"?e:window.event;
cssdropdown.di(this,event,this.getAttribute("rel"));
}}}}}};


function ddmsClick(obj){
	var con = obj.parentNode.parentNode;
	var opts = con.childNodes[1];
	opts.style.display = (opts.style.display == 'block') ? 'none':'block';
}

function ddmsCC(obj){
	var con = obj.parentNode.parentNode;
	var opts = con.childNodes[1];
	var choice = con.childNodes[0].childNodes[0];
	var hidden = con.childNodes[0].childNodes[2];

	opts.style.display = 'none';

	choice.innerHTML = obj.innerHTML;
	choice.value = obj.value;
	hidden.value = obj.value;
}












var INP_BORDER_NORMAL = "solid 2px #CCC";var INP_BORDER_ERROR = "solid 2px #F00";var INP_BACKGROUND_NORMAL = "#fff";var INP_BACKGROUND_ERROR = "#BFD3E6";var IS_DISTRO = false;function inpblur(o){o.style.background=INP_BACKGROUND_NORMAL;}function inpfocus(o){o.style.background=INP_BACKGROUND_ERROR;}
