/**
 *  @name Veraport V2 - veraport20.js
 *  @author wizvera
 *  @date 2011.07.22
**/

var vp_Version          = "2,5,0,5";
//if(navigator.platform == "Win64") vp_Version = "2,5,0,5";
var vp_X64Platform      = false;
var vp_MozilaPlugin     = true;
var vp_domainCookie     = true;
var vp_MozialVersion    = vp_Version;
var vp_mimeType         = "application/x-veraport20-plugin";
var vp_CLSID            = "CLSID:477D5B9A-6479-44F8-9718-9340119B0308";
var vp_installType      = ""; //NONE, TOP

/* Constant */
var VP_USE_COOKIE       = "Veraport20Use";
var VP_DEBUG_COOKIE     = "Veraport20Debug";
var VP_UPDATE_COOKIE    = "Veraport20Update";
var VP_INSTALL_COOKIE   = "Veraport20Install";

var VP_TYPE_SIMPLE      = "simple";
var VP_TYPE_MINI        = "mini";
var VP_TYPE_NORMAL      = "normal";
var VP_TYPE_FULL        = "full";
var VP_TYPE_MANAGE      = "manage";

var VP_CONF_AXINFOURL   = "axinfourl";
var VP_CONF_TYPE        = "type";
var VP_CONF_LOGOURL     = "logourl";
var VP_CONF_MSGURL      = "msgurl";
var VP_CONF_WEBINFOURL  = "webinfourl";
var VP_CONF_INFOPAGEURL = "infopageurl";
var VP_CONF_LANGUAGE    = "language";
var VP_CONF_CISENDURL   = "clientinfosendurl";
var VP_CONF_ILSENDURL   = "installlogsendurl";
var VP_CONF_SILENCE     = "silence";
var VP_CONF_SENDVPINFO  = "sendvpinfo";
var VP_CONF_INSTALLGUIDE= "installguide";
var VP_CONF_SELECTOBJECT= "selectobject";
var VP_CONF_DOMAIN      = "domain";
var VP_CONF_INITXPOS    = "initxpos";
var VP_CONF_INITYPOS    = "initypos";


var VP_CONF_SELECTOBJECT_ALL = "all";

var VP_TRUE             = 1;
var VP_FALSE            = 0;
var VP_DELAY            = 200; //ms

/* default base */
var VP_UPDATE_URL       = "http://update.wizvera.com/veraport20/v1.0/updateinfo.xml";
var VP_SITE_URL         = "http://sso.cau.ac.kr";
var VP_BASE_URL         = VP_SITE_URL + "/Common/wizvera/veraport";
var VP_HTML_URL         = VP_BASE_URL;

///////////////////////////////////////////////////////////////
//***********************************************************//
//wizvera test
if ( document.location.host.indexOf("tcauweb.cau.ac.kr") >= 0 
  || document.location.host.indexOf("tportal.cau.ac.kr") >= 0
  || document.location.host.indexOf("tgw.ekpdev.dev")    >= 0
  || document.location.host.indexOf("tsso.cau.ac.kr")    >= 0
  || document.location.host.indexOf("tgw.cau.ac.kr")     >= 0 )
{
  VP_SITE_URL = "http://tsso.cau.ac.kr:8080";
  VP_BASE_URL = VP_SITE_URL + "/Common/Wizvera/veraport";
  VP_HTML_URL = VP_BASE_URL;
}
//***********************************************************//
///////////////////////////////////////////////////////////////


var vp_ClientInfoSendUrl= VP_SITE_URL + "/wizvera/recv/recvClientInfo.jsp";
var vp_LogSendUrl       = VP_SITE_URL + "/wizvera/recv/recvInstallLog.jsp";

var vp_AxInfoUrl        = VP_BASE_URL + "/dist/axinfo.dist";
if (vp_MozilaPlugin && vp_isMozila()) {
    vp_AxInfoUrl        = VP_BASE_URL + "/dist/plinfo.dist";
} else if (navigator.appVersion.indexOf("WOW64")>0) {
    //vp_AxInfoUrl        = VP_BASE_URL + "/dist/axinfo_wow64.dist";
}

/****************************************
***** modify site information begin *****
*****************************************/
var VP_TYPE_MUST        = VP_TYPE_NORMAL; //VP_TYPE_SIMPLE, VP_TYPE_MINI, VP_TYPE_NORMAL, VP_TYPE_FULL
var VP_TYPE_SELECT      = VP_TYPE_NORMAL;
var VP_SITE_ID          = "verain"; //"wizvera";

if (VP_SITE_ID == "wizvera") {
    VP_SITE_URL         = "http://" + "veraport.wizvera.com";
    vp_ClientInfoSendUrl= VP_SITE_URL + "/wizvera/recv/recvClientInfo.jsp";
    vp_LogSendUrl       = VP_SITE_URL + "/wizvera/recv/recvInstallLog.jsp";
}
else if (VP_SITE_ID == "verain") {
    vp_AxInfoUrl        = VP_BASE_URL + "/dist/axinfo.dist.xml";
    vp_ClientInfoSendUrl= "";
    vp_LogSendUrl       = "";
}

