$(document).ready(function(){
	$('img.thumb').each(function(){
		var image = new Image();
		image.src = $(this).attr('image');
		$(this).click(function(){
			var newSrc   = $(this).attr('image');
			var newTitle = $(this).attr('title');
			$('#image').fadeOut(400, function(){
				$('#image').attr('title', newTitle);
				$('#image').attr('alt', newTitle);
				$('#image').attr('src',newSrc).bind('readystatechange load', function(){
					if (this.complete) $(this).fadeIn(400);
				})
			});		
		})
	})
	_wBase = 75;
	_hBase = 75;
	$('.image-search img').each(function(){
		var newLeftMargin = ($(this).width() > _wBase) ? (($(this).width() - _wBase)/2) : $(this).width();
		if(newLeftMargin < _wBase){
			$(this).css('marginLeft',(newLeftMargin*-1));
		}
		var newLeftTop = ($(this).height() > _hBase) ? (($(this).height() - _hBase)/2) : $(this).height();
		if(newLeftTop < _hBase){
			$(this).css('marginTop',(newLeftTop*-1));
		}
	})
	if(_CONTENT_SEARCH_KEYWORD != undefined){
		if(_CONTENT_SEARCH_KEYWORD != ''){
			if($('#content_keyword').length > 0){
				$('#content_keyword').val(_CONTENT_SEARCH_KEYWORD);
			}
		}
	}
});

function content_search(){
	content_keyword  = $('#content_keyword').val();
	if(content_keyword != ''){
		var search_url = new Array();
		search_url.push(_CONTENT_SEARCH_URL);
		search_url.push(content_keyword);
		window.location.href = search_url.join('');
	} else {
		alert('Digite o termo que deseja buscar.');
		$('#content_keyword').focus();
	}
}
