    $(document).ready(function()
    {
        $("#vai").click(function()
        {
            $('#loading').show();
            $('#loading').html("Please wait.." + "<img src='http://llg.sequentia.net/images/ajax.gif'/>");
            if (document.form1.email.value == "")
            {
                $('#loading').html("");
                alert('Please provide your email address.');
                return false;
            }
            if (document.form1.email.value.indexOf("'") > -1)
            {
                $('#loading').html("");
                alert('Invalid email!');
                return false;
            }
            if (document.form1.email.value.indexOf('"') > -1)
            {
                $('#loading').html("");
                alert('Invalid email!');
                return false;
            }

            var uri = "http://" + _llat.scriptHost + "/lla.aspx?i=" + Base64.encode("Tab") + "&m=" + Base64.encode("get") + "&c=" + Base64.encode("EmailCallBack") + "&f=" + Base64.encode("") + "&l=" + Base64.encode("") + "&e=" + Base64.encode(document.form1.email.value);
            //alert("before ajax " + uri);
            $.ajax({
                type: "GET",
                cache: false,
                async: false,
                url: uri,
                dataType: "script",
                error: function(xhr, error, exception)
                {
                    //alert("ajax fail: " + xhr.status);
                    $('#loading').html("");
                    alert("Email not found.");
                    document.getElementById("radio2").click();
                },
                success: function(data, textStatus)
                {
                    //alert("ajax success: " + textStatus);
                    $('#loading').html("");

                },
                complete: function(xhr, textStatus)
                {
                    //alert("ajax complete: " + textStatus);
                }
            });
            //alert("after ajax");
            return (false);           

            //      $.ajax({
            //      dataType: "jsonp",
            //      data: "email=" + document.form1.email.value +"&lcpid=" + document.testOnlineFormName.LcpId.value + "&leadsource=" + document.testOnlineFormName.PIID_22070_0.value + "&NLType="+ document.testOnlineFormName.NLType.value +"&ReturnPage=" + document.testOnlineFormName.ReturnPage.value + "&User_Notification=" + document.testOnlineFormName.User_Notification.value +"",
            //      jsonp: 'jsonp_callback',
            //      url: "http://llg.sequentia.net/checkemail.aspx",
            //            
            //            contentType: "application/json; charset=utf-8", 
            //      
            //      success: function(msg) {
            //          
            //          if(msg.urlReturn !=""){
            //              document.location = msg.urlReturn;
            //          }else{
            //              $('#loading').html("");
            //            alert("Email not found.");
            //            document.getElementById('radio2').click();
            //              
            //      }
            //      }
            //    });

        });
    });

    function EmailCallBack(result)
    {
        $('#loading').html("");
        try
        {
            var lead = Base64.decode(result);
            lead = JSON2.parse(lead);
            lead = lead.d;
            if ((lead != null) && (lead.email != null) && (lead.email.length > 0) && (lead.last_name != null) && (lead.last_name.length > 0))
            {
				if (document.getElementById('ppccode') != null) {
						urchinTracker(document.getElementById('ppccode').value);	
				}
                $leadlife('#form1').submit();
                document.location = ((document.testOnlineFormName.ReturnPage != null) && (document.testOnlineFormName.ReturnPage.value != "")) ? document.testOnlineFormName.ReturnPage.value : ((document.testOnlineFormName.action != null) && (document.testOnlineFormName.action != "")) ? document.testOnlineFormName.action : "http://llg.sequentia.net/thankspages/thanks.html";
                return (true);
            }
        }
        catch (e)
        {
        }
        alert("Email not found.");
        document.getElementById("radio2").click();
        return (false);
    }
    
    function showDiv(flag)
    {
        if (flag == 1)
        {
            document.getElementById('bigForm').style.display = "none";
            document.getElementById('smallForm').style.display = "";
        }
        else
        {
            document.getElementById('smallForm').style.display = "none";
            document.getElementById('bigForm').style.display = "";
        }
    }

    function change_W_I() 
    { 
        try
        {
            var objcountry = document.testOnlineFormName.PIID_23775_0; 
            var country = objcountry.options[objcountry.selectedIndex].text; 
            if (country == "Canada")
            { 
                document.testOnlineFormName.W.value = "43" ; 
                document.testOnlineFormName.I.value = "1" ;
            }
            else 
            {
                document.testOnlineFormName.W.value = "42" ; 
                document.testOnlineFormName.I.value = "1" ;
            }
        }
        catch (e)
        {
        }
    }
