 /**
 * <pre>
 * desc   : ÆË¾÷Ã¢À» ¿ÀÇÂÇÏ°í XecureSubmitÀ» ½ÇÇàÇÑ´Ù.
 *        : main, xecure´Â Á¤ÇØÁø frame ÀÌ¸§ÀÌ¹Ç·Î »ç¿ëÀÌ ºÒ°¡´ÉÇÏ´Ù.
 * </pre>
 * @type    function
 * @access  public
 * @param   form	submitÇÒ form object
 * @param	target	ÆË¾÷Ã¢ name
 * @param	width		°¡·Î»çÀÌÁî
 * @param	height		¼¼·Î»çÀÌÁî
 * @param	top			»ó´Ü¿©¹é
 * @param	left		ÁÂÃø ¿©¹é
 * @param	center		È­¸é Áß¾Ó Á¤·Ä ¿©ºÎ(true/false)
 * @param	scroll		½ºÅ©·Ñ¹Ù Ç¥½Ã ¿©ºÎ(yes/no)
 * @author  ±èÈ¿¿ø
 */
function XecureSubmit_popup(form, target, width, height, top, left ,center ,scroll){
	
	if(target=="main" || target=="xecure") {
		alert("main, xecure nameÀº ¸ÞÀÎÀ©µµ¿ì¿¡¼­ »ç¿ëÁßÀÎ ÀÌ¸§À¸·Î target ÁöÁ¤À» ÇÒ¼ö ¾ø½À´Ï´Ù.");
		return;
	}
	
	
	
	var strFeature;
	strFeature = "width=" + width + ", height=" + height +", scrollbars=" + scroll + ", status=no, resizable=no,direction=no,location=no,menubar=no,toolbar=no,titlebar=no,fullscreen=no";
	
	if(!center){
		strFeature += ",left="+left+",top="+top;
	}else{
		var winl = (screen.width - width) / 2;
		var wint = (screen.height - height) / 2;
		strFeature += ",left="+winl;
		strFeature += ",top="+wint;
	}
	
	// ÆË¾÷ ¿ÀÇÂ
	window.open("" ,target, strFeature);
	
	// targetÀ» ÆË¾÷Ã¢À¸·Î ÁöÁ¤
	form.target = target;

	XecureSubmit(form);
}

/**
 * <pre>
 * desc   : Á¦°øµÈ ÀÎÀÚµéÀ» ¼Ó¼ºÀ¸·Î ÆË¾÷À» ¶ç¿ì°í, XecureNavigate·Î urlÀ» ºÒ·¯¿Â´Ù.
 * </pre>
 * @type	function
 * @access	public
 * @param	url			ÆË¾÷ ÆäÀÌÁö ÁÖ¼Ò
 * @param	winName	À©µµ¿ì¸í
 * @param	width		°¡·Î»çÀÌÁî
 * @param	height		¼¼·Î»çÀÌÁî
 * @param	top			»ó´Ü¿©¹é
 * @param	left			ÁÂÃø ¿©¹é
 * @param	center		È­¸é Áß¾Ó Á¤·Ä ¿©ºÎ(true/false)
 * @param	scroll		½ºÅ©·Ñ¹Ù Ç¥½Ã ¿©ºÎ(yes/no)
 * @author	±èÇüÁø
 */
function XecureNavigate_popup(url,winName,width,height,top,left,center,scroll){
	if(winName=="main" || winName=="xecure") {
		alert("main, xecure nameÀº ¸ÞÀÎÀ©µµ¿ì¿¡¼­ »ç¿ëÁßÀÎ ÀÌ¸§À¸·Î target ÁöÁ¤À» ÇÒ¼ö ¾ø½À´Ï´Ù.");
		return;
	}

	var arg = "width=" + width + ", height=" + height +", scrollbars=" + scroll + ", status=no, resizable=no,direction=no,location=no,menubar=no,toolbar=no,titlebar=no,fullscreen=no";

	if(!center){
		arg += ",left="+left+",top="+top;
	}else{
		var winl = (screen.width - width) / 2;
		var wint = (screen.height - height) / 2;
		arg += ",left="+winl;
		arg += ",top="+wint;
	}

	var win = window.open('', winName, arg);
	if (win !=null) win.focus();

	XecureNavigate(url,winName);
}