var vp_AgreeSiteID      = VP_SITE_ID;
var vp_AgreeInstall     = VP_FALSE; //VP_TRUE; windows view opt default FALSE
var vp_AgreeDefUse      = VP_FALSE; //err check opt default FALSE
var vp_AgreePageURL     = VP_BASE_URL + "/sitelogo/agreement.html";

/****************************************
***** modify site information end *****
*****************************************/

/* variable */
var vp_CabUrl           = VP_BASE_URL + "/down/veraport20.cab";
var vp_ExeUrl           = VP_BASE_URL + "/down/veraport20.exe";
//if(navigator.platform == "Win64" && vp_X64Platform) {
if(vp_X64Platform && vp_isX64Platform()) {
    vp_CabUrl           = "http://veraport.wizvera.com/wizvera/veraport/down/veraport20-x64.cab";   //jhkoo77-20110411
    vp_ExeUrl           = "http://veraport.wizvera.com/wizvera/veraport/down/veraport20-x64.exe";   //jhkoo77-20110411
}

var vp_LogoS            = VP_BASE_URL + "/sitelogo/logo_small.gif";
var vp_LogoL            = ""; //VP_BASE_URL + "/sitelogo/logo_large.gif";
var vp_MsgS             = VP_BASE_URL + "/sitelogo/msg_small.gif";
var vp_MsgL             = VP_BASE_URL + "/sitelogo/msg_large.gif";
var vp_Html             = VP_BASE_URL + "/sitelogo/msg_info.html";

var vp_InstallPage      = VP_HTML_URL + "/install.html";
if (vp_MozilaPlugin && vp_isMozila())
    vp_InstallPage      = VP_HTML_URL + "/download.html";

/* Initialize */
try {
    //vp_notUse();
    //vp_setDebug();
    //if (!vp_isMultiBrowser()) vp_notUse(); //IE is veraport off
    vp_checkBrowser();
    vp_createObject();
    vp_init();
    //vp_update();
}
catch(err) {
    vp_alert("vp_Main[" + err.description  + "]");
}

/****************************************
**********   OPEN API begin    **********
*****************************************/

//[OPEN API] set axInfoUrl
function VP_setAxInfoUrl(axInfoUrl) {
    vp_AxInfoUrl = axInfoUrl;
    vp_setAxInfoUrl(vp_AxInfoUrl);
}

// [OPEN API] View Active-X Management
function VP_axManage() {
    VP_axInstall(VP_TYPE_MANAGE, false, '');
}

// [OPEN API] Required Install Active-X
function VP_axInstallMust() {
    VP_axInstall(VP_TYPE_MUST, true, '');
}

// [OPEN API] ALL Install Active-X
function VP_axInstallAll() {
    VP_axInstall(VP_TYPE_MUST, true, 'all');
}

// [OPEN API] Select Install Active-X
function VP_axInstallSelect(objectName) {
    VP_axInstall(VP_TYPE_SELECT, true, objectName);
}

// [OPEN API] Install Active-X
function VP_axInstall(installType, goInstallPage, objectName) {
    if(!vp_isMozila() && typeof(this.document.Vp20Ctl) == "undefined") vp_installType = "NONE";
    vp_checkVp20Install(goInstallPage);
    vp_setSelectObject(objectName);
    vp_showVeraport(installType);
}

//[OPEN API] Not Install Count Must
function VP_axCountMust() {
    return vp_getUninstalledCnt(0);
}

//[OPEN API] Not Install Count Opt
function VP_axCountOpt() {
    return vp_getUninstalledCnt(1);
}

//[OPEN API] set trustedSite
function VP_setTrustedSite(trustedSite) {
    //trustedSite = "*.wizvera.com,veraport.wizvera.com";
    if (!vp_isAvailable("VP_setTrustedSite", "2,0,0,22")) return;
    if (trustedSite == "") trustedSite = document.location.hostname;
    vp_setConfigure("trustedsite", trustedSite);
}

/***************************************
Previous version compatibility (bank.keb.co.kr)
/****************************************/
function VeraPortSetNbebank() {
    //VP_setAxInfoUrl("http://acs.keb.co.kr/dist/nbebank.dist");
}
function VeraPortShowAndInstall() {
    //alert("Warning delete function(VeraportShowAndInstall). used VP_axInstallMust()\n\tURL:" + location.pathname);
    //vp_showVeraport(VP_TYPE_NORMAL);
    VP_axInstall(VP_TYPE_MUST, false, '');
}
function VeraPortShow() {
    //alert("Warning delete function(VeraPortShow). used VP_axManage()\n\tURL:" + location.pathname);
    //vp_showVeraport(VP_TYPE_MANAGE);
    VP_axInstall(VP_TYPE_MANAGE, false, '');
}

/*
function VeraPortSetYescard() {
    //VP_setAxInfoUrl("http://acs.keb.co.kr/dist/yescard.dist");
}
function VeraPortSetB2c() {
    //VP_setAxInfoUrl("http://acs.keb.co.kr/dist/b2c.dist");
}
function VeraPortShowAndInstallEn() {
}
function VeraPortShowEn() {
}
*/

