/*
 * savvy.js (v0.1.1.1)
 * 27.04.2007
 * Cryno Bone http://www.chronosight.net/
 ***************************************************
 * References:
 * 1. ImageBOX object take some logic from Lightbox JS
 * 2. $pick() function taken directly from Mootools Framework
 * 3. Draggable and Resizer object taken with modification from dom-drag.js by www.youngpup.net
 * 4. DOM.addAfter() function taken from Dustin Diaz's Top 10 JavaScript Functions at <http://www.dustindiaz.com/top-ten-javascript/>
 * 5. Few prototype function taken from <http://www.hunlock.com/blogs/Ten_Javascript_Tools_Everyone_Should_Have> and <http://20bits.com/2007/03/08/the-philosophy-of-javascript/>
 * 6. Cal object based from The Strange Zen of JavaScript's How to build a simple calendar with JavaScript <http://jszen.blogspot.com/2007/03/how-to-build-simple-calendar-with.html>
*/
var Savvy = {
	version:"0.1.1.1",
	log:function(v) {
		try { 
			console.log(v); 
		} catch(e) { 
			alert(v); 
		}
	},
	href:function(u) {
		window.location.href = u;
	},
	browser:function() {
		return function() {
			var win = new Object;
			win.ie = win[window.XMLHttpRequest ? "ie7" : "ie6"] = (window.ActiveXObject ? true : false);
			win.khtml = ((document.childNodes && !document.all && !navigator.taintEnabled) ? true : false);
			win.gecko = (document.getBoxObjectFor != null ? true : false);
			win.opera = (window.opera ? true : false);
			return win;
		}();
	}()
};

Object.prototype.extend = function(params) {
	function F() {};
	F.prototype = this;
	var o = new F();
	for (key in params) 
		o[key] = params[key];
	return o;
};
Array.prototype.inArray = function(v){
	for (var i=0; i<this.length; i++) {
		if(this[i] === v) 
			return true;
	}
	return false;
};
Array.prototype.find = function(v) {
	var r = false;
	for(var i=0; i<this.length; i++) {
		if(typeof(v) == "function") {
			if(v.test(this[i])) {
				if(!r) 
					r = [];
				r.push(i);
			}
		} else {
			if (this[i]===v) {
				if (!r) 
					r = [];
				r.push(i);
			}
		}
	}
	return r;
};

Array.prototype.map = function(f) {
	var r=[];
	for(var i=0; i<this.length; i++)
		r.push(f(this[i]));
	return r;
};
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
};
String.prototype.ltrim = function() {
	return this.replace(/^\s+/g,"");
};
String.prototype.rtrim = function() {
	return this.replace(/\s+$/g,"");
};
String.prototype.striptags = function() {
	return this.replace(/<([^>]+)>/g,"");
};
String.prototype.htmlentities = function () {
	return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
};
String.prototype.toNumber = function () {
	return parseInt(this,10);
};
Number.prototype.toNumber = function() {
	return this;
};
function $(el) {
	var __o;
	var args = arguments;
	if(args.length === 1 && !$null(args[0])) { 
		var iel = args[0].split(" ");
		__o = document.getElementById(iel[0]);
		for(var i = 1;i < iel.length; i++)
			__o = $(__o,iel[i]);
	} else if(args.length === 2 && !$null(args[1])) {
		try {
			__o = args[0].getElementById(args[1]); 
		} catch(e) { 
			__o = document.getElementById(args[1]); 
		}
	} else return false;
	return __o;
};

function $T(el) {
	var __o, elm ="";
	var args = arguments;
	var rXi = new RegExp(/>/);
	function hClass(obj,v,i) {
		var __o = v.trim().split(".");
		
		var rXc = new RegExp(/\./);
		try {
			o = obj.getElementsByTagName(__o[0].trim());
		} catch(e) {
			o = document.getElementsByTagName(__o[0].trim());
		}
		if(rXc.test(v)) {
			var __c = new Array();
			for(var i=0;i<o.length;i++) {
				var c = o[i];
				var cA = c.className.split(" ");
				if(cA.inArray(__o[1].trim())) {
					if(__c.length === 0) 
						__c[0] = c;
					else 
						__c.push(c);
				}
			}
			return __c;
		} else {
			return o;
		}
	};
	if(args.length === 2) {
		__o = hClass(args[0],args[1]);
	} else if(args.length === 1) {
		if(rXi.test(el)) {
			var obj = el.trim().split(">");
			var o = obj[0].trim();
			elm = obj[1].trim();
			var iel = elm.split(" ");
			__o = $(o);
			__o = hClass(__o,iel[0].trim());
			for(var i = 1;i < iel.length; i++) {
				__o = hClass(__o,iel[i].trim());
			}
		} else {
			var iel = el.trim().split(" ");
			__o = document;
			__o = hClass(__o,iel[0].trim());
			for(var ii = 1;ii < iel.length;ii++) {
				__o = hClass(__o,iel[ii].trim());
			}
		} 
	}
	return __o;
};

function $A(el) {
	var r = false;
	var args = arguments;
	if(args.length === 2) {
		if(!$null(args[0])) {
			try { 
				r = args[0].createElement(args[1]); 
			} catch(e) { 
				r = document.createElement(args[1]); 
			}
		} else 
			r = document.createElement(args[1]);
	} else if(!$null(el)) 
		r = document.createElement(el);
	return r;
};

function $null(obj) {
	return (typeof(obj) == "undefined" || obj == null); 
};

function $pick(choose,option) {
	return (!$null(choose) ? choose : option);
};

function $bind(obj,el,r) {
	var r = (!$null(r) ? r : "element");
	if(!$null(obj) && !$null(el)) {
		if($$.get(obj,"id") == el) 
			return (r == "obj" ? obj : el);
		else 
			return false;
	} else if (!$null(el)) 
		return (r == "obj" ? $(el) : el);
	else if (!$null(obj)) 
		return (r == "obj" ? obj : $$.get(obj,"id"));
	else 
		return false;
};

var $$ = {
	get:function(o,a) {
		if(!$null(o)) 
			return o.getAttribute(a);
		else 
			return false;
	},
	set:function(o,a,v) {
		if(!$null(o)) {
			o.setAttribute(a,v);
			return true;
		} else 
			return false;
	},
	remove:function(o,a) {
		if(!$null(o)) {
			o.removeAttribute(a);
			return true;
		} else 
			return false;
	}	
};

var $$$ = {
	add:function(o,a) {
		if(!$null(o.className) && o.className.trim() != "") {
			o.className = o.className+" "+a;
			return true;
		} else if($null(o.className) || o.className.trim() == "") {
			o.className = a;
			return true;
		} else 
			return false;
	},
	remove:function(o,a) {
		if(!$null(o.className) && Replacer.trim(o.className) != "") {
			var arry = o.className.split(" ");
			o.className = "";
			for(var i=0;i<arry.length;i++) {
				if(arry[i] != a) 
					o.className = o.className+" "+a;
			}
		}
	},
	clear:function(o,a) {
		if(!$null(o.className) && o.className.trim() != "") {
			o.className = "";
		} else 
			$$.set(o,"class","");
	},
	has:function(o,a) {
		if(!$null(o.className) && o.className.trim() != "") {
			var arry = o.className.split(" ");
			return arry.inArray(a);
		}
	}
};

