/*
 * M2BRNET (m2brnet.com)
 * Autor: Alexandrino Souza (alexandrino.net)
 * Data de modificação: 26/07/2010
 */

function radioOx()
{		
	//tb_show('Radio Ox','#TB_inline?height=250&width=350&inlineId=box-radio','')
	//window.open("http://www.oxgrupo.com.br/som.html","Radio Ox","status=1"); 
	window.open ("http://www.oxgrupo.com.br/som.html","RadioOx","menubar=1,resizable=1,width=400,height=150"); 
	
	
}
 
$(function(){
	
	/* 
	 * SUBMENU
	 */
	 
	$('#main-menu li').mouseover(function(){
		$(this).children('ul').show();
		//$('#main-menu li').children('ul').css({'left':'1px'});
	}).mouseout(function(){
		$(this).children('ul').hide();
	});
	$('#main-menu li ul li').mouseover(function(){	
		$(this).children('ul').css({"left":"140px","top":"1px"});
	});
	
	$('.ofc').mouseover(function(){
		$('.ofc a.bt').addClass('act');
	}).mouseout(function(){
		$('.ofc a.bt').removeClass('act');
	});
	
	$('.op').mouseover(function(){
		$('.op a.bt').addClass('act');
	}).mouseout(function(){
		$('.op a.bt').removeClass('act');
	});		
	
	$('.eo').mouseover(function(){
		$('.eo a.bt').addClass('act');
	}).mouseout(function(){
		$('.eo a.bt').removeClass('act');
	});	
	
	$('.ohl').mouseover(function(){
		$('.ohl a.bt').addClass('act');
	}).mouseout(function(){
		$('.ohl a.bt').removeClass('act');
	});		
	
	$('.oed').mouseover(function(){
		$('.oed a.bt').addClass('act');
	}).mouseout(function(){
		$('.oed a.bt').removeClass('act');
	});		
	
	$('.oz').mouseover(function(){
		$('.oz a.bt').addClass('act');
	}).mouseout(function(){
		$('.oz a.bt').removeClass('act');
	});			
	
	$('.ol').mouseover(function(){
		$('.ol a.bt').addClass('act');
	}).mouseout(function(){
		$('.ol a.bt').removeClass('act');
	});			
	
	$('#content-side li').mouseover(function(){
		$(this).children('ul').show();
	}).mouseout(function(){
		$(this).children('ul').hide();
	});
	
	$('.list-atividades .bt').click(function(){
		if($(this).hasClass('act')){
			$(this).removeClass('act');
			$(this).parent('li').children('.det-at').hide();
		}else{
			$(this).addClass('act');
			$(this).parent('li').children('.det-at').show();
		}
		return false;
	});
	
	
	if($('.tbl-cardapio').length){
		
	$('.tbl-cardapio .cl1').each(function(){		
			var height = $(this).height();
			var height2 = $(this).children('small').height();
				
			if($(this).children('small').length){
				$(this).height( height + 30 ).css({'position':'relative','padding':'10px 0 0 0','vertical-align':'top'});
				$(this).parent('tr').children('.cl2').css({'vertical-align':'middle'});
				}
		});
	}
	
	// FUNÇÃO DO FLASH PARA ABRIR O POP DA RADIO OX

	
 	// Máscara de texto
	$(":text").labelify();	
	
	$('.tel').mask('(99) 9999-9999');
	$('#contato_nascimento').mask('99/99/9999');
	$('.data_form').mask('99/99/9999');
	$('#trabalhe_nascimento').mask('99/99/9999');
	
	// TARGET _BLANK
	$("a[rel=external]").attr('target','_blank');

	// valida e-mail
	var validaEmail = function(s) {
		var regexpEmail = /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		return regexpEmail.test(s);
	}; // fim validaEmail		
	
	/*
	// Banner Rotator	
	function mycarousel_initCallback(carousel)
	{
	    // Disable autoscrolling if the user clicks the prev or next button.
	    carousel.buttonNext.bind('click', function() {
	        carousel.startAuto(0);
	    });

	    carousel.buttonPrev.bind('click', function() {
	        carousel.startAuto(0);
	    });

	    // Pause autoscrolling if the user moves with the cursor over the clip.
	    carousel.clip.hover(function() {
	        carousel.stopAuto();
	    }, function() {
	        carousel.startAuto();
	    });
	};
    $('#parceiros').jcarousel({
        auto: 3,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });	
	*/
	// Cadastro de Newsletter
	$('#form-news #sub-news').click(function(){
		
	
		var error 			= '';
		var nome 			= $('#nome-news').val()
		var email 			= $('#email-news').val()
		
		if(!nome || nome == 'Nome')
		{
			error += 'Informe seu nome. <br />';		
		}
		else
		{
			$('#nome-news').css({'border':'1px solid #C6C9CD'});	
		}
		if(!email || email == 'E-mail')
		{
			error += 'Informe seu e-mail. <br />';		
		}
		else if (!validaEmail(email)) 
		{
			error += 'Informe um e-mail válido. <br />';		
		}
		else
		{
			$('#nome-news').css({'border':'1px solid #C6C9CD'});	
		}
		if(error)
		{
			$('.erro-news').html(error);
			return false;
		}
		
		else{
			//$('.erro-news').hide();
			$.post(
				'_inc/cadastro_newsletter.ajax.php',
				{
					nome: nome,
					email: email
				},
				function(data)
				{
					if(data == 'OK')
					{
						/*$("#sucess").show();
						$("#sucess").html(data);	*/	
						$('.erro-news').html('E-mail cadastrado com sucesso!');
						$('#nome-news').val('');
						$('#email-news').val('');				
						return false;						
					}
					if(data == 'ERR')
					{
						$('.erro-news').html('Ocorreu algum erro');
					}
					else{
						$('.erro-news').html('E-mail já cadastrado.');
					}
				}
			);
				
			return false;
		}
		
	});	
	
});
