(function($){
	$.extend({
		thick_rvaz_centralize : function(){
			//document.recalc();
			$('.thick-rvaz').css({width:$(window).width(), height:$(window).height()});
			var left = ($(window).width()/2) - ($('.thick-content').width()/2);
			var top  = ($(window).height()/2) - ($('.thick-content').height()/2);
			if($.browser.msie && ($.browser.version == 7 || $.browser.version == 6))
			left -= $('.thick-content').offset().left - left;
			$('.thick-content').css({top:top,left:left});
			//document.recalc();
			//alert('recalc');
		}
	});
	$.fn.thick_rvaz = function() {
	   //alert($.browser.version == 7);
	   $(window).bind('resize',function(){
			$('.thick-rvaz').css({width:$(window).width(), height:$(window).height()});
			var left = ($(window).width()/2) - ($('.thick-content').width()/2);
			var top  = ($(window).height()/2) - ($('.thick-content').height()/2);
			$('.thick-content').css({top:top,left:left});
	   });
	   return $(this).unbind('click').click(function(){
				var html = '<div class="thick-rvaz">&nbsp;</div><div class="thick-content">&nbsp;</div>';
				//$('.thick-rvaz,.thick-content').fadeOut('fast');
				//$('body').prepend(html);
				$href = $(this).attr('href');
				$href = $href.split('?');
				$href = $href[1];
				$params = $href.split('&');
				str_obj = '{';
				for(var i = 0; i < $params.length; i++){
					$indice = $params[i].split('=');
					str_obj += str_obj.length > 1 ? ',' : '';
					str_obj += '"'+$indice[0]+'":"'+$indice[1]+'"';
				}
				str_obj += '}';
				$params = eval('('+str_obj+')');
				//#TB_inline?height=505&width=810&inlineId=programa&modal=true
				var id_content = $params.inlineId;
				var left = ($(window).width()/2) - ($params.width/2);
				var top = ($(window).height()/2) - ($params.height/2);
				$('.thick-rvaz,.thick-content').show();
				$('.thick-content').css({top:top,left:left}).html($('#'+id_content).html());
				$('.thick-rvaz').css({width:$(window).width(), height:$(window).height()});
				init_focus();
				if($(this).hasClass('anuncieLink'))
				$('select[name=assunto]').selectOptions("quero anunciar");
				if($(this).hasClass('btFale'))
				$('select[name=assunto]').selectOptions("outros");
				if($(this).hasClass('btVerFotos')){
					var options = {
						idGallery: $params.idGalery, 
						urlAjaxImages: baseURL+'cms/ajax/getImgsGaleria.php',
						urlAjaxInfo: baseURL+'cms/ajax/loadInfoGalery.php',
						cols: 2,
						offset: 10,
						imgInit: 1,
						marginThumbs: '5px',
						boxThumbWidth: '70px',
						boxThumbHeight: '70px',
						boxImageWidth: '600px',
						boxImageHeight: '450px',
						pagination: 'Página %n de %t',
						info: '<span class="galeriaTitulo">%title</span> <span class="galeriaData">%d/%m/%Y (%credits) <a href="javascript:void(0);" click="tb_remove();" class="tbFechar">&nbsp;</a></span><span style="clear:both;"></span>',
						path: baseURL+'images/galerias/',
						resizeThumb: false,
						resizeImage: true,
						prevNextButtons: true,
						sulfixThumb: 'min_',
						btnPrevImage: baseURL+'images/galeriaRvaz/galeria_bt_anterior-trans.png',
						btnNextImage: baseURL+'images/galeriaRvaz/galeria_bt_proxima-trans.png',
						btnprevPage: baseURL+'images/layout/bt_input_left.png',
						btnnextPage: baseURL+'images/layout/bt_input.png'
					};
					$('.thick-content .classGaleriaNoticia').gallery_rVaz(options);
				}
				if($.browser.msie && ($.browser.version == 7 || $.browser.version == 6))
				$.thick_rvaz_centralize();
				return false;
			});
	}
})(jQuery);

function tb_init(objs){
	$(objs).thick_rvaz();
}
function open_thick(obj){
	$(obj).each(function(){
		var html = '<div class="thick-rvaz">&nbsp;</div><div class="thick-content">&nbsp;</div>';
		//$('.thick-rvaz,.thick-content').fadeOut('fast');
		//$('body').prepend(html);
		$href = $(this).attr('href');
		$href = $href.split('?');
		$href = $href[1];
		$params = $href.split('&');
		str_obj = '{';
		for(var i = 0; i < $params.length; i++){
			$indice = $params[i].split('=');
			str_obj += str_obj.length > 1 ? ',' : '';
			str_obj += '"'+$indice[0]+'":"'+$indice[1]+'"';
		}
		str_obj += '}';
		$params = eval('('+str_obj+')');
		//#TB_inline?height=505&width=810&inlineId=programa&modal=true
		var id_content = $params.inlineId;
		var left = ($(window).width()/2) - ($params.width/2);
		var top = ($(window).height()/2) - ($params.height/2);
		
		$('.thick-rvaz,.thick-content').show();
		$('.thick-content').css({top:top,left:left}).html($('#'+id_content).html());
		$('.thick-rvaz').css({width:$(window).width(), height:$(window).height()});
		init_focus();
		if($.browser.msie && ($.browser.version == 7 || $.browser.version == 6))
		$.thick_rvaz_centralize();
	});
}
function tb_remove(){
	$('.thick-rvaz,.thick-content').hide();
}