killSurvey = 0;
function checkForm() {
    var validNum = '0123456789';
    var alerts = '';
    var form = document.getElementById('syc_bridge');
    if (! form.zip.value) {
        alerts += "Please enter a ZIP Code.\n";
    } else if (form.zip.value.length < 5) {
        alerts += "Your ZIP Code must be five digits long.\n";
    } else {
        for (var i=0; i < form.zip.value.length; i++) {
            if (validNum.indexOf(form.zip.value.charAt(i)) == -1) {
                alerts += "Please use only numbers for ZIP Code.\n";
                break;
            }
        }
    }
    if (alerts) {
        alert (alerts);
        return (false);
    } else {
        killSurvey=1;
        form.address.value=form.zip.value;
        return (true);
    }
}

var rxLandingWin;
// Close a popup window
function rxCloseLandingWin() {
    if (rxLandingWin && rxLandingWin.open && !rxLandingWin.closed) {
        rxLandingWin.close();
    }
}
// Open a popup window with the specified URL, name and options - Close any open popups first
function rxOpenLandingWin(url, options) {
    rxCloseLandingWin();
    if (url != null) {
        rxLandingWin = window.open(url, 'rxLandingWin', options);
    }
}

// for tpi links
var server = location.host;


var BIHelper = {
    toUrl: "",
    submitFormDelay: 500,
    appName: "NC",

    logEventForAC: function(interaction, url, callback, app) {
        if(app == "RC") {
            tempUrl = url.substring(url.indexOf('/rc/'), url.length);
            this.toUrl = rc_base_url + tempUrl;
        } else if(app == "SYC") {
            tempUrl = url.substring(url.indexOf('/syc/'), url.length);
            this.toUrl = syc_base_url + tempUrl;
        } else {
            this.toUrl = url;
        }
        $('asisClicks').src = "/no_cache/vs/syc_clicks.asis?interaction=" + interaction + "&rand=" + (new Date()).getTime();
        if(callback != null) {
            setTimeout(callback, 200);
        }
        return false;
    },

    logEventForACForm: function(interaction) {
        $('asisClicks').src = "/no_cache/vs/syc_clicks.asis?interaction=" + interaction + "&rand=" + (new Date()).getTime();
        this.submitForm = false;
        var start = new Date().getTime();
        while(new Date().getTime() < start + this.submitFormDelay) {};
        return true;
    },

    openInNewWindow: function() {
        window.open(this.toUrl);
    },

    openInSameWindow: function() {
        document.location.href = this.toUrl;
    },

    openInPopup: function(wHeight, wWidth) {
        win = window.open(this.toUrl, 'popup__id' + Math.floor(Math.random()*1000), 'width=' + wWidth + ',height=' + wHeight + ',resizable=no,scrollbars=yes,toolbar=no,location=no,menubar=no');
    }
};
