/*
 * Slide module created by Dante.leonardo (www.leonardopereira.com)
 */
$(function(){
	// get objects
	var box 		= $("#boxVejaTambem"),
		mask		= box.find('.mask'),
		content		= mask.find('ul'),
		btnUp		= box.find('.lnk_vertical_arrow_top'),
		btnDown		= box.find('.lnk_vertical_arrow_bottom');
		
	// slide up action
	btnUp.click(function(){
		if(content.height() < mask.height()) return;
		
		topPos	= getTopPos(content);
		topPos	+= mask.height();
		
		if(topPos > 0)
			topPos = 0;
			
		content.animate({ marginTop: (topPos+'px') }, 'slow');
	})
	// slide down action
	btnDown.click(function(){
		if(content.height() < mask.height()) return;
		
		topPos	= getTopPos(content);
		topPos	-= mask.height();
		
		if((topPos - mask.height()) < -(content.height()))
			topPos = -(content.height() - mask.height());
		
		content.animate({ marginTop: (topPos-18+'px') }, 'slow');
	})
})

function getTopPos (obj) {
	return Number(String(obj.css('margin-top')).replace('px', ''));
}
