﻿ 
function _LoadLauncher()
{
    this._launcher = null; 
    this.isVistar = false;
    
    if (window.navigator.userAgent.toLowerCase().indexOf('msie') > -1)
	{
		this.Browser= "IE";
	}
	else if (window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1)
	{
		this.Browser= "FF";
	}
	else if (window.navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
	{
		this.Browser= "CHROME";
	}
	else if (window.navigator.userAgent.toLowerCase().indexOf('opera') > -1)
	{
		this.Browser= "OPERA";
	}
	else if (window.navigator.userAgent.toLowerCase().indexOf('safari') > -1)
	{
		this.Browser= "SAFARI";
	}
	else if (window.navigator.userAgent.toLowerCase().indexOf('netscape') > -1)
	{
		this.Browser= "NETSCAPE";
	}
	else if (window.navigator.userAgent.toLowerCase().indexOf("mozilla") != -1)
	{
        this.Browser= "MOZILLA";
    }
	else
	{
		this.Browser= "UNKNOWN";
	}
	
	if ( this.Browser == "IE" )
	{
		this.Format= "AX";
	}
	else if (  this.Browser == "UNKNOWN")
	{
		this.Format= "ERR";
	}
	else
	{
		this.Format= "NP";
	}
	
	if (this.Format == "NP")
	{
	    navigator.plugins.refresh(false);
	    
	    if (navigator.mimeTypes && navigator.mimeTypes["application/hlauncher-plugin,version=1.0.0.1"] && navigator.mimeTypes["application/hlauncher-plugin,version=1.0.0.1"].enabledPlugin) 
        {
            var str='<embed id="Launcher" type="application/hlauncher-plugin,version=1.0.0.1" width="0" height="0" hidden="true">';
            document.write(str);	
		    this._launcher = document.getElementById("Launcher");
		    
            return;
        }
	    else 
	    {
	        //alert("플러그인을 설치해주세요.");
	        var popup = window.open("http://su.hanbiton.com/Game/Guide/Setup.exe", "", "");

			//if(typeof(popup) == "undefined" || popup == null || typeof(popup.name) == "undefined" || typeof(popup.document.READATTR) == "undefined")
			if(!popup || popup.closed || typeof popup.closed=="undefined")
			{
				alert("Dropping the settings pop-up window.");
				//return false;
			}
	    }
    }
	else
	{
        // 비스타 체크
	    if(window.navigator.userAgent.indexOf('Win') != -1)
	    { 
		    var Version;
		    var temp = window.navigator.userAgent.split(";");
    		
		    for(i=0;i<temp.length;i++)
		    {
			    if(temp[i].indexOf('Win') != -1)
			    {
				    Version = temp[i];
			    }
		    }
    		
		    if(Version.indexOf('6.0') != -1)
		    {
			    this.isVistar = true; 
		    } else {
			    this.isVistar = false;
		    }
	    }	
	
	    if (document.getElementById("Launcher")) {
		    this._launcher = document.getElementById("Launcher");
	    } else if (parent && parent != this && parent.document.getElementById("Launcher")) {
		    this._launcher = parent.document.getElementById("Launcher");
	    }

	    if (this._launcher != null) {
		    // already load
		    return;
	    } else {
    		
		    if(!this.isVistar)
		    {
			    var str='<object id="Launcher" codebase="/ActiveX/HLauncher.cab#version=1,2,2,4" classid="CLSID:B01AAFA1-2478-44a3-8894-BE4D4C23C271" style="display:none"></object>';
		    }
		    else
		    {
			    var str='<object id="Launcher" codebase="/ActiveX/HLauncher_V.cab#version=1,2,2,4" classid="CLSID:B01AAFA1-2478-44a3-8894-BE4D4C23C271" style="display:none"></object>';
		    }
    		
    		
		    document.write(str);	
		    this._launcher = document.getElementById("Launcher");
	    }
	}
}

var LoadLauncher = new _LoadLauncher();

