var response;

var id = 1;
calculaSeta = function() {
    var num = id-1;
    $('.titleHighlight').find('h2').removeClass('highlight');
    $('.titleHighlight').removeClass('titleHighlight');

    $('div[id=title-'+id+']').addClass('titleHighlight');
    $('div[id=title-'+id+']').find('h2').addClass('highlight');

    id++;
    if(id == 4) {
        id = 1;
    }
}
Shadowbox.init({handleOversize: "drag"});

$(document).ready(
    function() {

        $('#menu li').hover(
            function () {
                $(this).addClass('hover');
            },
            function () {
                $(this).removeClass('hover');
            }
        );

        $('.imgContainer').cycle({
            fx:     'scrollRight',
            timeout: 6000,
            before:  calculaSeta
        });

        $('div[id*=title-]').click(
            function() {
                var temp_id = ($(this).get(0).id).split('-');
                id = temp_id[1];
                $('.imgContainer').cycle(id-1);
                return false;
            }
        );
        
        //slides
        $('.png_bg').prev().hover(function () {if($(this).next().hasClass('hover'))return;
						        		   		  $(this).next().slideUp();
						        		   		  $(this).next().addClass('hover');}
	  		  			  		 ,function () {if($(this).next().hasClass('hover')){
	  		  			  			   		      $(this).next().slideDown();
	  		  			  				   		  $(this).next().removeClass('hover');}} 									
		);		
		
		//dialog
		$('#dialog').dialog({
	    	draggable: true,
	        resizable:false,
	        height:120,
	        width:400,
	        modal: true,
	        title:'Mensagem'
	        }
		);
		$('#dialog').dialog('close');
		
		if(response != undefined)
			showMessageBox(response);
    }
);

function showMessageBox(message){
	$('#dialog').children('p').empty();
	$('#dialog').children('p').append(message);
	$('#dialog').dialog('open');
}

function validate(){
	var form  = $('#newsletter').children('form');
    var email = $('input[name=email]');
    var nome  =	$('input[name=name]');
    var sucess = true;
	  	
  	//Testa se algum valor foi colocado vazio ou com apenas espa�os
    if(jQuery.trim(email.val()) == '' || jQuery.trim(nome.val() == '')){
  		  sucess = false;
  	}
  	else if(email.val().indexOf('@') == -1){
  		  sucess = false;
  	}

  	if(sucess == true){
  		form.submit();
  	}
  	else { showMessageBox('&Eacute; necess&aacute;rio preencher corretamente todos os campos.'); }

}




