
function resizeDiv (){ 
	 var totalSize = $('#barra').width();
	$('#it-wrapper').css('width',totalSize - ($('#logo').width() + $('#text_more').width() + 100));
	var numChild = $('#items').find('.item').length;
	var sizeItems = (numChild * 88);
	$('#items').css('width', sizeItems + 'px');
	/*if(sizeItems < totalSize) {
		$('#scroll_right').hide();
		$('#scroll_left').hide();
	}*/

}

var resizeTimer = null;
	$(window).bind('resize', function() {
	if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(resizeDiv, 100);
});
	
$(document).ready(function () {
	resizeDiv();
	$('.tip').hide();
	$('#scroll_right').click(function() { hideAll(); $('#it-wrapper').scrollTo('+=252px',300);});	
	$('#scroll_left').click(function() { hideAll(); $('#it-wrapper').scrollTo('-=252px',300);});	
	$.each($('.item'),function(i,o){
										var dscdiv = $('#'+$(o).attr('id').replace('item','desc'));

										});
	$('.item').hover(
      function () {
		clearTimeout(window.hideTimer);
		hideAll();
		var dscdiv = $('#'+$(this).attr('id').replace('item','desc'));
		var position = $(this).offset();
		$(dscdiv).css({
					  'left': (parseInt(position.left)-100) + 'px'
					  });
		if(position.left + $(dscdiv).width() > screen.availWidth) {
			$(dscdiv).css('left', screen.availWidth - ($(dscdiv).width() + 30) + 'px');
			posdsc = $(dscdiv).offset();			
			$(dscdiv).find('.marker').css('left',((position.left - posdsc.left) + 25) + 'px');
		}
				
		$(dscdiv).fadeIn();
      }, 
      function () {
		  window.hideTimer = setTimeout(hideAll,3000);
      }
    );
	
	$('.tip').hover(
      function () {
		clearTimeout(window.hideTimer);
      }, 
      function () {
		  window.hideTimer = setTimeout(hideAll,3000);
      }
    );
	
});

function hideAll() {
	$('.tip').hide();
}

