jQuery(document).ready(function()
{

	function mouseOver(target)
	{	
	
		$(target).clearQueue();
//		$(target).addClass('ativo');
		$(target).fadeTo('linear', 1.0, function() {
			       // Animation complete.
			   });	
//		$(target).switchClass('','ativo',500,'linear');		
	}
	
	function mouseOut(target)
	{
		$(target).fadeTo('slow', 0.5, function() {
					// Animation complete.	
//					$(target).clearQueue();
			   });
//		$(target).switchClass('ativo','',500,'linear');	
		
	}
	
	function slideIn(target)
	{
   		$('#windows').addClass('normal').removeClass('full');
   		
   		$(target).animate({ right: '0px' }, 600, function() {
		    	// Animation complete.
		    	
		    	$(target).switchClass('fechado','aberto',1000);		
		    	$(target).hover( function(){ mouseOver(this) }, function(){ mouseOut(this) } );
		});
		
		console.log( 'painel entrou' );
	}
	
	function slideOut(target)
	{
		var delta  = '-=';
			delta += getStyle(target, 'width');
		
		
		$(target).unbind('mouseenter mouseleave');
		$(target).animate({ right: delta }, 500,'swing', function() {
			    // Animation complete.
		   		$(target).switchClass('aberto','fechado',1000);
		   		$('#windows').addClass('full').removeClass('normail');
		   		
		   		
		});
		
		console.log( 'painel saiu' );
	}
	
	function getStyle(x,styleProp)
	{
		if (x.currentStyle)
			var y = x.currentStyle[styleProp];
		else if (window.getComputedStyle)
			var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
		return y;
	}
	
	$('#txt').toggle( function(){ slideOut(this) }, function(){ slideIn(this) } );
	$('#txt').hover( function(){ mouseOver(this) }, function(){ mouseOut(this) } );
	
	$('.box').hover( function(){ mouseOver(this) }, function(){ mouseOut(this) } );
	$('.box').trigger('mouseleave');
	
});



var options = { 
	onOpen: function(obj){pageTracker._trackPageview(obj.content);},
	bgcolor:'#ffffff',
	overlayColor: '#dfdad5',
	overlayOpacity: 1,
};

Shadowbox.init(options);

