this.tooltip = function(){
xOffset = 10;
yOffset = 20;
jQuery(".fresposta,.fresposta2").hover(function(e){
jQuery(this).css("background-color","#CBE8F5");
this.t = this.title;
this.title = "";
jQuery("body").append("
"+ this.t +"
");
jQuery("#tooltip")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
jQuery(this).css("background-color","#ffffff");
this.title = this.t;
jQuery("#tooltip").remove();
});
jQuery(".fresposta,.fresposta2").mousemove(function(e){
jQuery("#tooltip")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function comecar(){
if ( jQuery("#nome").val().length< 3 ){
Sexy.alert("Atenção
Preencha seu nome com no mínimo 3 letras!");
return false;
}
if ( jQuery("#estado").val()=="" ){
Sexy.alert("Atenção
Selecione o estado em que mora.");
return false;
}
if ( jQuery("#cidade").val().length < 3 ){
Sexy.alert("Atenção
Preencha o nome de sua cidade. com no mínimo 3 letras");
return false;
}
return true;
}
function ShowInfo(){
jQuery.post("info.php",{type:'info'},function(data){
//jQuery("#info #rk").html( jQuery.xmlDOM( data ).find('quiz > ranking').text() );
jQuery("#info #pt").html( jQuery.xmlDOM( data ).find('quiz > pontos').text() );
jQuery("#progressbar div").progressBar( jQuery.xmlDOM( data ).find('quiz > percentual').text(), {showText: false} );
});
}
function ShowError(motivo,strtype){
// Info
ShowInfo();
// Contador
clearContador();
jQuery.post("info.php",{type:strtype},function(data){
var pontos = "Pontos: " + jQuery.xmlDOM( data ).find('quiz > pontos').text() + "
";
//var ranking = "Ranking: " + jQuery.xmlDOM( data ).find('quiz > ranking').text();
if( strtype=="finished" ){
Sexy.info("PARABÉNS!
"+motivo+pontos, {onComplete:
function() {
document.location.href="/";
}
});
}else{
Sexy.error(motivo+pontos, {onComplete:
function() {
document.location.href="/";
}
});
}
});
}
function contador(x){timer.init(0,x,'contador');}
function responder(strdata){
jQuery.post("quiz.php", { str: strdata }, function(data){
// finished
if( jQuery.xmlDOM( data ).find('quiz > finished').text()=="true" ){
ShowError( "Parabéns, você acertou todas as perguntas. Dificilmente alguém chega até aqui. Veja sua posição, quem sabe não está no TOP 100? E não se esqueça: Atualizamos as perguntas semanalmente. Volte sempre!
", "finished" );
}
// Show pergunta
if( jQuery.xmlDOM( data ).find('quiz > pergunta').text()!='' ){
jQuery("#perguntas").empty();
jQuery("#perguntas").append( jQuery.xmlDOM( data ).find('quiz > pergunta').text() );
jQuery("#perguntas").append( jQuery.xmlDOM( data ).find('quiz > respostas').text() );
var timer = jQuery.xmlDOM( data ).find('quiz > tempo').text();
// Ativar Colorir Sintaxe?
dp.SyntaxHighlighter.HighlightAll('code');
// Oculta Barra de ferramentas do parser
jQuery(".tools").hide();
// Tooltip
tooltip();
// Time
clearContador();
contador(timer);
}
// Show erro
if( jQuery.xmlDOM( data ).find('lost > motivo').text()!='' ){
ShowError( jQuery.xmlDOM( data ).find('lost > motivo').text(), "error" );
}
});
// Info
ShowInfo();
window.setTimeout("ShowInfo();", 5000);
}
function resp(str){
responder(str);
}
function convidar() {
Sexy.prompt('Seu nome
Coloque seu nome.
','',{ onComplete:
function(returnvalue) {
if(returnvalue!='')
{
jQuery.post("convidar.php", { nome: returnvalue, email: jQuery("#cemail").val() }, function(data){
if( trim(data)=="email" ){
Sexy.error('Atenção
O email digitado é inválido.
');
}else if( trim(data)=="nome" ){
Sexy.error('Atenção
Seu nome deve conter no mínimo 3 caracteres.
');
}else if( trim(data)=="enviado" ){
jQuery("#cemail").val("");
Sexy.info('Convite enviado!
O convite foi enviado!
');
}else if( trim(data)=="false" ){
Sexy.error('Erro!
O convite não foi enviado, tente novamente.
');
}
});
}
else
{
Sexy.alert('Atenção
O convite não foi enviado.
');
}
}
});
}
jQuery(document).ready(function(){
jQuery("div[id^='quiz']").toggleClass("tops");
jQuery("div[id='quiz1']").attr("class","top");
jQuery("div[id^='quiz']").mouseover(function(){
jQuery("div[id^='quiz']").toggleClass("tops");
jQuery("div[id^='quiz']").attr("class","tops");
jQuery(this).attr("class","top");
});
jQuery("#tabcf").click();
jQuery("#submit").click(function(){
if ( comecar() ){
jQuery.post("start.php", { nome: jQuery("#nome").val(), cidade: jQuery("#cidade").val(), estado: jQuery("#estado").val(), email: jQuery("#email").val(), login: jQuery("#login").val(), senha: jQuery("#senha").val(), captcha: jQuery("#captcha").val() }, function(data){
if ( trim(data)=="captcha" ){
Sexy.error("Atenção
Código de confirmação ( Captcha ) incorreto. Tente novamente.", {onComplete:
function() {
// Capatcha
jQuery("#imgcaptcha").click();
jQuery("#captcha").val("");
}
});
}else if( trim(data)=="true" ){
jQuery("#comecar").hide();
jQuery("#topo").hide();
jQuery("#estrutura-perguntas").show();
responder('');
}else if( trim(data)=="false" ){
jQuery("#comecar").show();
jQuery("#topo").show();
jQuery("#estrutura-perguntas").hide();
Sexy.alert("Atenção
Erro ao iniciar o quiz. Verifique se você preencheu corretamente os campos.");
}else if( trim(data)=="trunk" ){
Sexy.error("Atenção
Detectamos um palavrão em um dos campos. Infelizmente não é permitido continuar até alterar o campo.");
}
});
}
});
jQuery("#imgcaptcha,.divcaptcha a").click(function(){
jQuery("#imgcaptcha").attr("src",'captcha.php?'+Math.random());
});
jQuery("#convitesubmit").click(function(){
convidar();
});
if ( jQuery('.grid').html()!='' ){
jQuery('.grid').Scrollable(330, 755);
}
});