
if (typeof GLB == "undefined") {
    var GLB = {};
}
GLB.namespace = function() {
	var object = null, arrObjects = [];
    for (var i=0; i<arguments.length; i++) {
		object = GLB;
		
        for (var objI = arguments[i].split("."), j=(objI[0]=="GLB")? 1 : 0; j<objI.length; j++) {
            object[ objI[j] ] 	= object[ objI[j] ] || {};
            object 				= object[ objI[j] ];
        }
		arrObjects.push(object);
    }
    return (arrObjects.length>1)? arrObjects : object;
};
/*
Captura de elementos
*/
GLB.$ = function(){
	return function(){
		var elements = [];
				
		for(var i=0; i<arguments.length; i++){
			var obj = null;
			
			if(typeof arguments[i] === "string")		var obj = document.getElementById(arguments[i]) || null;
			else if(typeof arguments[i] === "object")	var obj = arguments[i];
			if(obj==null && arguments[i]== "html")		var obj = document.getElementsByTagName("html")[0];
			if(obj==null && arguments[i]== "body")		var obj = document.body;
			if(obj==null && arguments[i]== "window")	var obj = window;
			
			if(obj!=null)elements.push(obj);
		}
		
		if(elements.length==1)return elements[0];
		if(elements.length>1) return elements;
			
		return null;
	}
}();
/*
Criação de elementos
*/
GLB.create = function(){
	return function(element, props){
		var el = document.createElement(element);
		if(!el) return null;
		
		for(var attr in props){
			if(attr=="innerHTML")
				el.innerHTML = props[attr];
			else
				el[attr] = props[attr];
		}
		
		return el;
	}
}();

GLB.queryString = function(){
	
	var _get = function(ID){
		var URL = document.location.href;
		if(URL.indexOf('?' + ID + '=')>-1){
			var qString = URL.split('?');
			var keyVal = qString[1].split('&');
			for(var i=0;i<keyVal.length;i++){
				if(keyVal[i].indexOf(ID + '=')==0){
					var val = keyVal[i].split('=');
					return val[1];
				}
			}
			return null;
		}else{
			return null;
		}
	}	
	
	var _set = function(ID, value){
	}
	
	return {
			get: _get, 
			set: _set
		   }
}();

/*
Eventos
*/
GLB.event = function() {
	/*
		.version: 1.0

		.date:
		26/09/2007
		
		.usage:
		GLB.event.add(window, 'load', _onload);
		or
		GLB.event.add(window, 'load', {scope: objeto, callback: "methodOfObject"});
	*/
	var _add = function(obj, evt, callback) {		
		if(callback && typeof(callback)==="function")var func =  callback;
		else if(typeof(callback)==="object"){
			if(typeof(callback.scope)==="object"){
				var func = GLB.util.delegate.create(callback.scope, callback.callback);
			}
		}
		if(obj.addEventListener) {
			obj.addEventListener(evt, func, false);
		} else if(obj.attachEvent) {
			obj.attachEvent('on' + evt, func);
		}
	}	

	return  {
		add: function(obj, event, callback) { 
			if(typeof obj==="object" && typeof event==="string" && (typeof callback==="function" || 
			  (typeof callback==="object" && typeof callback.scope==="object" && typeof callback.callback==="string")))
				return _add(obj, event, callback);
			else
				return null;
		}
	};		

}();

GLB.addDOMLoadEvent = (function(){
								
   var _callbacks = [];
   var _intervalVerify;
   var _isLoaded;
   
   var _doLoad = function () {
	   clearInterval(_intervalVerify);
	   
        _isLoaded = true;   
		var callback;
        while (callback = _callbacks.shift())
            callback();

        if(document.onreadystatechange) document.onreadystatechange = null;
    };

    return function (func) {
        if (_isLoaded) return func();        
        if (!_callbacks[0]) {
            //Mozilla/Opera9
            if(document.addEventListener)
               document.addEventListener("DOMContentLoaded", _doLoad, false);

			//Internet Explorer
            document.onreadystatechange = function(){
             	if(this.readyState == "complete")_doLoad();
            }

            //Safari
            if (/WebKit/i.test(navigator.userAgent)) { // sniff
                _intervalVerify = setInterval(function() {
                    if (/loaded|complete/.test(document.readyState))_doLoad();
                }, 10);
            }

            //Outros
            var oldOnload = window.onload;
            window.onload = function() {
                _doLoad();
                if(oldOnload)oldOnload();
            };
        }
        _callbacks.push(func);
    }
})();

/**
Version
**/
GLB.namespace("Browser");
GLB.Browser.version = function(){
	var o={
	    ie:0,
	    opera:0,
        gecko:0,
        webkit:0
    };
    var ua=navigator.userAgent, m;

    // Modern KHTML browsers should qualify as Safari X-Grade
    if ((/KHTML/).test(ua)) {
        o.webkit=1;
    }
    // Modern WebKit browsers are at least X-Grade
    m=ua.match(/AppleWebKit\/([^\s]*)/);
    if (m&&m[1]) {
        o.webkit=parseFloat(m[1]);
    }

    if (!o.webkit) { // not webkit
        // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
        m=ua.match(/Opera[\s\/]([^\s]*)/);
        if (m&&m[1]) {
            o.opera=parseFloat(m[1]);
        } else { // not opera or webkit
            m=ua.match(/MSIE\s([^;]*)/);
            if (m&&m[1]) {
                o.ie=parseFloat(m[1]);
            } else { // not opera, webkit, or ie
                m=ua.match(/Gecko\/([^\s]*)/);
                if (m) {
                    o.gecko=1; // Gecko detected, look for revision
                    m=ua.match(/rv:([^\s\)]*)/);
                    if (m&&m[1]) {
                        o.gecko=parseFloat(m[1]);
                    }
                }
            }
        }
    }
    return o;
}();