var DOM = {
	add:function(p,c) {
		if(!$null(p) && !$null(c)) {
			p.appendChild(c);
			return true;
		} else {
			try { document.body.appendChild(p); }
			catch(e) { return false; }
		}
	},
	addText:function(p,t) {
		if(!$null(p) && t != "") return this.add(p,document.createTextNode(t));
		else return false;
	},
	addBefore:function(params) {
		var args = arguments;
		if(args.length == 3 && !$null(args[0]) && !$null(args[1]) && !$null(args[2])) {
			arguments[0].insertBefore(args[1],args[2]);
			return true;
		} else if(args.length == 2 && !$null(args[0]) && !$null(args[1])) {
			args[1].parentNode.insertBefore(args[0],args[1]);
			return true;
		} else return false;
	},
	addAfter:function(params) {
		var args = arguments;
		if(!$null(r.nextSibling)) {
			if(args.length == 3 && !$null(args[0]) && !$null(args[1]) && !$null(args[2])) {
				this.addBefore(args[0],args[1],args[2].nextSibling);
				return true;
			} else {
				try {
					this.addBefore(args[0],args[1].nextSibling);
					return true;
				} catch(e) { return false; }
			}
		} else return this.add(p,c);
	},
	remove:function(params) {
		var args = arguments;
		if(args.length === 2 && !$null(args[0]) && !$null(args[1])) {
			args[0].removeChild(args[1]);
			return true;
		} else
			args[0].parentNode.removeChild(args[0]);
	},
	change:function(params) {
		var args = arguments;
		if(args.length == 3 && !$null(args[0]) && !$null(args[1]) && !$null(args[2]))
			args[0].replaceChild(args[1],args[2]);
		else
			args[1].parentNode.replaceChild(args[0],args[1]);
	},
	empty:function(p) {
		if(!$null(p)) {
			if(p.hasChildNodes || p.innerHTML != "") p.innerHTML = "";
			return true;
		} else return false;
	}
};

