var PopDrape = {
	vsbl: [],
	showcls: null,
	hidecls: null,
	showShade: function(self)
	{
		self.css('display', self.attr('olddisplay'));
		self.css('visibility', 'visible');
		self.parent().find('.cord').addClass(PopDrape.showcls);
		self.parent().find('.cord').removeClass(PopDrape.hidecls);
	},
	hideShade: function(self)
	{
		self.css('visibility', 'hidden');
		self.attr('olddisplay', self.css('display'));
		self.parent().find('.cord').addClass(PopDrape.hidecls);
		self.parent().find('.cord').removeClass(PopDrape.showcls);
		self.css('display', 'none');
	},
	toggleShade: function(self)
	{
		shade = self.parent().find('.shade');
		if(shade.css('visibility') == 'hidden')
		{
			PopDrape.showShade(shade);
		}
		else
		{
			PopDrape.hideShade(shade);
		}
	},
	/*
	 * init:
	 * 		Initualizes the PopDrape object
	 * Arguments: class; show-class; hide-class; visible.
	 * 		class = css class for the drape.
	 * 		show-class = css class to apply when drape is shown
	 * 		hide-class = css class to apply when drape is hiden
	 * 		visible = array of class id's that will be visible when initualized.
	 */
	init: function()
	{
		if(arguments.length == 0)
		{
			cls = '';	
		}
		else
		{
			cls = arguments[0];
			if(arguments.length > 1)
			{
				PopDrape.showcls = arguments[1];
				if(arguments.length > 2)
				{
					PopDrape.hidecls = arguments[2];
					if(arguments.length > 3)
					{
						PopDrape.vsbl = arguments[3];
					}
				}
			}
		}
		cords = $(cls+' .cord');
		shades = $(cls+' .shade');
		cords.css('cursor', 'pointer');
		cords.click(function(){PopDrape.toggleShade($(this));});
		
		shades.each(function()
		{
			var i = 0;
			for(i = 0; i < PopDrape.vsbl.length; i++) 
				if(PopDrape.vsbl[i] == $(this).attr('id')) 
					return;
			PopDrape.hideShade($(this));
		});
	}
};
