var wv_vars=typeof(wv_vars)=="undefined"?new Array():wv_vars;
wv_vars["ui_width"]="430";
wv_vars["ui_height"]="378";
wv_vars["ui_version"]="UI0001";
wv_vars["ui_newwindow"]="yes";
wv_vars["ui_accountid"]="200106283515";
wv_vars["ui_host"]="as00.estara.com";
wv_vars["ui_maxreferrer"]=600;
wv_vars["ui_window"]=null;
wv_vars["ui_host_param"]="";
if(typeof (eStara_startCobrowseGUINoFunc)=="undefined"){
    var eStara_startCobrowseGUINoFunc=0;
}
wv_vars["ui_window"]=null;
function webISChatPop(){
    var _1=Array.prototype.slice.call(arguments);
    _1.push("calltype=webischatpop");
    var _2=wv_vars["ui_width"];
    var _3=wv_vars["ui_height"];
    wv_vars["ui_width"]=640;
    wv_vars["ui_height"]=480;
    _1.push({
        gatherVarFields:function(){
            var _4="";
            for(var i=1;i<=26;i++){
                eval("var eStara_assigned=(typeof(eStara_var"+i+")!=\"undefined\"&&eStara_var"+i+"!=null)");
                if(eStara_assigned){
                    var _6=i-1;
                    eval("var eStara_tmp=\"&optionaldata"+(_6==0?"":_6)+"=\"+escape(eStara_var"+i+");");
                    _4+=eStara_tmp;
                }
            }
            return _4;
        }
    });
    wv_vars["ui_window"]=wv_start(_1);
    wv_vars["ui_width"]=_2;
    wv_vars["ui_height"]=_3;
}
function webCall(){
    if(wv_vars["ui_window"]==null||wv_vars["ui_window"].closed){
        var _7=arguments;
        _7[_7.length++]="calltype=webcall";
        wv_vars["ui_window"]=wv_start(_7);
    }
}
function webCallBack(){
    var _8=arguments;
    _8[_8.length++]="calltype=webcallback";
    wv_vars["ui_window"]=wv_start(_8);
}
function webVoicePop(){
    var _9=arguments;
    _9[_9.length++]="calltype=webvoicepop";
    var d=new Date();
    _9[_9.length++]="wndname=win"+d.getTime();
    wv_start(_9);
}
function webSurveyPop(){
    var _b=arguments;
    _b[_b.length++]="calltype=websurveypop";
    _b[_b.length++]="features="+"width=640,height=480,menubar=no,toolbar=no,directories=no,scrollbars=yes,status=no,left=0,top=0,resizable=no";
    var _c=wv_vars["ui_width"];
    var _d=wv_vars["ui_height"];
    wv_vars["ui_width"]=640;
    wv_vars["ui_height"]=480;
    wv_vars["upload_only"]=1;
    wv_start(_b);
    wv_vars["ui_width"]=_c;
    wv_vars["ui_height"]=_d;
}
function wv_checklinkstatus(){
    var _e="0";
    for(var i=0;i<arguments.length;i++){
        var Arg=arguments[i].toString();
        var _11=Arg.indexOf("=");
        if(_11!=-1){
            var _12=(Arg.substring(0,_11)).toLowerCase();
            var _13=Arg.substring(_11+1,Arg.length);
            switch(_12){
                case "template":
                    _e=_13;
                    break;
            }
        }
    }
    if((typeof (wv_available_vars)!="undefined")&&(typeof (wv_available_vars[_e])!="undefined")){
        return wv_available_vars[_e];
    }else{
        return false;
    }
}
function wv_start(a){
    var _15="webVoiceWindow";
    var _16=(window.location).toString();
    var _17=escape(_16);
    if(_17.length>wv_vars["ui_maxreferrer"]){
        var _18=_16.indexOf("?");
        _16=_18>0?_16.substring(0,_18)+"---TRUNCATED":"UNAVAILABLE - URL IS TOO LONG";
        _17=escape(_16);
        if(_17.length>wv_vars["ui_maxreferrer"]){
            _16="UNAVAILABLE - URL IS TOO LONG";
        }
    }
    var _19=typeof (document.title)!="undefined"?document.title:"UNKNOWN";
    if(escape(_19).toString().length>255){
        _19=(document.title).toString().substring(0,243)+"---TRUNCATED";
    }
    var _1a=escape(_19);
    if(_1a.length>350){
        _19="UNAVAILABLE - TITLE IS TOO LONG";
    }
    var _1b=wv_vars["ui_newwindow"];
    var _1c=wv_vars["ui_width"];
    var _1d=wv_vars["ui_height"];
    var _1e=wv_vars["ui_version"];
    var _1f=wv_vars["ui_accountid"];
    var _20="";
    var _21="";
    var _22="";
    var _23="";
    var _24=(typeof (document.location.protocol)!="undefined"&&document.location.protocol=="file:")?"http":"";
    var _25="var";
    var _26=10;
    var _27=null;
    for(var i=0;i<a.length;i++){
        if(typeof a[i]=="string"){
            var _29=a[i].toString();
            var _2a=_29.indexOf("=");
            if(_2a!=-1){
                var _2b=(_29.substring(0,_2a)).toLowerCase();
                var _2c=_29.substring(_2a+1,_29.length);
                switch(_2b){
                    case "numvarfields":
                        _26=_2c;
                        break;
                    case "varname":
                        _25=_2c;
                        break;
                    case "wndname":
                        _15=_2c;
                        break;
                    case "referrer":
                        _16=_2c;
                        break;
                    case "pagetitle":
                        _19=_2c;
                        break;
                    case "newwindow":
                        _1b=_2c;
                        break;
                    case "width":
                        _1c=_2c;
                        break;
                    case "height":
                        _1d=_2c;
                        break;
                    case "accountid":
                        _1f=_2c;
                        break;
                    case "wv_ui":
                        _1e=_2c;
                        break;
                    case "features":
                        _20=_2c;
                        break;
                    case "baseurl":
                        _21=_2c;
                        break;
                    case "protocol":
                        _24=_2c;
                        break;
                    case "template":
                        _22=_2c;
                        _23+="&"+_2b+"="+escape(_2c);
                        break;
                    case "ppwinname":
                        if(_2c==""){
                            _2c="PagePushWindow"+(new Date()).getTime()+Math.round(Math.random()*1000000);
                            this.name=_2c;
                        }
                    default:
                        _23+="&"+_2b+"="+escape(_2c);
                        break;
                }
            }else{
                alert("ERROR: Invalid argument passed to webXXX() function - Arg"+i+" is missing '=' sign : "+_29);
                return null;
            }
        }else{
            var _2d=a[i];
            if(_2d.gatherVarFields){
                _27=_2d.gatherVarFields;
            }
        }
    }
    if(typeof (eStara_startCobrowseGUI)=="function"){
        eStara_startCobrowseGUI((wv_vars["upload_only"]==1),_22);
    }else{
        eStara_startCobrowseGUINoFunc=_22;
    }
    if(_27==null){
        for(var i=1;i<=_26;i++){
            eval("var eStara_assigned=(typeof(eStara_var"+i+")!=\"undefined\"&&eStara_var"+i+"!=null)");
            if(eStara_assigned){
                eval("var eStara_tmp=\"&"+_25+i+"=\"+escape(eStara_var"+i+");");
                _23+=eStara_tmp;
            }
        }
    }else{
        _23+=_27();
    }
    if(typeof (eStara_fsguid)!="undefined"){
        _23+="&estara_fsguid="+escape(eStara_fsguid);
    }
    if(_24!=""){
        _24+=":";
    }
    if(_21==""){
        _21=_24+"//"+wv_vars["ui_host"]+"/UI/"+_1e+"/"+_1e+".php";
    }
    if(_20==""){
        _20="width="+_1c+",height="+_1d+",menubar=no,toolbar=no,directories=no,scrollbars=no,status=no,left=0,top=0,resizable=no";
    }
    _23=_21+(_21.indexOf("?")==-1?"?":"&")+"donotcache="+escape((new Date()).getTime())+"&accountid="+escape(_1f)+"&referrer="+escape('http://www.guiamais.com.br/busca/habitasul-goiania-go')+"&pagetitle="+escape(_19)+wv_vars["ui_host_param"]+_23;
    if((typeof (wv_customurl)!="undefined")&&(typeof (wv_customurl[_22])!="undefined")&&(wv_customurl[_22]!="")){
        _23=wv_customurl[_22];
    }
    if((typeof (wv_customfeatures)!="undefined")&&(typeof (wv_customfeatures[_22])!="undefined")&&(wv_customfeatures[_22]!="")){
        _20=wv_customfeatures[_22];
    }
    if(window.esconsole!=null||typeof (window.esconsole)!="undefined"){
        esconsole.log("wv_start",_23,_15,_20);
    }
    if((typeof (wv_vars["timeout"+_22+"_url"])!="undefined")&&(wv_vars["timeout"+_22+"_url"]!="")){
        _23=wv_vars["timeout"+_22+"_url"];
        _15="_blank";
        if((typeof (wv_vars["timeout"+_22+"_webeventguiloaded"])!="undefined")&&(wv_vars["timeout"+_22+"_webeventguiloaded"]!="")){
            if(wv_vars["timeout"+_22+"_webeventguiloaded"].indexOf("javascript:")==0){
                eval(wv_vars["timeout"+_22+"_webeventguiloaded"].substring(11));
            }else{
                if(wv_vars["timeout"+_22+"_webeventguiloaded"].indexOf(".js")!=-1){
                    var _2e=document.getElementsByTagName("BODY").item(0);
                    var _2f=document.createElement("script");
                    _2f.type="text/javascript";
                    _2f.src=wv_vars["timeout"+_22+"_webeventguiloaded"];
                    _2e.appendChild(_2f);
                }else{
                    var _30=new Image();
                    _30.src=wv_vars["timeout"+_22+"_webeventguiloaded"];
                }
            }
        }
        if((typeof (wv_vars["timeout"+_22+"_features"])!="undefined")){
            _20=wv_vars["timeout"+_22+"_features"];
        }
    }else{
        if((typeof (wv_vars["timeout"+_22+"_features"])!="undefined")&&(wv_vars["timeout"+_22+"_features"]!="")){
            _20=wv_vars["timeout"+_22+"_features"];
        }
    }

    _23 = pathSite + "ctrl.php?acao=liguegratis&p=" + base64_encode(_23);

    if(_1b!="yes"){
        window.location=_23;
    }else{
        try{
            var w=window.open(_23,_15,_20);
            w.focus();
            return w;
        }catch(err){}
    }
    return null;
}

