// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function validateLeadGen() {
    if ($('leadgen[first_name]').value.length != 0 &&
        $('leadgen[last_name]').value.length != 0 &&
        $('leadgen[title]').value.length != 0 &&
        $('leadgen[company]').value.length != 0 &&
        $('leadgen[email]').value.length != 0) {

        if ($('leadgen[email]').value.match(/@/)) {
            return true;
        } else {
            alert('Please enter a valid email address.');
        }
    } else {
        alert('Please fill out all fields to continue.');
    }
    return false;
}

function doLeadGen(eid) {
    if (!validateLeadGen()) {
        return false;
    }

    $('lb_box_contents').style.display='none';
    new Effect.Fade('lb_box', {duration: 0.4});
    new Effect.Fade('lb_overlay', {duration: 0.4});

    var nextyear = new Date();
    nextyear.setFullYear(nextyear.getFullYear()+1);
    var lgkey = 'lead_gen_'+eid;
    document.cookie = lgkey+'=1;expires='+nextyear.toGMTString();
    return true;
}
