var __include_default = true;

//Nothing function to hrefs links
function n() { }

//Browse information
var Browse = {
	isIE: false,
	isMoz: false,
	isSaf: false,
	detect: function () {
		if ((navigator.userAgent.indexOf('Safari') != -1)) { this.isSaf = true; } 
		else if ((navigator.appName == 'Netscape')) { this.isMoz = true; } 
		else { this.isIE = true; }	   	
	}
}
Browse.detect();


//Class
var Class = {};
Class.extend = function (tmp_obj1, tmp_obj2) {
	for (var k in tmp_obj2) { tmp_obj1[k] = tmp_obj2[k]; }
	return tmp_obj1;
}


//Get element(s) by id, #id(array) or .classname(array)
var $ = function (tmp_query, tmp_root) {
	if (tmp_query.indexOf('.') > -1) {
		var r = [], elms, i = 0, i2 = 0, r2;
		
		tmp_query = tmp_query.substr(1, tmp_query.length - 1);
		
		tmp_root = (tmp_root != null) ? tmp_root : this;
		elms = (tmp_root.all) ? tmp_root.all : tmp_root.getElementsByTagName('*');
		
		for (; i < elms.length; i++) {
			if (tmp_query == elms[i].className) {
				r.push(elms[i]);
			}
		}
		
		return r;
	} else if (tmp_query.indexOf('#') > -1) {
		var r = [], elms, i = 0, i2 = 0, r2;
		
		tmp_query = tmp_query.substr(1, tmp_query.length - 1);
		
		tmp_root = (tmp_root != null) ? tmp_root : this;
		elms = (tmp_root.all) ? tmp_root.all : tmp_root.getElementsByTagName('*');
		
		for (; i < elms.length; i++) {
			if (tmp_query == elms[i].id) {
				r.push(elms[i]);
			}
		}
		
		return r;
	} else {
		if (document.getElementById(tmp_query)) {
			return document.getElementById(tmp_query);	
		} else {
			return null;
		}
	}
}


//Trace
var objtrace = {
	trace: function (tmp_with_functions) {
		var msg = '';
		var w_f = (tmp_with_functions != undefined) ? tmp_with_functions : false;
		var obj = this;
		
		for (var v in obj) {
			msg += '	' + v + ' = ';
			
			if (typeof(obj[v]) == "function") {
				if (w_f) {
					msg += '\'' + (new String(obj[v])) + '\'\n';
				} else {
					msg += '\'[function Function]\'\n';
				}
			} else {
				msg += '\'' + (new String(obj[v])) + '\'\n';
			}
		}
		
		var div = document.createElement('div');
		div.id = 'trace_' + Math.round(Math.random() * 99999);
		div.style.position = 'absolute';
		div.style.top = '0px';
		div.style.left = '0px';
		div.style.background = '#EEEEEE';
		div.innerHTML = '<pre style="font-family: Verdana; font-size: 10px;">' + typeof(this) + ' (' + (new String(this)) + ') {\n' + msg + '}</pre>';
		
		document.getElementsByTagName('body')[0].appendChild(div);
		
		Event.add(div, Event.CLICK, function () { this.remove(); });
	}
};

//Object
Class.extend(Object.prototype, {
	$: $,
	setAlpha: function (tmp_value) {
		if (tmp_value == 0) this.style.visibility = "hidden";
		if (Browse.isIE) {
			this.style.filter = "alpha(opacity=" + (tmp_value * 100) + ")";
		}
		this.style.opacity = tmp_value;
		this.alpha = tmp_value;
	},
	remove: function () {
		this.parentNode.removeChild(this);
	},
	trace: objtrace.trace
});


//Function
Class.extend(Function.prototype, {
	bind: function() {
		var _args = Array.toArray(arguments);		
		var _obj = _args.shift();
		var _method = this;
		
		return function(e) { return _method.apply(_obj, [e || window.event].concat(_args)); }
	}
});


