$(document).ready(function() {
	
	// Hora do Topo
	$('.oferecimentoIn').clock({"calendar":"false","format":"24"});
	
	// var newyear = new Date("December 31, 2011 23:59:59");
	// $('.oferecimentoIn').countdown({until: newyear});

	// REJECT (Aviso para navegadores desatualizados)
	$.reject(); // Default Settings  
	// return false;

	$('.LinkPublicidade').click(function(){
		$.ajax({
			url:'/publicidade/clique/'+$(this).attr('rel'),
			type:'get',
			data:{'href':$(this).attr('href')}
		});
	});
	
	// Fechar Float
	$('.close_container_float').click(function(){
		$('#container_float').fadeOut();
		return false;
	})
	
	// Twitter
	if ($(".tweet").length) {
		$(".tweet").tweet({
		    join_text: "auto",
		    avatar_size: 35,
		    count: 4,
		    auto_join_text_default: '',
		    auto_join_text_ed: '',
		    auto_join_text_ing: '',
		    auto_join_text_reply: '',
		    auto_join_text_url: '',
		    loading_text: 'Carregando tweets...',
		    query: '@mcz40'
		});
	};
	
	// Colorbox
	$(".colorboxiframe").colorbox({width:"30%", height:"60%", iframe:true});
	
	
	// Gazeta Web
	var s = document.createElement("script");
	s.type = "text/javascript"; s.async = true; s.charset = "iso-8859-1";
	s.src = "http://gazetaweb.globo.com/Barra/nova/js/barra.js";
	var ss = document.getElementsByTagName("script")[0]; ss.parentNode.insertBefore(s, ss);
});

$('img.rounded').one('load',function () {
	var img = $(this);
	var img_width = img.width();
	var img_height = img.height();
 
	// build wrapper
	var wrapper = $('<div class="rounded_wrapper"></div>');
	wrapper.width(img_width);
	wrapper.height(img_height);
 
	// move CSS properties from img to wrapper
	wrapper.css('float', img.css('float'));
	img.css('float', 'none')
 
	wrapper.css('margin-right', img.css('margin-right'));
	img.css('margin-right', '0')
 
	wrapper.css('margin-left', img.css('margin-left'));
	img.css('margin-left', '0')
 
	wrapper.css('margin-bottom', img.css('margin-bottom'));
	img.css('margin-bottom', '0')
 
	wrapper.css('margin-top', img.css('margin-top'));
	img.css('margin-top', '0')
 
	wrapper.css('display', 'block');
	img.css('display', 'block')
 
	// IE6 fix (when image height or width is odd)
	if ($.browser.msie && $.browser.version == '6.0')
	{
		if(img_width % 2 != 0)
		{
			wrapper.addClass('ie6_width')
		}
		if(img_height % 2 != 0)
		{
			wrapper.addClass('ie6_height')			
		}
	}
 
	// wrap image
	img.wrap(wrapper);
 
	// add rounded corners
	img.after('<div class="tl"></div>');
	img.after('<div class="tr"></div>');
	img.after('<div class="bl"></div>');
	img.after('<div class="br"></div>');
	
}).each(function(){
	if(this.complete) $(this).trigger("load");
});


function newWindow(mypage, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',status=yes, resizable'
	win = window.open(mypage, '', winprops)

	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}
}

