﻿$(document).ready(function() {

    $('.listitem').hover(
        function() {
            $(this).append('<div id="overlay"></div>');
            //$('#overlay').css({ background: '#ffffff', opacity: 0, width: '484px', height: '174px', cursor: 'pointer', position: 'absolute', top: '0px', left: '0px' });
            //$('#overlay').animate({ opacity: 0.15 });
        },
        function() {
            $('#overlay').remove();
        }
    );

    $('.listitem').click(function() {

        var href = '';
        href = $(this).find('.hoverlink').attr('href');
        //alert(href);
        window.location = href;

    });



    //quick login
    //$('#signup').submit(function() {

    //  ajaxsignup();
    //  return false;

    //});
    $('#signup button').click(function() {

        ajaxsignup();
        return false;

    });



});


function ajaxsignup() {

    var email = $('form#signup #email').val();

    var result = '';
    var test = '';

    $.ajax({
        type: "POST",
        url: "/SignUp.aspx",
        data: "ajax=true&email=" + email,
        success: function(msg) {

            //alert(msg);
            $('#ajx').remove();
            if (msg == "notvalid") {
                $('#signup').prepend('<p id="ajx" class="error">Please enter a valid email address</p>');
            }
            if (msg == "inuse") {
                $('#signup').prepend('<p id="ajx" class="error">You\'re already signed up!</p>');
            }
            if (msg == "saved") {
                $('#signup').prepend('<p id="ajx" class="success">Thank you! We\'ll be in touch</p>');
                $('#signup #email, #signup button').remove();
            }


        }
    });
    
}