var IEmenu = {
	init: function(){
		if($.browser.msie){
			$("#principal>li").hover(IEmenu.contextMenuOn, IEmenu.contextMenuOff);
			$("#principal>li>ul>li").hover(IEmenu.contextSubMenuOn, IEmenu.contextSubMenuOff);
		}
	},
	
	contextMenuOn: function(){
		$(this).addClass("over");
		$("a.mainMenuOpt", this).css("background","url('img/menu_active.jpg') repeat-x bottom").css("color","#004177");
	},
	
	contextMenuOff: function(){
		$(this).removeClass("over");
		$("a.mainMenuOpt", this).css("background"," url('img/menu_back.jpg') repeat-x bottom").css("color","#FFF");
	},
	
	contextSubMenuOn: function(){
		$("ul", this).show();
	},
	
	contextSubMenuOff: function(){
		$("ul", this).hide();
	}
};

var AtendOnline = {
	init : function(){
		$(".atd").removeAttr("target");
		//$(".atd").attr("href", "javascript:void();");
		$(".atd").click(AtendOnline.open);
	},
	
	open : function(){
		window.open( 'http://www.gb.com.br/gb/suporte/cliente/index.asp', 'AtendimentoOnline', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=450, left=300, top=100');
		return false;
	}
};

var Brindes = {
	init : function(){
		$("#brindes td").hover(Brindes.on, Brindes.off);
	},
	
	on : function(){
		$(this).addClass("over");
	},
	
	off : function(){
		$(this).removeClass("over");
	}
};

var Games = {
	show : "carros",

	init : function(){
		$("#games h3").hide();
		//$("#games ul li a").attr("href","javascript:void();");
		$("#games ul li a").click(Games.dispara);
		$("#games td").hover(Games.tdOver, Games.tdOut);
		Games.showHide();
	},
	
	dispara : function(){
		Games.show = $(this).attr("id").substr(1);
		Games.showHide();
		return false;
	},
	
	showHide : function(){
		$("#carros, #acao, #concen, #cartas").hide();
		$("#lcarros, #lacao, #lconcen, #lcartas").removeClass("act");
		$("#l" + Games.show).addClass("act");
		$("#" + Games.show).show();
	},
	
	tdOver : function(){
		$(this).addClass("over");
	},
	
	tdOut : function(){
		$(this).removeClass("over");
	}
};

var PictureShow = {
	init : function(){
		$("#brindes a").click(PictureShow.mostra);
		$("#picturefundo").click(PictureShow.viewThumbs);
	},
	
	mostra : function(){
		$("#picturefundo").fadeIn(500);
		img = this.href;		
		$.ajax({
			type: "get",
			url: img,
			cache: true,
			success: function(){
				$("#pictureshow").html("<img src='" + img + "' />");
				$("#pictureshow").css("margin-left", "-" + Math.ceil($("#pictureshow img").attr("width")/2) + "px");
				$("#pictureshow").css("margin-top", "-" + Math.ceil($("#pictureshow img").attr("height")/2) + "px");
				$("#pictureshow").slideDown(1000);
				}
			});
		return false;
	},
	
	viewThumbs : function(){
		$("#pictureshow").slideUp(500, function(){$("#picturefundo").fadeOut(500);});
		
	}
};

var Reg = {
	init : function(){
		$("#reglink").removeAttr("target");
		//$("#reglink").attr("href", "javascript:void();");
		$("#reglink").click(Reg.open);
	},
	
	open : function(){
		window.open('regulamento.html', 'Regulamento', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=450, left=300, top=100');
		return false;
	}
};

$(function(){
	IEmenu.init();
	AtendOnline.init();
	Brindes.init();
	Reg.init();
	Games.init();
});
