/**
 * Class: ToggleBox
 * @targ: Target
 * @objetive: objective to toggleShow
 * 
 * Author: Oesía Net. (dprados@oesia.com)
 */

var ToggleBox = function(){}
ToggleBox.prototype = {
	target: "",
	objetive: "",
	init: function(targ, objective){
		
		this.target = document.getElementById(targ);
		this.objetive = document.getElementById(objective);
		
		try {
			if (this.target == null) 
				throw "[Portal Sala prensa] Elementos target no encontrado.";
			else  if (this.objetive == null) 
					throw "[Portal Sala prensa] Elementos objetivo no encontrado.";
			else
				this.fire();	
		}
		catch(e){
			throw new Error(e);
		}
	},
	fire: function(){
		addEvent(this.target, "click", function(){
			this.toggle(this.objetive, true);
		}.bind(this));
	},
	toggle: function(objetive, changeClass){
		/*Pure js*/
		/*var status = objetive.style.display || "block";
		var action = (status=="block")?"expand":"collapse";
		objetive.style.display = (status=="block")?"none":"block";*/
		
		/*jQuery*/
		$(objetive).slideToggle();
		
		if(changeClass){
			toggleClass(this.target, "icon-expand", "icon-collapse")
		}
		
		return objetive.style.display;
	}
}