/***************************************
Previous version compatibility (hanabank.com, scfirstbank.com)
/****************************************/
function SetAxInfoName(dist_name) {
    alert("Warning delete function(SetAxInfoName). used VP_axInstallSelect(objectName)\n\tURL:" + location.pathname);
    //vp_AxInfoUrl = VP_BASE_URL + "/down/dist/" + dist_name;
    //vp_setAxInfoUrl(vp_AxInfoUrl);
    VP_setAxInfoUrl(VP_BASE_URL + "/down/dist/" + dist_name);
}
function VeraportShowAndInstall() {
    //alert("Warning delete function(VeraportShowAndInstall). used VP_axInstallMust()\n\tURL:" + location.pathname);
    //vp_showVeraport(VP_TYPE_NORMAL);
    VP_axInstall(VP_TYPE_MUST, false, '');
}
function VeraportShow() {
    //alert("Warning delete function(VeraportShow). used VP_axManage()\n\tURL:" + location.pathname);
    //vp_showVeraport(VP_TYPE_MANAGE);
    VP_axInstall(VP_TYPE_MANAGE, false, '');
}
function VeraportSelectInstall(axname,viewtype) {
    //alert("Warning delete function(VeraportSelectInstall). used VP_axInstallSelect(objectName)\n\tURL:" + location.pathname);
    //vp_setSelectObject(axname);
    //vp_showVeraport(viewtype);
    VP_axInstall(viewtype, false, axname);
}

/****************************************
**********   OPEN API end      **********
*****************************************/

