﻿var _orderCutted;
var _strPath_ = "http://" +  (typeof globalConstants == 'undefined' ? location.hostname : globalConstants.appPath) + "/";
$.ajaxSetup({
    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    dataType: 'json'
});

//::: Fix WebService date format conversion [/Date(119846565)/] :::::::::::::::::::::::::::
var reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/;
var reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
if (typeof JSON == 'undefined') {
    $.getScript("/scripts/json2.js").done(function (script, textStatus) {
        JSON_setup();
    });
} else {
    JSON_setup();
}
function JSON_setup() {
    JSON.parseWithDate = function (json) {
        try {
            var res = JSON.parse(json,
            function (key, value) {
                if (typeof value === 'string') {
                    var a = reISO.exec(value);
                    if (a)
                        return new Date(Date.UTC(+a[1], +a[2] - 1,
                                                 +a[3], +a[4], +a[5], +a[6]));
                    a = reMsAjax.exec(value);
                    if (a) {
                        var b = a[1].split(/[-+,.]/);
                        return new Date(b[0] ? +b[0] : 0 - +b[1]);
                    }
                }
                return value;
            });
            return res;
        } catch (e) {
            throw new Error("JSON content could not be parsed");
            return null;
        }
    };
    $.ajaxSetup({
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        async: false,
        cache: false,
        dataFilter: function (jsonString, type) {
            if (type == "json") {
                var res = JSON.parseWithDate(jsonString);
                if (typeof (res) === "string")
                    return jsonstring; // return JSON as jQuery double parses          
                //            if (res && res.hasOwnProperty("d"))
                //                return (typeof res.d === "string") ?
                //                        JSON.stringify(res.d) : // jQuery double parses  
                //                        res;
                return res;
                //return JSON.stringify(res);
            }
            return jsonString;
        },
        error: function (request, status, error) {
            alert(request.responseText);
        }
    });
}

// Check if user is allowed to login From DemoDay Feature
function DemoDayCheckLogin() {
    var uName = $("[id$=txtNewEmail]").val();
    var uPass = $("[id$=txtNewPassword]").val();
    if (uName.length > 0 && uPass.length > 0)
        return postFile(_strPath_ + "Login.aspx?uname=" + uName + "&upass=" + uPass, HandleLogin);
    else {        
        var htmlBodyContent = "Login Failed. Please contact our Sales Support to activate your Demo Day";
        $("[id$=demoDayMsg]").html(htmlBodyContent);
        $("[id$=demoDayMsgContainer]").show();
        $("[id$=divDemoDayStep]").hide();
    }
}
// Check if user is allowed to login
function CheckLogin() {
    var uName = $("[id$=txtEmail]");
    var uPass = $("[id$=txtPass]");
    if (uName.val().length > 0 && uPass.val().length > 0)
        ValidateLogin(uName.val(), uPass.val());
    else {
        var htmlBodyContent = "<div class='DialogHeading' style='padding-bottom:10px;'>Login Failed.</div><div>Please fill both username and password, and try again.</div>";
        $(".msgBox-Cancel-btn").show();
        $(".msgBox-Ok-btn").hide();
        ShowModalPopup("Error Message", htmlBodyContent);
        $(".loading").hide();
        _gaq.push(['_trackEvent', 'sign-in', 'failed']);
    }
}

function ValidateLogin(uName, uPass) {
    return postFile(_strPath_ + "login.aspx?uname=" + uName + "&upass=" + uPass, HandleLogin);
}

