/**
* CAPTCHA JS AJAX
*
* @author Zehair ALAOUI SOSSE <deepscripts@gmail.com>
* @website http://blog.deepscripts.com/
* @license GPL v3
*/
$(document).ready(function()
{
/*
* Check The Captcha
*/
$('#dscheckcapcha').live('click',function(event)
{
event.preventDefault();
$('#dscaptchaerror').hide().html('');
overlay(1);
$.dsPOST('check',$('#dscaptchaverify').serialize(), 'json', function(data)
{
if(data.status==0)
{
$('#dscaptchaerror').fadeIn().html(data.erreur);
$('#dscaptchaverify').stop(true,true).fadeTo(200,1);
$('#dsrebuildcaptcha').click();
}
else
{
$('#dscaptchaverify').fadeOut(700, function()
{
$('#dslinkdownload').fadeIn(700).html(data.msg);
});
}
});
});
/*
* Reload Captcha
*/
$('#dsrebuildcaptcha').live('click',function(e)
{
overlay(1);
$("#dsimageverify").attr("src", "php/ajax.php?action=captcha");
overlay(0);
});
/*
* Open the download in a new onglet
*/
$('.dscheckcapcha').live('click',function(e)
{
var target = $(this).attr('href');
window.open(target);
});
/*
* AJAX function
*/
$.dsPOST = function(action,data,typedata,callback)
{
$.post('php/ajax.php?action='+action,data,callback,typedata);
}
/*
* Function to simulate loading...
*/
function overlay(type)
{
var formTF = $('#dscaptchaverify');
if(formTF.css('opacity') && formTF.css('opacity')!=1)
{
return false;
}
if(type==1)
formTF.stop(true,true).fadeTo(200,0.5);
else
formTF.stop(true,true).fadeTo(200,1);
}
}); |