//
// INIplugin128 install Java Script(New Version)

// 1. update 2000.04.08  wakano@initech.com
//      downloadURL Ãß°¡
//		NS¹öÀü:2.0.0.12,  IE¹öÀü:2.0.0.12 
// 2. update 2000.04.18  wakano@initech.com
//		downloadURL ¼öÁ¤
// 3. update 2000.07.08  wakano@initech.com
//		NS¹öÀü:2.0.1.4,  IE¹öÀü:2.0.1.4 

var downloadURL		= 'http://' + window.location.host;
	downloadURL		+= '/initech/plugin/';

var packageNSURL 	= downloadURL + 'npINIplugin20.jar';
var packageIEURL 	= downloadURL + 'axINIplugin20.cab';
var NSInstallURL 	= downloadURL + 'ns_install.html';
var NSUpdateURL 	= downloadURL + 'ns_install.html';
var manualPackageIE	= downloadURL + 'INIplugin_IE.exe';
var manualPackageNS	= downloadURL + 'INIplugin_NS.exe';
var manualInstallURL	= downloadURL + 'manual_install.html';

var versionMaj = 2;
var versionMid = 0;
var versionMin = 4;
var versionBuild = 1;

function install_MsgBox(msg)
{
	//alert(msg)
}

function isNewPlugin(desc)
{
    index = desc.indexOf('v.', 0);
    if (index < 0)
        return false;
    desc += ' ';

    versionString = desc.substring(index +2, desc.length);
    arrayOfStrings = versionString.split('.');
    thisMaj = parseInt(arrayOfStrings[0], 10);
    thisMid = parseInt(arrayOfStrings[1], 10);
    thisMin = parseInt(arrayOfStrings[2], 10);
    thisBuild = parseInt(arrayOfStrings[3], 10);

    if (thisMaj > versionMaj)
        return true;
    else if (thisMaj < versionMaj)
        return false;
    if (thisMid > versionMid)
        return true;
    else if (thisMid < versionMid)
        return false;
    if (thisMin > versionMin)
        return true;
    else if (thisMin < versionMin)
        return false;
    if (thisBuild > versionBuild)
        return true;
    else if (thisBuild < versionBuild)
        return false;

    return true;
}

function hostname() 
{
	return window.location.host;
}

function downloadNow () 
{
	s = navigator.userAgent.indexOf("/");	
	e = navigator.userAgent.indexOf(" ");	
	ver = navigator.userAgent.substring(s+1, e);
	if(ver<4.07){
		top.location = manualInstallURL;
		return false;
	}

	if ( navigator.javaEnabled() ) {
		trigger = netscape.softupdate.Trigger;
		if ( trigger.UpdateEnabled() ) {
			if (navigator.platform == "Win32") {
				 return  trigger.StartSoftwareUpdate( packageNSURL, trigger.DEFAULT_MODE);
			} else 
				alert('[sp128inipay PlugIn]Àº À©µµ¿ìÁî 95/98/NT È¯°æ¿¡¼­¸¸ ÀÛµ¿ÇÕ´Ï´Ù.')
		} else 
			alert('NetscapeÀÇ SmartUpdate ¼³Ä¡¸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.');
	} else 
		alert('Java ½ÇÇàÀ» °¡´ÉÇÏµµ·Ï ÇØ¾ßÇÕ´Ï´Ù.');
	return false
}

function OpenWin(bUpdate)
{
	if (bUpdate) 
		top.location = NSUpdateURL;
	else
		top.location = NSInstallURL;
}

function downloadNow2 (bUpdate) 
{
	s = navigator.userAgent.indexOf("/");	
	e = navigator.userAgent.indexOf(" ");	
	ver = navigator.userAgent.substring(s+1, e);
	if(ver<4.07){
		top.location = manualInstallURL;
		return false;
	}
	
	if ( navigator.javaEnabled() ) {
		trigger = netscape.softupdate.Trigger;
		if ( trigger.UpdateEnabled() ) {
			if (navigator.platform == "Win32") {
				OpenWin(bUpdate);
			} else 
				alert('[INIplugin128 PlugIn]Àº À©µµ¿ìÁî 95/98/NT È¯°æ¿¡¼­¸¸ ÀÛµ¿ÇÕ´Ï´Ù.')
		} else 
			alert('NetscapeÀÇ SmartUpdate ¼³Ä¡¸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.');
	} else 
		alert('Java ½ÇÇàÀ» °¡´ÉÇÏµµ·Ï ÇØ¾ßÇÕ´Ï´Ù.');
	return false
}

