function trim(str){return str.replace(/^\s+|\s+$/g,"");}

function carregarPagina(pagina, id){
	$("#feedback").ajaxStart(function(){
    $(this).show();
    });
	$('#'+id).load(pagina);
	$("#feedback").ajaxStop(function(){
    $(this).fadeOut();
    });
}

function executaGet(pagina, retorno, id){
	pagina = pagina + '&' + Math.random();
	$.get(pagina,
	null,
	function(dados){
		$("#alerta").children("#selected").html(dados);
		$("#alerta").fadeIn("slow");
	});
	$('#'+id).load(retorno);
}

function executaPost(form){
	var options = {
	success: function(dados) {
		$("#alerta").children("#selected").html(dados);
		$("#alerta").fadeIn("slow");
		}
	};
	$('#'+form).ajaxSubmit(options);
}

function ocultarAlerta(){
	$("#alerta").fadeOut("slow");	
}

function popUp(url, width, height, nome, scrol) {
	if (scrol != null && scrol =="scroll" ) {
		parametros = 'width='+width+',height='+height+',scrollbars=1'; 
	} else {
		parametros = 'width='+width+',height='+height+',scrollbars=auto';
	}
	window.open(url, nome, parametros);
}

function exibirPergunta(div,contador){
	var divAtual = $('#textoAtualFlash').val();
	$("#"+divAtual).fadeOut('normal', function() {
		$("#"+div).fadeIn();
		$('#img_cont').attr('src','css/img/numero_'+contador+'.jpg');
	});
	$('#textoAtualFlash').attr('value',div);
}


function geraQuiz(){
	$("#formQuiz").ajaxSubmit({
		beforeSubmit: function(){
			$('#feedback').toggle();
		},
		success: function(retorno){
			$('#feedback').toggle();
			$("#questoes").html(retorno);
			$('#img_cont').attr('src','css/img/letra_R.gif');
		}
	});
}

$(document).ready( function() {
    $('A[rel="popup"]').click( function() {
		window.open($(this).attr('href'),'Votar','height=250,width=350');		
        return false;
    });
});