// CKKeyPro¸¦ ·ÎµåÇÏ±â À§ÇÑ Element ¼±¾ð
var KeyPro_Container_Object = document.createElement("<div id='KeyPro_Contaner_Div'><div>");

var CKKeyPro_CLSID="clsid:6CE20149-ABE3-462E-A1B4-5B549971AA38";	
var CKKeyPro_CODEBASE_x64= "http://www.mgame.com/common_js/CKKeyPro3011_64k.cab";                              
var CKKeyPro_CODEBASE_x86= "http://www.mgame.com/common_js/CKKeyPro3011_32m.cab";
var CKKeyPro_VERSION="version=3,0,1,1";
var USING_CKKeyPro = "1";
var USING_CUSTOM_IMAGE = 1;
var CUSTOM_IMAGE_URL = "http://image.mgame.com/mgamezzang/contents/member/20090701_mgame_sam.bmp";
//var CUSTOM_IMAGE_URL = "";

var isCreated = false;


function CreateCKKeyProObject()
{
	//var isCreated = false;
	if(isCreated == true)
		return;

		var Str="";
	
		Str+= '<object classid="' + CKKeyPro_CLSID + '"';
		if(navigator.cpuClass.toLowerCase() == "x64")
		{
			CKKeyPro_VERSION = "version=3,0,1,1";
			Str+= '\n\t codebase="' + CKKeyPro_CODEBASE_x64 + '#' + CKKeyPro_VERSION + '"';
		}
		else
		{
			Str+= '\n\t codebase="' + CKKeyPro_CODEBASE_x86 + '#' + CKKeyPro_VERSION + '"';
		}
		Str+= '\n\tvspace="0" hspace="0" width="0" id="CKKeyPro" style="display:none;">';
		Str+= '\n\t <PARAM name="PKI" value="simple">';
		Str+= '\n\t <PARAM name="DefaultEnc" value="Off">';
			
		if(USING_CUSTOM_IMAGE)
			Str+= '\n\t <PARAM name="ImageURL" value="' + CUSTOM_IMAGE_URL + '">';
			
		Str+= '\n</object>';
				
		isCreated = true;

		if(KeyPro_Container_Object != null)
			KeyPro_Container_Object.innerHTML = Str;
}

function ClearCKKeyProObject()
{	
	
	//var isCreated = true;
	
	if(!isCreated)
		return;

	//document.write("");
	
	KeyPro_Container_Object.innerHTML = "";
	
	isCreated = false;
}
function XecureCK_UIEevents(frm,ele,event,keycode)
{
	var obj;
	var eventObj;

	try{
		obj=document.forms[frm].elements[ele];
		if( document.createEventObject )
		{
			eventObj = document.createEventObject();
			eventObj.keyCode=keycode;
			if(obj)
			{
				obj.fireEvent(event,eventObj);
			}
		}
	}
	catch(e) {}
}

/*
	Rescan the current HTML Document & protects newly added elements.
	Call this function if you are adding Input Elements through JavaScript.
*/

function CKKeyPro_ReScan()
{
	if(document.CKKeyPro==null || typeof(document.CKKeyPro) == "undefined" || document.CKKeyPro.object==null)
	{
		//CKKeyPro is not running in current document.
		return;
	}
	document.CKKeyPro.ReScanDocument();
}

function HaveControl_CK()
{
	if(document.CKKeyPro==null || typeof(document.CKKeyPro) == "undefined" ||document.CKKeyPro.object==null)
	{
		alert("Å°º¸µå º¸¾È ÇÁ·Î±×·¥ÀÌ ¼³Ä¡µÇÁö ¾Ê¾Ò½À´Ï´Ù.");
		return false;
	}
	else
		return true;
}

function CKKeyPro_Clear(frmName,eleName)
{
 	if(document.CKKeyPro==null || typeof(document.CKKeyPro) == "undefined" || document.CKKeyPro.object==null)
        {
                //XecureCK is not running in current document.
                return;
        }
	document.CKKeyPro.Clear(frmName,eleName,0);
}

function CKKeyPro_GetVariable(name)
{
		//È®Àå E2E PKI=XecureWebEx ÀÏ¶§ ¾Æ·¡ ÁÙ ÀÌ¿ë
		//return xgate_addr;
}