/**
Version
**/
GLB.jsPathDefault = "../js";
GLB.setJsPath = function(path){
	if(!typeof path === "string")return;
	GLB.jsPathDefault = (path.lastIndexOf("/")>=path.length)? path.substring(0, path.length-1) : path;
}
/**
Version
**/
GLB.controlPackage = function(){
	/*
		.version: 1.0
		
		.date:
		20/09/2007
		
		.usage:
		GLB.controlPackage.include("../js/arquivo.js");
		GLB.controlPackage.loadScript("../js/arquivo.js", callBack);
		
		.required
		GLB.util.httpRequest
		GLB.util.delegate
	*/
	GLB.namespace("GLB.util");
	
	var _onLoadScript = function(args){
		var scriptElement = document.createElement("script");
		scriptElement.setAttribute('type', 'text/javascript');
		scriptElement.innerHTML = args.result.responseText;
				
		document.getElementsByTagName('head')[0].appendChild(scriptElement);
		
		var callback = args.callback;	
		if(typeof(callback)==="object" && typeof(callback.arguments)==="object")callback.arguments.result = args.result.responseText;
		
		if(callback && typeof(callback)==="function")callback();
		else if(typeof(callback)==="object"){
			if(typeof(callback.scope)==="object"){
				var func = GLB.util.delegate.create(callback.scope, typeof(callback.callback)==="string" ? callback.callback : 'onLoadScript');
				if(func)func((callback.arguments)? callback.arguments : args.result.responseText);
			}
		}		
	}
	
	var _log = function(message){
		alert(" >> "+message);
	}
	
	return {
		include: function(path){
			if(typeof(path) != "string") return null;
			
			var scriptElement = document.createElement("script");
			scriptElement.setAttribute('type', 'text/javascript');
			scriptElement.setAttribute('src', path);
			
			document.getElementsByTagName('head')[0].appendChild(scriptElement);
		},
		loadScript: function(path, callBack){
			if(typeof(path) != "string") return null;
				
			if(!GLB.util.delegate){
				_log("Erro: O uso do método GLB.controlPackage.loadScript exige o pacote GLB.util.delegate já carregado");
				return null;
			}
			if(!GLB.util.httpRequest){
				_log("Erro: O uso do método GLB.controlPackage.loadScript exige o pacote GLB.util.httpRequest já carregado");
				return null;
			}
			
			var callbackLoad = {
				onComplete: _onLoadScript,
				arguments: {
					callback: callBack,
					path: path
				}
			}
			GLB.util.httpRequest.get(path, "", callbackLoad, false);			
		}
	}
}();

GLB.namespace("GLB.util");
GLB.util.css = function(){
	/*
		.version: 1.0
		
		.date:
		20/09/2007
		
		.usage:
		obj1.function = GLB.util.Delegate(obj2, "method");
		
		.required
		GLB.util.html
		
	*/
	var _isIe 		= GLB.Browser.version.ie;
	var _isOpera 	= GLB.Browser.version.opera;
	
	var _getStyle	= function(element, style) {
		element = (typeof element === "object")? element: GLB.$(element);
		var value = undefined;
		
		style = (style == 'float' || style == 'cssFloat') ? (_isIe? 'styleFloat' : 'cssFloat') : GLB.util.html.camelize(style);
		if (!value && !_isIe) {
			var css = document.defaultView.getComputedStyle(element, null);
			value = css ? css[style] : null;
		}		
		
		if (!value && element.currentStyle && _isIe) value = element.currentStyle[style];
		
		if (style == 'opacity' && _isIe) {
			if(value = (GLB.util.css.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))
				if (value[1])return parseFloat(value[1]) / 100;
		 
			return 1.0;
		}else if(style == 'opacity'){
			return value ? parseFloat(value) : 1.0;
		}
		
		if (value == 'auto' && _isIe) {
		  if ((style == 'width' || style == 'height') && (GLB.util.css.getStyle('display') != 'none'))
			return element['offset'+GLB.util.html.capitalize(style)] + 'px';
		  
		  return null;
		}
		
		return value == 'auto' ? null : value;		  
	}
	
	var _setStyle = function(element, styles, camelized) {
		element = (typeof element === "object")? element: GLB.$(element);
		
		var elementStyle = element.style, match;
		if (typeof styles === "string") {
			element.style.cssText += ';' + styles;
			return styles.indexOf('opacity') > -1 ? _setOpacity(element, styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
		}
	
		for (var property in styles)
			if (property == 'opacity')
				element.setOpacity(styles[property])
			else
				elementStyle[(property == 'float' || property == 'cssFloat') ?
					(elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : (camelized ? property : GLB.util.html.camelize(property))] = styles[property];
	
		return element;
	}
	
	var _setOpacity = function(element, value) {
		
		
		element = (typeof element === "object")? element: GLB.$(element);	
		
		if(!_isIe){
			element.style.opacity = (value == 1 || value === '') ? '' :  (value < 0.00001) ? 0 : value;	
			//alert(" OPACITY ::: "+element.style.opacity);
		}else {
			
			var filter = _getStyle(element, 'filter') || "", style = element.style;
			if (value == 1 || value === '') {
				style.filter = filter.replace(/alpha\([^)]*\)/,'');
				return element;
			}else if(value < 0.00001){
				value = 0;
			}
			style.filter = filter.replace(/alpha\([^)]*\)/, '') + 'alpha(opacity=' + (value * 100) + ')';
		}
		
		return element;
	}
	
	var _getDimensions = function(element) {
		element = (typeof element === "object")? element: GLB.$(element);
				
		var display = GLB.util.css.getStyle(element, 'display');
		
		// Safari bug
		if (display != 'none' && display != null)return{width: element.offsetWidth, height: element.offsetHeight};
		
		// All *Width and *Height properties give 0 on elements with display none,
		// so enable the element temporarily
		var els = element.style;
		
		var originalVisibility = els.visibility;
		var originalPosition = els.position;
		var originalDisplay = els.display;
		
		els.visibility = 'hidden';
		els.position = 'absolute';
		els.display = 'block';
		
		var originalWidth = element.clientWidth;
		var originalHeight = element.clientHeight;
		
		els.display = originalDisplay;
		els.position = originalPosition;
		els.visibility = originalVisibility;
		
		return {width: originalWidth, height: originalHeight};
	}
	
	var _getPosition = function(element){
		var x = 0, y = 0;
		if (!document.layers) {
			
			var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
			var mac = document.all && !onWindows && getExplorerVersion() == 4.5;
			var par = element;
			var lastOffsetTop = 0;
			var lastOffsetLeft = 0;
			
			while(par){
				if(par.leftMargin && !onWindows) x += parseInt(par.leftMargin);
				if(par.topMargin && !onWindows ) y += parseInt(par.topMargin);
				
				if((par.offsetLeft != lastOffsetLeft) && par.offsetLeft) 	x += parseInt(par.offsetLeft);
				if((par.offsetTop != lastOffsetTop) && par.offsetTop) 		y += parseInt(par.offsetTop);
				
				if(par.offsetLeft != 0) lastOffsetLeft 	= par.offsetLeft;
				if(par.offsetTop != 0 ) lastOffsetTop 	= par.offsetTop;
				
				par = mac ? par.parentElement : par.offsetParent;
			}
			
		} else if(element.x && element.y){
			x += element.x;
			y += element.y;
		}
		
		return {x: x, y: y};
	}
	
	var _addClass = function(element, _class){
		if(typeof element === "string") element = GLB.$(element);
		
		if (!element.className) element.className = ''; 
		var className = element.className;		
		if (!className.match(RegExp("\\b"+_class+"\\b"))) className = className.replace(/(\S$)/,'$1 ')+_class;		
		element.className = className;
	}
	var _removeClass = function(element, _class){
		if(typeof element === "string") element = GLB.$(element);
		
		if (!element.className) element.className = ''; 
		var className = element.className; 
		className = className.replace(RegExp("(\\s*\\b"+_class+"\\b(\\s*))*","g"),'$2');
		element.className = className;
	}
	
	var _checkClass = function(element, _class){
		if(typeof element === "string") element = GLB.$(element);
		
		if (!element.className) element.className = ''; 
		var className = element.className; 
		
		return className.match(RegExp("\\b"+_class+"\\b"));
	}
	
	var _log = function(message){
	}
			
	return {
		getStyle:function(element, style){
			if(!GLB.util.html)_log("Erro: O uso desse método (GLB.util.css.getStyle) exige o pacote GLB.util.html já carregado");
			
			if(_isOpera){
				switch(style) {
				  case 'left':
				  case 'top':
				  case 'right':
				  case 'bottom':
					if (_getStyle(element, 'position') == 'static') return null;
				  default: return _getStyle(element, style);
				}
			}else{
				return _getStyle(element, style);
			}			
		},
		setStyle:function(element, styles, camelized){
			if(!GLB.util.html)_log("Erro: O uso desse método (GLB.util.css.setStyle) exige o pacote GLB.util.html já carregado");			
			return 	_setStyle(element, styles, camelized);
		},
		getHeight: function(element) {
			return _getDimensions(element).height;
		},		
		getWidth: function(element) {
			return _getDimensions(element).width;
		},
		getPosition:function(element){
			return _getPosition(element);
		},
		addClass:function(element, _class){
			return _addClass(element, _class);
		},
		removeClass:function(element, _class){
			return _removeClass(element, _class);
		},
		checkClass:function(element, _class){
			return _checkClass(element, _class);
		}
	}
}();



