swfobject.embedSWF("swf/menu.swf?o=1", "swf_menu", "960", "320", "9.0.0", "", "", {wmode:"transparent"});
swfobject.embedSWF("swf/creditos.swf", "swf_creditos", "400", "30", "9.0.0", "", "", {wmode:"transparent"});

var ajax = $.ajax();

$(document).ready(function(){
	$("a[rel='zoom']").colorbox();
});

function op_light(url, titulo){
	$.fn.colorbox({href:url, title:titulo});	
}

function close_flo(){
	$("#floater").hide();	
}
function verificar_news(){
	//Get the data from all the fields
	var nome = $('input[name=txtNome]');
	var email = $('input[name=txtEmail]');

	//Simple validation to make sure user entered something
	//If error found, add hightlight class to the text field
	if (nome.val() == '') {
		alert('Preencha o campo Nome!');
		nome.focus();
		return false;
	}
	if (email.val() == '') {
		alert('Preencha o campo E-mail!');
		email.focus();
		return false;
	} else {
		var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!regex.test(email.val())) {
			alert('E-mail inválido!');
			email.focus();
			return false;
		}
	}
	
	$.ajax({
		type: "POST",
		url: 'cadastrar_news.aspx',
		async: false,
		data: {txtNome:nome.val(), txtEmail:email.val()}, 
		timeout: 2000,
        error: function(){
               alert('ERRO!\nTente novamente mais tarde.');
        },
		dataType: "html",
		success: function(data){
			nome.val('');
			email.val('');
			alert('Informações cadastradas com sucesso.');
		}
	});
		
	return false;
}

function get(url){

	$("#loader_pg").show();
	$("#pagina").hide();
	$("#pagina").html('');

	ajax = $.ajax({
		type: "GET",
		url: url,
		cache: true,
		timeout: 2000,
        error: function(){
			get("erro.asp?p=" + url);	
        },
		dataType: "html",
		success: function(data){
			$("#loader_pg").hide();
			$("#pagina").show();
			$("#pagina").html(data);
		}
	});
		
	return false;
}

function cardapio(){
	$('#wrap #nav .content').css('position', '');
	$('.cardapio .area .content .item').click(function(){
		
		document.title = 'COPA - ' + $(this).attr('title');
		
		var item_id = $(this).find('dl').attr('id');

		var data = item_id.split('-');
		var cat_id = data[1];
		var prd_id = data[0];
		
		if($('div[class*="info-"]:visible').size() >= 1){
			$.each($('div[class*="info-"]:visible'), function(){
				if($(this).attr('class') != 'item_info info-' + cat_id){
					$(this).slideUp('slow', function(){
														$(this).hide();
														$(this).html('');
														$('html,body').animate({scrollTop: $('#' + item_id).offset().top}, 1000);
													   });
				}
			});
		}else{
			$('html,body').animate({scrollTop: $('#' + item_id).offset().top}, 2000);
		}

		get_cardapio_item(cat_id, prd_id);
		
		$(".item").removeClass('ativo');
		$(this).addClass('ativo');
		$('.info-' + cat_id).slideDown('slow');
	});

	if(window.location.hash != ""){
		$(window.location.hash).parent().click();
	}
}
function goTo(id){
	$('html,body').animate({scrollTop: $('#c' + id).offset().top}, 1000);	
}
function get_cardapio_item(cid, pid){

	$(".info-" + cid).html('');
	//document.title = 'COPA';

	ajax = $.ajax({
		type: "GET",
		url: "ax_Cardapio_Item.aspx?ItemID=" + pid + "&LocID=" + cid,
		cache: true,
		timeout: 2000,
        error: function(){
			return false;	
        },
		dataType: "html",
		success: function(data){
			$(".info-" + cid).html(data);
			$('.cardapio .item_info .close').click(function(){
				$('.info-' + cid).slideUp('slow', function(){$(this).hide();$(this).html('');$(".item").removeClass('ativo');});
				return false;
			});
		}
	});
		
	return false;
}

