﻿// JScript File

function doShow() {


        document.getElementById("divwizard").style.display = "inline";
        document.getElementById("msgdiv").innerHTML = "";
}
function doHide() {
    document.getElementById("ctl00_txtEmailid").value = "";
        document.getElementById("divwizard").style.display = "none";
        //document.getElementById("ctl00_Chkwinners").checked = 0;
        document.getElementById("ctl00_chkdiscount").checked = 0;
        document.getElementById("ctl00_lblmessage").innerText = "";
        document.getElementById("msgdiv").innerHTML = "";
    }

    function thankyoushow() {

        document.getElementById("divThankyou").style.display = "inline";
    }
    function thakyouhide() {
        document.getElementById("divThankyou").style.display = "none";
    }


function saveData() {

    var txtEmail = document.getElementById("ctl00_txtEmailid").value;
    //var chkwinn = document.getElementById("ctl00_Chkwinners").checked;
    var chkwinn = false;
        var chkdisc = document.getElementById("ctl00_chkdiscount").checked;
        createXMLHttpRequest();
        var url = "SavePageData.aspx?Emailid=" + txtEmail + "&chkwin=" + chkwinn + "&chkdisc=" + chkdisc; 
        xmlHttp.onreadystatechange = getdetails;
        xmlHttp.open("get", url, true);
        xmlHttp.send(null);
}
function createXMLHttpRequest() {

        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
           
        }
        catch (oError) {
            try {
                xmlHttp = new XMLHttpRequest();
                
              
                
            }
            catch (e) {
                throw new Error(e);
            }
        }
    }
    function createVoteXMLHttpRequest() {

        try {
            votexmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
           
        }
        catch (oError) {
            try {
                votexmlHttp = new XMLHttpRequest();
                
              
                
            }
            catch (e) {
                throw new Error(e);
            }
        }
    }
function getdetails() {

        if (xmlHttp.readyState == 4) 
        {
            if (xmlHttp.status == 200) 
            {
                var msg = xmlHttp.responseText;
                
//                 var col_array=msg.split("-");
//                 var part_num=0;
//                while (part_num < col_array.length)
//                {
//                //alert(col_array[part_num]);
//                 part_num+=1;
//                 }
                // alert(col_array[0]);
                 //document.getElementById("msgdiv").innerHTML = col_array[0];
                 if(msg=="You have submitted details successfully")
                 {
                 thankyoushow();
                }
            }

            else {
                alert("Error Code :" + xmlHttp.status);
            }
        }
    }
function check() {

    if (document.getElementById("ctl00_txtEmailid").value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
              document.getElementById("msgdiv").innerHTML = "Enter a Valid email";
         }
         else {
             saveData();
         }

     }

     function loadSignUp() {
         $.blockUI({
         message: $('#divwizard'),
             css: {
                 top: '20%'
             }
         });
       
       
     }

     function hideSignUp() {
         $('#divThankyou').hide();
         $('#divSignup').show();
         $('#divwizard').hide();
         $('#ctl00_txtEmailid').val('');
         $('#msgdiv').html('');
         $("INPUT[type='checkbox']").attr('checked', false); 
         setTimeout($.unblockUI, 10);
     }
     
     function saveDataViaVote() {

        var txtEmail = document.getElementById("ctl00_txtmailid1").value;
        var chkwinn = document.getElementById("ctl00_chkwebisodeUpdates").checked;
        var chkdisc = document.getElementById("ctl00_chksendmeinfo").checked;
       if(txtEmail!=null)
       {
       if(chkwinn==true||check==true)
       {
        createVoteXMLHttpRequest();
        var url = "SavePageData.aspx?Emailid=" + txtEmail + "&chkwin=" + chkwinn + "&chkdisc=" + chkdisc    +"&case=vote"; 
        votexmlHttp.onreadystatechange = getVotedetails;
        votexmlHttp.open("get", url, true);
        votexmlHttp.send(null);
        }
        }
}

function getVotedetails() {

        if (votexmlHttp.readyState == 4) 
        {
            if (votexmlHttp.status == 200) 
            {
                var msg = votexmlHttp.responseText;
                if(msg="You have submitted details successfully")
                {
                // alert("submitted");
                  // hideVotePopUp();
               thankyouVotemessageshow();
                }
               //  var col_array=msg.split("-");
                // var part_num=0;
               // while (part_num < col_array.length)
               // {
                //alert(col_array[part_num]);
               //  part_num+=1;
               //  }
                // alert(col_array[0]);
                 //document.getElementById("msgdiv").innerHTML = col_array[0];
              
                
            }

            else {
                alert("Error Code :" + votexmlHttp.status);
            }
        }
    }
    function thankyouVotemessageshow() {

      // hideVoteSignupPopUp();
        $.blockUI({
         message: $('#divthankyouVotemessageshow'),
             css: {
                 top: '20%'
             }
         });
     
       
    }
    
      function hidethankyouVotemessagePopUp() {
      
         $('#divthankyouVotemessageshow').hide();
         setTimeout($.unblockUI, 10);
     }