GLB.namespace("GLB.util");
GLB.util.html = function(){
	/*
		.version: 1.0
		
		.date:
		20/09/2007
		
		.usage:
		obj1.function = GLB.util.Delegate(obj2, "method");
	*/
	return {
		stripTags:function(htmlText){
			return htmlText.replace(/<\/?[^>]+>/gi, '');
		},
		escape:function(htmlText){
			var div = document.createElement('div');
			var text = document.createTextNode(htmlText);
			div.appendChild(text);
			
			return div.innerHTML;	
		},
		unescape:function(htmlText){
			var div = document.createElement('div');
			div.innerHTML = stripTags(htmlText);
			
			return div.childNodes[0].nodeValue;
		},
		camelize:function(htmlText) {
			var parts = htmlText.split('-'), len = parts.length;
			if (len == 1) return parts[0];
			
			var camelized = htmlText.charAt(0) == '-' ? 
				parts[0].charAt(0).toUpperCase() + parts[0].substring(1) : parts[0];
			
			for (var i = 1; i < len; i++)
				camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
			
			return camelized;
		},		
		capitalize:function(htmlText) {
			return htmlText.charAt(0).toUpperCase() + htmlText.substring(1).toLowerCase();
		}
	}
}();

GLB.namespace("GLB.util");
GLB.util.delegate = function(){
	/*
		.version: 1.0
		
		.date:
		20/09/2007
		
		.usage:
		obj1.function = GLB.util.Delegate(obj2, "method");
	*/
	return {
		create:function(obj, method){
			
			if(typeof(method) != "string" || typeof(obj) != "object" || typeof(obj[method]) != "function") return null;
			return function(){
				return obj[method].apply(obj, arguments);
			}			
		}
	}	
}();