//Array
Class.extend(Array.prototype, {
	trace: objtrace.trace,
	each: function (tmp_func) {
		var i = 0;
		var length = this.length;
		
		var ev = "tmp_func(i, this[i])";
		
		for (; i < length; i++) {
			eval(ev);
		}
	},
	remove: function (tmp_itens) {
		if (typeof(tmp_itens) != "object") {
			tmp_itens = [tmp_itens];
		}
		
		var i = 0; i2 = 0;
		var new_array = [];
		
		for (; i < this.length; i++) {
			if (tmp_itens.indexOf(this[i]) == -1) {
				new_array[i2] = this[i];
				i2++;
			}
		}
		
		return new_array;
	}
});
if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function(tmp_item, tmp_i) {
		var length = this.length;
		
		tmp_i = (tmp_i) ? tmp_i : 0;
		if (tmp_i < 0) tmp_i = length + tmp_i;
		
		for (; tmp_i < length; tmp_i++) { if (this[tmp_i] === tmp_item) { return tmp_i; } }
		
		return -1;
	}
}

Array.toArray = function (tmp_obj) {
	if (!tmp_obj) return [];
	if (tmp_obj.toArray) return tmp_obj.toArray();
	
	var l = tmp_obj.length || 0, r = new Array(l);
	
	while (l--) r[l] = tmp_obj[l];
	
	return r;
};


//String
Class.extend(String.prototype, {
	trim: function () {
		var r = /\s*((\S+\s*)*)/g;
		var r2 = /((\s*\S+)*)\s*/g;
		return this.replace(r, "$1").replace(r2, "$1");		
	},
	formatVars: function () {
		var words = new Array();
		var i = 0;
		var control_string = "";
		
		tmp_string = this;
		
		words[0] = [33, 34, 35, 36, 39, 92, 92, 92, 92, 44, 34, 58, 59, 60, 62, 92, 64, 92, 92, 92, 92, 92, 124, 92, 126, 127, 128, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 142, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255];
		words[1] = ["%21","%22","%23","%24","%27","%28","%29","*","%2B","%2C","%2F","%3A","%3B","%3C","%3E","%3F","%40","%5B","%5D","%5E","%60","%7B","%7C","%7D","%7E","%7F","%80","%82","%83","%84","%85","%86","%87","%88","%89","%8A","%8B","%8C","%8E","%91","%92","%93","%94","%95","%96","%97","%98","%99","%9A","%9B","%9C","%9E","%9F","%A1","%A2","%A3","%A4","%A5","%A6","%A7","%A8","%A9","%AA","%AB","%AC","%AD","%AE","%AF","%B0","%B1","%B2","%B3","%B4","%B5","%B6","%B7","%B8","%B9","%BA","%BB","%BC","%BD","%BE","%BF","%C0","%C1","%C2","%C3","%C4","%C5","%C6","%C7","%C8","%C9","%CA","%CB","%CC","%CD","%CE","%CF","%D0","%D1","%D2","%D3","%D4","%D5","%D6","%D7","%D8","%D9","%DA","%DB","%DC","%DD","%DE","%DF","%E0","%E1","%E2","%E3","%E4","%E5","%E6","%E7","%E8","%E9","%EA","%EB","%EC","%ED","%EE","%EF","%F0","%F1","%F2","%F3","%F4","%F5","%F6","%F7","%F8","%F9","%FA","%FB","%FC","%FD","%FE","%FF"];
	
		for (; i < words[0].length; i++) {
			do {
				control_string = tmp_string;
				tmp_string = tmp_string.replace(String.fromCharCode(words[0][i]), words[1][i]);
			} while (control_string != tmp_string);
		}
		
		return tmp_string; 
	}
});


