﻿function survey() {
var ticks = new Date().getTime();
    $.get('/surveylauncher/check.aspx?time'+ticks, function (data) {
        $("#surveyinvite").html(data);
        var width = $(window).width();
        width = (width / 2) - 150;
        $(".surveyinvite").animate({ left: width+"px" }, 2000);
    });



}
function survey_yes() {
    $.get('/surveylauncher/check.aspx?response=yes', function (data) {
        if (navigator && (navigator.userAgent.toLowerCase()).indexOf("chrome") > -1) {
            var div = "'#surveyinvite'";
            $("#surveyinvite2").html('<a href="/surveylauncher/redirect.aspx?url=' + data + '" target="_blank" onclick="$('+div+').toggle();">Click here to take survey</a>');
        }
        else {
            var newwin = window.open("", "Survey", 'width=800,height=600,scrollbars=yes ');

            if ((newwin == undefined) || (newwin.outerWidth == 0)) {
                var div = "'#surveyinvite'";
                $("#surveyinvite2").html('<a href="/surveylauncher/redirect.aspx?url=' + data + '" target="_blank" onclick="$(' + div + ').toggle();">Click here to take survey</a>');
            }
            else {
                // newwin.opener = null;
                newwin.location = '/surveylauncher/redirect.aspx?url=' + data;
                newwin.width = 800;
                newwin.height = 600;
                $(".surveyinvite").animate({ left: "-500px" }, 2000);

            }
        }

    });
    return false;
}
function survey_no() {
    $.get('/surveylauncher/check.aspx?response=no', function (data) {
        $(".surveyinvite").animate({ left: "-500px" }, 2000);
    });
    return false;
}
function survey_maybe() {
    $.get('/surveylauncher/check.aspx?response=maybe', function (data) {
        $(".surveyinvite").animate({ left: "-500px" }, 2000);
    });
    return false;
}

$(function () { survey(); });
