//********************************************************************************
// MYINEWS PAGE FUNCTIONALITY
//********************************************************************************

//--------------------------------------------------------------------------------
// Events
//--------------------------------------------------------------------------------

//Set the events on load
$(document).ready
(
    function()
    {   
        $("#btnSubscribe").click
        (
            function()
            {                   
                Subscribe();
                
                return false;
            }            
        );
        
        //CHECK : Verify if the 'Enter Key' was pressed
        $(".Subscribe").keypress
        (
            function(e) 
            {                                
                //Gather the key pressed
                var charCode = (e.which) ? e.which : event.keyCode
        
                //CHECK : Verify that the key pressed is 'Enter' key
                if (charCode == 13) //Enter Key 
                {
                    Subscribe();
                    
                    return false;                          
                } 
            }        
        ); 
    }
);

//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
// Functions
//--------------------------------------------------------------------------------

function Subscribe()
{   
     $.blockUI({ css: { 
                border: 'none', 
                padding: '15px', 
                backgroundColor: '#000', 
                '-webkit-border-radius': '10px', 
                '-moz-border-radius': '10px', 
                opacity: '.5', 
                color: '#fff' 
                } });
                
    //Gather the Output data
    ob_post.AddParam("strEmailAddress", $("#EmailAddress").val());    
    ob_post.post("MyiNews.aspx", "SubscribeToMyiNews", "function(){}"); 
    
    return false;
}

function SubscribeSuccess(response)
{    
    setTimeout($.unblockUI, 1);

    //Clear the email address
    $("#EmailAddress").val("");
  
    //Show the confirmation message
    DisplayErrorMessage("Your request has been sent.\r\nIf you have any other questions, please contact MyiLibrary technical support at\r\n <a href='mailto:milsupport@ingramdigital.com'>milsupport@ingramdigital.com</a>");
    
    return false;
}

//--------------------------------------------------------------------------------
