
var flog8p = new Object();
flog8p.hideAnimate = function( obj ) {
	try{
		if(typeof(obj)=="string")obj = document.getElementById(obj);
		var eff = new fx.Combo(obj, {
			onComplete:function() {
				Element.remove(this.el);
			}
		});
		eff.toggle();
	}catch(e){}
}

flog8p.Applications = function(){};
flog8p.Applications.prototype = {
	accordion:function(links,contents,opac)	{
		var f8acc = new fx.Accordion(links, contents, {opacity: opac});
	},
	closeRemember:function(obj)	{
		var eff = new fx.RememberHeight(obj, {transition:fx.quadIn});
		return eff;
	}
}
flog8p.accordion = function(linkClass,containerClass){
	var grupos = document.getElementsByClassName(containerClass);
	var links =  document.getElementsByClassName(linkClass);
	new fx.Accordion(links, grupos, {opacity: true});
	
	//var f8App = new flog8p.Applications();
	//f8App.accordion(links,grupos,true);
}

flog8p.initBox = function( component ){
	var handler = document.getElementById(component + '_handler');
	var contents = document.getElementById(component + '_contents');
	var eff = new fx.RememberHeight(contents, {transition:fx.quadIn, onComplete:function(){
		var size = parseInt(this.el.style.height);
		if ( size > 0 ) {
			this.el.style.height = '';
		}
	}});

	if (eff.fx.now > 0 ) {
		handler.innerHTML = '[-]';
	} else {
		handler.innerHTML = '[+]';		
	}
	
	handler.onclick = function() {
		this.blur();
		if (eff.fx.now > 0 ) {
			handler.innerHTML = '[+]';
		} else {
			handler.innerHTML = '[-]';		
		}
		eff.toggle();
		return false;
	}
}

flog8p.closeBox = function(a,container,init){
	// alert(a);
	var f8App = new flog8p.Applications();
	var boxPerf = f8App.closeRemember(container);
	if(!init)boxPerf.toggle();
	this.changeCaracter(a,'[-]','[+]');
	a.blur();
	return false;
}


flog8p.changeCaracter = function(obj,open,close){
	obj.innerHTML = obj.innerHTML.indexOf(open)!= -1 ? obj.innerHTML = obj.innerHTML.split(open).join(close) : 	 obj.innerHTML = obj.innerHTML.split(close).join(open);
}


flog8p.move = function(target,objMove,offx,offy){
	this.target = document.getElementById(target);
	this.obj = document.getElementById(objMove);
	this.offx = offx;
	this.offy = offy;
	this.obj.style.display = "block";
	this.obj.style.left = this.moveX(this.offx,this.target)+"px";
	this.obj.style.top = this.moveY(this.offy,this.target)+"px";
	var eff = new fx.Opacity(objMove,{});
	eff.setOpacity(0);
	eff.now = 0;
	eff.toggle();
	return false;
};
flog8p.move.prototype = {
	moveX:function(x, elem){
		if (!document.layers) {
			var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
			var mac = document.all && !onWindows && getExplorerVersion() == 4.5;
			var par = elem;
			var lastOffset = 0;
			while(par){
				if(par.leftMargin && !onWindows) x += parseInt(par.leftMargin);
				if((par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
				if(par.offsetLeft != 0) lastOffset = par.offsetLeft;
				par = mac ? par.parentElement : par.offsetParent;
			}
		} else if (elem.x) x += elem.x;
		return x;	
	},
	moveY:function(y, elem)
	{
		if(!document.layers) {
			var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
			var mac = document.all && !onWindows && getExplorerVersion() == 4.5;
			var par = elem;
			var lastOffset = 0;
			while(par){
				if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
				if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
				if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
				par = mac ? par.parentElement : par.offsetParent;
			}		
		} else if (elem.y >= 0) y += elem.y;
		return y;
	}
	
}
flog8p.Scroll = function(container,mask,speed){
	/*
		container -> div com o conteudo que será scrollado;
		mask -> div com position absolute e overflow hidden;
		speed -> valor em pixel do movimento;
		
	*/

	//detect browser
	this.gE = (document.getElementById) ? 1:0;
	this.aL = (document.all) ? 1:0;
	
	//atribuindo argumentos, passados no construtor
	this.container = document.getElementById(container);
	this.mask = document.getElementById(mask);
	this.speed = speed;
	
	//variaveis de controle;
	this.ymax = 0;
	this.ymin = 0;
	this.xmax = 0;
	this.xmin = 0;
	this.ymove = 0;
	this.xmove = 0;
	this.interval = 0;
	
	//init
	this.init();
};
flog8p.Scroll.prototype = {
	init:function(hor)
	{
	    var msH = parseInt(this.mask.offsetHeight);
		var ctH = parseInt(this.container.offsetHeight);
	    var msW = parseInt(this.mask.offsetWidth);
		var ctW = parseInt(this.container.offsetWidth);
		this.ymin = (ctH - msH) * -1;
		this.xmin = (ctW - msW) * -1;
		
		//alert(ctH+","+msH);
		
	},
	stopScroll:function(){
		clearTimeout(this.interval);
	},
	scrollUp:function()
	{
		if (this.ymove < this.ymax) {
			this.ymove+= this.speed;
			if (this.ymove > this.ymax) this.ymove = this.ymax;
			this.moveTo(this.xmove, this.ymove);
			var self = this;
			this.interval = setTimeout(function() {self.scrollUp()} ,25);
		}
	},
	scrollDown:function()
	{
		//alert(this.ymove+","+this.ymin);
		if (this.ymove > this.ymin) {
			this.ymove -= this.speed;
			if (this.ymove < this.ymin) this.ymove = this.ymin;
			this.moveTo(this.xmove, this.ymove);
			var self = this;
			this.interval = setTimeout(function() {self.scrollDown()} ,25);
		}
	},
	scrollLeft:function()
	{
		
		if (this.xmove < this.xmax) {
			this.xmove+= this.speed;
			if (this.xmove > this.xmax) this.xmove = this.xmax;
			this.moveTo(this.xmove, this.ymove);
			var self = this;
			
			this.interval = setTimeout(function() {self.scrollLeft()} ,25);
		}
	},
	scrollRight:function()
	{
	
		if (this.xmove > this.xmin) {
			this.xmove -= this.speed;
			if (this.xmove < this.xmin) this.xmove = this.xmin;
			this.moveTo(this.xmove, this.ymove);
			var self = this;
			this.interval = setTimeout(function() {self.scrollRight()} ,25);
		}
	},
	moveTo:function(x, y) 
	{
		if(this.gE){
			this.container.style.left = x + "px";
			this.container.style.top = y + "px";
		}else if(this.aL){
			this.container.style.pixelLeft = x;
			this.container.style.pixelTop = y;
		}
	}
}