﻿if (typeof(google) == "object") {
	var map_elm = document.getElementById("map");
	if (map_elm) {
		function mapsLoaded() {
			if (GBrowserIsCompatible()) {
				var map = new google.maps.Map2(map_elm);
				var point = new google.maps.LatLng(-23.640308,-46.697356);
			
				map.addControl(new google.maps.SmallMapControl());
				map.setCenter(point, 17);
				map.addOverlay(new google.maps.Marker(point));
				map.openInfoWindow(point, document.createTextNode("Bufalo Grill"));
			}
		}
	
		google.load("maps", "2", {"callback" : mapsLoaded});
		window.onunload = function () { GUnload() }; //Prevents memory leak
	}
}

/*if (typeof(swfobject) == "object") {
	var params = { quality: "high", wmode: "transparent", allowscriptaccess: "sameDomain" };
	
	swfobject.embedSWF(root_path+'media/common_banner.swf', "common_banner", "width", "height", "10.0.0", root_path+'media/expressInstall.swf', false, params);
	if (document.getElementById("banner-specific")) {
		swfobject.embedSWF(root_path+'media/banner.swf', "banner-specific", "width", "height", "10.0.0", root_path+'media/expressInstall.swf', false, params);
	}
}*/
window.onload = function() {
/*	if ($("body#home").length > 0) {
		$.prettyPhoto.open('/images/carnes/01_full.jpg', 'Aproveite!', 'Preço especial do rodízio no jantar – R$25,90<br><span style="font-size: smaller">(Todos os dias - exceto bebidas e sobremesas)</span>');
	}*/
};

if (typeof(jQuery) == "function") {
	$(function() {
		$('head').append('<link rel="stylesheet" type="text/css" href="/styles/jquery.plugins.css" media="screen" />');

		
		$('a[rel="external"]').click(function(e) {
			e.preventDefault();
			window.open(this.href, this.title);
		});
		$('a[rel="popup"]').click(function(e) {
			e.preventDefault();
			params = "width=1024,height=768,fullscreen=0,menubar=0,location=0,status=0,toolbar=0,scrollbars=1";
			window.open(this.href, this.title, params);
		});
		
		if (/MSIE 6/i.test(navigator.userAgent)) {
			$('#nav li').hover(
				function () {
					$(this).addClass('over');
				},
				function () {
					$(this).removeClass('over');
				}
			)
		}
    
        $("#telephone, #mobile").attr('alt', 'phone').setMask();
        $("#event_date, #birthday").attr('alt', 'date').setMask();
       
    	/*if ($.isFunction($.fn.lightBox)) {
   			$('a[rel*=lightbox]').lightBox({
   				overlayBgColor: '#000',
   				overlayOpacity: 0.4,
   				imageBlank: '/images/lightbox-blank.gif',
   				imageLoading: '/images/lightbox-ico-loading.gif',
   				imageBtnClose: '/images/lightbox-btn-close.gif',
   				imageBtnPrev: '/images/lightbox-btn-prev.gif',
   				imageBtnNext: '/images/lightbox-btn-next.gif',
   				containerResizeSpeed: 350,
   				txtImage: 'Imagem',
   				txtOf: 'de'
   			});
   		}*/

   		if ($.isFunction($.fn.prettyPhoto)) {
   			$("a[rel^='prettyPhoto']").prettyPhoto({
				animationSpeed: 'normal', /* fast/slow/normal */
				padding: 40, /* padding for each side of the picture */
				opacity: 0.4, /* Value betwee 0 and 1 */
				showTitle: true, /* true/false */
				allowresize: false, /* true/false */
				counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				theme: 'dark_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
			});
   		}

		if ($.isFunction($.fn.validate)) {
	        $('#reservas #content form').before("<div id='errors'><strong>Corrija os seguintes erros:</strong><ul></ul></div>").validate({
				rules: {
					name: "required",
					company: "required",
					email: {
						required: true,
						email: true
					},
					telephone: "required",
					mobile: "required",
					people_amount: "required",
					event_date: {
						required: true,
						date: true
					},
					comments: "required"
				},
				messages: {
					name: "Informe o seu Nome",
					company: "Informe a Empresa",
					email: {
						required: "Informe o seu E-mail",
						email: "E-mail inválido"
					},
					telephone: "Informe o Telefone",
					mobile: "Informe o Celular",
					people_amount: "Informe a quantidade de pessoas",
					event_date: {
						required: "Informe a data do evento",
						date: "Data inválida"
					},
					comments: "Deixe seu comentário"
				},
	            errorElement: 'strong',
				errorContainer: "#errors",
				errorLabelContainer: "#errors ul",
				wrapper: "li"
	        });
			$('#promocoes #content form').before("<div id='errors'><strong>Corrija os seguintes erros:</strong><ul></ul></div>").validate({
				rules: {
					name: "required",
					address: "required",
					email: {
						required: true,
						email: true
					},
					telephone: "required",
					mobile: "required",
					birthday: {
						required: true,
						date: true
					}
				},
				messages: {
					name: "Informe o seu Nome",
					address: "Informe o Endereço",
					email: {
						required: "Informe o seu E-mail",
						email: "E-mail inválido"
					},
					telephone: "Informe o Telefone",
					mobile: "Informe o Celular",
					birthday: {
						required: "Informe a sua Data de Nascimento",
						date: "Data inválida"
					}
				},
	            errorElement: 'strong',
				errorContainer: "#errors",
				errorLabelContainer: "#errors ul",
				wrapper: "li"
	        });
		}
		if (!$("#cardapio").is(":hidden")) {
			carousel_props = { 
				pagination: true,
				loop: true,
				autoSlide: true, 
				autoSlideInterval: 3000,
				delayAutoSlide: 1000,
				effect: 'fade'
			};
			$("#cardapio-menu a").click(function() {
				$('.slideshow').fadeOut('fast');
				slide = $($(this).attr('href')+" .slideshow");
				if (!slide.is('.js')) {
					slide.fadeIn().carousel(carousel_props);
				} else {
					slide.fadeIn();
				}
				
			});
			
			if (location.hash != '') {
				slide = $('#'+location.hash+' .slideshow');
			} else {
				slide = $('.cardapio-item:first .slideshow');
			}

			slide.fadeIn().carousel(carousel_props);
		}
		if (!$('#home').is(':hidden')) {
			$("#images_scroll").carousel({
				loop: true,
				autoSlide: true, 
				autoSlideInterval: 3000,
				delayAutoSlide: 1000,
				effect: 'fade'
			}).find('.next, .previous').hide('fast');
		}
		/*$.getScript("http://jquery-rotate.googlecode.com/files/jquery.rotate.1-1.js", function() {
			if (document.getElementById("cardapio")) {
				$(".cardapio-item").rotate(30);
			}
		});*/
	});
}
