/**
 * Effect manager
 * 
 * @author Antoine Ughetto
 * @version 0.1
 * 
 * @package P6_framework
 * @subpackage javascript
 */
var P6_effects = {
	
	'anim':function(obj){	
		if(!document.getElementById(obj.id)){obj.id=eval(obj.id)}
		new YAHOO.util.Anim(obj.id, obj.parameters, obj.duration, eval(obj.easing)).animate();		
	},	
	'animcall':function(obj){		
		var anim_call =new YAHOO.util.Anim(obj.id, obj.parameters, obj.duration, eval(obj.easing))
		anim_call.onComplete.subscribe(obj.subscribe);
		anim_call.animate();		
	},
	
	'motion':function(obj){
		
		if(!document.getElementById(obj.id)){obj.id=eval(obj.id)}
		new YAHOO.util.Motion(obj.id, obj.parameters, obj.duration, eval(obj.easing)).animate();		
		
	},
	
	'moveTo':function(obj){
		P6_effects.motion({'id':obj.id, 'parameters':{ 'points' : {'to' : obj.parameters }}, 'duration':obj.duration, 'easing' :obj.easing});	
		
	},
	
	'fadein':function(obj){		
		P6_effects.anim({'id':obj.id, 'parameters':{'opacity' : {'from' : 0 , 'to': 1} }, 'duration':obj.duration, 'easing' :obj.easing});		
	},
	'fadeout':function(obj){
		P6_effects.anim({'id':obj.id, 'parameters':{'opacity' : {'from' : 1 , 'to': 0} }, 'duration':obj.duration, 'easing' :obj.easing});		
			
	},
	
	'reduce':function(obj){
		el = document.getElementById(obj.id);
		if(!el){
			el=document.getElementById(eval(obj.id));
		}
		
		P6_effects.anim({'id':obj.id, 'parameters':{'width' : {'from' : el.offsetWidth , 'to': 0}, 'height' : {'from' : el.offsetHeight , 'to': 0} }, 'duration':obj.duration, 'easing' :obj.easing});	
		
	},	
	'grow':function(obj){
		el = document.getElementById(obj.id);
		if(!el){
			el=document.getElementById(eval(obj.id));
		}
		
		P6_effects.anim({'id':obj.id, 'parameters':{'width' : {'from' : 0 , 'to': el.offsetWidth}, 'height' : {'from' : 0 , 'to': el.offsetHeight} }, 'duration':obj.duration, 'easing' :obj.easing});			
	},
	
	'reduceW':function(obj){
		el = document.getElementById(obj.id);
		if(!el){
			el=document.getElementById(eval(obj.id));
		}
		
		P6_effects.anim({'id':obj.id, 'parameters':{'width' : {'from' : el.offsetWidth , 'to': 0}}, 'duration':obj.duration, 'easing' :obj.easing});	
		
	},	
	'growW':function(obj){
		el = document.getElementById(obj.id);
		if(!el){
			el=document.getElementById(eval(obj.id));
		}
		
		P6_effects.anim({'id':obj.id, 'parameters':{'width' : {'from' : 0 , 'to': el.offsetWidth}}, 'duration':obj.duration, 'easing' :obj.easing});			
	},
	
	'reduceH':function(obj){
		el = document.getElementById(obj.id);
		if(!el){
			el=document.getElementById(eval(obj.id));
		}
		
		P6_effects.anim({'id':obj.id, 'parameters':{'height' : {'from' : el.offsetHeight , 'to': 0} }, 'duration':obj.duration, 'easing' :obj.easing});	
		
	},	
	'growH':function(obj){
		el = document.getElementById(obj.id);
		if(!el){
			el=document.getElementById(eval(obj.id));
		}
		
		P6_effects.anim({'id':obj.id, 'parameters':{'height' : {'from' : 0 , 'to': el.offsetHeight} }, 'duration':obj.duration, 'easing' :obj.easing});			
	}
	
}
