/// <reference path="C:\projects\_jQuery\jquery-vsdoc.js"/>
$(document).ready(function () {
    if (typeof OneWeb.Admin === "undefined") {
        //do stuff only when NOT logged in to OW
        //survey
        if ($("#survey_con").length > 0) {
            $("#modalBackgroundOverlay").prependTo('body');
            $("#colorbox").appendTo('form');
            //check for survey cookie - if not present launch survey and create cookie
            if ($.cookie('clearwater_socialsurvey') == null) {
                $.colorbox({ opacity: 0.7, width: "720px", inline: true, href: "#survey", overlayClose: false });
                $('#tmpl_appsurvey_ss_dd_socialmedia').change(function () {
                    if ($(this).val() == 'I don\'t use social media') {
                        $('#tmpl_appsurvey_ss_btnSubmitImage').focus();
                    }
                });
            }
        }
        //set cookie when close button is clicked or when form is submitted
        function set_clearwater_cookie() {
            if ($.cookie('clearwater_socialsurvey') == null) {
                //$.cookie('clearwater_socialsurvey', "surveyed", { expires: 9999, path: '/', domain: 'clearwater.isl.ca', secure: false }); //staging
                $.cookie('clearwater_socialsurvey', "surveyed", { expires: 9999, path: '/', domain: 'clearwater.ca', secure: false }); //prod
            }
        }
        $("#cboxClose").click(function () { set_clearwater_cookie(); });
        $(".submit_survey").click(function () { set_clearwater_cookie(); $.colorbox.close(); }); //$('body').scrollTop(0);
    } else {
        //do stuff when LOGGED IN to OW
        //survey
        $("#survey_container").css({ "display": "block" });
        $("#survey_container").css({ "width": "675px" });
    }
});