// Handle login. 
// If username and password are valid redirect to player page, else show error message and stay at sign in page
function HandleLogin(theXMLHttp) {
    if (theXMLHttp.readyState == 4) {
        if (theXMLHttp.status == 200) {
            result1 = theXMLHttp.responseText; result = result1.split("~~|~~")[0];
            if (result == "LOGINOK") {
                SetLogin(result1.split("~~|~~")[1], result1.split("~~|~~")[2]);                                 
                //window.location.href = "player.aspx"; 
            } else if (result == "LOGINFAIL") { 
                var strErrMsg = result1.split("~~|~~")[1];
                var htmlBodyContent = "<div class='DialogHeading' style='padding-bottom:10px;'>Login Failed.</div><div>" + strErrMsg + "</div>";                
                $(".msgBox-Cancel-btn").show();
                $(".msgBox-Ok-btn").hide();
                ShowModalPopup("Error Message", htmlBodyContent);
                $(".loading").hide();                                                                   
            } 
        } 
    }
}
// Send Forgot password email
function ForgotPassword() {        
    if ($("[id$=txtEmail]").val().length == 0) {
        var htmlBodyContent = "<div class='DialogHeading' style='padding-bottom:10px;'>Email was not sent.</div><div>Please enter the email address on your WatchIndia.TV account.</div>";        
        $(".msgBox-Cancel-btn").show();
        $(".msgBox-Ok-btn").hide();
        ShowModalPopup("Error Message", htmlBodyContent);
        $(".loading").hide();
        return false;        
    } else {
        var parameters = '{strEmail: "' + $("[id$=txtEmail]").val() + '"}';
        var webMethod = 'WIServices.asmx/SendForgotPasswordMail';
        $.ajax(
        { type: 'POST',
            contentType: 'application/json; charset=utf-8',
            url: webMethod,
            data: parameters,
            dataType: 'json',
            async: false,
            success: function (data) {
                if (data.d)
                    htmlBodyContent = "<div class='DialogHeading' style='padding-bottom:10px;'>Email sent.</div><div>Your password has been sent to the email address you entered.</div>";
                else
                    htmlBodyContent = "<div class='DialogHeading' style='padding-bottom:10px;'>Email was not sent.</div><div>Please check your email address and try again.</div>";
                $(".msgBox-Cancel-btn").hide();
                $(".msgBox-Ok-btn").show();
                $('.msgBox-Ok-btn').click(function () {
                    $(this).removeClass('msgBox-Ok-btn').addClass('msgBox-Ok-btnClick');
                    HideModalPopup();
                    $(this).removeClass('msgBox-Ok-btnClick').addClass('msgBox-Ok-btn');
                });
                ShowModalPopup("Pay Attention", htmlBodyContent);
                $(".loading").hide();
            }
        });
    }
}

function SetLogin(id, hashID) {
    var parameters = '{subscriberHash: "' + id + '", hashID: "' + hashID + '"}';
    var webMethod = 'LASERVICE/service.asmx/SetLogin';
    $.ajax(
        { type: 'POST',
            contentType: 'application/json; charset=utf-8',
            url: webMethod,
            data: parameters,
            dataType: 'json',
            async: false,
            success: function (data) {
                if (data.d == "Authorization Succeed") {
                    HideModalPopup();
                    window.location.href = _strPath_ + "player.aspx";
                }
                else {
                    var strErrMsg = data.d;
                    var htmlBodyContent = "<div class='DialogHeading' style='padding-bottom:10px;'>Login Failed.</div><div>" + strErrMsg + "</div>";
                    $(".msgBox-Cancel-btn").show();
                    $(".msgBox-Ok-btn").hide();
                    ShowModalPopup("Error Message", htmlBodyContent);
                    $(".loading").hide();
                }
            }
            , error: function (request, status, error) {
                alert(request.responseText);
            }
        });
}
//Add/Remove the authentication cookie based on the checkbox status
function AddRemoveAuthCookie() {
    if ($("[id$=chkRememberMe]").attr('checked')) {        
        var strAuthCookieVal = $("[id$=txtEmail]").val() + "~|~" + $("[id$=txtPass]").val();
        var parameters = '{strCookieValue: "' + strAuthCookieVal + '"}';
        var webMethod = 'WIServices.asmx/CreateAuthCookie';
        $.ajax(
        { type: 'POST',
            contentType: 'application/json; charset=utf-8',
            url: webMethod,
            data: parameters,
            dataType: 'json',
            async: false,
            success: function (data) {
                // Write to cookie
                setCookie("LA_AUTH", data.d, 7);
            }
        });
    } else {
        eraseCookie("LA_AUTH");
    }
}