/* functions */
function vp_init() {
    //vp_setWindowPosition(-100, -100); //add v2,0,0,20
    vp_setDomain(VP_SITE_URL); //add v2,0,0,7
    vp_setAxInfoUrl(vp_AxInfoUrl);
    vp_setLogo(vp_LogoL);
    vp_setMsg(vp_MsgL);
    vp_setWebInfo(vp_Html);
    vp_setType(VP_TYPE_MANAGE);
    vp_setLogSendUrl(vp_LogSendUrl);
    vp_setClientInfoSendUrl(vp_ClientInfoSendUrl);
    vp_setSelectObject("");
    vp_setSendVpInfo(false);
    //vp_setConfigure("language", "eng");
    //vp_setConfigure("trustedsite","http://test.com,http://veraport.wizvera.com");
}
function vp_getUninstalledCnt(objType) {
    var obj = vp_getObject();
    if(obj == null) return -1;
    vp_loadInfo();
    var unInstallCnt = obj.GetUninstalledCnt(objType);
    //alert(installCnt + ":" + objType);
    return unInstallCnt;
}
function vp_isAvailable(fnName, inVersion) {
    var thisArray = vp_Version.split(',');
    var inputArray = inVersion.split(',');
    for (i=0; i<4; i++) {
        if (parseInt(thisArray[i], 10) > parseInt(inputArray[i], 10)) {
            return true;
        } else if (parseInt(thisArray[i], 10) < parseInt(inputArray[i], 10)) {
            vp_alert("vp_isAvailable[function:" + fnName + "is not support][version:" + inVersion + "]");
            return false;
        }
    }
    return true;
}
function vp_setWindowPosition(xPos, yPos) {
    if (!vp_isAvailable("vp_setRequireAgreement", "2,0,0,20")) return;
    vp_setConfigure(VP_CONF_INITXPOS,xPos);
    vp_setConfigure(VP_CONF_INITYPOS,yPos);
}
function vp_setRequireAgreement(agree,siteid,url,defuse) {
    if (!vp_isAvailable("vp_setRequireAgreement", "2,0,0,8")) return;
    var obj = vp_getObject();
    if(obj == null) return "null";
    return obj.SetRequireAgreement(agree,siteid,url,defuse); //windows view, no error check
}
function vp_notUpdateToDay(days)
{
    var today = new Date();
    var expiry = new Date(today.getTime() + days * 24 * 60 * 60 * 1000);
    document.cookie=VP_UPDATE_COOKIE+"=N; path=/; expires=" + expiry.toGMTString();
}
function vp_update() {
    var obj = vp_getObject();
    if(obj == null) return "null";

    //alert(document.cookie);
    if (vp_getCookie(VP_UPDATE_COOKIE) == "N")
        return;

    //alert(document.cookie);
    vp_notUpdateToDay(1);
    return obj.Update(VP_UPDATE_URL);
}
function vp_isMozila() {
    if (navigator.appName == 'Netscape' || navigator.appName == 'Opera') return true;
    return false;
}
function vp_checkVp20Plugin() {
    var plugins = navigator.plugins;
    if(plugins == null || plugins.length == 0) return false;
    for(var i=0;i<plugins.length;i++) {
        //modify 2010.11.02
        if (typeof(plugins[i][0]) == "undefined") continue;
        if(vp_mimeType == plugins[i][0].type ) return true;
    }
    return false;
}
function vp_checkVp20Install(goInstallPage) {
    if (!vp_isUse()) return false;
    try {
        if (vp_isMozila()) {
            var myMimetype = navigator.mimeTypes[vp_mimeType];
            //modify 2010.08.23
            if ( myMimetype && vp_checkVp20Plugin()) {
                //alert("installOK:" + myMimetype);
            }
            else {
                //alert("not install:" + myMimetype);
                if (goInstallPage) vp_goVp20InstallPage();
                return false;
            }
        }
        else {
            if( ((typeof(this.document.Vp20Ctl) == "undefined") || (this.document.Vp20Ctl == "undefined")
                ||(this.document.Vp20Ctl == null) || (this.document.Vp20Ctl.object == null) )) {
                if (goInstallPage) vp_goVp20InstallPage();
                return false;
            }
        }
    }
    catch(err) {
        vp_alert("vp_checkVp20Install[" + err.description + "]");
    }
    return true;
}
function vp_getDomain() {
	var thisDomain = document.location.hostname;
	try {
	    var idx = thisDomain.indexOf(".");
	    thisDomain = thisDomain.substring(idx+1);
	} catch(err) {
        alert("vp_getDomain[" + thisDomain + "][" + err.description + "]");
    }
    return thisDomain;
}
function vp_goVp20InstallPage() {
	var thisDomain = vp_getDomain();
    if (vp_InstallPage.indexOf(thisDomain)<0) {
        if (vp_getCookie(VP_INSTALL_COOKIE) == "Y") {
            document.cookie=VP_INSTALL_COOKIE+"=N; path=/;";
            //alert("Not goInstallPage:" + vp_InstallPage + "\n" + thisDomain + "\n" + vp_InstallPage.indexOf(thisDomain));
        	return;
        }
        document.cookie=VP_INSTALL_COOKIE+"=Y; path=/;";
    }
    
    var thisPage = window.location.href;
    if (thisPage.indexOf(vp_InstallPage) < 0 && vp_installType != "NONE") {
        if (vp_installType == "TOP")
            top.window.location.href = vp_InstallPage + "?url=" + thisPage;
        else
            window.location.href = vp_InstallPage + "?url=" + thisPage;
    }
}
function vp_isX64Platform() {
    if(navigator.platform == "Win64") return true;
    if(navigator.platform.match(/Win32/i)) {
        if (navigator.userAgent.match(/Win64/i) || navigator.platform.match(/Win64/i)) return true;
    }
    return false;
}
function vp_checkBrowser() {
    try {
        var browserInfo = ["", -1];
        var index = -1;
        var tmp = "";

        //if(navigator.platform == "Win64") {
        if(vp_isX64Platform()) {
            if (!vp_X64Platform) vp_notUse(); //jhkoo77-20110411
        }
        else if(navigator.platform != "Win32") { //add 2010/06/15
            vp_notUse();
        }

        if (vp_isMozila()) {
            browserInfo = vp_getMozilaInfo();
            if (!vp_MozilaPlugin) vp_notUse();
        }
        else {
            browserInfo[0] = "MSIE";
            if (navigator.userAgent.indexOf(browserInfo[0]) > 0) {
                index = navigator.userAgent.lastIndexOf(browserInfo[0])+browserInfo[0].length+1;
                tmp = navigator.userAgent.substring(index);
                index = tmp.indexOf(";");
                browserInfo[1] = tmp.substring(0, index);
                if (browserInfo[1]<5.0) vp_notUse();
                // add 2010.02.16 windows 98 NOT USE
                var os = window.navigator.appVersion;
                if(os.indexOf(" Windows 98") != -1 || os.indexOf(" Windows 95") != -1
                    ||  os.indexOf(" Windows NT 4.0") != -1) vp_notUse();
            } else {
                browserInfo[0] = navigator.appName;
                browserInfo[1] = "NOT_OK";
                vp_notUse();
            }
        }

        if (!vp_isUse()) {
            var msg  = "Browser Information\t\t[" + navigator.platform + "][" + browserInfo + "]\n\n";
                msg += "Navigator Information\n";
                msg += "navigator.appName\t\t[" + navigator.appName + "]\n";
                msg += "navigator.userAgent\t[" + navigator.userAgent + "]\n";
                msg += "navigator.appCodeName\t[" + navigator.appCodeName + "]\n";
                msg += "navigator.appVersion\t[" + navigator.appVersion + "]\n";
                msg += "navigator.systemLanguage\t[" + navigator.systemLanguage + "]\n";
                msg += "navigator.javaEnabled()\t[" + navigator.javaEnabled() + "]\n";
                msg += "navigator.systemLanguage\t[" + navigator.systemLanguage + "]\n";
                msg += "navigator.language\t\t[" + navigator.language + "]\n";
                msg += "navigator.cpuClass\t\t[" + navigator.cpuClass + "]\n";
                msg += "navigator.platform\t\t[" + navigator.platform + "]\n";

            vp_alert(msg);
        }

    }
    catch(err) {
        vp_alert("vp_checkBrowser[" + err.description + "]");
        vp_notUse();
    }
}
function vp_getMozilaInfo() {
    try {
        var browserInfo = ["", -1];
        var browserName = "";
        var browserVersion = -1;
        var index = -1;
        var tmp = "";
        if (navigator.userAgent.lastIndexOf("Navigator") > 0) { //Firefox
            browserInfo[0] = "Navigator";
            index = navigator.userAgent.lastIndexOf(browserInfo[0])+browserInfo[0].length+1;
            tmp = navigator.userAgent.substring(index);
            browserInfo[1] = tmp;
        }
        else if (navigator.userAgent.lastIndexOf("Firefox") > 0) {
            browserInfo[0] = "Firefox";
            index = navigator.userAgent.lastIndexOf(browserInfo[0])+browserInfo[0].length+1;
            tmp = navigator.userAgent.substring(index);
            browserInfo[1] = tmp;
            index = tmp.indexOf(" ");
            if (index > 0) browserInfo[1] = tmp.substring(0, index);
        }
        else if (navigator.userAgent.lastIndexOf("Chrome") > 0) { //Safari
            browserInfo[0] = "Chrome";
            index = navigator.userAgent.lastIndexOf(browserInfo[0])+browserInfo[0].length+1;
            tmp = navigator.userAgent.substring(index);
            index = tmp.indexOf(" ");
            browserInfo[1] = tmp.substring(0, index);
        }
        else if (navigator.userAgent.lastIndexOf("Safari") > 0 && navigator.userAgent.lastIndexOf("Version") > 0) {
            browserInfo[0] = "Safari";
            index = navigator.userAgent.lastIndexOf("Version")+"Version".length+1;
            tmp = navigator.userAgent.substring(index);
            index = tmp.indexOf(" ");
            browserInfo[1] = tmp.substring(0, index);
        }
        else if (navigator.userAgent.lastIndexOf("Opera") > -1 && navigator.userAgent.lastIndexOf("Version") > 0) {
            browserInfo[0] = navigator.appName;
            index = navigator.userAgent.lastIndexOf("Version")+"Version".length+1;
            tmp = navigator.userAgent.substring(index);
            browserInfo[1] = tmp;
        }
        else {
            browserInfo[0] = navigator.appName;
            index = navigator.userAgent.indexOf("/")+1;
            tmp = navigator.userAgent.substring(index);
            index = tmp.indexOf(" ");
            browserInfo[1] = tmp.substring(0, index);
        }
    }
    catch(err) {
        vp_alert("vp_getMozilaInfo[" + err.description + "]");
        vp_notUse();
    }
    return browserInfo;
}
function vp_getCookie( name ) {
    try {
        var nameOfCookie = name + "=";
        var x = 0;
        while ( x <= document.cookie.length ) {
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie ) {
           if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                endOfCookie = document.cookie.length;
           return unescape( document.cookie.substring( y, endOfCookie ) );
        }
           x = document.cookie.indexOf( " ", x ) + 1;
           if ( x == 0 ) break;
        }
    }
    catch(err) {
        vp_alert("vp_getCookie[" + err.description + "]");
    }
    return "";
}

