//*** eCustomerOpinions survey code v4.0.2 ****/
//* Copyright (c) 2005 eDigitalResearch.com   */
//* Please refer to our Terms & Conditions    */
//* for conditions of use.                    */
//* Do NOT modify this code unless directed   */
//* to do so by a member of eDigitalResearch  */
//* staff.                                    */
//*********************************************/

var ecos_data = '';
var ecos_data2 = '';
var ecos_data3 = '';
var ecos_test = 0;

var ecos_sid = 389547844;
var ecos_host = 'ecustomeropinions.com';
var ecos_ver = '402';
var ecos_go = 0;
var ecos_pu = 0;
var ecos_hm = 0;
var ecos_pm = 0;
var ecos_survey_size_x = 550;
var ecos_survey_size_y = 400;
var ecos_jscode = '';
var ecos_runjs = 'ecos_run();';


var brok = false;
if (parseInt(navigator.appVersion.charAt(0)) >= 4)
    brok = true;


function buildurl(destpage) {
    var ecos_url = ecos_host + '/popup/' + destpage + '.php?sid=' + ecos_sid;

    ecos_url = ((document.location.protocol == 'https:') ? 'https://' : 'http://') + ecos_url;

    if (ecos_test > 0)
        ecos_url = ecos_url + '&test=1';

    ecos_url += '&v=' + ecos_ver + '&r=' + Math.round(Math.random() * 100000);

    var myvar2 = '';
    myvar = window.location.href;

    var icount = 0;
    for (i=0; i<myvar.length; i++) {
        if (myvar.charAt(i) == '/')
            icount++;
        if (icount >= 3)
            myvar2 += myvar.charAt(i);
    };

    if (ecos_data.length > 0)    ecos_url += '&data=' + ecos_data;
    if (ecos_data2.length > 0)    ecos_url += '&data2=' + ecos_data;
    if (ecos_data3.length > 0)    ecos_url += '&data3=' + ecos_data;

    if ((screen.width > 0) && (screen.height > 0))
        ecos_url += '&xres=' + screen.width + '&yres=' + screen.height;

    if (screen.colordepth > 0)
        ecos_url += '&depth=' + screen.colordepth;

    ecos_url += '&url=' + escape(myvar2.substring(0,100));
    ecos_url += '&referrer=' + escape(document.referrer.substring(0,100));

    return ecos_url;
};


function ecos_popup_popup() {

    var ua = navigator.userAgent;
    if ((ua.indexOf('NT 5.1') > 0) && (ua.indexOf(' SV1') > 0))
        return false;

    var sw = window.open(buildurl('survey'), 'surveywin', 'location=0,toolbar=no,width=' + ecos_survey_size_x + ',height=' + ecos_survey_size_y + ',directories=no,status=no,scrollbars=yes,resizable=yes');

    if ((ecos_pu) && (sw))
        sw.blur();

    return sw;
}


function ecos_popup_layer() {
    if (!document.getElementById)
        return false;

    var url = buildurl('layer') + '&inlayer=1';
    var t = '<SCR' + 'IPT LANGUAGE="Javascript" SRC="' + url + '"></SCR' + 'IPT>';

    var b, a = document.getElementById("ecos_iframe2");
    if (a.contentDocument)
        b = a.contentDocument;
    else if (a.contentWindow)
        b = a.contentWindow.document;
    else if (a.document)
        b = a.document;
    else
        return false;

    b.open();
    b.write(t);
    b.close();

    return true;
}


function ecos_layer_run() {
    eval(ecos_jscode);
}


function ecos_layer_gono() {
    document.getElementById('ecos_surveylayer').style.visibility = 'hidden';
};


function ecos_layer_gosurveysize() {
    ecos_layer_gono();
    var full_survey_url = buildurl('survey') + '&doneperm=1';
    sw = window.open(full_survey_url, 'surveywin',
        'location=0,toolbar=no,width=' + ecos_survey_size_x + ',height=' + ecos_survey_size_y + ',directories=no,status=no,scrollbars=yes,resizable=yes');
};


var runcounter = 0;
function ecos_popup() {

    if (document.getElementById)
        if (!document.getElementById("ecos_iframe"))
            if (runcounter < 10) {
                runcounter++;
                setTimeout('ecos_popup()', 100);
                return;
            };

    if (ecos_go) {

        switch (ecos_pm) {
        case 0 : ecos_popup_popup(); break;
        case 1 : ecos_popup_layer(); break;
        case 2 : if (!ecos_popup_popup()) ecos_popup_layer(); break;
        case 3 : if (!ecos_popup_layer()) ecos_popup_popup();
        };
    };
};


function ecos_run() {
    if (ecos_go) {
        if (ecos_hm == 0)
            ecos_popup();
        else if ((ecos_hm == 1) && (brok)) {
            ecos_pm = 0;
            window.onunload = ecos_popup;
        };
    };
};


function ecos_i() {
    eval(ecos_runjs);
};


var runcounter2 = 0;
function ecos_load() {
    var a, b;
    if (!(a = document.getElementById("ecos_iframe"))) {
        if (++runcounter2 < 10)
            setTimeout('ecos_load()', 100);
        return;
    };

    var t = '<SCR' + 'IPT LANGUAGE="Javascript" SRC="' + buildurl('i') + '"></SCR' + 'IPT>';
    if (a.contentDocument)
        b = a.contentDocument;
    else if (a.contentWindow)
        b = a.contentWindow.document;
    else if (a.document)
        b = a.document;
    if (b) {
        b.open();
        b.write(t);
        b.close();
    };
};


if ((document.getElementById) && (window.frames)) {
    ecos_load();
} else {
    ecos_img = new Image;
    ecos_img.src = buildurl('i') + '&nosup=1';
};