GLB.namespace("GLB.util");
GLB.util.httpRequest = function(){
	/*
		.version: 1.0
		
		.date:
		20/09/2007
		
		.usage:
		GLB.util.httpRequest.get("url", {params}, callback=function(){}, waitResponse);
		or
		GLB.util.httpRequest.post("url", {params}, {scope: object, onComplete: function(){}, arguments: {}}, waitResponse);
		
	*/	
	var _events = ["onStart", "onOpen", "onSend", "onLoad", "onComplete"];
	var _filter = encodeURIComponent;
	var	_objectsHTTP = [
						function(){return new XMLHttpRequest();},
						function(){return new ActiveXObject("MSXML2.XMLHTTP.3.0");},
						function(){return new ActiveXObject("Msxml2.XMLHTTP");},
						function(){return new ActiveXObject("Microsoft.XMLHTTP");}
						];
	/*
		 *- Metódo de verificação sobre o suporte ao HTTPRequest
		 |method _isSupported
		 |private static
		 |return {Boolean}  retorna o suporte ao uso do Objeto HTTP
	*/
	var _isSupported = function(){
		return !!_getConnection();
	};
	/*
		Método de captura de conexão
		|method _getConnection
		|private static
		|return {HTTP}  retorna o Objeto HTTP
	*/
	var _getConnection = function(){
		for(var i=0; i<_objectsHTTP.length; i++){
			try{
				return _objectsHTTP[i]();
			}catch(e){};
		}
		return null;
	};
	/*
		Formatação dos paramêtros para envio via GET ou POST
		|method _formatParams
	 	|private static
		|param  {Object} params - lista dos parametros a ser formatado
		|return {String} retorna uma string com os parâmetros formatados
	*/
	var _formatParams = function(params){
		var i, r = [];
		for(i in params){
			r[r.length] = i + "=" + (_filter ? _filter(params[i]) : params[i]);
		}
		return r.join("&");
	};
	/*
		Metódo de execução da consulta principal
		|method _request
	 	|private static
		|param  {String} method 			- Metódod de consulta: GET ou POST
		|param  {String} url 				- Url do arquivo requisitado
		|param  {Object} params 			- Lista de paramêtros a ser enviado ao arquivo
		|param  {Object||Function} handler	- callback
		|param  {String} headers 			- Cabeçalho para envio na solicitação
		|param  {Boolean} waitResponse		- Definição sobre a assincronia na consulta
		|return {Booelan} retorna um valor booleano sobre o sucesso da consulta
	*/
	var _request = function(method, url, params, handler, headers, waitResponse){
		if(!GLB.util.delegate && handler)_log("Erro: O uso desse método (get || post) exige o pacote GLB.util.delegate já carregado");
		var i, o = _getConnection(), f = typeof handler === "function", a = typeof handler === "object" && handler.arguments;
		try{
			if(typeof handler === "object" && handler.arguments)handler.arguments.result = o;

			o.open(method, url, !waitResponse);

			waitResponse || (o.onreadystatechange = function(){
				var s = _events[o.readyState];
				var func = f ? handler : (handler[s] ? handler[s]: null);
				if(func){
					if(typeof handler === "object" && typeof handler.scope==="object")var func = GLB.util.delegate.create(handler.scope, func);			
					func((typeof handler === "object" && handler.arguments)? handler.arguments : o)
				}				
			});
			
			o.setRequestHeader("HTTP_USER_AGENT", "XMLHttpRequest");
			
			for(i in headers)o.setRequestHeader(i, headers[i]);
			o.send(params);
			
			var func = f ? handler : ((handler["onComplete"])? handler["onComplete"]: null);			
			if(waitResponse && func){
				if(typeof handler === "object" && typeof handler.scope === "object")var func = GLB.util.delegate.create(handler.scope, "onComplete");
				func((typeof handler === "object" && handler.arguments)? handler.arguments : o)
			}			
			
			return o;
		}
		catch(e){
			return false;
		}
	};
	
	var _log = function(message){
		alert(" >> "+message);
	}
	
	return {
		/*
			Metódo de execução da consulta via GET
			|method get
			|public static
			|param  {String} url 				- Url do arquivo requisitado
			|param  {Object} params 			- Lista de paramêtros a ser enviado ao arquivo
			|param  {Object||Function} handler	- callback
			|param  {Boolean} waitResponse		- Definição sobre a assincronia na consulta
			|return {Booelan} retorna um valor booleano sobre o sucesso da consulta
		*/
		get:function(url, params, handler, waitResponse){
			return _request("GET", url + (url.indexOf("?") + 1 ? "&" : "?") + _formatParams(params), null, handler, {
				"Content-Type": "text/html; charset:UTF-8",
				"Content-length": 0,
				"Connection": "close"			
			}, waitResponse);
		},
		/*
			Metódo de execução da consulta via POST
			|method post
			|public static
			|param  {String} url 				- Url do arquivo requisitado
			|param  {Object} params 			- Lista de paramêtros a ser enviado ao arquivo
			|param  {Object||Function} handler	- callback
			|param  {Boolean} waitResponse		- Definição sobre a assincronia na consulta
			|return {Booelan} retorna um valor booleano sobre o sucesso da consulta
		*/
		post:function(url, params, handler, waitResponse){
			return _request("POST", url, params = _formatParams(params), handler, {
				"Connection": "close",
				"Content-Length": params.length,
				"Method": "POST " + url + " HTTP/1.1",
				"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
			}, waitResponse);
		}
	}	
}();



GLB.namespace("GLB.util");
GLB.util.hash = function(){
	var _isIE 				= (GLB.Browser.version.ie!=0);
	var _urlIframe			= "/Teste/equipe/luizadolpho/control.html";
	var _lastHash 			= "";
	var _checkInterval  	= null;
	var _hashProperties 	= [];
	var _events				= [];
	var _scope				= {};
	var _handleInterval		= 2000;
	var _ifStartHash		= false;
	
	var _startHash = function() {
		if(_ifStartHash)return;
	 	//if(_isIE === true)_createIFrame();	  
	 	_checkBookmark();
		_checkInterval = setInterval(_handleHistory, _handleInterval);
		
		_ifStartHash = true;
	}
	
	var _addEventListener = function( prop, obj, callback ){
		if(_events[prop]==undefined)_events[prop] = [];
		_events[prop].push( {obj: obj, callback: callback}  );
	}
	
	var _removeEventListener = function( prop, obj, callback){
		for(var i=0, x=_events[prop].length; i<x; i++){
			if(obj == _events[prop].obj) _events[prop].splice(i, 1);
		}
	}
	
	var _setTimeInterval = function( time ){
		_handleInterval = time;
		
		if(_checkInterval==null)return;
		
		clearInterval( _checkInterval );
		_checkInterval = setInterval(_handleHistory, _handleInterval);
	}
	
	var _startHandle = function(){
		_checkInterval = setInterval(_handleHistory, _handleInterval);		
	}
	
	var _stopHandle = function(){
		clearInterval( _checkInterval );
		_checkInterval = null;
	}
	
	var _setHashPropertie = function( prop, value ){		
		_hashProperties[prop] = value;
		_makeHistory( _getHashByProperties( _hashProperties ) );
		
		if(_events[prop] && _events[prop].length>0)_dispatchEventListener( _events[prop], value );
	}
	
	var _getHashPropertie = function( prop  ){
		return _hashProperties[prop];
	}
	
	
	//------------- METODOS PRIVADOS ---------------------//
	
	var _dispatchEventListener = function( events, argument ){
		 for(var i=0, x=events.length; i<x; i++){
			itemCall = events[i];
			var func = GLB.util.delegate.create(itemCall.obj, itemCall.callback);	
			func( argument );
		 }
	}
	
	var _makeHistory = function( hash ){
		_stopHandle();	
		
		//if(_isIE === true)GLB.$("content-hash").setAttribute("src", _urlIframe + "?hash=" + hash);
		window.location.hash = hash;
		_lastHash = hash;
		
		_startHandle();
	}
	
	var _handleHistory = function() {		
		var hash			 	= _getHash();
		var _newProperties  	= _getPropertiesByHash( hash );
		var _modifyProperties	= _getModifyProperties( _hashProperties, _newProperties );	
		
		_hashProperties = _newProperties;
		
		if(hash != _lastHash || _modifyProperties.length>0){	
			_makeHistory( hash );
		}
		
		for(var i=0, x=_modifyProperties.length; i<x; i++)
			_events[_modifyProperties[i]] && _dispatchEventListener( _events[_modifyProperties[i]], _newProperties[_modifyProperties[i]] );			
	}
	
	var _createIFrame = function() {
		var _body 		= GLB.$("body");
		var _iframe 	= GLB.util.css.setStyle(GLB.create("iframe", {src: _urlIframe, id: "content-hash"}), "display:none");
		
		_body.appendChild(_iframe);
		
		GLB.$("content-hash").onload = GLB.util.delegate.create(GLB.util.hash, "onloadiframe");
	}
	
	var _getHash = function(){
		var i, href;
		
        href 	= top.location.href;
        i 		= href.indexOf("#");
		
        return i >= 0 ? href.substr(i + 1) : "";	
	}
	
	var _getHashIE = function(){
		var i, href;
		
        href 	= GLB.$("content-hash").src;
        i 		= href.indexOf("?hash=");
		
        return i >= 0 ? href.split("?hash=")[1] : "";	
	}
	
	var _getHashByProperties = function( props ){
		var hash = "";
		for(var attr in props){
			hash += (hash=="")? attr +"="+ props[attr]: "&"+attr+"="+ props[attr];
		}
		return hash;
	}
	
	var _getModifyProperties = function( propA, propB ){
		var propsM = [];
		for(var attr in propA){
			if(propB[attr]!=undefined || (propA[attr]==propB[attr] && propA[attr]==undefined))continue;
			propsM.push( attr );
		}
		for(var attr in propB){
			if(propB[attr]!=propA[attr])propsM.push( attr );
		}
		return propsM;
	}
	
	var _getPropertiesByHash = function( hash, value ){
		var arr 	= hash.split("&");
		var props 	= [];
		
		for(var i=0, x=arr.length; i<x; i++){
			var prop 	= arr[i].split("=")[0];
			var value 	= arr[i].split("=")[1];
			
			props[prop] = value;
		}
		
		return props;
	}
	
	var _checkBookmark = function() {
		var hash = _getHash(); 		
		if(hash!=""){
			//if(_isIE === true)GLB.$("content-hash").setAttribute("src", _urlIframe + "?hash=" + hash);
			window.location.hash = hash;
		}
	}
	
	return {
		startHash: _startHash,
		addEventListener: _addEventListener,
		removeEventListener: _removeEventListener,
		setTimeInterval: _setTimeInterval,
		setHashPropertie: _setHashPropertie,
		getHashPropertie: _getHashPropertie,
		onloadiframe: function(){ GLB.$('body').innerHTML += "<br>leu iframe"; alert("RELEU IFRAME") }
	};
}();