function base64_encode(decStr){
        var base64s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        var bits;
        var dual;
        var i = 0;
        var encOut = "";
        while(decStr.length >= i + 3){
            bits = (decStr.charCodeAt(i++) & 0xff) <<16 | (decStr.charCodeAt(i++) & 0xff) <<8 | decStr.charCodeAt(i++) & 0xff;
            encOut += base64s.charAt((bits & 0x00fc0000) >>18) + base64s.charAt((bits & 0x0003f000) >>12) + base64s.charAt((bits & 0x00000fc0) >> 6) + base64s.charAt((bits & 0x0000003f));
        }
        if(decStr.length -i > 0 && decStr.length -i < 3){
            dual = Boolean(decStr.length -i -1);
            bits = ((decStr.charCodeAt(i++) & 0xff) <<16) |    (dual ? (decStr.charCodeAt(i) & 0xff) <<8 : 0);
            encOut += base64s.charAt((bits & 0x00fc0000) >>18) + base64s.charAt((bits & 0x0003f000) >>12) + (dual ? base64s.charAt((bits & 0x00000fc0) >>6) : '=') + '=';
        }
        return encOut;
    }

function webChatPop(){
    var wv_argscopy = arguments;
    wv_argscopy[wv_argscopy.length++]="wndname=eStaraChat_200106283515";
    wv_argscopy[wv_argscopy.length++]="calltype=webchatpop";
    var prev_ui_width=wv_vars["ui_width"];
    var prev_ui_height=wv_vars["ui_height"];
    wv_vars["ui_width"]=500;
    wv_vars["ui_height"]=500;
    wv_start(wv_argscopy);
    wv_vars["ui_width"]=prev_ui_width;
    wv_vars["ui_height"]=prev_ui_height;
}

function freeCall(eid, esk){
    webVoicePop(
        'var1=17',
        'var2=' + eid,
        'var3=data hunter',
        'var4=',
        'var5=16',
        'var6=',
        'var7=',
        'var8=3',
        'AuthorizeURL=http://services.guiamais.com.br/authenticateCall.aspx?esk=' + esk,
        'Template=716159',
        'newwindow=yes');
}