function InitSignInPage() {
    var strAuthCookieVal = getCookie("LA_AUTH");
    if (strAuthCookieVal.length > 0) {
        var parameters = '{strCookieValue: "' + strAuthCookieVal + '"}';
        var webMethod = 'WIServices.asmx/GetAuthCookieValues';
        $.ajax(
        { type: 'POST',
            contentType: 'application/json; charset=utf-8',
            url: webMethod,
            data: parameters,
            dataType: 'json',
            async: false,
            success: function (data) {
                var arrCookieValues = data.d.split("~|~");
                $("[id$=txtEmail]").val(arrCookieValues[0]);
                $("[id$=txtPass]").val(arrCookieValues[1]);
            }
        });
    }
}
// Fetch user order info and redirect to correct funnel page
function StartFunnel() {
    // Read cookie and generate JSON order object that contains all the current order info
    var nLastStep = 0;
    var nLangPack = 0;
    var lstPredefinedPacks = "";
    var lstCustomPacks = "";
    var strEncryptCookieVal = getCookie("LA_ORDER");
    if (strEncryptCookieVal.length > 0) {
        // Get last funnel step
        var parameters = '{strEncryptCookieVal: "' + strEncryptCookieVal + '"}';
        var webMethod = 'FunnelWebService.asmx/GenerateOrderFromEncryptCookie';
        $.ajax(
            { type: 'POST',
                contentType: 'application/json; charset=utf-8',
                url: webMethod,
                data: parameters,
                dataType: 'json',
                async: false,
                success: function (data) {
                    nLastStep = data.d.StepID;
                    lstPredefinedPacks = data.d.lstPacks;
                    lstCustomPacks = data.d.lstChannels;
                }
            });
        // Get language pack ID (0 = if none exist)
        var parameters = '{strPredefinedPackagesIDs: "' + lstPredefinedPacks + '"}';
        var webMethod = 'FunnelWebService.asmx/GetLanguagePackID';
        $.ajax(
            { type: 'POST',
                contentType: 'application/json; charset=utf-8',
                url: webMethod,
                data: parameters,
                dataType: 'json',
                async: false,
                success: function (data) {
                    nLangPack = data.d;
                }
            });
    }
    RedirectToFunnelStartPage(nLastStep, nLangPack, lstCustomPacks, lstPredefinedPacks);
}
// Redirect to funnel to the last step the user reached
function RedirectToFunnelStartPage(nLastStep, nLangPack, lstCustomPacks, lstPredefinedPacks) {
    var strURL = "package_selection.aspx";
    if ((lstCustomPacks.length > 0 || lstPredefinedPacks > 0) && nLangPack == 0)
        strURL = "custom_combination.aspx";
        
    CommonRedirect(strURL, "");
}

function InitEmptyDemo() {    
    var strEncryptCookieVal = "";
    var parameters = '{strEncryptCookieVal: "' + strEncryptCookieVal + '"}';
    var webMethod = 'FunnelWebService.asmx/GenerateOrderFromEncryptCookie';
    $.ajax(
    { type: 'POST',
        contentType: 'application/json; charset=utf-8',
        url: webMethod,
        data: parameters,
        dataType: 'json',
        async: false,
        success: function (data) {
            _orderCutted = data.d;            
        }
    });
}

function AppendValuesToDemo(strNewValues) {
    var parameters = '{strNewValues: "' + strNewValues + '", strEncryptVal: "' + _orderCutted.DecryptValue + '"}';
    var webMethod = 'FunnelWebService.asmx/AppendValuesToOrder';
    $.ajax(
    { type: 'POST',
        contentType: 'application/json; charset=utf-8',
        url: webMethod,
        data: parameters,
        dataType: 'json',
        async: false,
        success: function (data) {
            _orderCutted = data.d;           
        },
        error: function (request, status, error) {
            alert(request.responseText);
        }
    });
}