var submitCount = 0;   //Áßº¹ È£Ãâ ¹æÁö¿ë º¯¼ö
 /**
 * <pre>
 * desc   : ÀÏ¹ÝÄÁÅÙÃ÷ ÆäÀÌÁö¸¦ HELPER_PARSE¸¦ ÀÌ¿ëÇØ ¿¬´Ù.
 *        : ÀÏ´Ü AS-IS Parameter ±×´ë·Î »ç¿ë. ÃßÈÄ ¼öÁ¤ ÀÖÀ»¼ö ÀÖÀ½.
 *        : submitCount º¯¼ö´Â ´õºíÅ¬¸¯ ¹æÁö¿ë
 * </pre>
 * @type    function
 * @access  public
 * @param   argFileName     ¿¬°áÇÒ ÆÄÀÏ °æ·Î
 * @param   argNeedSession  ·Î±×ÀÎ ¼¼¼Ç ÇÊ¿ä¿©ºÎ(Y/N)
 * @param	argScreenName   ?(AS-IS ¿¡¼­´Â °ÅÀÇ 'È­¸é'À¸·Î ÁöÁ¤)
 * @param   argRedirectUrl  RedirectionURL (AS-IS »ç¿ë »ç·Ê ¸øÃ£À½)
 * @param   argServiceId    ¾÷¹«ÄÚµå(Ex. Ä«µå : cr)
 * @param   argMenuId       ÆäÀÌÁöÄÚµå(Flash GNB¿¡¼­ ¸Þ´ºÆ÷Ä¿½º ¿ëµµ·Î »ç¿ë)
 * @param   argAnchorLink   ÆäÀÌÁö ·Îµù½Ã Æ÷Ä¿½ÌÇÒ ¸µÅ©°¡ ÀÖÀ» °æ¿ì ÁöÁ¤
 * @author  ¼­»ó½Ä
 */
function slink(argFileName, argNeedSession, argScreenName, argRedirectUrl, argServiceId, argMenuId, argAnchorLink) {

	if( typeof(argFileName) == 'undefined' || argFileName == 'undefined' || argFileName == "" ) {
		alert("È£ÃâµÉ ÆäÀÌÁö°¡ Á¤ÀÇµÇÁö ¾Ê¾Ò½À´Ï´Ù.");
		return;
	}

	if( typeof(argAnchorLink) == 'undefined' || argAnchorLink == 'undefined' || argAnchorLink == null ) {
		argAnchorLink = "";
	}

	if(submitCount > 0) {
		return;
	}
	
	if(top.xecure.xecure_token=="NO_TOKEN"){
		location.href="/helper/HELPER_PARSE_01WA.do?parseFileBody=" + argFileName + "&screenName=" + argScreenName + "&redirectUrl=" + argRedirectUrl + "&serviceId=" + argServiceId + "&menuId=" + argMenuId + "&needSession=" + argNeedSession + "&anchorLink=" + argAnchorLink;
	} else {
		XecureNavigate("/helper/HELPER_PARSE_01WA.do?parseFileBody=" + argFileName + "&screenName=" + argScreenName + "&redirectUrl=" + argRedirectUrl + "&serviceId=" + argServiceId + "&menuId=" + argMenuId + "&needSession=" + argNeedSession + "&anchorLink=" + argAnchorLink,'main');
	}
	submitCount++;

}






var xmlHttp;

function createXMLHttpRequest()
{
	var xmlHttp;
	if (window.ActiveXObject) {
		try {
			xmlHttp =  new ActiveXObject("Msxml2.XMLHTTP");	// IE6
		}
		catch (e) {
			try {
				xmlHttp =  new ActiveXObject("Microsoft.XMLHTTP");	// IE4, IE5
			} catch (e2) {}
		}
	} else if (window.XMLHttpRequest) {
		xmlHttp =  new XMLHttpRequest();
	}
	return xmlHttp;
}