function vp_isUse() {
    if (vp_getCookie(VP_USE_COOKIE) == "N") return false;
    return true;
}
function vp_setUse() {
	if (vp_domainCookie) {
	    document.cookie=VP_USE_COOKIE+"=Y; path=/; domain=." + vp_getDomain();
	} else {
		document.cookie=VP_USE_COOKIE+"=Y; path=/;";
	}
}
function vp_notUse() {
	if (vp_domainCookie) {
	    document.cookie=VP_USE_COOKIE+"=N; path=/; domain=." + vp_getDomain();
	} else {
	    document.cookie=VP_USE_COOKIE+"=N; path=/;";
	}
}
function vp_setDebug() {
	if (vp_domainCookie) {
	    document.cookie=VP_DEBUG_COOKIE+"=Y; path=/; domain=." + vp_getDomain();
	} else {
	    document.cookie=VP_DEBUG_COOKIE+"=Y; path=/;";
	}
}
function vp_notDebug() {
	if (vp_domainCookie) {
	    document.cookie=VP_DEBUG_COOKIE+"=N; path=/; domain=." + vp_getDomain();
	} else {
	    document.cookie=VP_DEBUG_COOKIE+"=N; path=/;";
	}
}
function vp_notUseDays(days) {
    var today = new Date();
    var expiry = new Date(today.getTime() + days * 24 * 60 * 60 * 1000);
	if (vp_domainCookie) {
	    document.cookie=VP_USE_COOKIE+"=N; path=/; expires=" + expiry.toGMTString() + "; domain=." + vp_getDomain();
	} else {
	    document.cookie=VP_USE_COOKIE+"=N; path=/; expires=" + expiry.toGMTString();
	}
}
function vp_isDebug() {
    if (vp_getCookie(VP_DEBUG_COOKIE) == "Y") return true;
    return false;
}
function vp_alert(msg) {
    if (vp_isDebug())
        alert(msg);
    else
        document.cookie="Veraport20Alert=" + msg + "; path=/;";
}
function vp_createObject() {
    var objstr = "";
    if (!vp_isUse()) return;
    //add 2011.1.4 wizvera
    if (document.getElementById("Vp20Ctl") != null) return;
    if (vp_isMozila()) {
        //add 2010.08.23
        var myMimetype = navigator.mimeTypes[vp_mimeType];
        if ( myMimetype ) {
            objstr += '<embed ID="Vp20Ctl" width="0" height="0" ';
            objstr += 'codeBaseURL="' +  vp_CabUrl + '#version=' + vp_MozialVersion + '" ';
            objstr += 'type="' + vp_mimeType + '" />';
        }
    }
    else {
        //objstr += '<object id="Vp20Ctl" width="1" height="1" classid="';
        objstr += '<object id="Vp20Ctl" width="1" height="1" style="visibility:hidden;"  classid="';
        objstr += vp_CLSID;
        objstr += '" codebase="';
        objstr += vp_CabUrl;
        objstr += '#version=';
        objstr += vp_Version;
        objstr += '"></object>';
    }
    //vp_alert(objstr);
    document.write(objstr);

    //add 2010.05.25 wizvera
    try {
        if(!vp_isMozila() && typeof(this.document.Vp20Ctl) == "undefined") {
            var debugMsg = "[" + typeof(this.document.Vp20Ctl) + "]";
            var el  = document.createElement("div");
            el.innerHTML = objstr;
            if (document.body != null) document.body.appendChild(el);
            if(typeof(this.document.Vp20Ctl) == "undefined") vp_installType = "NONE";
            debugMsg += "[" + typeof(this.document.Vp20Ctl) + "]";
            vp_alert("createObject:" +  debugMsg);
        }
    } catch(err) {
        vp_installType = "NONE";
        vp_alert("vp_createObject:[" + err.description + "]");
    }
}
function vp_getObject() {
    if(!vp_checkVp20Install(false)) return null;
    return document.getElementById("Vp20Ctl");
}
function vp_getLastError() {
    var obj = vp_getObject();
    if(obj == null) return "null";
    return obj.GetLastErrorMsg();
}
function vp_getConfigureAll() {
    var obj = vp_getObject();
    if(obj == null) return "null";
    return obj.GetConfigureAll();
}
function vp_getConfigureJson() {
    var obj = vp_getObject();
    if(obj == null) return "null";
    return obj.GetConfigureJson();
}
function vp_showVeraport(type) {
    vp_setAxInfoUrl(vp_AxInfoUrl);
    vp_setLogSendUrl(vp_LogSendUrl);
    vp_setClientInfoSendUrl(vp_ClientInfoSendUrl);
    vp_setRequireAgreement(vp_AgreeInstall,vp_AgreeSiteID,vp_AgreePageURL,vp_AgreeDefUse); //add v2,0,0,8

    var flag = 1;
    if(type ==  VP_TYPE_MANAGE || type ==  VP_TYPE_FULL) {
        vp_setLogo(vp_LogoL);
        vp_setMsg(vp_MsgL);
        vp_setWebInfo(vp_Html);
        if(type ==  VP_TYPE_MANAGE) flag = 0;
    } else {
        vp_setLogo(vp_LogoS);
        vp_setMsg(vp_MsgS);
    }
    vp_setConfigure("type",type);
    vp_show(flag);
}
function vp_setWebInfo(url) {
    vp_setConfigure(VP_CONF_WEBINFOURL,url);
}
function vp_setDomain(domain) {
    if (!vp_isAvailable("vp_setDomain", "2,0,0,7")) return;
    vp_setConfigure(VP_CONF_DOMAIN,domain);
}
function vp_setMsg(url) {
    vp_setConfigure(VP_CONF_MSGURL,url);
}
function vp_setLogo(url) {
    vp_setConfigure(VP_CONF_LOGOURL,url);
}
function vp_setClientInfoSendUrl(url) {
    vp_setConfigure(VP_CONF_CISENDURL,url);
}
function vp_setLogSendUrl(url) {
    vp_setConfigure(VP_CONF_ILSENDURL,url);
}
function vp_setAxInfoUrl(url){
    vp_AxInfoUrl = url;
    vp_setConfigure(VP_CONF_AXINFOURL, url);
}
function vp_setType(type) {
    vp_setConfigure(VP_CONF_TYPE,type);
}
function vp_setInstallGuide(url) {
    vp_setConfigure(VP_CONF_INSTALLGUIDE,url);
}
function vp_delay(gap){
    if (gap < 0) return;
    var then,now;
    then=new Date().getTime();
    now=then;
    while((now-then)<gap) {
        now=new Date().getTime();
    }
}
function vp_show(flag) {
    var obj = vp_getObject();
    if(obj == null) return;
    vp_loadInfo();
    //obj.ShowType(flag);
    var res = obj.ShowType(flag);
    try {
        if(res == 0) { // fail
            var code = obj.GetLastErrorCode(); //add v2,0,0,8
            if(code == 58) vp_notUse();
        }
        else {
            vp_delay(VP_DELAY);
        }
    } catch(err) {
        vp_alert("vp_show:deplay[" + err.description + "]");
    }
}
function vp_setConfigure(key,value) {
    var obj = vp_getObject();
    if(obj == null) return;
    obj.SetConfigure(key,value);
}
function vp_uninstallAll() {
    var obj = vp_getObject();
    if(obj == null) return;
    obj.UninstallAll();
}
function vp_loadInfo() {
    var obj = vp_getObject();
    if(obj == null) return "null";
    var ret = obj.LoadInfo("");
    return ret;
}
function vp_setSendVpInfo(flag) {
    vp_setConfigure(VP_CONF_SENDVPINFO,flag);
}
function vp_SetSendVpInfo(flag) {
    vp_setSendVpInfo(flag);
}
function vp_setSelectObject(name) {
    vp_setConfigure(VP_CONF_SELECTOBJECT,name);
}