function DemoDayWorker(webMethod) {
    var parameters = '{strEncryptCookieVal: "' + _orderCutted.DecryptValue + '"}';
    $.ajax(
    { type: 'POST',
        contentType: 'application/json; charset=utf-8',
        url: webMethod,
        data: parameters,
        dataType: 'json',
        async: false,
        success: function (data) {
            _orderCutted = data.d;            
        }
    });
}

function DemoDayValidation_Step1() {
    var strErrMsg_Step1 = "";
    var regOnlyDigits = /^[0-9]+$/;
    if (!regOnlyDigits.test($('#txtPhone_Country').val()) || !regOnlyDigits.test($('#txtPhone_Area').val()) || !regOnlyDigits.test($('#txtPhone_Number').val()))
        strErrMsg_Step1 = "Phone number not valid. Please use only digits.<br/>";
    if ($('#txtPhone_Country').val().length == 0 || $('#txtPhone_Area').val().length == 0 || $('#txtPhone_Number').length == 0)
        strErrMsg_Step1 = "Please fill all phone number values.<br/>";
    strPhoneNumber = $('#txtPhone_Country').val() + $('#txtPhone_Area').val() + $('#txtPhone_Number').val();
    strPhoneNumber = strPhoneNumber.replace(/^0+/, '');
    if (strPhoneNumber.length < 7)
        strErrMsg_Step1 = "Phone number not valid. Please check phone length.<br/>";
    if (strErrMsg_Step1.length > 0) {
        strErrMsg_Step1_HTML = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Negative.png' style='border:0px;vertical-align:middle;'></div>";
        strErrMsg_Step1_HTML += "<div class='NegativeServiceText' style='padding-top:4px;'>" + strErrMsg_Step1 + "</div></div>";
        $('#demo-step-1-msg').html(strErrMsg_Step1_HTML);
    }
    return strErrMsg_Step1;      
}
function DemoDayValidation_Step2() {
    var strErrMsg_Step2 = "";            
    if ($('#txtPassword').val().length == 0)
        strErrMsg_Step2 += "Please enter your demo day code.<br/>";
    if (strErrMsg_Step2.length > 0) {
        strErrMsg_Step2_HTML = "<div style='margin-top:5px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Negative.png' style='border:0px;vertical-align:middle;'></div>";
        strErrMsg_Step2_HTML += "<div class='NegativeServiceText' style='padding-top:4px;'>" + strErrMsg_Step2 + "</div></div>";
        $('#demo-step-2-msg').html(strErrMsg_Step2_HTML);
    }
    return strErrMsg_Step2;
}
function DemoDayValidation_Step3() {
    var strErrMsg_Step3 = "";
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if (!emailReg.test($('#txtNewEmail').val())) {
        strErrMsg_Step3 = "Email address not valid.<br/>";
    }
    if ($('#txtNewEmail').val().length == 0) {
        strErrMsg_Step3 = "Please enter your email address.<br/>";
    }
    if ($('#txtNewPassword').val().length < 6) {
        strErrMsg_Step3 += "Password must be at least 6 characters.<br/>";
    }
    if (strErrMsg_Step3.length > 0) {
        strErrMsg_Step3_HTML = "<div style='margin-top:5px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Negative.png' style='border:0px;vertical-align:middle;'></div>";
        strErrMsg_Step3_HTML += "<div class='NegativeServiceText' style='padding-top:4px;'>" + strErrMsg_Step3 + "</div></div>";
        $('#demo-step-3-msg').html(strErrMsg_Step3_HTML);
    }
    return strErrMsg_Step3;
}