function XecureAjaxGet(form, handler)
{
	var qs ;
	var path ;
	var cipher;
	var url;

	qs_begin_index = form.action.indexOf('?');

	// if action is relative url, get base url from window location
	path = getPath(form.action);
	// get path info & query string & hash from action url
	
	if ( qs_begin_index < 0 ) {
		qs = "";
	}
	else {
		qs = form.action.substring(qs_begin_index + 1, form.action.length );
	}
	
	//qs = qs + "&" + XecureMakePlain(form);
	if ( SSOTokenUse == 'TRUE' ) { get_data = "sToken=" + xecure_token + "&SSOStatus=" + SSOStatus + "&r=" + uid;}
			else get_data = "sToken=NO_TOKEN&SSOStatus=FALSE";
	
	qs = get_data + "&" + XecureMakePlain(form);

	// encrypt QueryString of action field
	if( gIsContinue == 0 ) {
		gIsContinue = 1;

		if( IsNetscape60() )		// Netscape 6.0
		cipher = document.XecureWeb.nsIXecurePluginInstance.BlockEnc(xgate_addr, path, XecureEscape(qs),"GET");
		else {
			cipher = document.XecureWeb.BlockEnc(xgate_addr, path, XecureEscape(qs),"GET");
		}
		gIsContinue = 0;
	}
	
	else {
		alert(busy_info);
		return false;
	}
	
	
	
	if( cipher == "" )	return XecureWebError() ;
	
	url = path + "?q=" + escape_url(cipher);
	
	
	xmlHttp = createXMLHttpRequest();
	//xmlHttp.onreadystatechange = handleStateChange;
	
	if(handler)		// º°µµ ÇÚµé·¯°¡ ÀÖÀ¸¸é ÁöÁ¤
		xmlHttp.onreadystatechange = handler;
	else
		xmlHttp.onreadystatechange = handleStateChange;
	
	
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
	return false;
}

function XecureAjaxPost( form, handler )
{
	var qs ;
	var path ;
	var cipher;
	var url;
	var p_value;
	
		
	qs_begin_index = form.action.indexOf('?');

	// if action is relative url, get base url from window location
	path = getPath(form.action);
	
	// get path info & query string & hash from action url
	if ( qs_begin_index < 0 ) {
		qs = "";
	}
	else {
		qs = form.action.substring(qs_begin_index + 1, form.action.length );
	}

	// encrypt QueryString of action field
	
	if( gIsContinue == 0 ) {
		gIsContinue = 1;

		if( IsNetscape60() )		// Netscape 6.0
			cipher = document.XecureWeb.nsIXecurePluginInstance.BlockEnc(xgate_addr, path, XecureEscape(qs),"GET");
		else {
			cipher = document.XecureWeb.BlockEnc(xgate_addr, path, XecureEscape(qs),"GET");
		}
		gIsContinue = 0;
	}
	else {
		alert(busy_info);
		return false;
	}
	
	if( cipher == "" )	return XecureWebError() ;

	url = path + "?q=" + escape_url(cipher);

	if ( SSOTokenUse == 'TRUE' ) { posting_data = "sToken=" + xecure_token + "&SSOStatus=" + SSOStatus + "&r=" + uid;}
			else posting_data = "sToken=NO_TOKEN&SSOStatus=FALSE";
			
	posting_data = posting_data+"&"+XecureMakePlain( form );
	
	if( gIsContinue == 0 ) {
		gIsContinue = 1;

		if( IsNetscape60() )		// Netscape 6.0
			cipher = document.XecureWeb.nsIXecurePluginInstance.BlockEnc ( xgate_addr, path, XecureEscape(posting_data), "POST" );
		else{
			cipher = document.XecureWeb.BlockEnc ( xgate_addr, path, XecureEscape(posting_data), "POST" );
		}
		gIsContinue = 0;
	}
	else {
		alert(busy_info);
		return false;
	}
	

	if( cipher == "" )	return XecureWebError() ;
	
	p_value = "p="+escape_url(cipher);
		
	xmlHttp = createXMLHttpRequest();
	xmlHttp.open("POST", url, true);
	if(handler)		// º°µµ ÇÚµé·¯°¡ ÀÖÀ¸¸é ÁöÁ¤
		xmlHttp.onreadystatechange = handler;
	else
		xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", cipher.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(p_value);
	
	return false;
}