//Event class
var Event = {
	onready_events: [],
	onready_state: false,
	initialize: function () {
		if ((document.addEventListener) && (!this.onready_state)) {
			document.addEventListener("DOMContentLoaded", this.runOnReadyEvents.bind(this), false); 
		} else {
			if (Browse.isMoz) {
				if ((new RegExp("/loaded|complete/i")).test(document.readyState) === false) {
					setTimeout(arguments.callee, 10); return;
				}
				
				Event.runOnReadyEvents();
			} else if (Browse.isIE) {
				try {
					document.documentElement.doScroll("left");
				} catch (e) {
					setTimeout(arguments.callee, 10); return;
				}
				
				Event.runOnReadyEvents();
			}
		}
	},
	runOnReadyEvents: function () {
		this.onready_events.each(function (k, v) {
			v();
		});
		
		this.onready_events = undefined;
		this.onready_state = true;
	},
	add: function (tmp_obj, tmp_event, tmp_function) {		
		if (typeof tmp_event == "string") {
			if (tmp_event.indexOf(" ") > -1) {
				var arr = tmp_event.split(" ");
				for (var i = 0; i < arr.length; i++) {
					Event.add(tmp_obj, arr[i], tmp_function);	
				}
				
				return true;
			}
		} else if (typeof tmp_event == "object") {
			for (var i = 0; i < tmp_event.length; i++) {
				Event.add(tmp_obj, tmp_event[i], tmp_function);	
			}
			
			return true;
		}
		
		if (tmp_obj) {
			tmp_event = String(tmp_event).toLowerCase();
			
			if (tmp_event == "ready") {
				if (this.onready_state) {
					tmp_function();
				} else {
					this.onready_events.push(tmp_function);
				}
			} else {
				if (window.attachEvent) {
					tmp_obj.attachEvent('on' + tmp_event, tmp_function);
				} else if (window.addEventListener) {
					tmp_obj.addEventListener(tmp_event, tmp_function, false);
				} else {
					tmp_obj['on' + tmp_event] = tmp_function;
				}
			}
			
			return true;
		} else {
			return false;
		}
	},
	remove: function (tmp_obj, tmp_event, tmp_function) {
		if (window.detachEvent) {
			tmp_obj.detachEvent('on' + tmp_event, tmp_function);
		} else if (window.removeEventListener) {
			tmp_obj.removeEventListener(tmp_event, tmp_function, false);
		} 
		if (tmp_obj['on' + tmp_event] == tmp_function) {
			tmp_obj['on' + tmp_event] = null;
		}
	},
	ABORT: 'abort',
	BLUR: 'blur',
	CHANGE: 'change',
	CLICK: 'click',
	DBL_CLICK: 'dblclick',
	ERROR: 'error',
	FOCUS: 'focus',
	KEY_DOWN: 'keydown',
	KEY_PRESS: 'keypress',
	KEY_UP: 'keyup',
	LOAD: 'load',
	MOUSE_DOWN: 'mousedown',
	MOUSE_MOVE: 'mousemove',
	MOUSE_OUT: 'mouseout',
	MOUSE_OVER: 'mouseover',
	MOUSE_UP: 'mouseup',
	RESET: 'reset',
	RESIZE: 'resize',
	SELECT: 'select',
	SUBMIT: 'submit',
	UNLOAD: 'unload',
	READY: 'ready'
};
Event.initialize();

//Window
Class.extend(window, {
	openCenteredPopup: function (tmp_url, tmp_w, tmp_h, tmp_name, tmp_extra) {
		var x = (screen.width - tmp_w) / 2;
		var y = (screen.height - tmp_h) / 2;
		
		tmp_extra = (tmp_extra) ? tmp_extra : '';
		tmp_name = (tmp_name) ? tmp_name : 'centered_window_' + String(Math.round(Math.random() * 99999));

		return window.open(tmp_url, tmp_name, 'height=' + tmp_h + ', width=' + tmp_w + ', left=' + x + ', top=' + y + tmp_extra);
	}
});


//Window Position class
function WindowPosition() {
	this.x = 0;
	this.y = 0;
	this.w = 0;
	this.h = 0;
	
	if (typeof(window.pageYOffset) == 'number') {
		this.x = window.pageXOffset;
		this.y = window.pageYOffset;
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		this.x = document.body.scrollLeft;
		this.y = document.body.scrollTop;
	} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {	
		this.x = document.documentElement.scrollLeft;
		this.y = document.documentElement.scrollTop;
	}
	
	if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		this.w = document.documentElement.clientWidth;
		this.h = document.documentElement.clientHeight;
	} else if (typeof(window.innerWidth) == 'number') {
		this.w = window.innerWidth;
		this.h = window.innerHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		this.w = document.body.clientWidth;
		this.h = document.body.clientHeight;
	}
}