GLB.namespace("GLB.common");
GLB.common.Galeria = function(){
	/*
		.version: 1.0
		
		.date:
		12/12/2007
		
		.usage:
		var galeria = new GLB.common.Galeria ("galeria.xml");
		
		.required
		GLB.util.html
		GLB.util.css
		GLB.util.httprequest
		GLB.util.animation		
		GLB.util.hash
		GLB.util.delegate
	*/
	
	var _classBtnThumb 				= "btn-thumb";
	var _classThumbGaleria 			= "thumb-galeria";
	var _classLinkTag				= "link-tag";
	var _classLinkNoticia			= "link-noticia";
	
	_galeria = function( urlGaleria ){
		this._urlGaleria 	= urlGaleria;
		this._xmlGaleria 	= "";
		this._xmlNodes 	 	= "";
		
		this._fotos			= [];
		this._tags			= [];
		
		GLB.util.hash.startHash();			
		
		this._indexThumbIni = GLB.util.hash.getHashPropertie("fotogaleria");
		if(isNaN(Number(this._indexThumbIni)))this._indexThumbIni = 0;		
		
		this._ifShowThumb	= false;
		
		this._totalThumbs	= 0;
		this._thumbsLoad	= 0;
		this._thumbs		= [];
		
		this._indexPag		= 0;
		this._indexThumb	= 0;
		this._wPaginacao	= 0;
		this._wTotal		= 0;
		
		this._thumbsPag		= 5;
		this._itemsPag		= 1;
		
		this._intervalSlide	= null;	
		this._ifSlide		= false;
		this._timeInterval	= 3000;
	}
	_galeria.prototype = {
		init:function(){
			GLB.util.hash.addEventListener("fotogaleria", this, "onchangehash");
			
			this.showHideTags( false );
			this.loadGaleria( this._urlGaleria );
		},
		onchangehash:function( newProp ){
			if(newProp===null || newProp===undefined || isNaN(newProp) || this._indexThumb==newProp-1)return;
			
			this._indexThumbIni = Math.max(0, Math.min(this._thumbs.length-1, newProp-1));
			this._indexPag		= Math.ceil((this._indexThumbIni+1)/this._thumbsPag)-1;
			
			this.goPagByIndex();
			this.loadImagesByIndexPag( this._indexPag );
			this.enablePagThumb();
			
			this.showImage( this._thumbs[this._indexThumbIni].parentNode._data, this._thumbs[this._indexThumbIni].parentNode );
		},
		setThumb:function( indexThumbIni ){
			this._indexThumbIni	= indexThumbIni||0;
		},
		setNavegacaoItems:function( ctNavegacao, btnPagNext, btnPagPrev, listaThumbs, listaThumbsItem, btnSlide ){
			this._ctNavegacao			= GLB.$(ctNavegacao);
			this._ctBtnPagNext 			= GLB.$(btnPagNext);
			this._ctBtnPagPrev 			= GLB.$(btnPagPrev);
			this._ctListaThumbs 		= GLB.$(listaThumbs);
			this._ctListaThumbsItem 	= GLB.$(listaThumbsItem).cloneNode(true);	
			this._btnSlide				= GLB.$(btnSlide);
		},
		setInfoItems:function( ctInformacao, imagemGaleria, btnImgPrev, btnImgNext, notice, autor, listaNoticias, listaNoticiasItem, fotoCorrente, totalFotos ){
			this._ctInformacao 			= GLB.$(ctInformacao);
			this._ctImagemGaleria 		= GLB.$(imagemGaleria);
			this._ctBtnImgPrev 			= GLB.$(btnImgPrev);
			this._ctBtnImgNext 			= GLB.$(btnImgNext);
			this._ctNotice 				= GLB.$(notice);
			this._ctAutor		 		= GLB.$(autor);
			this._ctListaNoticias 		= GLB.$(listaNoticias);
			this._ctListaNoticiasItem 	= GLB.$(listaNoticiasItem)? GLB.$(listaNoticiasItem).cloneNode(true) : "";	
			this._lbFotoCorrente		= GLB.$(fotoCorrente);
			this._lbTotalFotos 			= GLB.$(totalFotos);
		},
		setTags:function( listaTags, listaTagsItem, btnTags, btnImgTags, urlImgMais, urlImgMenos ){
			this._ctListaTags 			= GLB.$(listaTags);
			this._ctListaTagsItem 		= GLB.$(listaTagsItem).cloneNode(true);
			this._ctBtnTags 			= GLB.$(btnTags);
			this._ctBtnImgTags 			= GLB.$(btnImgTags);
			this._urlImgMais	 		= urlImgMais;
			this._urlImgMenos 			= urlImgMenos;
		},
		setImgButtons:function(btnRight, btnRightOff, btnLeft, btnLeftOff){
			
			this._btnRight 			= btnRight 		|| "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-direita-azul.gif";
			this._btnRightOff 		= btnRightOff 	|| "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-direita-azul-off.gif";
			this._btnLeft 			= btnLeft		|| "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-esquerda-azul.gif";
			this._btnLeftOff 		= btnLeftOff 	|| "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-esquerda-azul-off.gif";
			
		},
		loadGaleria:function( urlGaleria ){
			var Css				= GLB.util.css;
			
			GLB.util.httpRequest.get(urlGaleria, "", {scope: this, onComplete: "onLoadGaleria"});
		},
		onLoadGaleria:function( result ){
			this._xmlGaleria 	= result.responseXML;
			this._xmlNodes 		= result.responseXML.documentElement;
			
			this.createTags( this.parseNodeTags( this._xmlNodes ) );
			this.createThumbs( this.parseNodeFotos( this._xmlNodes ) );
			this._btnSlide.onclick = GLB.util.delegate.create(this, "stopIniSlide");
		},
		parseNodeTags:function( nodes ){
			
			var tags = nodes.getElementsByTagName("tag");
			
			for(var i=0, x=tags.length; i<x; i++){
				
				this._tags.push({
								 id: this._tags.length,
								 tag: tags[i].firstChild.nodeValue,
								 href: tags[i].attributes[0].value					 
								 });
				
			}			
			
			return this._tags;
		},
		parseNodeFotos:function( nodes ){
			
			var fotos = nodes.getElementsByTagName("foto");
			
			for(var i=0, x=fotos.length; i<x; i++){
				
		//alert(fotos[i].getElementsByTagName("autor")[0].firstChild.nodeValue);
				
				this._fotos.push({
								 id: this._fotos.length,
								 thumb: fotos[i].attributes[0].value,
								 foto: fotos[i].attributes[1].value,
								 noticia: fotos[i].getElementsByTagName("noticia")[0].firstChild.nodeValue,
								 autor: "Fotógrafo: "+fotos[i].getElementsByTagName("autor")[0].firstChild.nodeValue
								 //autor: fotos[i].attributes[2].value							 
								 });
				
			}			
			
			return this._fotos;
		},
		createTags:function( tags ){
			this._ctListaTags.innerHTML = "";		
			

			for(var i=0, x=tags.length; i<x; i++){
				var itemLista = this._ctListaTagsItem.cloneNode(true);
				var links	  = this.getElementsByClass( itemLista, "a", _classLinkTag );
				
				for(var j=0, y=links.length; j<y; j++){
					links[j]._class 	= this;
					links[j]._data	 	= tags[i];
					links[j]._index	 	= i;
					links[j].innerHTML 	= tags[i].tag;
					
					links[j].onclick 	= this.onReleaseTag;
				}
				
				this._ctListaTags.appendChild( itemLista );
			}
			
			if(tags.length>0){
				this._ctBtnTags.style.display = "block";
				this._ctBtnTags.onclick = GLB.util.delegate.create(this, "swapTag");
			}else{
				this._ctBtnTags.style.display = "none";
			}
		},
		createThumbs:function( fotos ){		
			this._ctListaThumbs.innerHTML = "";		
			
			this._totalThumbs	= fotos.length;
			this._thumbsLoad	= 0;
			this._thumbs		= [];
			
			for(var i=0, x=fotos.length; i<x; i++){
				var itemLista = this._ctListaThumbsItem.cloneNode(true);
				var links	  = this.getElementsByClass( itemLista, "a", _classBtnThumb );
				var thumbs	  = this.getElementsByClass( itemLista, "img", _classThumbGaleria );
				
				
				for(var j=0, y=links.length; j<y; j++){
					links[j]._class 	= this;
					links[j]._data	 	= fotos[i];
					links[j]._index	 	= i;
					links[j].onclick 	= this.onReleaseThumb;
				}
				
				for(var j=0, y=thumbs.length; j<y; j++){
					thumbs[j]._id		= j+1;
					thumbs[j]._class	= this;
					thumbs[j]._srcThumb	= fotos[i].thumb;
					thumbs[j].onload	= this.onLoadThumb;
					thumbs[j].loaded	= false;
					
					this._thumbs.push(thumbs[j]);
				}
				
				this._ctListaThumbs.appendChild( itemLista );
			}
			this._lbTotalFotos.innerHTML = this._thumbs.length;
			this.onCreateThumbs();
		},
		onCreateThumbs:function(){
			var Css				= GLB.util.css;
			var thumb			= this._thumbs[0];
			
			var loadW 	= Css.getWidth(thumb);
			var fl = parseInt(Css.getStyle(thumb, "padding-left").replace("px" ,""), 10) || 0;
			var fr = parseInt(Css.getStyle(thumb, "padding-right").replace("px" ,""), 10) || 0;
			var ml = parseInt(Css.getStyle(thumb, "margin-left", true).replace("px" ,""), 10) || 0;
			var mr = parseInt(Css.getStyle(thumb, "margin-right", true).replace("px" ,""), 10) || 0;
			
			var indexThumb 		= Math.max(0, Math.min(this._thumbs.length, this._indexThumbIni-1));
			
			this._indexPag		= Math.ceil(indexThumb/this._thumbsPag);
			this._wPaginacao	= loadW + 4 - (fl+fr);
			this._wTotal		= this._wPaginacao*this._thumbs.length;
						
			Css.setStyle(this._ctListaThumbs, "width: "+this._wTotal+"px");
			
			this.goPagByIndex();
			this.loadImagesByIndexPag( this._indexPag );
			this.enablePagThumb();
			
			if(!this._ifShowThumb){
				this.showImage( this._thumbs[indexThumb].parentNode._data, this._thumbs[indexThumb].parentNode );
			}			
		},
		loadImagesByIndexPag:function( index ){
			var limitImage 	= Math.min(this._indexPag*this._itemsPag+this._thumbsPag, this._thumbs.length)
			var iniImage 	= Math.max(0, limitImage-this._thumbsPag);			
						
			for(var i=iniImage, x=limitImage; i<x; i++){
				
				if(this._thumbs[i].loaded)continue;
				
				this._thumbs[i].src = this._thumbs[i]._srcThumb;
				this._thumbs[i].loaded = true;
			}			
		},
		onReleaseThumb:function(){			
			var Css 	= GLB.util.css;
			if( Css.checkClass(this, "selecionado") )return false;			
			
			//if( Css.checkClass(this.parentNode, "loading") )return false;
			
			this._class.showImage( this._data, this );			
			return false;
		},
		onReleaseTag:function(){
			return false;
		},
		deselectAllThumbs:function(){
			var Css 	= GLB.util.css; 
			for(var i=0, x=this._thumbs.length; i<x; i++){
				Css.removeClass( this._thumbs[i].parentNode, "selecionado" );
			}
		},
		selectThumbs:function( btns ){
			var Css 	= GLB.util.css; 
			for(var i=0, x=btns.length; i<x; i++){
				Css.addClass( btns[i], "selecionado" );
			}
		},
		showImage:function( data, element ){
			var Css = GLB.util.css; 
			Css.addClass(this._ctInformacao, "loading");
			
			this._ctImagemGaleria.onload = GLB.util.delegate.create(this, "onLoadImage");
			this._ctImagemGaleria.src = data.foto;			
			this._indexThumb = element._index;
			
			GLB.util.hash.setHashPropertie("fotogaleria", this._indexThumb+1 );
			
			this._lbFotoCorrente.innerHTML	= this._indexThumb+1;
			this._ctNotice.innerHTML		= data.noticia;
			//auterado para por o autor WR
			this._ctAutor.innerHTML         = data.autor;
			//this._ctAutor.href         = data.autor;
			
			this.enablePagImage();
			this.deselectAllThumbs();
			this.selectThumbs( this.getElementsByClass( element.parentNode, "a", _classBtnThumb ) );
		},
		onLoadImage:function(){
			var Css = GLB.util.css; 
			Css.removeClass(this._ctInformacao, "loading");
		},
		onLoadThumb:function(){
			var Css = GLB.util.css; 
			var li 	= this;
						
			while(li.nodeName.toLowerCase()!="li") li = li.parentNode;
			Css.removeClass(li, "loading");
			
			this._class._thumbsLoad++;
		},
		enablePagThumb:function(){
			var Css = GLB.util.css; 
			
			if(this._indexPag<Math.ceil(this._thumbs.length/this._itemsPag)-1 && this._indexPag<this._thumbs.length-this._thumbsPag){
				Css.removeClass(this._ctBtnPagNext, "link-desabilitado");
				this._ctBtnPagNext.getElementsByTagName("img")[0].src = "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-direita-azul.gif";
				
				this._ctBtnPagNext.onclick = GLB.util.delegate.create(this, "nextPag");
			}else{
				Css.addClass(this._ctBtnPagNext, "link-desabilitado");
				this._ctBtnPagNext.getElementsByTagName("img")[0].src = "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-direita-azul-off.gif";
				
				this._ctBtnPagNext.onclick = function(){return false};
			}
			if(this._indexPag>0){
				Css.removeClass(this._ctBtnPagPrev, "link-desabilitado");
				this._ctBtnPagPrev.getElementsByTagName("img")[0].src = "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-esquerda-azul.gif";
				
				this._ctBtnPagPrev.onclick = GLB.util.delegate.create(this, "prevPag");
			}else{
				Css.addClass(this._ctBtnPagPrev, "link-desabilitado");
				this._ctBtnPagPrev.getElementsByTagName("img")[0].src = "http://www.colegiolondrinense.com.br/imgsite/estrutura/galeria/seta-esquerda-azul-off.gif";
				
				this._ctBtnPagPrev.onclick = function(){return false};
			}
		},
		enablePagImage:function(){
			var Css = GLB.util.css; 
			
			if(this._indexThumb<this._thumbs.length-1){
				Css.removeClass(this._ctBtnImgNext, "link-desabilitado");
				this._ctBtnImgNext.onclick = GLB.util.delegate.create(this, "nextThumb");
			}else{
				Css.addClass(this._ctBtnImgNext, "link-desabilitado");
				this._ctBtnImgNext.onclick = function(){return false};
			}
			if(this._indexThumb>0){
				Css.removeClass(this._ctBtnImgPrev, "link-desabilitado");
				this._ctBtnImgPrev.onclick = GLB.util.delegate.create(this, "prevThumb");
			}else{
				Css.addClass(this._ctBtnImgPrev, "link-desabilitado");
				this._ctBtnImgPrev.onclick = function(){return false};
			}
		},
		nextPag:function(){
			//this.stopSlide();
			
			this._indexPag++;
			
			this.enablePagThumb();
			this.animPagByIndex();
			
			return false;
		},
		prevPag:function(){
			//this.stopSlide();
			
			this._indexPag--;
			
			this.enablePagThumb();
			this.animPagByIndex();
			
			return false;
		},
		nextThumb:function(){
			this.stopSlide();
			
			this._indexThumb = Math.min(this._indexThumb+1, this._thumbs.length-1);
			this._thumbs[this._indexThumb].parentNode.onclick();
			
			if(this._indexThumb>=this._indexPag*this._itemsPag+this._thumbsPag){
				this._indexPag++;
				this.animPagByIndex();
			}
			return false;
		},
		prevThumb:function(){
			this.stopSlide();
			
			this._indexThumb = Math.max(this._indexThumb-1, 0);
			this._thumbs[this._indexThumb].parentNode.onclick();
			
			if(this._indexThumb<this._indexPag*this._itemsPag){
				this._indexPag--;
				this.animPagByIndex();
			}
			return false;
		},
		startNextFoto:function( ){
			if(this._indexThumb==this._thumbs.length-1){
				this._indexThumb = 0;
				this.stopSlide();
			}else{
				this._indexThumb = Math.min(this._indexThumb+1, this._thumbs.length-1);
			}		
					
			var Css 	= GLB.util.css;			
			var btn 	= this._thumbs[this._indexThumb].parentNode;
			
			if( Css.checkClass( btn, "selecionado") );		
			this.showImage( btn._data, btn );
			
			if(!(this._indexThumb>this._indexPag*this._itemsPag && this._indexThumb<this._indexPag*this._itemsPag+this._thumbsPag)){
				var indexPag = Math.max(0, ((this._indexThumb+1)-this._thumbsPag)/this._itemsPag);
				this._indexPag = indexPag;
								
				this.animPagByIndex();
				this.enablePagThumb();
				this.enablePagImage();
			}			
		},
		stopIniSlide:function(){
			this._ifSlide = !this._ifSlide;
			this._btnSlide.innerHTML  = (this._ifSlide)? "parar slideshow": "iniciar slideshow";
			//alert(this._ifSlide);
			
			if(this._ifSlide){
				var _self = this;
				this._intervalSlide = setInterval(function(){ _self.startNextFoto() }, this._timeInterval);
				//alert("iniciar");
			}else{
				this.stopSlide();
				//alert("parar");
			}
			
			return false;
		},
		stopSlide:function(){
			clearInterval(this._intervalSlide);
			this._ifSlide = false;
			this._btnSlide.innerHTML  = (this._ifSlide)? "parar slideshow": "iniciar slideshow";
			//alert("aki");
		},
		goPagByIndex:function(){
			var xend = -Math.max(0, Math.min((this._thumbs.length-this._thumbsPag)*this._wPaginacao, (this._indexPag*this._itemsPag)*this._wPaginacao));
			
			var Css	= GLB.util.css;
			Css.setStyle(this._ctListaThumbs, "left: "+Math.round(xend)+"px");
		},
		animPagByIndex:function(){
			var Tween 	= GLB.common.animation.Tween;			
			var Css		= GLB.util.css;
			
			var xini = parseInt((Css.getStyle(this._ctListaThumbs, "left") || "0").replace("px" ,""), 10) || 0;
			var xend = -Math.min((Math.max(this._thumbs.length, this._thumbsPag)-this._thumbsPag)*this._wPaginacao, (this._indexPag*this._itemsPag)*this._wPaginacao);
			
			var anim = new Tween(xini, xend, 500, {element: this._ctListaThumbs, _class:this});
			//anim.easingEquation = GLB.common.animation.elasticEquation; 
			anim.onAnimation 	= this.adjustPosPag;
			anim.onEndAnimation = this.endAdjustPosPag;
			anim.init();	
		},
		adjustPosPag:function(value, args){
			if(!args.element)return;
		
			var Css	= GLB.util.css;
			Css.setStyle(args.element, "left: "+Math.round(value)+"px");
		},
		endAdjustPosPag:function(value, args){
			if(!args.element)return;
			
			var Css = GLB.util.css;
			Css.setStyle(args.element, "left: "+Math.round(value)+"px");	
			
			args._class.loadImagesByIndexPag( this._indexPag );
		},
		showHideTags:function( value ){
			this._ctListaTags.style.display = value? "block": "none";
		},
		swapTag:function(){
			var onShow = !(this._ctListaTags.style.display=="block");
			this.showHideTags( onShow );
			
			this._ctBtnImgTags.src = onShow? this._urlImgMenos: this._urlImgMais;			
			return false;	
		},
		getElementsByClass:function( elmentRoot, elementName, _class ){
			var Css			= GLB.util.css;
			var items 		= elmentRoot.getElementsByTagName( elementName );
			var itemsClass  = [];
			
			for(var i=0, x=items.length; i<x; i++){
				if(Css.checkClass( items[i], _class))
					itemsClass.push(items[i]);
			}
			return itemsClass;			
		}
	}
	
	return _galeria;		
}();

