var invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
$(function(){


$('#menu').width(72); 
$('#imprimir div').click(function(){
     window.print();
 })
$('#Username').val('')
$('#up').click(function(){
    $('html,body').animate({scrollTop: 0}, 1000);
})

$('#back').click(function(){
    history.back(-1) ;
    return false;
})
$('#sede-conbec a').fancybox();
$("#dropmenu ul").css({display: "none"}); // Opera Fix
$("#dropmenu li").hover(
    function(){
	    
	    $(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(400);
	    $(this).find('a:first').addClass('bg')
    },function(){
	    $(this).find('ul:first').css({visibility: "hidden"});
	    $(this).find('a:first').removeClass('bg')
    }
);
 $('#dropmenu li a:last').css('border','none');

  //Select all anchor tag with rel set to tooltip
    $(".cliente-images img").mouseover(function(e) {
         
	div = $(this).parents('div:first').find('div');
	if(div.length)
	{
	    div.css('top', e.pageY + 10 );
	    div.css('left', e.pageX + 15 );
	    div.fadeIn('500');
	    div.fadeTo('10',0.9);
	} 
    }).mousemove(function(e) {
	div = $(this).parents('div:first').find('div');
	if(div.length)
	{
	    div.css('top', e.pageY + 10 );
	    div.css('left', e.pageX + 15 );
	}
    }).mouseout(function() {
	$(this).parents('div:first').find('div').hide();
    });
    
//$(".cliente-images img").mouseover(
//    function(){
//	div = $(this).parents('div:first').find('div');
//	if(div.length)
//	{
//	    div.fadeIn();
//	}
//	    
//    },function(){
//	
//    }
//);

$('#internas-banner div').fadeIn(2000)
if($('#internas-footer-menu').length)
{
 $('#internas-footer-menu a:last').css('border','none');
    w = 0 ;
    $('#internas-footer-menu a').each(function(){
	w+=$(this).outerWidth(true);
    });
    $('#internas-footer-menu').width(w)   
}

    
$('#form form').submit(function() {
  if(!$.trim($('#Username').val()))
  {
     alert('Informe o e-mail.') 
     $('#Username').focus();
     return false;
  }
  else if(!$.trim($('#Password').val()))
  {
      alert('Informe a senha.');
      $('#Password').focus()
      return false;
  }
  else
  {
      return true;
  }
  
});
    $('#home-centro').flash(
	    {
		    // test_flashvars.swf is the flash document
		    swf: BASE+"media/swf/imagerotator.swf",
		    height: 310,
		    width: 684, 
		    
		    // these arguments will be passed into the flash document
		    flashvars: {
			    allowfullscreen: 'true',
			    file:BASE+'media/slider/'+lang+'.xml',
			    shownavigation:false,
			    height: 310,
			    rotatetime:slider_timer,
			     width: 684, 
    						    linkfromdisplay:true,
//			    repeat:true,
    						    shuffle:true
		    }
	    }
    );
    
	$(".blk,.blue").hover(
	    function(){
		    $(this).children().css('text-decoration','underline');
	    },function(){
		    $(this).children().css('text-decoration','none');

	    }
	);
	$(".plus").hover(
	    function(){
		    $(this).css('background-image','url('+BASE+'media/css/images/ic-mais-over.jpg)');
	    },function(){
		    $(this).css('background-image','url('+BASE+'media/css/images/ic-mais.jpg)');
	    }
	);
	    
	$(".plus1").hover(
	    function(){
		    $(this).css('background-image','url('+BASE+'media/css/images/ic-mais.jpg)');
	    },function(){
		    $(this).css('background-image','url('+BASE+'media/css/images/ic-mais-over.jpg)');
	    }
	);


	    $('#formcontatos').ajaxForm({
		beforeSubmit: checa_contato,
		success: retorno_contato,
		dataType:'json'
	    });

	    function checa_contato(formData, jqForm) {
		var img = '<img src="'+BASE+'media/images/error.png" style="vertical-align:middle;margin-right:5px;">';
		var f = jqForm[0];
		$('#callback').html('').hide();
		
		var msg = " \n";
		if (!$.trim($('#name').val())){
		    msg = msg + img + "Preencha o campo Nome<br />";
		}
		if (!$.trim($('#email').val())){
		    msg = msg + img + "Preencha o campo Email<br />";
		}
		if (!$.trim($('#message').val())){
		    msg = msg + img + "Preencha o campo Mensagem<br />";
		}
		if (msg != " \n"){
		    mem1 = "\n "+msg;
		    t1 = 1;
		}
		else
		{
		    mem1 = "";
		    t1 = 2;
		}
		if((t1 == 1 )){
		    $('#callback').html(mem1).fadeIn(500);
		    if (!$.trim($('#name').val()))
	            {
			$('#name').focus();
		    }
		    else if(!$.trim($('#email').val()))
		    {
			$('#email').focus();
		    }
		    else if(!$.trim($('#message').val()))
		    {
			$('#message').focus();
		    }
		    return false;
		}
		else
		{
		    if (invalid.test($('#email').val()) == false) {
			$('#callback').html(img+'O endereço de e-mail digitado não é válido.').fadeIn(500);
			$('#email').focus();
			return false;
		    }
		    else {
			$('#callback').append('<center><span style="font-size:14px">Enviando ...</span></center>').fadeIn(500);
			$('#formcontatos').hide();
			return true;
		    }
		}
 
	    }

	    function retorno_contato(r)  {
		

		if(r.status)
		{
		    $('#callback').html(r.msg).fadeIn(500);
		    $('#formcontatos').resetForm().show();
		    //redir=setTimeout("window.location = '/'",3000);
		}
		else
		{
		    $('#callback').html(r.msg).fadeIn(500);
		    $('#formcontatos').show();
		}
	    }
		
})