function vp_isMultiBrowser() {
    try {
        if (vp_isMozila()) return true;
        var value1 = vp_getCookie("Verain");
        var value2 = vp_getCookie("Verain2Web");
        if(value1 != "" || value2 != "") return true; //verain
    } catch(e) {
        alert("vp_isMultiBrowser[" + err.description + "][" + document.cookie + "]");
    }
    return false;
}












function GetTD(value) {
    var td = document.createElement("TD");
    td.innerText = value;
    td.textContent = value;     //for firefox
    return td;
}
function UpdateDistributeInfo(target) {
    var parent = document.getElementById(target);
    if(parent == null) return ;
    var obj = vp_getObject();
    if(obj == null) return;

    try {
        var distinfo = eval(obj.GetDistributeInfo());
        var info = "";
        var version = (distinfo[0].version == 0) ? "V10" : "V20";
        if(distinfo[0].verstring != null && distinfo[0].verstring != "undefined")
        {
            version = distinfo[0].verstring;
        }
        info = info + "version[" + version;
        info = info + "] createDate[" + distinfo[0].createdate;
        if(distinfo[0].allowdomains != null && distinfo[0].allowdomains != "undefined")
        {
            //info = info +  "<br>allowDomains : " + distinfo[0].allowdomains;
            var strDomain = distinfo[0].allowdomains;
            var arrayDomain = strDomain.split(";");
            info = info +  "] <br>allowDomains";
            for(i=0;i<arrayDomain.length;i++) {
                info = info + "[" + arrayDomain[i] + "] ";
            }
        }

        parent.innerHTML = info;
    }
    catch(err) {
        vp_alert("UpdateDistributeInfo[" + err.description + "]");
    }
}
function _selectInstall(name) {
    var config = eval(vp_getConfigureJson());
    //alert(vp_getConfigureJson());
    var curr = "";
    for(var i=0;i<config.length;i++) {
        if(config[i].key == 'type') {
            curr = config[i].value;
            break;
        }
    }
    var old = curr;
    if(curr == "")
        return;

    if(curr == VP_TYPE_MANAGE)
        vp_setConfigure('type',VP_TYPE_FULL);

    vp_setSelectObject(name);
    vp_show(1);

    vp_setConfigure('type',old);

}
function GetAgreementInfo() {
    var obj = vp_getObject();
    if(obj == null) return "" ;
    try {
        var result = "-------------------------\n";
        var info = eval(obj.GetAgreementInfo());
        for(key in info[0]) {
            result += key;
            result += " : ";
            result += info[0][key];
            result += "\n";
            if(key == "baselocation") result += "-------------------------\n";
        }
        return result;
    }
    catch(err) {
        vp_alert("GetAgreementInfo[" + err.description + "]");
    }

}
function UpdateInstallState(target) {
    var parent = document.getElementById(target);
    if(parent == null) return ;

    while(parent.rows != null && parent.rows.length > 0) parent.deleteRow(0);

    var obj = vp_getObject();
    if(obj == null) return ;

    //vp_setAxInfoUrl(vp_AxInfoUrl);
    vp_loadInfo();

    try {
        var axinfo = eval(obj.GetAxInfo());
        var state = "";
        var type = "";

        for(var i=0;i<axinfo.length;i++) {

            var tr = document.createElement("TR");

            tr.appendChild(GetTD(axinfo[i].objectname));
            tr.appendChild(GetTD(axinfo[i].displayname));
            tr.appendChild(GetTD(axinfo[i].objectversion));
            tr.appendChild(GetTD(axinfo[i].systemtype));
            //tr.appendChild(GetTD((axinfo[i].version == 1) ? "V10" : "V20"));

            var td;
            td  = GetTD((axinfo[i].installstate == 0) ? "not install" : "installed");
            td.className = (axinfo[i].installstate == 0) ? "ninstall" : "install";
            tr.appendChild(td);

            td = GetTD((axinfo[i].objecttype == 0) ? "must" : "option");
            td.className = (axinfo[i].objecttype == 0) ? "must" : "opt";
            tr.appendChild(td);

            /*
            var htmlvalue = "<input type='button' value='install' ";
            var scriptvalue = "onclick=\"javascript:_selectInstall(\'"+axinfo[i].objectname+"\');\" ";

            if(axinfo[i].installstate == 0) {
                htmlvalue = htmlvalue;
            } else {
                htmlvalue = htmlvalue + " disabled='disabled' ";
            }
            htmlvalue = htmlvalue + scriptvalue;
            htmlvalue = htmlvalue + " >";
            */

            var htmlvalue = "";
            htmlvalue = "<a href='" + axinfo[i].downloadurl + "'>dn1</a> ";
            htmlvalue += "<a href='" + axinfo[i].backupurl + "'>dn2</a> ";
            if(axinfo[i].installstate == 0) {
                htmlvalue += "<a href=\"javascript:VP_axInstallSelect(\'"+axinfo[i].objectname+"\');\">install</a>";
            } else {
                htmlvalue += "<a href=\"javascript:VP_axInstallSelect(\'"+axinfo[i].objectname+"\');\">install</a>";
                //htmlvalue += "install";
            }
            htmlvalue += " <a href=\"javascript:ViewSource('axInstallSelect', \'"+axinfo[i].objectname+"\');\">src</a>";

            td = GetTD("");
            td.innerHTML = htmlvalue;
            tr.appendChild(td);
            parent.appendChild(tr);
        }
    }
    catch(err) {
        vp_alert("UpdateInstallState[" + err.description + "]");
    }
}