// JavaScript Document
GLB.namespace("GLB.common");
GLB.common.animation = function(){
	/*
		.version: 1.0
		
		.date:
		20/09/2007
		
		.usage:
		var anim = new GLB.common.animation.Tween(inivalue, endvalue, duration);
		anim.setAnimation(GLB.common.animation.bounceEquation);
		anim.init();				
	*/
	
	/*
	Static Function
	*/
	var _easingEquation = function(t,b,c,d,a,p)
	{
		return c/2 * ( Math.sin( Math.PI * (t/d-0.5) ) + 1 ) + b;
	}
	var _bounceEquation = function(t,b,c,d,a,p)
	{
		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;
		}
	}
	var _elasticEquation = 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 < 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);
	}
	/*
		Class		
	*/
	var $anim = function(inivalue, endvalue, duration, args){
		this._duration 	= duration;
		this._inicial 	= inivalue;	
		this._final 	= endvalue;
		this._args		= args;		
	}
	$anim.prototype = {
		init:function(){
			if(typeof this._inicial === "array" && typeof this._final === "array" && this._inicial.length != this._final.length)return;
			
			var _self = this;
		
			this._iniTime = new Date().getTime();
			this._interval = setInterval(function(){
				_self.setAnimation();
			}, 5);
		},
		setAnimation:function(){
			var curTime = new Date().getTime()-this._iniTime;	
			
			if (curTime >= this._duration){
				  this.onEndAnimation && this.onEndAnimation(this._final, this._args || {});
				 clearInterval(this._interval);
				 return;
			}
			
			if(typeof this._inicial === "object"){
				var _tempArr = [];
				for(var i=0; i<this._inicial.length; i++){
					_tempArr.push(this.easingEquation(curTime, this._inicial[i], parseInt(this._final[i]-this._inicial[i]), this._duration));
				}
				this.onAnimation && this.onAnimation(_tempArr, this._args || {});
			}else
				this.onAnimation && this.onAnimation(this.easingEquation(curTime, this._inicial, parseInt(this._final-this._inicial), this._duration), this._args || {});
		},
		easingEquation:_easingEquation
	}
	
	return {
		Tween			: $anim,
		easingEquation	: _easingEquation,
		bounceEquation	: _bounceEquation,
		elasticEquation	: _elasticEquation
	}
}();

