var JadeFX = {
	_create_fx: function(element)
	{
		if(typeof(element.fx)=="undefined")	{ element.fx= new Object();	}
	},
	Show: function (element)
	{
		//Jade.FX._create_fx(element);
		//if(typeof(element.fx._display)!="undefined"){ element.style.display = element.fx._display; }
		element.style.display = 'block';
		element.visible = true;
	},
	Hide: function (element)
	{
		/*
		if(element.style.display!='none'){
			Jade.FX._create_fx(element);
			element.style.display=
			element.fx._display = element.style.display;
			
			element.style.display = 'none';
		}*
		*/
		element.style.display = 'none';
		element.visible = false;
	},
	IsShow: function (element){
		return element.style.display!='none';
	},
	SetOpacity: function (element,opacity){
		element.style.opacity = (opacity / 100);
		if(Jade.Browser.isIE){ element.style.filter = "alpha(opacity=" + opacity + ")"; }
	},
	ToggleDisplay: function (element) 
	{
		Jade.FX._create_fx(element);
		if ( element.style.display != 'none' )
		{
			element.fx._display = element.style.display;
			element.style.display = 'none';
		}
		else
		{
			element.style.display = element.fx._display;
		}
	},
	Fade: function (element,start,end,step,time)
	{
		if(typeof(step)=="undefined") { step = 1; }
		if(typeof(time)=="undefined") { time = 1; }
		if(start<0) { start=0; }
		if(end>100) { end=100; }
		if(start>end) { step = -step; }
		Jade.FX._create_fx(element);
		
		Jade.FX.SetOpacity(element,start);
		element.style.visibility='visible';
		if(typeof(element.fx._display)!="undefined") { element.style.display = element.fx._display; }
		
		element.fx.fade_time = time;
		element.fx.fade_step = step;
		element.fx.fade_end = end;
		element.fx.fade_current = start;
		
		setTimeout(function() { Jade.FX._fade(element); },time);
	},
	_fade: function (obj)
	{
		
		obj.fx.fade_current += obj.fx.fade_step;
		if(obj.fx.fade_step>0 && obj.fx.fade_current>obj.fx.fade_end) { obj.fx.fade_current = obj.fx.fade_end; }
		if(obj.fx.fade_step<0 && obj.fx.fade_current<obj.fx.fade_end) { obj.fx.fade_current = obj.fx.fade_end; }
		Jade.FX.SetOpacity(obj, obj.fx.fade_current);
		
		if(obj.fx.fade_step>0 && obj.fx.fade_current<obj.fx.fade_end) { setTimeout(function() { Jade.FX._fade(obj); },obj.fx.fade_time); }
		else if(obj.fx.fade_step<0 && obj.fx.fade_current>obj.fx.fade_end) { setTimeout(function() { Jade.FX._fade(obj); },obj.fx.fade_time); }
		if(obj.fx.fade_current==100) { Jade.FX.Show(obj); }
		if(obj.fx.fade_current==0) { Jade.FX.Hide(obj); }
	},
	Resize: function(object,start_width,start_height,end_width,end_height,step_x,step_y,time)
	{
		if(typeof(step_x)=="undefined") { step_x=1; }
		if(typeof(step_y)=="undefined") { step_y=1; }
		if(typeof(time)=="undefined") { time=1; }
		
		if(start_width>end_width) { step_x = -step_x; }
		if(start_height>end_height) { step_y = -step_y; }
		
		
		Jade.FX._create_fx(object);
		Jade.FX._parse_size(object,start_width,start_height);
		
		
		object.fx.resize_time=time;
		object.fx.resize_step_x=step_x;
		object.fx.resize_step_y=step_y;
		object.fx.resize_width=end_width;
		object.fx.resize_height=end_height;
		
		setTimeout(function() { Jade.FX._resize(object); },time)
	},
	_resize: function(object)
	{
		var width=object.fx.resize_current_width+object.fx.resize_step_x;
		var height=object.fx.resize_current_height+object.fx.resize_step_y;
		
		if(object.fx.resize_step_x>0 && width>object.fx.resize_width) { width=object.fx.resize_width; }
		if(object.fx.resize_step_x<0 && width<object.fx.resize_width) { width=object.fx.resize_width; }
		
		if(object.fx.resize_step_y>0 && height>object.fx.resize_height) { height=object.fx.resize_height; }
		if(object.fx.resize_step_y<0 && height<object.fx.resize_height) { height=object.fx.resize_height; }
		
		if(width!=object.fx.resize_width || height!=object.fx.resize_height ) 
		{
			setTimeout(function() { Jade.FX._resize(object); },object.fx.resize_time);
		}
		else
		{
			if(typeof(object.onfinishresize)!="undefined" && typeof(object.onfinishresize)!="object") { object.onfinishresize(); }			
		}
		
		Jade.FX._parse_size(object,width,height);
	},
	SlideDown: function (object,start_height,end_height,step,time)
	{
		if(typeof(step)=="undefined") { step=0; }
		if(typeof(time)=="undefined") { time=1; }
		if(start_height>end_height) { step = -step; }
		
		
	},
	Blink:function(object,time){
		Jade.FX.ToggleDisplay(object);
		setTimeout(function(){ Jade.FX.Blink(object,time); },time);
	},
	_parse_size: function(object,width,height)
	{
		object.fx.resize_current_width=width;
		object.fx.resize_current_height=height;
		object.style.width=width+'px';
		object.style.height=height+'px';
	}
}
Jade.LoadLibrary('FX',JadeFX);