function DemoDayWorkFlow(nStepNumber) {
    var strErrMsg = "";
    var htmlBodyContent = "";
    var strPhoneNumber = "";
    strPhoneNumber = $('#txtPhone_Country').val() + $('#txtPhone_Area').val() + $('#txtPhone_Number').val();
    strPhoneNumber = strPhoneNumber.replace(/^0+/, '');  
    if (_orderCutted == undefined)
        InitEmptyDemo();
    switch (nStepNumber) {
        case 0:
            // Input Validation                        
            strErrMsg = DemoDayValidation_Step1();
            if (strErrMsg.length == 0) {
                AppendValuesToDemo('demoDayMobile=' + strPhoneNumber);
                DemoDayWorker('FunnelWebService.asmx/DemoDayInitialization');
                _gaq.push(['_trackPageview', 'demo-day/phone-step1']);
                
                // invoke AdService scripts
                var oImg = document.createElement('img');                
                oImg.setAttribute('src', 'http://www.googleadservices.com/pagead/conversion/1051820908/?value=2&amp;label=p7Q8COLflAIQ7IbG9QM&amp;guid=ON&amp;script=0');
                oImg.setAttribute('alt', '');
                oImg.setAttribute('height', '1px');
                oImg.setAttribute('width', '1px');
                oImg.setAttribute('style', 'border-style:none;');
                document.body.appendChild(oImg);

                // invoke AdCenter scripts
                if (!window.mstag) mstag = { loadTag: function () { }, time: (new Date()).getTime() };
                $.getScript("//flex.atdmt.com/mstag/site/907d58d0-a020-4aa1-be34-9d1569f037ed/mstag.js");
                mstag.loadTag("analytics", { dedup: "1", domainId: "1118467", type: "1", revenue: "2", actionid: "34242" });

                if (_orderCutted.ErrorMessage.length > 0) {
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Negative.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='NegativeServiceText' style='padding-top:4px;'>" + _orderCutted.ErrorMessage + "</div></div>";
                } else {
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Positive.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='PositiveServiceText' style='padding-top:4px;'>SMS message is sent to +" + $('#txtPhone_Country').val() + " " + $('#txtPhone_Area').val() + " " + $('#txtPhone_Number').val() + "</div></div>";
                }
                $('#demo-step-1-msg').html(htmlBodyContent);
            }
            break;
        case 1:
            // Input Validation                        
            strErrMsg = DemoDayValidation_Step1();
            if (strErrMsg.length == 0) {                
                AppendValuesToDemo('demoDayMobile=' + strPhoneNumber);
                DemoDayWorker('FunnelWebService.asmx/DemoDayInitialization');
                _gaq.push(['_trackPageview', 'demo-day/phone-step1']);
                
                // invoke AdService scripts
                var oImg = document.createElement('img');                
                oImg.setAttribute('src', 'http://www.googleadservices.com/pagead/conversion/1051820908/?value=2&amp;label=p7Q8COLflAIQ7IbG9QM&amp;guid=ON&amp;script=0');
                oImg.setAttribute('alt', '');
                oImg.setAttribute('height', '1px');
                oImg.setAttribute('width', '1px');
                oImg.setAttribute('style', 'border-style:none;');
                document.body.appendChild(oImg);

                // invoke AdCenter scripts
                if (!window.mstag) mstag = { loadTag: function () { }, time: (new Date()).getTime() };
                $.getScript("//flex.atdmt.com/mstag/site/907d58d0-a020-4aa1-be34-9d1569f037ed/mstag.js");
                mstag.loadTag("analytics", { dedup: "1", domainId: "1118467", type: "1", revenue: "2", actionid: "34242" });

                if (_orderCutted.ErrorMessage.length > 0) {
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Negative.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='NegativeServiceText' style='padding-top:4px;'>" + _orderCutted.ErrorMessage + "</div></div>";
                } else {
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Positive.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='PositiveServiceText' style='padding-top:4px;'>SMS message is sent to +" + $('#txtPhone_Country').val() + " " + $('#txtPhone_Area').val() + " " + $('#txtPhone_Number').val() + "</div></div>";
                }                
                $('#demo-step-1-msg').html(htmlBodyContent);
            }
            break;
        case 2:
            // Input Validation                        
            strErrMsg = DemoDayValidation_Step1();
            strErrMsg += DemoDayValidation_Step2();
            if (strErrMsg.length == 0) {                          
                AppendValuesToDemo('demoDayPassword=' + $('#txtPassword').val() + '&demoDayMobile=' + strPhoneNumber);
                DemoDayWorker('FunnelWebService.asmx/DemoDayVerification');
                _gaq.push(['_trackPageview', 'demo-day/code-step2']);
                if (_orderCutted.ErrorMessage.length > 0) {
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Negative.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='NegativeServiceText' style='padding-top:4px;'>" + _orderCutted.ErrorMessage + "</div></div>";
                } else {
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Positive.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='PositiveServiceText' style='padding-top:4px;'>Free Code OK</div></div>";
                }
                $('#demo-step-2-msg').html(htmlBodyContent);
            }                        
            break;
        case 3:
            // Input Validation
            strErrMsg = DemoDayValidation_Step1();
            strErrMsg += DemoDayValidation_Step2();
            strErrMsg += DemoDayValidation_Step3();
            if (strErrMsg.length == 0) {
                AppendValuesToDemo('password=' + $('#txtNewPassword').val() + '&demoDayMail=' + $('#txtNewEmail').val());
                DemoDayWorker('FunnelWebService.asmx/DemoDayActivation');
                _gaq.push(['_trackPageview', 'demo-day/complete-step3']);
                if (_orderCutted.ErrorMessage.length > 0) {
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Negative.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='NegativeServiceText' style='padding-top:4px;'>" + _orderCutted.ErrorMessage + "</div></div>";
                    $('#demo-step-3-msg').html(htmlBodyContent);
                    return;
                } else {
                    _gaq.push(['_setCustomVar', 1, 'demo-day', 'registered', 2]);
                    _gaq.push(['_trackPageview']);
                    htmlBodyContent = "<div style='margin-top:10px;'><div style='float:left;margin-right:5px;'><img alt='' src='images/V3/Icon_Positive.png' style='border:0px;vertical-align:middle;'></div>";
                    htmlBodyContent += "<div class='PositiveServiceText' style='padding-top:4px;'>Thank you! Logging in...</div></div>";
                    $('#demo-step-3-msg').html(htmlBodyContent);
                }                

                // invoke AdService scripts
                var oImg = document.createElement('img');
                oImg.setAttribute('src', 'http://www.googleadservices.com/pagead/conversion/1051820908/?value=10&amp;label=m2tkCNrglAIQ7IbG9QM&amp;guid=ON&amp;script=0');
                oImg.setAttribute('alt', '');
                oImg.setAttribute('height', '1px');
                oImg.setAttribute('width', '1px');
                oImg.setAttribute('style', 'border-style:none;');
                document.body.appendChild(oImg);

                // invoke AdCenter scripts
                if (!window.mstag) mstag = { loadTag: function () { }, time: (new Date()).getTime() };
                $.getScript("//flex.atdmt.com/mstag/site/907d58d0-a020-4aa1-be34-9d1569f037ed/mstag.js");
                mstag.loadTag("analytics", { dedup: "1", domainId: "1118467", type: "1", revenue: "10", actionid: "34241" });
                DemoDayCheckLogin();
            }
            break;
    }
}

function DemoDayDidntGetCodeMsg() {
    htmlBodyContent = "Please contact our Sales Support to activate your Demo Day";
    $("[id$=demoDayMsg]").html(htmlBodyContent);
    $("[id$=demoDayMsgContainer]").show();
    $("[id$=divDemoDayStep]").hide(); 
}

function CloseMsg() {
    $("[id$=demoDayMsg]").html('');
    $("[id$=demoDayMsgContainer]").hide();
    $("[id$=divDemoDayStep]").show(); 
}