/**
 *  @updateInfo
 *   1. update 2009.10.15 V2,0,0,4
 *    - site: scfirstbank
 *   2. update 2009.11.20 V2,0,0,5
 *    - add allowDomain
 *    - site: hanbank
 *   3. update 2009.11.30 V2,0,0,5
 *    - add function VP_axManage(),VP_axInstallMust(),VP_axInstallSelect(),VP_axInstall()
 *   4. update 2009.12.?  V2,0,0,6
 *   5. update 2009.12.05  V2,0,0,7
 *    - remove mod_updater.dll, veraport20updater.exe
 *    - add updater.exe
 *    - modify VP_UPDATE_URL : "http://update.wizvera.com/veraport20/v1.0/updateinfo.xml"
 *   6. update 2009.12.28  V2,0,0,7
 *    - add mozilla maual setup (vp_ExeUrl4Moz)
 *   7. update 2009.12.28  V2,0,0,8
 *    - add SetRequireAgreement()
 *    - add GetAgreementInfo()
 *   8. update 2010.01.20  V2,0,0,9
 *    - veraport20.dll, veraport20main.exe
 *      (mozilla plugin find bug fix)
 *   8. update 2010.02.24  V2,0,0,11
 *    - veraport20.dll, veraport20main.exe
 *      add SelectObejct option "all"
 *      change file copy order in cab (cause for SCSK)
 *   9. update 2010.03.09  V2,0,0,13
 *    - veraport20.dll, veraport20main.exe
 *  10. update 2010.03.11  V2,0,0,13
 *    - add Veraport Updater function (vp_notUpdateToday())
 *    - modify vp_Update() : check Update Cookie
 *  11. update 2010.04.01  JS
 *    - add set vp_AxInfoUrl function (VP_setAxInfoUrl())
 *  12. update 2010.04.20  V2,0,0,16
 *    - modify cab install(not inf install bug patch)
 *    - modify install bug patch
 *  13. update 2010.04.29  V2,0,0,18
 *    - modify cab install(IssacWeb, Report Express)
 *  14. update 2010.05.26  JS
 *    - add vp_installType option("", "NONE", "TOP")
 *    - mod vp_createObject(), vp_goVp20InstallPage()
 *  15. update 2010.08.03  V2,0,0,19
 *    - modify cab install(Adobe_Flash)
 *    - modify exe install parameter(install.exe /opthin)
 *  16. update 2010.08.10  V2,0,0,20
 *    - vp_showVeraport:  change the window position
 *    - add function vp_setWindowPosition
 *  17. update 2010.08.18  JS
 *    - add function: VP_axCountMust(), VP_axCountOpt(), vp_getUninstalledCnt(objType)
 *  18. update 2010.08.23  JS
 *    - add function: vp_checkVp20Plugin
 *    - mod function: vp_checkVp20Install(), vp_createObject()
 *  19. update 2010.09.29  V2,0,0,21
 *    - add systemType for WOW64
 *  20. update 2010.10.04  V2,0,0,22
 *    - add function VP_setTrustedSite
 *  21. update 2010.10.25  V2,0,0,24(23)
 *    - fix mozilla plug-in bug
 *  22. update 2010.10.28  V2,0,0,25
 *    - fix mozilla system check bug
 *    - fix veraport20unloader.exe bug
 *  23. update 2010.11.01  V2,0,0,26
 *    - fix win7 cab install(Fasoo.com WebDRM)
 *  24. update 2011.01.04  JS
 *    - mod function: vp_createObject(): Avoid creating duplicate objects
 *  25. update 2011.01.28  JS
 *    - kebbank compatibility function
 *  26. update 2011.02.15  V2,0,0,27
 *    - fix flash,gauce install bug fix
 *  27. update 2011.03.10  JS
 *    - add vp_isMultiBrowser() function
 *  28. update 2011.03.16  V2,0,0,28
 *    - fix mfc42.exe install
 *  29. update 2011.04.15  V2,0,0,30
 *    - fix select install UAC
 *  30. update 2011.04.22  V2,5,0,2 JS
 *    - support Windows Win64
 *  31. update 2011.05.12  V2,5,0,3
 *    - support SSL
 *  32. update 2011.05.30  V2,5,0,4
 *    - fix plug-in mine type compare
 *  33. update 2011.07.11  V2,5,0,5
 *    - fix cab install
 *  34. update 2011.07.22  JS
 *    - add vp_domainCookie, vp_getDomain(), modify vp_goVp20InstallPage()
**/
