$("document").ready(function ()
{
bool_reg = /register.asp/.test(document.location.href); // call recordTime on register.asp page only
if (bool_reg) {
var load_time = new Date(); // get the time when we load form
recordTime(load_time);
}
});
function recordTime(load_time) {
var focus_time;
$('[name=firstname],[name=lastname],[name=address],[name=address2],[name=city],[name=zipcode],[name=email],[name=email2],[name=otherregion]').focus( function(){focus_time = new Date();} ); // get current time onFocus for particular input field
$('[name=firstname],[name=lastname],[name=address],[name=address2],[name=city],[name=zipcode],[name=email],[name=email2],[name=otherregion]').blur( function(){ getBlurTime(focus_time,this.name); }); // get time when we loose focus on input field
// get time when we submit the form and subtract this time and load_time to get the total form submission time.
$('[name=formreg]').submit( function(){ getBlurTime(load_time,'formreg'); });
}
function getBlurTime(focus_time,input) {
var blur_time = new Date(); // get current time onBlur for particular input field
var time = blur_time - focus_time; // subtract focus time and blur time to total focus time for that particular input
// now we need to store this focus time for each input, so create hidden element
// if we already have hidden element then add old value with new time and update this hidden field value
if ($('#time_'+input+'').length) {
var old_time = $('#time_'+input+'').val();
var new_time = parseInt(time) + parseInt(old_time)
$('#time_'+input+'').val(new_time) ;
} else { // else create new hidden input
$('formreg').add('').appendTo('[name=formreg]');
}
}
var params = FL.queryParams(),
games = {
1: params.game1 || [],
2: params.game2 || [],
3: params.game3 || [],
4: params.game4 || [],
5: params.game5 || [],
6: params.game6 || []
};
function flip( show, hide )
{
show.style.display = '';
hide.style.display = 'none';
}
function drawlabel(i)
{
document.write("
");
document.write("" + i + "");
document.write("
");
}
function drawcheck(game, i, qp)
{
document.write("
");
document.write("");
document.write("
");
}
function checkReload()
{
$('[name^=game]').each(function (ndx, cb)
{
if(cb.checked){
var parts = cb.id.split('box');
addCB('', parseInt(parts[0]), parseInt(parts[1]));
}
});
}
function checkTop()
{
var ok = true,
ids = ['firstname', 'lastname', 'email', 'address', 'city', 'zipcode'],
input;
FL.lang.forEach(ids, function(id)
{
input = document.getElementById(id);
if (! input.value) {
input.style.background = "red";
ok = false;
}
else {
input.style.background = "white";
}
})
if( !ok ) {
window.scrollTo(0,0);
alert("Some of your required fields are still empty. Please fill them in.");
}
return ok;
}
function checkPIN()
{
var ok = true,
input = document.getElementById('pin'),
hidden = document.getElementById('hiddenpin');
if (hidden.value != input.value ) {
input.style.background = "red";
ok = false;
}
else {
input.style.background = "";
}
if( !ok ) {
window.scrollTo(0,0);
alert("Your pin does not match.");
}
return ok;
}
function checksForGame(game)
{
return game === 6 ? 7 : 6;
}
function addCB( cb, game, box )
{
var maxchecks = checksForGame(game);
if( games[game].length >= maxchecks ) {
cb.checked = false;
alert("You have already chosen all "+maxchecks+" numbers for that game.");
return;
}
if ($.inArray(box, games[game]) === -1){ games[game].push( box ); }
}
function remCB( cb, game, box )
{
if( !games ) return;
if( !games[game] ) return;
var ndx = $.inArray(box, games[game]);
games[game].splice(ndx, 1 );
}
function cbClick( cb )
{
var parts = cb.id.split('box'),
game = parseInt( parts[0] ),
box = parseInt( parts[1] );
cb.checked ?
addCB( cb, game, box ) :
remCB( cb, game, box );
}
function qp( cb )
{
var game = cb.value;
// disable & clear the numbers
$('[name=game'+ game +']').attr('checked', false).attr('disabled', cb.checked);
// restore the previously selected values on uncheck
if( !cb.checked && games[game] )
for( var j = 0; j < games[game].length; j++ )
document.getElementById( game+"box"+games[game][j] ).checked = true;
}
function checkNumsForSubmit()
{
var error = false;
var ok = true;
for( var i = 1; i <= 6; i++ ) {
if( document.getElementById("quickpick"+i).checked ) continue;
if( document.getElementById("hotpick"+i).checked ) continue;
var maxchecks = checksForGame(i);
if( games && games[i] && games[i].length == maxchecks ) continue;
ok = false;
var errorstr = "Please select "+maxchecks+" numbers, 'QUICK PICK', or 'HOT PICK' for game "+i+".";
if( error ) error = error.concat("\n"+errorstr);
else error = errorstr;
}
if( error )
alert(error);
return ok;
}
function checkCCSubmit()
{
var ccnum = document.getElementById('cc_num');
var trash = new RegExp("[\\s-]");
var regex = new RegExp("^[0123456789]{15,16}$");
var cvv = document.getElementById('cvv');
while( trash.test( ccnum.value ) )
ccnum.value = ccnum.value.replace( trash, "" );
var ok = regex.test( ccnum.value );
if( !ok ) {
var badchars = new RegExp("[^0123456789]");
if( badchars.test( ccnum.value ) )
alert("You have invalid characters in your credit card number. Please use only numbers.");
else alert("You must enter a valid credit card number.");
}
if( ok && cvv && cvv.style.display != 'none' ) {
var badchars = new RegExp("[^0123456789]");
if( cvv.value == "" || badchars.test( cvv.value ) ) {
ok = false;
alert("You must enter a valid cvv number.");
window.open('/popup/cvv.asp', '_blank', 'width=370,height=520,left=300,top=300');
}
}
// check if our submit cookie is set
var nameEQ = "transactionsubmit=";
var ca = document.cookie.split(';');
var value = "";
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) value = c.substring(nameEQ.length,c.length);
}
if( value.length ) {
alert("You have sent a transaction in the last 30 seconds. To avoid any chances of double billing your card, please wait 30 seconds before trying to submit again.");
ok = false;
}
if( ok ) {
// we're gonna submit so set the cookie
var date = new Date();
date.setTime(date.getTime()+30*1000);
document.cookie = "transactionsubmit=yes; expires=" + date.toGMTString() + "; path=/";
}
return ok;
}
function cvvpop(lang) {
window.open('http://images.freelotto.com/www.freelotto.com///images/en/default/popup/CVV2_20100129.gif', '', 'width=310,height=360,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}
function whatishotpick(lang) {
window.open('http://images.freelotto.com/www.freelotto.com///images/en/default/popup/HotpicksExplanation.gif','', 'width=400,height=250,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}
function whyphonepop() {
window.open("/why_phone.asp", '', 'width=350,height=200,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no');
}
function errormsg() {
with (document.formreg) {
if (firstname.value == "")
return "You need to enter your first name.";
if (lastname.value == "")
return "You need to enter your last name.";
if (address.value == "")
return "You need to enter your address.";
if (zipcode.value == "")
return "You need to enter your postal code.";
if (city.value == "")
return "You need to enter your city.";
if (email.value == "")
return "You need to enter your email address.";
if (email2.value == "")
return "You need to enter your email address twice.";
if (email.value != email2.value)
return "Your email addresses do not match.";
}
return null;
}