var CSS = {
	styler:function(__) {
		var o = __.obj;
		var cT = new Array();
		cT = __.css;
		for(var i = 0;i < cT.length; i++) {
			for(var inst in cT[i]) {
				if(cT[i].hasOwnProperty(inst)) { this.set(o,inst,cT[i][inst]); }
			}
		}
	},
	set:function(o,a,v) {
		try { 
			o.style[a] = v;
			return true;
		} catch(e) { return false; }
	},
	get:function(o,a) {
		if(!$null(o.style[a])) return o.style[a];
		else return false;
	},
	png:function(__) {
		var o = $bind(__.obj,__.element,"obj");
		__.gecko = $pick(__.gecko,"");
		__.ie = $pick(__.ie,"scale");
		if(window.ActiveXObject) {
			this.set(o,"filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+__.uri+"',sizingMethod='"+__.ie+"')");
		} else {
			this.set(o,"background","url('"+__.uri+"') "+__.gecko);
		}
	}
};

var Opacity = {
	step:new Array(),speed:new Array(),istart:new Array(),iend:new Array(),ifunc:new Array(),interval:new Array(),
	init:function(__) {
		var elm = $bind(__.obj,__.element);
		__.delay = (__.delay && __.delay > 0 ? __.delay : 1);
		this.step[elm] = 1;
		this.istart[elm] = __.start;
		this.iend[elm] = __.end;
		this.ifunc[elm] = $pick(__.oncomplete,null);
		this.speed[elm] = (__.speed && __.speed > 0 ? __.speed : 1);
		if(__.start > __.end) {
			this.fadeout(elm);
			this.interval[elm] = setInterval("Opacity.fadeout('"+elm+"')",__.delay);
		} else if(__.start < __.end) { 
			this.fadein(elm);
			this.interval[elm] = setInterval("Opacity.fadein('"+elm+"')",__.delay);
		}
	},
	set: function(g,v) {
		v = (v > 100 ? 100 : (v < 0 ? 0 : v));
		try {
			var o = $(g);
			if(v == 0 && CSS.get(o,"visibility") != "hidden") CSS.set(o,"visibility","hidden");
			else if(v > 0 && CSS.get(o,"visibility") != "visible") CSS.set(o,"visibility","visible");
			if (window.ActiveXObject) {
				if (!o.currentStyle || !o.currentStyle.hasLayout) CSS.set(o,"zoom",1);
				try { o.filters.item("DXImageTransform.Microsoft.Alpha").opacity = v; }
				catch (e) { CSS.set(o,"filter","alpha(opacity="+v+")"); }
			} else {
				CSS.set(o,"opacity",(v/100));
				CSS.set(o,"MozOpacity",(v/100));
			}
		} catch(e) { }
	},
	fadein: function(g) {
		var f = this.step[g]++, s = this.istart[g], e = this.iend[g];
		f = (f*this.speed[g]);
		s = Math.round(s+f);
		if(s < e) this.set(g,s);
		else {
			this.set(g,e);
			var f = this.ifunc[g];
			if(f != null && typeof(f) == "string") eval(f);
			else if(f != null && typeof(f) == "function") f();
			clearInterval(this.interval[g]);
			this.interval[g] = null;
		}
		this.istart[g] = s;
	},
	fadeout: function(g) {
		var f = this.step[g]++, s = this.istart[g], e = this.iend[g];
		f = (f*this.speed[g]);
		s = Math.round(s-f);
		if(s>e) Opacity.set(g,s);
		else {
			this.set(g,e);
			var f = this.ifunc[g];
			if(f != null && typeof(f) == "string") eval(f);
			else if(f != null && typeof(f) == "function") f();
			clearInterval(this.interval[g]);
			this.interval[g] = null;
		}
		this.istart[g] = s;
	},
	power:function(s,e,st) {
		var dif = (Math.abs(s-e) - 1);
		var step = 1;
		for(var i = 1; i < st; i++) step += i;
		if(dif>step) return true;
		else return false;			
	}
};

var Test = {
	string:function(v) {
		return (typeof(v) == "string" && v != "" && isNaN(v));
	},
	integer:function(v) {
		return (!isNaN(v) && v != "");
	},
	email:function(v) {
		var rX = new RegExp(/^[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/);
		return (v != "" && rX.test(v));
	},
	lengths:function(r,v) {
		var epx = r.split("-");
		if(epx[0] == "max") return (v.length <= epx[1].toNumber() ? true : false); 
		else if(epx[0] == "min") return (v.length >= epx[1].toNumber()? true : false);
		else if(epx[0] == "exact") return (v.length == epx[1].toNumber()? true : false);
	},
	ip:function(v) {
		var rX = new RegExp(/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/);
		return (v != "" && rX.test(v));
	}
};
var File = {
	path:function(n) {
		var rX = new RegExp(/(.*)\/([^\/\\]+)(\.\w+)$/);
		var f = n.match(rX);
		return {path:m[1],file:m[2],extension:m[3]};
	}
};
var Form = {
	first:null,
	confirm:function(v) {
		if(!v || v.trim() == "") v = "Do you really want to run this action?";
		return confirm(v);
	},
	clear:function(o) {
		var x = "", obj = o.elements;
		for (var i=0; i < obj.length; i++){
			var _o = obj[i];
			if(_o.type == "text" || _o.type == "password" || _o.type == "textarea") _o.value = "";
		}
	},
	validate:function(o) {
		var x = "", obj = o.elements;
		Form.first = null;
		for (var i=0; i < obj.length; i++){
			var _o = obj[i];
			if (_o.name != ""){
				_o.onchange = function() { return false; };
				var cha = new RegExp("(max|min|exact)\-(\d*)");
				if(!_o.className) _o.className = "";
				var thisClass = _o.className.split(" ");
				if(thisClass.inArray("required")  && _o.value.trim() == "") {
					this.error(_o, "Please fill the following field!");
					this.mark(_o);
				} else if(thisClass.inArray("string") && !Test.string(_o.value)) {
					this.error(_o, "Please fill the following field (string)!");
					this.mark(_o);
				} else if(thisClass.inArray("integer") && !Test.integer(_o.value)) {
					this.error(_o, "Please fill the following field (integer)!");
					this.mark(_o);
				} else if(thisClass.inArray("email") && !Test.email(_o.value)) {
					this.error(_o, "Please fill correct e-mail address!");
					this.mark(_o);
				} else {
					CSS.set(_o,"border","1px solid #06c");
				}
				for(var ii = 0; ii < thisClass.length; ii++) {
					if(thisClass[ii].match(cha)) {
						if(!Test.lengths(thisClass[ii],_o.value)) {
							var matcherror = thisClass[ii].split("-");
							this.error(_o, "Require "+matcherror[0]+" of "+matcherror[1]+" characters.",true);
							this.mark(_o);
						}
					}
				}
				if (_o.type == "checkbox" && _o.checked == true) {
					x = x + "&" + _o.name + "=" + Replacer.html(_o.value);
				} else if (_o.type == "radio" && _o.checked == true) {
					x = x + "&" + _o.name + "=" + Replacer.html(_o.value);
				} else if (_o.type != "checkbox" && _o.type != 'radio') {
					x = x + "&" + _o.name + "=" + Replacer.html(_o.value);
				}
			}
		}
		if(Form.first) { 
			Form.first.focus();
			return false; 
		} else return x;
	},
	mark:function(o) {
		if(!Form.first) Form.first = o;
	},
	error: function(o,msg,bool) {
		var boolean = $pick(bool,false);
		if(!$(o.name+"_error")) {
			var oE = $A("span");
			$$.set(oE,"id",o.name+"_error");
			oE.className = "form_error";
			DOM.addText(oE,msg);
			DOM.add(o.parentNode,oE);
			CSS.set(o,"border","1px solid #f00");
			o.onchange = function() {
				if(o.value != "") { 
					CSS.set(o,"border","1px solid #06c");
					if(oE) DOM.remove(o.parentNode,oE);
					Form.first = null;
				}
			};
		} else if($(o.name+"_error") && boolean == true) {
			var obj = $(o.name+"_error");
			if(obj.innerHTML.match(msg) == false && obj.innerHTML.trim() != "") obj.innerHTML += " "+msg;
			CSS.set(o,"border","1px solid #f00");
			o.onchange = function() {
				if(o.value != "") { 
					CSS.set(o,"border","1px solid #06c");
					if(obj) DOM.remove(o.parentNode,obj);
					Form.first = null;
				}
			};
		}
	},
	quickAJAX:function(__) {
		var o = $bind(__.obj,__.element,"obj");
		var params = this.validate(o);
		if(params) {
			params = (__.params ? __.params : "")+params;
			AJAX.submit({parameters:params,uri:__.uri,method:"POST"});
			return true;
		} else return false;
	},
	xtendedInput: function(__) {
		var o = $bind(__.obj,__.element,"obj");
		var pL = 0;
		o.onkeyup = function() {
			if(o.value.length >= __.init_start && o.value.length < __.init_limit) {
				if(o.value.length > pL) o.size = o.size+1;
				else if(o.value.length < pL) o.size = o.size-1;
			}
			if((__.init_row && __.init_row != "undefined") && o.value.length >= l) {
				var nTA = $A("textarea");
				$$.set(nTA,"cols",__.init_limit);
				$$.set(nTA,"rows",__.init_row);
				nTA.value = o.value;
				$$.set(nTA,"name", $$.get(o,"name"));
				DOM.change(nTA,o);
				$$.set(nTA,"id",g);
			}
			pL = o.value.length;
		};
	},
	tick_rows: function(int_start, int_end, var_id) {
		var checker = $("ticker_" + int_start + "_" + int_end), x = false, swap = false;
		if(checker.checked == true) { 
			x = true;
			swap = true;
		}
		for(var i = int_start; i <= int_end; i++) $(var_id+i).checked = x;
		$("ticker_" + int_start + "_" + int_end).checked = swap;
	}
};

var Replacer = {
	and:function(v) {
		s = new String(v);
		s = s.replace(/&/g,"[n]");
		s = s.replace(/\+/g,"[a]");
		return s;
	},
	html:function(v) {
		s = new String(v);
		s = this.and(s);
		s = escape(s);
		return s;
	},
	trim:function(v) {
		s = new String(v);
		s = s.replace(/^\s+/g,"");
		s = s.replace(/\s+$/g,"");
		return s;
	},
	xml:function(v) {
		s = new String(v);
		s = s.replace(/\[lt\]/g,"<");
		s = s.replace(/\[gt\]/g,">");
		s = s.replace(/\[n\]/g,"&");
		s = s.replace(/\&quot\;/g,"\"");
		s = s.replace(/\&rsquo\;/g,"\'");
		s = s.replace(/\[br\]/g,"\n");
		s = s.replace(/\[break\]/g,"<br />");
		return s;
	}
};

var Tabber = {
	el:new Array(),
	init: function(__) {
		this.el[__.obj] = __.rel;
		this.set(__.obj,__.activeTab);
		var as = $T("a");
		for (var i=0; i < as.length; i++){
			var a = as[i];
			if($$.get(a,"href") && $$.get(a,"id") && $$.get(a,"rel") == __.rel) {
				a.onclick = function() {
					Tabber.set(__.obj,$$.get(this,"id"));
					return false;
				};
			}
		}
	},
	set: function(obj,g) {
		var o = $(g), defTab = o.href.split("#"), _o = $(defTab[1]), tLs = $T("a"),tCs = $T("div");
		var el = this.el[obj];
		o.parentNode.className = "tabberactive";
		_o.className = "tabbertab";
		Opacity.init({element:$$.get(_o,"id"),start:0,end:100});
		for(var i=0;i<tLs.length;i++) {
			var tL = tLs[i];
			if(($$.get(tL,"id") != $$.get(o,"id")) && $$.get(tL,"rel") == el) {
				tL.parentNode.className = "";
			}
		}
		for(var i=0;i<tCs.length;i++) {
			var tC = tCs[i];
			if(($$.get(tC,"id") != $$.get(_o,"id")) && tC.className == "tabbertab" && $$.get(tC.parentNode,"id") == obj) { 
				tC.className = "tabbertabhide";
			}
		}
	}
};

var PItO = {
	obj:new Array(),counter:0,zindex:101,statusText:new Array(),title:new Array(),
	show:function(__) {
		if((__.element && Replacer.trim(__.element) != "") || __.obj) {
			var elm = $bind(__.obj,__.element);
			__.onclose = $pick(__.onclose,null);
			__.minimize = $pick(__.minimize,true);
			__.autoFocus = $pick(__.autoFocus,false);
			__.thisClass = $pick(__.thisClass,"pitowin");
			__.title = $pick(__.title,"");
			__.titleClass = $pick(__.titleClass,"pitoheader");
			__.width = (__.width > 0 ? __.width : 1);
			__.height = (__.height > 0 ? __.height : 1);
			__.minWidth = (__.minWidth > 0 ? __.minWidth : 250);
			__.minHeight = (__.minHeight > 0 ? __.minHeight : 80);
			__.zIndex = $pick(__.zIndex,++PItO.zindex);
			__.animate = $pick(__.animate,false);
			__.resize = $pick(__.resize,false);
			__.draggable = $pick(__.draggable,true);
			__.anywhereClose = $pick(__.anywhereClose,false);
			PItO.title[elm] = __.object_title; 
			PItO.statusText[elm] = "Loading "+PItO.title[elm]+" window.";
			if($(elm)) {
				PItO.hide(elm,__.onclose);
				return false;
			} else {
				var d = document.body, o = $A("div");
				var oW = __.width, oH = __.height;
				var hW = d.offsetWidth.toNumber();
				var hH = d.offsetHeight.toNumber;
				var sXY = Windows.getScroll();
				var oTop = Math.round(((hW-200)/2)+sXY[0]);
				var oLeft = Math.round((((screen.height-200)-200)/2)+sXY[1]);
				var xS = Math.round(((hW-oW)/2)+sXY[0]);
				var yS = Math.round((((screen.height-200)-oH)/2)+sXY[1]);
				xS = (xS < 0 ? 0 : xS);
				yS = (yS < 0 ? 0 : yS);
				$$.set(o,"id",elm);
				PItO.obj.push(elm);
				PItO.counter++;
				if(__.autoFocus == true) {
					o.onclick = function() {
						Opacity.set(elm,100);
						if(!CSS.get($(elm),"zIndex") || CSS.get($(elm),"zIndex") < PItO.zindex) {
							++PItO.zindex;
							CSS.set($(elm),"zIndex",PItO.zindex);
						}
						for(var nit = 0;nit < PItO.counter;nit++) {
							if(PItO.obj[nit] != elm) Opacity.set(PItO.obj[nit],60);
						}
					};
					for(var nit = 0;nit < PItO.counter;nit++) {
						if(PItO.obj[nit] != elm) Opacity.set(PItO.obj[nit],60);
					}
				} else CSS.set(o,"zIndex",__.zIndex);
				if(__.anywhereClose == true) {
					o.onclick = function() {
						PItO.hide(elm,__.onclose);
					};
				}
				if(__.title != "") {
					var oHd = $A("div");
					var oC = $A("div");
					var oM = $A("div");
					DOM.addText(oHd,__.title);
					CSS.styler({obj:oHd,css:[{"margin":"0px","padding":"0px","cursor":"move"}]});
					CSS.styler({obj:oC,css:[{"display":"inline","position":"absolute","top":"2px","right":"5px","width":"16px","height":"16px","cursor":"pointer","margin":"1px 0px","background":"url('"+savvy_close+"') no-repeat"}]});
					oC.onclick = function(){ PItO.hide(elm,__.onclose);};
					CSS.styler({obj:oM,css:[{"display":"inline","position":"absolute","top":"2px","right":"21px","width":"16px","height":"16px","cursor":"pointer","margin":"1px 0px","background":"url('"+savvy_minimize+"') no-repeat"}]});
					if(__.minimize === true) {
						oM.onclick = function() {
							if(CSS.get(o.childNodes[4],"visibility") == false || CSS.get(o.childNodes[4],"visibility") == "visible") {
								CSS.styler({obj:o.childNodes[4],css:[{"visibility":"hidden","display":"none"}]});
								if(o.childNodes[3]) CSS.styler({obj:o.childNodes[3],css:[{"visibility":"hidden","display":"none"}]});
								Opacity.set($$.get(o.childNodes[4],"id"),0);
								$$.set(o,"oy",parseInt(CSS.get(o,"height")));
								Animation.y.init({obj:o,start:o.offsetHeight,end:25,delay:1,no_position:true});
							} else {
								CSS.styler({obj:o.childNodes[4],css:[{"visibility":"visible","display":"block"}]});
								if(o.childNodes[3]) CSS.styler({obj:o.childNodes[3],css:[{"visibility":"visible","display":"block"}]});
								Animation.y.init({obj:o,start:25,end:$$.get(o,"oy"),delay:1,no_position:true});
								setTimeout("Opacity.init({element:'"+$$.get(o.childNodes[4],"id")+"',start:10,end:100,delay:10,speed:1})",1000);
							}
						};
					}
					oHd.className = __.titleClass;
					DOM.add(o,oM);
					DOM.add(o,oC);
					DOM.add(o,oHd);
				}
				o.className = __.thisClass;
				DOM.add(d,o);
				if(__.draggable === true) {
					if(!$null(oHd)) Draggable.init({obj:oHd,objRoot:o});
					else Draggable.init({obj:o});
				}
				if(__.animate == true) Opacity.init({element:elm,start:0,end:100,delay:1});
				var oRd = $A("div");
				$$.set(oRd,"id",elm+"_resizer");
				CSS.styler({obj:oRd,css:[{"position":"absolute","bottom":"1px","right":"1px","margin":"0px","padding":"0px","width":"9px","height":"9px"}]});
				DOM.add(o,oRd);
				if(__.resize == true) {
					CSS.styler({obj:oRd,css:[{"cursor":"se-resize","background":"url('"+savvy_resize+"') no-repeat"}]});
					try {
						Resizer.init({obj:oRd,objRoot:o,minX:__.minWidth,minY:__.minHeight});
					} catch(e) { }
				}
				CSS.styler({obj:o,css:[{"position":"absolute","top":yS+"px","left":xS+"px","width":oW+"px","height":oH+"px"}]});
			}
			this.statusText[elm] = this.title[elm]+" loaded.";
			if(__.autoFocus == true) PItO.zTop(elm);
			return o;
		} else return false;
	},
	zTop:function(el) {
		var o = $(el);
		++PItO.zindex;
		CSS.set(o,"zIndex",PItO.zindex);
	},
	hide:function(g,iF) {
		var o = $(g);
		var f = iF;
		if(f != null && typeof(f) == "string") eval(f);
		else if(f != null && typeof(f) == "function") f();
		DOM.remove(o.parentNode,o);
		try {
			var arry = this.obj;
			var deindex = arry.indexOf(g);
			arry.splice(deindex, 1);

			this.counter--;
			this.obj = arry;
		} catch(e) {}
		this.statusText[g] = this.title[g]+" closed.";
	}
};

var AJAX = {
	obj:null,debug:false,reply:null,method:null,responseID:null,timeOut:5000,
	init:function(){
		var xhttp = false;
		if(window.XMLHttpRequest) xhttp = new XMLHttpRequest();
		else if(window.ActiveXObject) {
			try { xhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
			catch (e) { 
				try { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
				catch (e) {} 
			}
		}
		if(!xhttp) { 
			Savvy.log("Sorry, your browser doesn't support AJAX!"); 
			return false;
		} else {
			AJAX.obj = xhttp;
			return true;
		}
	},
	submit:function(__) {
		if(AJAX.obj == null) AJAX.init(); 
		var req = AJAX.obj;
		this.method = (!__.method || __.method != "GET" ? "POST" : "GET");
		AJAX.debug = (__.debug ? __.debug : false);
		if (req.readyState == 4 || req.readyState == 0) {
			if(this.method == "POST") {
				req.open("POST",__.uri, true);
				req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				req.send(__.parameters);
			} else {
				req.open("GET",__.uri+__.parameters, true);
				req.send("");
			}
			if(__.oncomplete) req.onreadystatechange = __.oncomplete;
			else req.onreadystatechange = this.response;
		} else {
			setTimeout("AJAX.submit({parameters:'"+__.parameters+"',uri:'"+__.uri+"',method:'"+this.method+"'})",AJAX.timeOut);
		}
	},
	response:function() {
		var req = AJAX.obj;
		if(req.readyState == 4) {
			this.reply = req.responseText;
			if(AJAX.debug == true) Savvy.log(req.responseText);
			if(Replacer.trim(req.responseText) != "" && req.status == 200) {
				var a = eval("("+req.responseText+")");
				//var a = eval("+req.responseText+");
				if(!$null(a.alertpop) && Replacer.trim(a.alertpop) != "") alert(a.alertpop);
				if(!$null(a.jumpto) && Replacer.trim(a.jumpto) != "") Savvy.href(a.jumpto);
				if(!$null(a.add2id) && Replacer.trim(a.add2id) != "" && a.result != "") {
					$(a.add2id).innerHTML = Replacer.xml(a.result);
				}
				if(!$null(a.exec) && Replacer.trim(a.exec) != "") { 
					try { a.exec(a.result); } 
					catch(e) { eval("parent."+a.exec+"(a.result);"); }
				}
			} else AJAX.onabort();
		}
	},
	onabort:function() {
		var req = AJAX.obj;
		req.abort();
		AJAX.obj = null;
		Savvy.log("No response from server!");
	}
};

var Event = {
	On: function(__) {
		var r = false;
		var obj = (!__.obj || __.obj == "undefined" ? window : __.obj);
		if(obj.attachEvent) {
			try { r = obj.attachEvent("on"+__.trigger, __.load_function); } 
			catch(e) { 
				try { r = obj.addEventListener(__.trigger,__.load_function,false); } 
				catch(e) { r = "Unable to load window.attachEvent: "+e; }
			}
		} else { 
			try { r = obj.addEventListener(__.trigger,__.load_function,false); } 
			catch(e) { r = "Unable to load window.addEventListener: "+e; }
		}
		return r;
	},
	Off: function(__) {
		var r = false;
		var obj = (!__.obj || __.obj == "undefined" ? window : __.obj);
		if(obj.removeEvent) {
			try { r = obj.removeEvent("on"+__.trigger, __.load_function); } 
			catch(e) { 
				try { r = obj.removeEventListener(__.trigger,__.load_function,false); }
				catch(e) { r = "Unable to load window.attachEvent: "+e; }
			}
		} else { 
			try { r = obj.removeEventListener(__.trigger,__.load_function,false); }
			catch(e) { r = "Unable to load window.addEventListener: "+e; }
		}
		return r;
	}
};

var Animation = {
	y : {
		delay:new Array(),step:new Array(),istart:new Array(),limitspeed:new Array(),iend:new Array(),ifunc:new Array(),ipos:new Array(),middle:new Array(),interval:new Array(),
		size: function(g,v) {
			var o = $(g);
			try { CSS.set(o,"height",v+"px");
			} catch(e) { CSS.set(o,"height","0px"); }
		},
		top: function(g,v) {
			var o = $(g);

			try { CSS.set(o,"top",v+"px");
			} catch(e) { CSS.set(o,"top","0px"); }
		},
		init:function(__) {
			var elm = $bind(__.obj,__.element);
			__.oncomplete = (__.oncomplete ? __.oncomplete : null);
			__.delay = (__.delay && __.delay > 0 ? __.delay : 1);
			__.step = (__.step && __.step > 0 ? __.step : 1);
			__.limit_speed = (__.limit_speed && __.limit_speed > 0 ? __.limit_speed : 0);
			__.no_position = (__.no_position ? __.no_position : false);
			this.step[elm] = __.step;
			this.delay[elm] = __.delay;
			this.istart[elm] = __.start;
			this.iend[elm] = __.end;
			this.ifunc[elm] = __.oncomplete;
			this.ipos[elm] = __.no_position;
			this.limitspeed[elm] = __.limit_speed;
			if(__.start < __.end) {
				this.middle[elm] = (__.start + Math.floor(Math.abs(__.start - __.end)/2));
				this.grow(elm);
				this.interval[elm] = setInterval("Animation.y.grow('"+elm+"')",__.delay);
			} else if(__.start > __.end) {
				this.middle[elm] = (__.start - Math.floor(Math.abs(__.start - __.end)/2));
				this.shrink(elm);
				this.interval[elm] = setInterval("Animation.y.shrink('"+elm+"')",__.delay);
			}
		},
		grow:function(g) {
			var f = this.step[g], ls = this.limitspeed[g], s = this.istart[g], e = this.iend[g], pos = this.ipos[g], o = $(g);
			f = (Animation.power(s,e,f) ? ++f : --f);
			if(ls > 0) f = (f > ls ? ls : (f > 0 ? f : 1));
			else f = (f > 0 ? f : 1);
			this.step[g] = f;
			s = Math.floor(s + f);
			if(s < e) {
				if(o.style.position && pos != true) {
					var oTop = parseInt(o.style.top), fTop = Math.floor(oTop - (f/2));
					if(fTop >= 0) this.top(g,fTop);
					this.size(g,Math.floor(s+(f/1)));
				} else this.size(g,s);
			} else {

				this.size(g,e);
				var f = this.ifunc[g];
				if(f != null && typeof(f) == "string") eval(f);
				else if(f != null && typeof(f) == "function") f();
				clearInterval(this.interval[g]);
				this.interval[g] = null;
			}
			this.istart[g] = s;
		},
		shrink:function(g){
			var f = this.step[g], ls = this.limitspeed[g], s = this.istart[g], e = this.iend[g], pos = this.ipos[g], o = $(g);
			f = (Animation.power(s,e,f) ? ++f : --f);
			if(ls > 0) f = (f > ls ? ls : (f > 0 ? f : 1));
			else f = (f > 0 ? f : 1);
			this.step[g] = f;
			s = Math.floor(s - f);
			if(s > e) {
				if(o.style.position && pos != true) {
					var oTop = parseInt(o.style.top), fTop = Math.floor(oTop + (f/2));
					if(fTop >= 0) this.top(g,fTop);
					this.size(g,Math.floor(s-(f/1)));
				} else this.size(g,s);
			} else {
				this.size(g,e);
				var f = this.ifunc[g];
				if(f != null && typeof(f) == "string") eval(f);
				else if(f != null && typeof(f) == "function") f();
				clearInterval(this.interval[g]);
				this.interval[g] = null;
			}
			this.istart[g] = s;
		}
	},
	x : {
		delay:new Array(),step:new Array(),istart:new Array(),limitspeed:new Array(),iend:new Array(),ifunc:new Array(),ipos:new Array(),middle:new Array(),interval:new Array(),
		size: function(g,v) {
			var o = $(g);
			try { CSS.set(o,"width",v+"px");
			} catch(e) { CSS.set(o,"width","0px"); }
		},
		left: function(g,v) {
			var o = $(g);
			try { CSS.set(o,"left",v+"px");
			} catch(e) { CSS.set(o,"left","0px"); }
		},
		init:function(__) {
			var elm = $bind(__.obj,__.element);
			__.oncomplete = (__.oncomplete ? __.oncomplete : null);
			__.delay = (__.delay && __.delay > 0 ? __.delay : 1);
			__.step = (__.step && __.step > 0 ? __.step : 1);
			__.limit_speed = (__.limit_speed && __.limit_speed > 0 ? __.limit_speed : 0);
			__.no_position = (__.no_position ? __.no_position : false);
			this.step[elm] = __.step;
			this.delay[elm] = __.delay;
			this.istart[elm] = __.start;
			this.iend[elm] = __.end;
			this.ifunc[elm] = __.oncomplete;
			this.ipos[elm] = __.no_position;
			this.limitspeed[elm] = __.limit_speed;
			if(__.start < __.end) {
				this.grow(elm);
				this.interval[elm] = setInterval("Animation.x.grow('"+elm+"')",__.delay);

			} else if(__.start > __.end) {
				this.shrink(elm);
				this.interval[elm] = setInterval("Animation.x.shrink('"+elm+"')",__.delay);
			}
		},
		grow:function(g) {
			var f = this.step[g], ls = this.limitspeed[g], s = this.istart[g], e = this.iend[g], pos = this.ipos[g], o = $(g);
			f = (Animation.power(s,e,f) ? ++f : --f);
			if(ls > 0) f = (f > ls ? ls : (f > 0 ? f : 1));
			else f = (f > 0 ? f : 1);
			this.step[g] = f;
			s = Math.floor(s + f);
			if(s < e) {
				if(o.style.position && pos != true) {
					var oLeft = parseInt(o.style.left), fLeft = Math.floor(oLeft - (f/2));
					if(fLeft >= 0) this.left(g,fLeft);
					this.size(g,Math.floor(s+(f/1)));
				} else this.size(g,s);
			} else {
				this.size(g,e);
				var f = this.ifunc[g];
				if(f != null && typeof(f) == "string") eval(f);
				else if(f != null && typeof(f) == "function") f();
				clearInterval(this.interval[g]);
				this.interval[g] = null;
			}
			this.istart[g] = s;
		},
		shrink:function(g){
			var f = this.step[g], ls = this.limitspeed[g], s = this.istart[g], e = this.iend[g], pos = this.ipos[g], o = $(g);
			f = (Animation.power(s,e,f) ? ++f : --f);
			if(ls > 0) f = (f > ls ? ls : (f > 0 ? f : 1));
			else f = (f > 0 ? f : 1);
			this.step[g] = f;
			s = Math.floor(s - f);
			if(s > e) {
				if(o.style.position && pos != true) {
					var oLeft = parseInt(o.style.left), fLeft = Math.floor(oLeft + (f/2));
					if(fLeft >= 0) this.left(g,fLeft);
					this.size(g,Math.floor(s-(f/1)));
				} else this.size(g,s);
			} else {
				this.size(g,e);
				var f = this.ifunc[g];
				if(f != null && typeof(f) == "string") eval(f);
				else if(f != null && typeof(f) == "function") f();
				clearInterval(this.interval[g]);
				this.interval[g] = null;
			}
			this.istart[g] = s;
		}
	},
	power:function(s,e,st) {
		var dif = (Math.abs(s-e) - 1);
		var step = 1;
		for(var i = 1; i < st; i++) step += i;
		if(dif > step) return true;
		else return false;			
	}
};

var Scroll = {
	
};

var Fx = {
	
};

var Cal = {
	days:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
	months:["January","February","March","April","May","June","July","August","September","October","November","December"],
	daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],
	fields:new Array,
	types:new Array,
	lastDate:new Array,
	element:null,
	count:0,
	calDate:new Array,
	calMonth:new Array,
	calYear:new Array,
	init:function(__) {
		var elm = $bind(__.obj,__.element);
		this.element = elm;
		this.count++;
		if(!$null(__.field))
			this.fields[elm] = elm+"_"+__.field;
		this.types[elm] = $pick(__.type,"single");
		this.calDate[elm] = new Date();
		if($null(__.month) || isNaN(__.month) || __.month > 12 || __.month < 0) 
			this.calMonth[elm] = this.calDate[elm].getMonth();
		else
			this.calMonth[elm] = Math.abs(__.month - 1);
		if($null(__.year) || isNaN(__.year) || __.month < 1000) 
			this.calYear[elm] = this.calDate[elm].getFullYear();
		else
			this.calYear[elm] = __.year;
		$(elm).innerHTML = "Generating Cal...";
		this.generate(elm);
	},
	prev:{
		month:function(elm){
			Cal.calDate[elm] = new Date(Cal.calYear[elm], (Cal.calMonth[elm]-1));
			Cal.calMonth[elm] = Cal.calDate[elm].getMonth();
			Cal.calYear[elm] = Cal.calDate[elm].getFullYear();
			$(elm).innerHTML = "Generating Cal...";
			Cal.generate(elm);
		},
		year:function(elm){
			Cal.calDate[elm] = new Date((Cal.calYear[elm]-1), Cal.calMonth[elm]);
			Cal.calMonth[elm] = Cal.calDate[elm].getMonth();
			Cal.calYear[elm] = Cal.calDate[elm].getFullYear();
			$(elm).innerHTML = "Generating Cal...";
			Cal.generate(elm);
		}
	},
	next:{
		month:function(elm){
			Cal.calDate[elm] = new Date(Cal.calYear[elm], (Cal.calMonth[elm]+1));
			Cal.calMonth[elm] = Cal.calDate[elm].getMonth();
			Cal.calYear[elm] = Cal.calDate[elm].getFullYear();
			$(elm).innerHTML = "Generating Cal...";
			Cal.generate(elm);
		},
		year:function(elm){
			Cal.calDate[elm] = new Date((Cal.calYear[elm]+1), Cal.calMonth[elm]);
			Cal.calMonth[elm] = Cal.calDate[elm].getMonth();
			Cal.calYear[elm] = Cal.calDate[elm].getFullYear();
			$(elm).innerHTML = "Generating Cal...";
			Cal.generate(elm);
		}
	},
	compareDate:function(first,second) {
		var fD = first.split("-").reverse().join("/");
		var sD = second.split("-").reverse().join("/");
		fDO = new Date(fD);
		sDO = new Date(sD);
		if(sDO > fDO) return true;
		else return false;
	},
	addToField:function(elm,Y,m,d) {
		var o =$(elm+"_"+Y+m+d);
		var mi = (m < 10 ? "0"+m : m);
		var di = (d < 10 ? "0"+d : d);
		if(this.types[elm] == "single") {
			if($null($$.get(o,"sel"))) {
				if(!$null(this.lastDate[elm])) {
					var lD = $(elm+"_"+this.lastDate[elm]);
					CSS.styler({obj:lD,css:[{"background":"transparent","color":"#000"}]});
					$$.remove(lD,"sel");
				}
				$$.set(o,"sel","yes");
				CSS.styler({obj:o,css:[{"background":"#333","color":"#fff"}]});
				$(this.fields[elm]).value = Y+"-"+mi+"-"+di;
				this.lastDate[elm] = Y+""+m+""+d;
			} else {
				$$.remove(o,"sel");
				CSS.styler({obj:o,css:[{"background":"transparent","color":"#000"}]});
				$(this.fields[elm]).value = "";
			}
		} else if(this.types[elm] == "multiple") {
			var values = $(this.fields[elm]).value;
			var va = values.split("|");
			if(va.inArray(Y+"-"+mi+"-"+di)) {
				va.splice(va.indexOf(Y+"-"+mi+"-"+di),1);
				var im = va.join("|");
				CSS.styler({obj:o,css:[{"background":"transparent","color":"#000"}]});
				$(this.fields[elm]).value = im;
			} else {
				$$.set(o,"sel","yes");
				CSS.styler({obj:o,css:[{"background":"#333","color":"#fff"}]});
				va.push(Y+"-"+mi+"-"+di);
				var im = va.join("|");
				$(this.fields[elm]).value = im;
			}
		}
	},
	generate:function(elm) {
		var first_day = new Date(this.calYear[elm], this.calMonth[elm], 1);
		var start_day = first_day.getDay();
		if (this.calMonth[elm] == 1 && (this.calYear[elm] % 4 == 0 && this.calYear[elm] % 100 != 0) || this.calYear[elm] % 400 == 0) 
			var monthLength = 29;
		var monthLength = $pick(monthLength,this.daysInMonth[this.calMonth[elm]]);
		var html = "<table class='calendar-table'>";
		html += "<tr><th colspan='7'>";
		html += "<tr><th colspan='7'>";
		html += "<a href='javascript:void(0)' onclick='Cal.prev.year(\""+elm+"\")'>&laquo;</a> <a href='javascript:void(0)' onclick='Cal.prev.month(\""+elm+"\")'>&lt;</a> ";
		html +=  this.months[this.calMonth[elm]] + "&nbsp;" + this.calYear[elm];
		html += " <a href='javascript:void(0)' onclick='Cal.next.month(\""+elm+"\")'>&gt;</a> <a href='javascript:void(0)' onclick='Cal.next.year(\""+elm+"\")'>&raquo;</a>";
		html += "</th></tr>";
		html += "<tr class='calendar-header'>";
		for (var i = 0; i <= 6; i++ ){
			html += "<td class='calendar-header-day'>";
			html += this.days[i];
			html += "</td>";
		}
		html += "</tr><tr>";
		var day = 1;
		for (var i = 0; i < 9; i++) {
			for (var j = 0; j <= 6; j++) {
				html += "<td class='calendar-day'";
				if (day <= monthLength && (i > 0 || j >= start_day)) {
					html += " id='"+elm+"_"+this.calYear[elm]+(this.calMonth[elm]+1)+day+"' ";
					if(!$null(this.fields[elm])) html += "onclick='Cal.addToField(\""+elm+"\","+this.calYear[elm]+","+(this.calMonth[elm]+1)+","+day+")'";
					html += ">";
					html += day;
					day++;
				} else html += ">";
				html += "</td>";
			}
			if (day > monthLength) break;
			else html += "</tr><tr>";
		}
		html += "</tr></table>";
		$(elm).innerHTML = html;
		if(!$null(this.fields[elm])) {
			var inp = $A("input");
			$$.set(inp,"id",this.fields[elm]);
			$$.set(inp,"name",this.fields[elm]);
			$$.set(inp,"type","text");
			DOM.add($(elm),inp);
		}
	}
};

var Windows = {
	getScroll: function () {
		var scrOfX = 0, scrOfY = 0;
		if(typeof window.pageYOffset == "number") {
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		return [scrOfX,scrOfY];
	}
};
var Draggable = {
	obj:null,
	init:function(__) {
		var o = __.obj;
		o.onmousedown = Draggable.start;
		o.root = $pick(__.objRoot,o);
		o.hmode	= true;
		o.vmode	= true;
		if(isNaN(parseInt(CSS.get(o.root,"left")))) CSS.set(o.root,"left","0px");
		if(isNaN(parseInt(CSS.get(o.root,"top")))) CSS.set(o.root,"top","0px");
		o.minX = $pick(__.minX,null);
		o.maxX = $pick(__.maxX,null);
		o.minY = $pick(__.minY,null);
		o.maxY = $pick(__.maxY,null);
		
		o.root.onDragStart = new Function();
		o.root.onDragEnd = new Function();
		o.root.onDrag = new Function();
	},
	start:function(e) {
		var o = Draggable.obj = this;
		e = Draggable.fixE(e);
		var y = parseInt(CSS.get(o.root,"top"));
		var x = parseInt(CSS.get(o.root,"left"));
		o.root.onDragStart(x,y);
		o.lastMouseX = e.clientX;
		o.lastMouseY = e.clientY;
		if(o.minX != null) o.minMouseX = e.clientX - x + o.minX;
		if(o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
		if(o.minY != null) o.minMouseY = e.clientY - y + o.minY;
		if(o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
		document.onmousemove = Draggable.drag;
		document.onmouseup = Draggable.end;
		return false;
	},
	drag:function(e){
		e = Draggable.fixE(e);
		var o = Draggable.obj;
		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(CSS.get(o.root,"top"));
		var x = parseInt(CSS.get(o.root,"left"));
		var nx, ny;
		if (o.minX != null) ex = Math.min(ex, o.mixMouseX);
		if (o.maxX != null) ex = Math.max(ex, o.maxMouseX);
		if (o.minY != null) ey = Math.min(ey, o.minMouseY);
		if (o.maxY != null) ey = Math.max(ey, o.maxMouseY);
		nx = x + ((ex - o.lastMouseX) * 1);
		ny = y + ((ey - o.lastMouseY) * 1);
		CSS.set(o.root,"left",nx+"px");
		CSS.set(o.root,"top",ny+"px");
		o.lastMouseX = ex;
		o.lastMouseY = ey;
		o.root.onDrag(nx, ny);
		return false;
	},
	end:function(){
		document.onmousemove = null;
		document.onmouseup = null;
		Draggable.obj.root.onDragEnd(parseInt(CSS.get(Draggable.obj.root,"left")),
			parseInt(CSS.set(Draggable.obj.root,"top")), Draggable.obj.root);
		Draggable.obj = null;
	},
	fixE : function(e){
		if ($null(e)) e = window.event;
		if ($null(e.layerX)) e.layerX = e.offsetX;
		if ($null(e.layerY)) e.layerY = e.offsetY;
		return e;
	}
};
var Resizer = {
	obj:null,
	init:function(__) {
		// __.obj, __.oRoot, __.minX, __.maxX, __.minY, __.maxY
		var o = __.obj;
		o.onmousedown = Resizer.start;
		o.root = $pick(__.objRoot,o);
		o.hmode	= true;
		o.vmode	= true;
		o.minX = $pick(__.minX,null);
		o.minY = $pick(__.minY,null);
		o.maxX = $pick(__.maxX,null);
		o.maxY = $pick(__.maxY,null);
		o.root.onResizeStart = new Function();
		o.root.onResizeEnd = new Function();
		o.root.onResize	= new Function();
	},
	start:function(e){
		var o = Resizer.obj = this;
		e = Resizer.fixE(e);
		var y = parseInt(CSS.get(o.root,"height"));
		var x = parseInt(CSS.get(o.root,"width"));
		o.root.onResizeStart(x,y);
		o.lastMouseX = e.clientX;
		o.lastMouseY = e.clientY;
		if(o.minX != null) o.minMouseX = e.clientX - x + o.minX;
		if(o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
		if(o.minY != null) o.minMouseY	= e.clientY - y + o.minY;
		if(o.maxY != null) o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		document.onmousemove = Resizer.resize;
		document.onmouseup = Resizer.end;
		return false;
	},
	resize : function(e){
		e = Resizer.fixE(e);
		var o = Resizer.obj;
		var ey = e.clientY;
		var ex = e.clientX;
		var y = parseInt(CSS.get(o.root,"height"));
		var x = parseInt(CSS.get(o.root,"width"));
		var ow = x;
		var oh = y;
		var nx, ny;
		if (o.minX != null) ex = Math.max(ex, o.minMouseX);
		if (o.maxX != null) ex = Math.min(ex, o.maxMouseX);
		if (o.minY != null) ey = Math.max(ey, o.minMouseY);
		if (o.maxY != null) ey = Math.min(ey, o.maxMouseY);
		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));
		CSS.set(o.root,"width",(ow+(nx-x))+"px");
		CSS.set(o.root,"height",(oh+(ny-y))+"px");
		o.lastMouseX	= ex;
		o.lastMouseY	= ey;
		o.root.onResize(Math.round(nx-x), Math.round(ny-y));
		return false;
	},
	end : function(){
		document.onmousemove = null;
		document.onmouseup   = null;
		Resizer.obj.root.onResizeEnd(parseInt(Resizer.obj.root.style.width),
			parseInt(Resizer.obj.root.style.height),Resizer.obj.root);
		Resizer.obj = null;
	},
	fixE : function(e){
		if (typeof(e) == "undefined") e = window.event;
		if (typeof(e.layerX) == "undefined") e.layerX = e.offsetX;
		if (typeof(e.layerY) == "undefined") e.layerY = e.offsetY;
		return e;
	},
	childResize:function(__) {
		var o = __.obj;
		var child = __.child;
		for(var i = 0; i < child.length; i++) {
			try {
				CSS.set(child[i],"width",(parseInt(child[i].style.width)+__.width)+"px");
			} catch(e) {}
			CSS.set(child[i],"height",(parseInt(child[i].style.height)+__.height)+"px");
		}
	}
};
var Activity = {
	status:null,
	show:function(b) {
		b = $null(b) ? true : b;
		if(b == true) this.overlay.on();
		var o = $A("img");
		var imgPreload = new Image();
		this.status = "loading";
		imgPreload.onload = function() {
			if(!$null(Activity.status)) {
				o.src = savvy_activity;
				this.status = "loaded";
				CSS.styler({obj:o,css:[{"width":this.width+"px","height":this.height+"px"}]});
				PItO.show({element:"loaderv2",width:this.width,height:this.height,zIndex:50,thisClass:""});
				DOM.add($("loaderv2"),o);
			}
		};
		imgPreload.src = savvy_activity;
	},
	hide:function(b) {
		var o = $("loaderv2");
		this.status = null;
		b = ($null(b) ? true : b);
		if(b == true) this.overlay.off();
		if(o) DOM.remove(o);
	},
	overlay : {
		on:function() {
			var d = document.body, lb = $("lboverlay");
			if(lb && CSS.get(lb,"width") == "0px") {
				CSS.styler({ obj:lb, css:[{"width":d.offsetWidth+"px","height":d.offsetHeight+"px"}] });
				Opacity.init({obj:lb,start:0,end:75,delay:1,speed:300});
			} else if(lb && CSS.get(lb,"width") != "0px") {
				Opacity.init({obj:lb,start:0,end:75,delay:1,speed:300});
			} else if(!lb) {
				var o = $A("div");
				CSS.styler({
					obj:o,
					css:[{
						"background":"#000",
						"position":"absolute",
						"top":"0px",
						"left":"0px",
						"display":"block",
						"zIndex":"50",
						"width":d.offsetWidth+"px",
						"height":d.offsetHeight+"px"
					}]
				});
				$$.set(o,"id","lboverlay");
				DOM.add(d,o);
				Opacity.init({obj:o,start:0,end:75,delay:1,speed:300});
			} 
		},
		off:function() {
			var o = $("lboverlay");
			Opacity.init({obj:o,start:75,end:0,delay:1,speed:300});
		},
		onerror:function() {
			var lb = $("lboverlay");
			if(lb && lb.offsetWidth > 0) CSS.styler({ obj:lb, css:[{"width":"0px","height":"0px"}] });
		}
	}
};

var JScript = {
	href:function(u) {
		window.location.href = u;
	}	
}