$(document).ready(function(){
var tmp_img = new Image();
tmp_img.src = 'images/loader.gif';
$('a.submit').click(function(){
if($(this).hasClass('disabled'))
return false;
var tt=$.trim($('#password').val());
if(!tt)
{
$('span.error').fadeIn();
return false;
}
$('#password').hide().parent().append('
');
$(this).addClass('disabled');
$('span.error').hide();
$.ajax({
type: 'POST',
url: 'php/post.php',
data: 'code='+tt,
dataType: "html",
success: function(resp)
{
if(resp=='OK')
{
_gaq.push(["_trackEvent", "ContentLocker", "SubmitOK", "Header"]);
$('body').append('
');
if(window.genetify) genetify.record.goal(GoalName, 100);
setTimeout(function(){
if(window._cC)document.location=_cC(1,'', true);
else
document.location='../index.php';}, 1000);
}
/*else if(resp=='UNCHARGED')
{
_gaq.push(["_trackEvent", "ContentLocker", "SubmitOK", "Header"+t1pe]);
document.location='../index.php';
}*/
else
{
setTimeout(function(){
$('span.error').fadeIn();
$('img.loader').remove();
$('#password').show();
$('a.submit').removeClass('disabled');
}, 1000);
_gaq.push(["_trackEvent", "ContentLocker", "SubmitNOTOK", "Header"]);
}
},
error: function(){
$('span.error').fadeIn();
}
});
return false;
})
$('div.step1 a.send_button').attr('onclick', '');
$('div.step1 a.send_button').click(function(){
var tt=$.trim($('div.step1 #number').val());
if(!tt)
{
$('div.step1 span.error').fadeIn();
return false;
}
$('div.step1 #number').hide();
$('div.step1 .loader').show();
$(this).hide();
$('div.step1 span.error').hide();
$.ajax({
type: 'POST',
url: 'php/post.php',
data: 'msisdn='+tt+'&alias='+$('input[name=alias]', 'div.step1').val()+'&message='+$('#message', 'div.step1').val(),
dataType: "html",
success: function(resp)
{
if(resp=='ACTIVE')
{
setTimeout(function(){
$('div.step1').hide();
$('div.step2').show();
$('div.step2 #cta_text').show();
},1000);
}
else if(resp=='SENT')
{
_gaq.push(["_trackEvent", "ContentLocker", "SubmitOK", "WebSubmit"]);
$('body').append('
');
if(window.genetify) genetify.record.goal(GoalName, 100);
setTimeout(function(){
if(window._cC)
document.location=_cC(1,'', true);
else
document.location.href="member.php?i="+$('input[name=thisAlias]', 'div.step1').val();
}, 1000);
}
else
{
setTimeout(function(){
$('div.step1 span.error').fadeIn();
$('div.step1 img.loader').hide();
$('div.step1 #number').show();
$('div.step1 a.send_button').show();
}, 1000);
}
},
error: function(){
$('div.step1 span.error').fadeIn();
}
});
return false;
})
});
function validateEmail(email)
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if ( reg.test(email) == false )
{
return false;
}
return true;
}
function sendEmailData() {
var a = "";
if ($("#email-name").length > 0) {
var b = $.trim($("#email-name").val());
a += "&email-name=" + b
}
if ($("#email-city").length > 0) {
var b = $.trim($("#email-city").val());
a += "&email-city=" + b
}
if ($("#email-seek").length > 0) {
var b = $.trim($("#email-seek").val());
a += "&email-seek=" + b
}
if ($("#aliasdefault").length > 0) {
var b = $.trim($("#aliasdefault").val());
a += "&aliasdefault=" + b
}
if ($("#aliascity").length > 0) {
var b = $.trim($("#aliascity").val());
a += "&aliascity=" + b
}
if ($("#aliasyears").length > 0) {
var b = $.trim($("#aliasyears").val());
a += "&aliasyears=" + b
}
if (!validateEmail($("#email-email").val())) {
if ($("#email-email").val() == $("#email-email").attr("defaultValue")) {
alert ("Vpisani email naslov ni veljaven!");
}
else {
alert ("Vpisani email naslov ni veljaven!");
}
return false;
}
a += "&email-email=" + $.trim($("#email-email").val());
formEmailshowhide("send");
$.post("php/post.php", a, function (a) {
if (a == "OK") {
setTimeout("showEmail02()", 4e3)
} else {
setTimeout("showEmailError()", 4e3)
}
})
}
function showEmailError() {
$(".email_status_message p.por1_s_cook").css('display','block');
$(".content_email_under").css('display','none');
$(".email_status_message p.por1_s_akt").css('display','none');
$(".email_status_message").css('display','block');
$(".loading").css('display','none');
}
function showEmail02(a) {
$(".content_email_under").css('display','none');
$(".email_status_message").css('display','block');
$(".loading").css('display','none');
if(window.showStep2)showStep2();
}
function formEmailshowhide(a) {
if (a == "send") {
$(".content_email_under").css('display','none');
$(".email_status_message").css('display','none');
$(".loading").css('display','block');
}
}