function StartSmartUpdate() {
	install_MsgBox(downloadURL);
	install_MsgBox(navigator.appName);
	if (navigator.appName == 'Netscape') 
		return StartSmartUpdate_NS();
	else
		return StartSmartUpdate_IE();
}

function StartSmartUpdate_NS() 
{
	install_MsgBox(navigator.userAgent);
	var PlugMime = navigator.mimeTypes["application/x-INIplugin128v20"];
	if (PlugMime) {   // ÀÌ¹Ì ¼³Ä¡µÇ¾î ÀÖ´Â °æ¿ì
		if ( isNewPlugin(PlugMime.enabledPlugin.description) == false) {
			if (confirm('[INIplugin-128]Àº ¾÷±×·¹ÀÌµå µÇ¾ú½À´Ï´Ù. Áö±Ý ¼³Ä¡ÇÏ½Ã·Á¸é È®ÀÎ ¹öÆ°À» ´©¸£¼¼¿ä.' )) {
				if (navigator.userAgent.indexOf("Mozilla/3") == 0 ) {
					top.location = manualInstallURL;
					//alert("[INIplugin-128]Àº Netscape 4.x ÀÌ»ó¿¡¼­¸¸ ÀÛµ¿ÇÕ´Ï´Ù.");
					return false;
				}
				else if (navigator.userAgent.indexOf("Mozilla/4") == 0) 
					//return downloadNow2(true);
					return downloadNow();
			} //if confirm
		} //if isNewPlugin
	} else {     // PlugIn ÀÌ ¼³Ä¡µÇ¾î ÀÖÁö ¾ÊÀº °æ¿ì
		if (confirm('¾ÈÀüÇÑ ¼­ºñ½º¸¦ À§ÇÏ¿© [INIplugin-128 PlugIn]À» ¼³Ä¡ÇÕ´Ï´Ù.')) {
			if (navigator.userAgent.indexOf("Mozilla/3") == 0 ) {
				top.location = manualInstallURL;
				//alert("[INIplugin-128]Àº Netscape 4.x ÀÌ»ó¿¡¼­¸¸ ÀÛµ¿ÇÕ´Ï´Ù.");
				return false;
			} else if (navigator.userAgent.indexOf("Mozilla/4") == 0) {
				return downloadNow();
				//return downloadNow2(false);
			}
		} //if confirm
	} // else PlugIn 
	document.writeln('<EMBED type="application/x-INIplugin128v20" name="INIplugin" width=2 height=2></EMBED>');
	return true;
}

function StartSmartUpdate_IE() 
{
	install_MsgBox(navigator.userAgent);

	s = navigator.userAgent.indexOf("MSIE ");	
	e = navigator.userAgent.indexOf("; Windows");	
	ver = navigator.userAgent.substring(s+4, e);

	//¼³Ä¡°¡ ¾ÈµÇ´Â ¹öÀüÀ» Ãß°¡ÇÏ¼¼¿ä.... À§¿¡ ³ª¿À´Â ¹öÀüÀ¸·Î...
/*	install_MsgBox(ver);
	if ( (ver < 4.00) || (ver == 4.01)  || (ver == 5.0) ){
		top.location = manualInstallURL;
		return false;
	}
*/
	document.writeln('<OBJECT ID="INIplugin" CLASSID="CLSID:06228E75-DEB1-11D3-B702-00001CD5DA14" width=2 height=2 ');
	document.writeln('CODEBASE='+ packageIEURL + '#Version=2,0,4,1>');
	document.writeln('</OBJECT>');		
	return true;
}

