//<![CDATA[
var PATTERN_Num =/^[0-9]+$/; 
var PATTERN_Phone =/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/; 
var PATTERN_Htel =/^[0-9]{3}-[0-9]{3,4}-[0-9]{4}$/; 
var PATTERN_Mail =/^[0-9a-zA-Z]([-.+]?[0-9a-zA-Z_])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/i;
var PATTERN_Domain =/^[.a-zA-Z0-9-]+.[a-zA-Z]+$/;
var PATTERN_Alpha =/^[a-zA-Z]+$/; 
var PATTERN_Host =/^[a-zA-Z-]+$/; 
var PATTERN_Hangul =/[가-힣]/; 
var PATTERN_AlphaNum = /^[a-zA-Z0-9]+$/;
var PATTERN_HangulEng =/^[가-힣a-zA-Z]+$/; 
var PATTERN_Chracter =/^[가-힣a-zA-Z0-9]+$/; 
var PATTERN_HangulOnly =/^[가-힣]*$/; 
var PATTERN_ID = /^[a-zA-Z]{1}[a-zA-Z0-9]{5,15}$/;
var PATTERN_illegalStr = "~`!@#$%^&*()_-+=\|]}[{'\";:/?.><,";
var PATTERN_Same = /^(.)(\1)*$/;
var PATTERN_BadKeyword = /`|~|!|@|#|\$|%|\^|&|\*|\(|\)|\-|\_|\+|\=|\|\||<|>|\,|\.|\?|\/|:|;|'|"|\[|\]|\{|\}/gi;
var PATTERN_Date = /^[0-9]{4}\-[0-9]{2}-[0-9]{2}$/



if(navigator.userAgent.indexOf('Firefox') >= 0){
  (function(){
    var events = ["mousedown", "mouseover", "mouseout", "mousemove", "mousedrag",
                  "keypress", "keyup", "keydown", "blur",
                  "click", "dblclick"];  
    for (var i = 0; i < events.length; i++){
      window.addEventListener(events[i], function(e){
        window.event = e;
      }, true);
    }
  }());
};



function LengthLimitCheck(e, val, limit) {
	var keynum;
    var keychar;
    var numcheck;

    if (jQuery.browser.msie) // IE
    {
        keynum = e.keyCode;
    }
    else // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
	
	if(val.length >= limit) {
		if( (keynum >= 32 && keynum <= 40) || keynum == 45 || (keynum >= 16 && keynum <= 21) ) {
			return true;
		}
		else {
			return false;
		}
	}
	else {
		return true;
	}
}

function GetEventKeyCode(e) {
	if (jQuery.browser.msie) // IE
    {
        return e.keyCode;
    }
    else // Netscape/Firefox/Opera
    {
        return e.which;
    }
}

function isCorpNo(bizID) {
	var checkID = new Array(1, 3, 7, 1, 3, 7, 1, 3, 5, 1);
    var i, Sum=0, c2, remander;

 	bizID = bizID.replace(/-/gi,''); 

	for (i=0; i<=7; i++){
		Sum += checkID[i] * bizID.charAt(i);
	}

	c2 = "0" + (checkID[8] * bizID.charAt(8));
	c2 = c2.substring(c2.length - 2, c2.length);

	Sum += Math.floor(c2.charAt(0)) + Math.floor(c2.charAt(1));

	remander = (10 - (Sum % 10)) % 10 ;

	if(bizID.length != 10){
		return false;
	}else if (Math.floor(bizID.charAt(9)) != remander){
		return false;
	}else{
		return true;
	}
}

function GetExtension(str) {
	if(str.indexOf(".") < 0) {
		return "";
	}
	
	var token = str.split(".");
	
	return token[token.length - 1].toUpperCase();
}

function ClipBoard(str, msg) {
	try
	{
		window.clipboardData.setData("Text", str);
		alert(msg);		
	}
	catch (ex)
	{
		alert('해당 웹브라우저는 지원하지 않습니다.');
	}
}

function resizeIframe(id)
{
	frame = document.getElementById(id);
	innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;

	objToResize = (frame.height) ? frame : (frame.style) ? frame.style : frame;

	if ( document.all )
	{ 
		objToResize.height = innerDoc.body.scrollHeight + 30; 
	}
	else
	{
		$(innerDoc).ready(function () {
			var readHeight = innerDoc.documentElement.scrollHeight;
			objToResize.height = readHeight + "px";
		});	
	}
}

function ResizeIFrameHeight(obj) {
	frame = obj;
	innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;

	objToResize = (frame.height) ? frame : (frame.style) ? frame.style : frame;

	if ( document.all )
	{ 
		objToResize.height = innerDoc.body.scrollHeight + 30; 
	}
	else
	{
		$(innerDoc).ready(function () {
			var readHeight = innerDoc.documentElement.scrollHeight;
			objToResize.height = readHeight + "px";
		});
		/*
		var readHeight = document.documentElement.scrollHeight;
		objToResize.height = innerDoc.body.scrollHeight + (innerDoc.body.offsetHeight - innerDoc.body.clientHeight) + 30;

		if(objToResize.height < 500) 
		{
			objToResize.height = 500;
		}
		*/			
	}
}

function getOffsetTop(obj) {
	var vTop = 0;                
	if(obj.offsetParent){            
		do{                
			vTop += obj.offsetTop;            
		} while(obj = obj.offsetParent);        
	}        
	return vTop;
}

function getOffsetLeft(obj) {
	var vLeft = 0;                
	if(obj.offsetParent){            
		do{                
			vLeft += obj.offsetLeft;            
		} while(obj = obj.offsetParent);        
	}        
	return vLeft;
}


function ImageButtonSubmit(frmName, validateHandler) {
    if (validateHandler) {
        if (validateHandler() == false) {
            return false;
        }
    }

    jQuery(frmName).dom.submit();
}

function ResizeWindow(width, height) {
    var widthGap = 0;
    var heightGap = 0;
    
    self.resizeTo(width, height);
    
    widthGap = width - self.document.body.clientWidth;
    heightGap = height - self.document.body.clientHeight;

    if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
        self.resizeTo(width + widthGap, height + heightGap + 15);
    }
    else {
        self.resizeTo(width + widthGap, height + heightGap);
    }
}

function setCookie(name, value, expiredays)
{
    var todayDate = new Date();
    //test용  유효시간을 1분동안 설정
    //todayDate.setMinutes(todayDate.getDay() + expiredays);

    //유효기간을 하루동안 설정
    todayDate.setDate( todayDate.getDate() + expiredays );
    //alert("ccc"+todayDate.toGMTString() );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}

function getCookie(strName)
{
    var strCookieName = strName + "=";
    var objCookie = document.cookie;
    if (objCookie.length > 0){
        var nBegin = objCookie.indexOf(strCookieName);
        if (nBegin < 0){
            return "";
        }
        nBegin += strCookieName.length;
        var nEnd = objCookie.indexOf(";", nBegin);
        if (nEnd == -1){
            nEnd = objCookie.length;
        }
    }
    return unescape(objCookie.substring(nBegin, nEnd));
}

function OpenPopup(win, id, url, width, height) {
	
	var top,left;
  top = (screen.height - height) / 2
  left = (screen.width - width) / 2
  var newWin = window.open(url, id,'width='+width+',height='+height+',top='+top+',left='+left+',scrollbars=auto,status=yes'); 
  if(newWin == null)
  {
    alert("팝업이 차단되었습니다.");
  }
  else
  {
    newWin.focus();
  }
  win = newWin;
  return newWin;
  
	
/*
  if(win == null) {
		win = window.open(url, id,'width='+width+',height='+height+',top='+top+',left='+left+',scrollbars=auto,status=yes'); 
		win.focus();
	}
	else {
		try
		{
		    win.resizeTo(width,height);
		    win.moveTo(left,top);
		    win.document.location.href = url;
		    win.focus();
		}
		catch (ex)
		{
		  win = window.open(url, id, 'width='+width+',height='+height+',top='+top+',left='+left+',scrollbars=auto,status=yes'); 
			win.focus();
		}
	}
	
	var x,y; 
    if (win.innerHeight) { // IE 외 모든 브라우저 
        x = (screen.availWidth - win.innerWidth) / 2; 
        y = (screen.availHeight - win.innerHeight) / 2; 
		
    }else if (win.documentElement && win.documentElement.clientHeight) { // Explorer 6 Strict 모드 
        x = (screen.availWidth - win.documentElement.clientWidth) / 2; 
        y = (screen.availHeight - win.documentElement.clientHeight) / 2; 
    }else if (win.body) { // 다른 IE 브라우저( IE &lt; 6) 
        x = (screen.availWidth - win.body.clientWidth) / 2; 
        y = (screen.availHeight - win.body.clientHeight) / 2; 
    } 
    win.moveTo(x,y);
    return win;
	
*/
}

function OpenPopupScroll(win, id, url, width, height) {
	if(win == null) {
		win = window.open(url, id,'width='+width+',height='+height+',scrollbars=yes,status=yes'); 
	}
	else {
		try
		{
		    win.resizeTo(width,height);
		    win.document.location.href = url;
		}
		catch (ex)
		{
			win = window.open(url, id, 'width='+width+',height='+height+',scrollbars=yes,status=yes'); 
		}
	}	
}


Array.prototype.remove = function(idx){
	var temp = new Array();
	var i = this.length;

	while(i > idx){
		var kk = this.pop();
		temp.push(kk);

		i--;
	}

	for(var i=temp.length - 2; i>=0; i--){
		this.push(temp[i]);
	}
}

Array.prototype.swap = function(idx1, idx2){
	var temp = this[idx1];
	this[idx1] = this[idx2];
	this[idx2] = temp;
}

Array.prototype.find = function(obj){
	for(i = 0; i < this.length; i++) {
		if(this[i] == obj) {
			return i;
		}
	}

	return -1;
}

String.prototype.replaceAll = function(regex, replacement) {
    return this.split(regex).join(replacement);
}

String.prototype.comma=function(){
    var str=new Array();
    var v=this.replace(/,/gi,''); //콤마를 빈문자열로 대체
    for(var i=0;i<=v.length;i++){ //문자열만큼 루프를 돈다.
        str[str.length]=v.charAt(v.length-i); //스트링에 거꾸로 담음
        if(i%3==0&&i!=0&&i!=v.length){ //첫부분이나, 끝부분에는 콤마가 안들어감
            str[str.length]='.'; //세자리마다 점을 찍음 - 배열을 핸들링할때 쉼표가 들어가면 헛갈리므로
        }
    }
    
    str=str.reverse().join('').replace(/\./gi,','); //배열을 거꾸로된 스트링으로 바꾼후에, 점을 콤마로 치환
    
    return str;
}

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/gi, "");
}

String.prototype.getByteLength = function() {
	return calculateBytes(this);
}

String.prototype.splitRemoveBlank = function(pattern) {
	var temp = new Array;
	var data = this.split(pattern);

	for(var i = 0; i < data.length; i++) {
		if(data[i].trim().length > 0) {
			temp.push(data[i]);
		}
	}
	
	return temp;
}

String.prototype.cutByte = function (vn_maxlength)
{
	var vn_sumlength=0;
	var vn_restr='';
	for(var i= 0;i < this.length; i++)
	{
		if( escape(this.charAt(i)).length > 3 ) { vn_length = 2; }
		else if (this.charAt(i) == '<' || this.charAt(i) == '>') { vn_length = 4; }
		else { vn_length = 1 ; }

		if ( vn_maxlength < (vn_sumlength + vn_length) ) { break; }
		vn_sumlength += vn_length;
		vn_restr += this.charAt(i);
	}
	return (vn_restr);
}

function CheckNickname(str) {
    patten = eval(PATTERN_Chracter); 
    if(!patten.test(str))
	{  
		return false; 
	} 

	return true;
}

function CheckId(str) {
	patten = eval(PATTERN_ID); 
	if(!patten.test(str))
	{  
		return false; 
	} 

	return true;
}

function CheckEmail(str) {
	patten = eval(PATTERN_Mail); 
	if(!patten.test(str))
	{  
		return false; 
	} 

	return true;
}

function CheckHandphone(str) {
	patten = eval(PATTERN_Htel); 
	if(!patten.test(str))
	{  
		return false; 
	} 

	return true;
}

function CheckDate(str) {
	patten = eval(PATTERN_Date); 

	if(!patten.test(str))
	{  
		return false; 
	}

	var day = new Date(str.split("-")[0], str.split("-")[1] - 1, str.split("-")[2], 0, 0, 0);

	if(str != day.toString()) {
		return false; 
	}

	return true;
}

function CheckNumber(str) {
	var patten = eval(PATTERN_Num);
	if(!patten.test(str))
	{
		return false; 
	} 

	return true;
}

Date.prototype.toString = function() {
	var strDay = this.getFullYear() + "-" + (this.getMonth() + 1 + "").zf(2) + "-" + (this.getDate() + "").zf(2);
	return strDay;
}

function AlphaNumericOnlyInput(e) {
    var keynum;
    var keychar;
    var numcheck;

    if (jQuery.browser.msie) // IE
    {
        keynum = e.keyCode;
    }
    else // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }

    if (keynum == 8 || keynum == 0 || keynum == 9) {
        return true;
    }

    keychar = String.fromCharCode(keynum);

    var patten = eval(PATTERN_AlphaNum);
    if (!patten.test(keychar)) {
        return false;
    }

    return true;
}

function AutoTab(txt, limit, element) {
	if(txt.length >= limit) {
		element.focus();
	}
}

function NumericOnlyInput(e) {
	var keynum;
	var keychar;
	var numcheck;

	if (jQuery.browser.msie) // IE
	{
		keynum = window.event.keyCode;
	}
	else // Netscape/Firefox/Opera
	{
		keynum = window.event.which;
	}
	
	if(keynum == 8 || keynum == 0 || keynum == 9) {
		return true;
	}
	var keyStr =String.fromCharCode(keynum);

	if("0123456789".indexOf(keyStr) != -1)
	{
		return true;
	}
	else {
		return false;
	}
	/*
	keychar = String.fromCharCode(keynum);

	var patten = eval(PATTERN_Num); 
	if(!patten.test(keychar))
	{  
		return false; 
	} 

	return true;
	*/
}

function trims(input)
{
	try
	{
	
		var keynum;

		if (jQuery.browser.msie) // IE
		{
			keynum = event.keyCode;
		}
		else // Netscape/Firefox/Opera
		{
			keynum = event.which;
		}
			// Backspace , 한영키, Shift , CapsLock
		if(keynum == 8 || keynum == 21 || keynum == 16 || keynum == 20)
			return
			
			inputed = input.value.trim();

		if (!isAlphaNumeric(inputed))
		{
			inputed="";
			alert("영문소문자와 숫자로만 입력하십시오");
		}
		
		input.value = inputed;
	
	}
	catch (e)
	{
	}
		
}
function isAlphaNumeric( inStr ) 
{
		if (inStr.length > 0) 
		{ 
		      	for (i=0; i < inStr.length; i++) 
		      	{
				    if (!((inStr.charAt(i) >= 'a' && inStr.charAt(i) <= 'z') || (inStr.charAt(i) >= '0' && inStr.charAt(i) <= '9')) ) 
				    {
					    return false;
				    }	
	      		}
	      		return true;
	    }
	    else 
	    { 
	    		return false; 
	    }		
}

// Zero-Fill
String.prototype.zf = function(l) { return '0'.string(l - this.length) + this; }

String.prototype.string = function(l) { var s = '', i = 0; while (i++ < l) { s += this; } return s; }

function calculateBytes( szValue)
{
	var tcount = 0;

	var tmpStr = new String(szValue);
	var temp = tmpStr.length;

	var onechar;
	for ( k=0; k<temp; k++ )
	{
		onechar = tmpStr.charAt(k);

		if (escape(onechar).length > 4)
		{
			tcount += 2;
		}
		else
		{
			tcount += 1;
		}
	}

	return tcount;
}


/* ie6 - png 투명지원 */

function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}

/* media삽입 */
function insertMedia(movie, width, height, id) {
    var strObjTag = new String();
    
    if (navigator.appName.indexOf("Microsoft") != -1)
	{
        strObjTag += '<object id="'+id+'" CLASSID="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+width+'" CODEBASE="#Version=7,0,0,1954" height="'+height+'">';
        strObjTag += '<param name="url" value="'+movie+'">';
        strObjTag += '<PARAM NAME="autoStart" value="True">';
        strObjTag += '<PARAM NAME="PlayCount" VALUE="1">';
        strObjTag += '<param NAME="stretchToFit" VALUE="true">';
        strObjTag += '<param NAME="TransparentAtStart" VALUE="1">';
        strObjTag += '<param NAME="SendkeyboardEvents" VALUE="1">';
        strObjTag += '<param name="fullScreen" value="0">';
        strObjTag += '<param name="mute" value="false">';
        strObjTag += '<PARAM NAME="EnableContextMenu" VALUE="0">';
        strObjTag += '<PARAM NAME="volume" VALUE="90">';
        strObjTag += '</object>';
    }
    else {
        strObjTag += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp" src="'+movie+'" width="'+width+'" height="'+height+'"  SHOWCONTROLS=1 SHOWSTATUSBAR=1 AUTOSTART=1  showpositioncontrols="1" showcontrols="1" EnableContextMenu="false"    transparentatstart="0" autosize="0" animationatstart="0" volume="90" loop="false"> ';
    }
    document.write(strObjTag);
}

/* media삽입 */
function insertSound(movie, id) {
    var strObjTag = new String();

    strObjTag += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp" src="' + movie + '" width="400" height="68"  SHOWCONTROLS=1 SHOWSTATUSBAR=1 AUTOSTART=1  showpositioncontrols="1" showcontrols="1" EnableContextMenu="false"    transparentatstart="0" autosize="0" animationatstart="0" volume="90" loop="false"> ';
    
    document.write(strObjTag);
}

function writeFlash(url, x, y, z, id) 
{
	EmbedStr = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0' width='" + x + "' height='" + y + " id='" + z + "' '>";
	EmbedStr += "<param name='allowScriptAccess' value='always' />";
	EmbedStr += "<param name='movie' value='" + url + "' />";
	
	EmbedStr += "<param name='id' value='" + id + "' />"; // 플래쉬 컨텐츠에 id를 부여 합니다.
	EmbedStr += "<param name='base' value='.' />"; 	// 플래쉬 기준으로 경로를 바꿉니다.

	EmbedStr += "<param name='quality' value='high' />";
	EmbedStr += "<param name='bgcolor' value='#ffffff' />";
	EmbedStr += "<param name='menu' value='false' />";
	EmbedStr += "<param name='wmode' value='opaque' />";
	EmbedStr += "<embed id='" + id + "', base='.' src='" + url + "' quality='high' menu='flase' wmode='opaque' bgcolor='#ffffff' width='" + x + "' height='" + y + "' name='" + z + "'allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' />";
	EmbedStr += "</object>";
	
	document.write(EmbedStr);
	return;
}

/* flash삽입 플래쉬 */
function insertFlash(swf, width, height, bgcolor, id, flashvars, allowScript)
{
	var strFlashTag = new String();
	var allowScriptStr = "sameDomain";
	if(allowScript) {
		allowScriptStr = allowScript;
	}

	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
		strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
		strFlashTag += '<param name="movie" value="' + swf + '"/>';

		if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
		strFlashTag += '<param name="quality" value="best"/>';
		strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
		strFlashTag += '<param name="menu" value="false"/>';
		strFlashTag += '<param name="salign" value="LT"/>';
		strFlashTag += '<param name="scale" value="showall"/>';
		strFlashTag += '<param name="wmode" value="transparent"/>';
		strFlashTag += '<param name="allowScriptAccess" value="' + allowScriptStr + '"/>';
		strFlashTag += '</object>';
	}
	else
	{
		strFlashTag += '<embed src="' + swf + '" ';
		strFlashTag += 'quality="best" ';
		strFlashTag += 'bgcolor="' + bgcolor + '" ';
		strFlashTag += 'width="' + width + '" ';
		strFlashTag += 'height="' + height + '" ';
		strFlashTag += 'menu="false" ';
		strFlashTag += 'scale="showall" ';
		strFlashTag += 'id="' + id + '" ';
		strFlashTag += 'salign="LT" ';
		strFlashTag += 'wmode="transparent" ';
		strFlashTag += 'allowScriptAccess="' + allowScriptStr + '" ';
		if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
		strFlashTag += 'type="application/x-shockwave-flash" ';
		strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
		strFlashTag += '</embed>';
	}

	document.write(strFlashTag);
}

/* flash삽입 플래쉬 태그 */
function CreateFlash(swf, width, height, bgcolor, id, flashvars, allowScript)
{
	var strFlashTag = new String();
	var allowScriptStr = "sameDomain";
	if(allowScript) {
		allowScriptStr = allowScript;
	}

	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
		strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
		strFlashTag += '<param name="movie" value="' + swf + '"/>';

		if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
		strFlashTag += '<param name="quality" value="best"/>';
		strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
		strFlashTag += '<param name="menu" value="false"/>';
		strFlashTag += '<param name="salign" value="LT"/>';
		strFlashTag += '<param name="scale" value="showall"/>';
		strFlashTag += '<param name="wmode" value="transparent"/>';
		strFlashTag += '<param name="allowScriptAccess" value="' + allowScriptStr + '"/>';
		strFlashTag += '</object>';
	}
	else
	{
		strFlashTag += '<embed src="' + swf + '" ';
		strFlashTag += 'quality="best" ';
		strFlashTag += 'bgcolor="' + bgcolor + '" ';
		strFlashTag += 'width="' + width + '" ';
		strFlashTag += 'height="' + height + '" ';
		strFlashTag += 'menu="false" ';
		strFlashTag += 'scale="showall" ';
		strFlashTag += 'id="' + id + '" ';
		strFlashTag += 'salign="LT" ';
		strFlashTag += 'wmode="transparent" ';
		strFlashTag += 'allowScriptAccess="' + allowScriptStr + '" ';
		if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
		strFlashTag += 'type="application/x-shockwave-flash" ';
		strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
		strFlashTag += '</embed>';
	}

	return strFlashTag;
}

/// Flex
var requiredMajorVersion = 9;	// Major version of Flash required
var requiredMinorVersion = 0;	// Minor version of Flash required
var requiredRevision = 28;		// Minor version of Flash required

function insertFlex(flex, width, height, bgcolor, id, flashvars) {
	var hasProductInstall = DetectFlashVer(6, 0, 65);
	
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);	// Version check based upon the values defined in globals

	if ( hasProductInstall && !hasRequestedVersion ) {
		// DO NOT MODIFY THE FOLLOWING FOUR LINES
		// Location visited after installation is complete if installation is required
		var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
		document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		var MMdoctitle = document.title;

		AC_FL_RunContent(
			"src", "playerProductInstall",
			"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
			"width", width,
			"height", height,
			"align", "middle",
			"id", id,
			"quality", "high",
			"bgcolor", bgcolor,
			"name", id,
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	} else if (hasRequestedVersion) {
		// if we've detected an acceptable version
		// embed the Flash Content SWF when all tests are passed
		AC_FL_RunContent(
				"src", flex,
				"FlashVars", flashvars,
				"width", width,
				"height", height,
				"align", "middle",
				"id", id,
				"quality", "high",
				"bgcolor", bgcolor,
				"name", id,
				"allowScriptAccess","sameDomain",
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	  } else {  // flash is too old or we can't detect the plugin
		var alternateContent = 'Alternate HTML content should be placed here. '
		+ 'This content requires the Adobe Flash Player. '
		+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
		document.write(alternateContent);  // insert non-flash content
	  }
}
/// Flex

/// Ajax

function SuccessAjax(xhr) {
    alert(xhr);
}

function FailAjax() {
	alert("시스템 장애입니다.\n고객센터에 문의하세요.");
}

function AjaxLoad(targetUrl, parammeters, requestMethod, successHandler, failHandler) {
    var successFunc = successHandler;
    var failFunc = failHandler;

    if (!successFunc) {
        successFunc = SuccessAjax;
    }

    if (!failFunc) {
        failFunc = FailAjax;
    }

	$(document).unbind('ajaxSuccess');
	$(document).unbind('ajaxError');
    $(document).ajaxError(failFunc);

	var date = new Date();
	if(parammeters) {
		parammeters.TTTT = date.getTime();
	}
	else {
		parammeters =({TTTT : date.getTime() })
	}

	$.ajax({
		url: targetUrl,
		type: requestMethod,
		data: parammeters,
		success: successHandler
	 });
}

function AjaxLoadNotAsync(targetUrl, parammeters, requestMethod, successHandler, failHandler) {
    var successFunc = successHandler;
    var failFunc = failHandler;

    if (!successFunc) {
        successFunc = SuccessAjax;
    }

    if (!failFunc) {
        failFunc = FailAjax;
    }

	$(document).unbind('ajaxSuccess');
	$(document).unbind('ajaxError');
    $(document).ajaxError(failFunc);

	var date = new Date();
	if(parammeters) {
		parammeters.TTTT = date.getTime();
	}
	else {
		parammeters =({TTTT : date.getTime() })
	}

	$.ajax({
		url: targetUrl,
		async:false, 
		type: requestMethod,
		data: parammeters,
		success: successHandler
	 });
}

function AjaxSubmit(frm, validateHandler, successHandler, failHandler) {
    if (validateHandler) {
        if (validateHandler() == false) {
            return false;
        }
    }

	var sslUrl = [
		"loginWeb.hmc",
		"RealnameCheck.hmc",
		"ParentRealnameCheck.hmc",
		"ParentAgree.hmc",
		"InputInformation.hmc",
		"AuthConfirm.hmc",
		"AuthInfo.hmc",
		"MyInfoModifyCheckProcess.hmc",
		"ChangeIpinCheckPwd.hmc",
		"agreement.hmc",
		"RealNameProcess.hmc",
		"CareListUserCheckProcess.hmc",
		//"RealNameCheck.hmc", 법인
		//"CorporateInfoModifyProcess.hmc", 법인
		"UpdateInformation.hmc",
		//"VerifyPassword.hmc",
		"login.hmc"
	];

	var hostNames = [
		"www.happymoney.co.kr",
		"corp.happymoney.co.kr",
		"twww.happymoney.co.kr",
		"tcorp.happymoney.co.kr",
		"dwww.happymoney.co.kr",
		"dcorp.happymoney.co.kr"
	];

	sslUrl.sort();
	hostNames.sort();

	var frmActionStr = frm.action + "";
	var actionStr = "";
	var hostNm = document.location + "";
	var sslIdx = -1, hostIdx = -1;

	if ( frmActionStr && frmActionStr != "" ) {
		actionStr = frmActionStr.substr(frmActionStr.lastIndexOf("/")+1);

		sslIdx = jQuery.inArray(actionStr,sslUrl);
	}

	if ( frmActionStr.indexOf("https://") > -1 ) {
		frmActionStr = frmActionStr.substring(8);
	} else if ( frmActionStr.indexOf("http://") > -1 ) {
		frmActionStr = frmActionStr.substring(7);
	} else {

	}

	if ( hostNm && hostNm != "" ) {
		hostNm = hostNm.substr(hostNm.indexOf("://")+3);
		if ( hostNm.indexOf("/") > -1)
		{
			hostNm = hostNm.substring(0,hostNm.indexOf("/"));
		}
		if ( frmActionStr.indexOf(hostNm) > -1 ) {
			frmActionStr = frmActionStr.substring(hostNm.length);
		}
		hostIdx = jQuery.inArray(hostNm,hostNames);
	}

	if(	sslIdx > -1 ) {
		//개발 환경 SSL 사용해제
		if( hostIdx > -1) {
			frm.action = "https://" + hostNm + frmActionStr.substring(0, frmActionStr.lastIndexOf("/")+1) + actionStr;
		} else {
			frm.action = "http://" + hostNm + frmActionStr.substring(0, frmActionStr.lastIndexOf("/")+1) + actionStr;
		}
	}
   
    var actionPage = frm.action;
    var successFunc = successHandler;
    var failFunc = failHandler;

    if (!actionPage) {
        actionPage = document.location + "";
    }

    if (!successFunc) {
        successFunc = SuccessAjax;
    }

    if (!failFunc) {
        failFunc = FailAjax;
    }

	if( sslIdx > -1 ) {
		frm.submit();
	}
	else {
		$(frm).unbind('ajaxSuccess');
		$(frm).unbind('ajaxError');

		//$(frm).ajaxError(failFunc);

		$(frm).ajaxSubmit({
			url: actionPage.replace("https://","http://"),
			type: 'post',
			success: successFunc,
			error:failFunc
		});
	}
}
/// Ajax

/*
function main_popup(){
	window.open("popup/main_popup_1.html","","width=320, height=400, top=0, left=0")
	window.open("popup/main_popup_2.html","","width=320, height=400, top=0, left=330")
}*/

function isValidDate(iDate) {
	if( iDate.length != 8 ) {
		return false;
	}
	
	var year = parseInt(iDate.substring(0, 4));
	var month = parseInt(iDate.substring(4, 6).replace(/^0(\d)/g,"$1")) - 1;
	var day = parseInt(iDate.substring(6).replace(/^0(\d)/g,"$1"));
	var oDate = new Date(year, month, day);

	if( oDate.getFullYear()     != iDate.substring(0, 4) 
	  || oDate.getMonth() + 1 != iDate.substring(4, 6).replace(/^0(\d)/g,"$1") 
	  || oDate.getDate()      != iDate.substring(6).replace(/^0(\d)/g,"$1") ){
	 
		return false;
	}

	return true;
}

var JuminNumber = {
	isValidJuminNo : function (juminno) {
	  if(juminno=="" || juminno==null || juminno.length!=13) {
		alert("주민등록번호를 적어주세요.");
		return false;
	  }
	  
	  var jumin1 = juminno.substr(0,6);
	  var jumin2 = juminno.substr(6,7);
	  var yy     = jumin1.substr(0,2);        // 년도
	  var mm     = jumin1.substr(2,2);        // 월
	  var dd     = jumin1.substr(4,2);        // 일
	  var genda  = jumin2.substr(0,1);        // 성별
	  var msg, ss, cc;

	  // 숫자가 아닌 것을 입력한 경우
	  if (!this.isNumeric(jumin1)) {
		alert("주민등록번호 앞자리를 숫자로 입력하세요.");
		return false;
	  }

	  // 길이가 6이 아닌 경우
	  if (jumin1.length != 6) {
		alert("주민등록번호 앞자리를 다시 입력하세요.");
		return false;
	  }
	  
	  // 첫번째 자료에서 연월일(YYMMDD) 형식 중 기본 구성 검사
	  if (yy < "00" 
		  || yy > "99" 
		  || mm < "01" 
		  || mm > "12" 
		  || dd < "01" 
		  || dd > "31") {
		alert("주민등록번호 앞자리를 다시 입력하세요.");
		return false;
	  }
	  
	  // 숫자가 아닌 것을 입력한 경우
	  if (!this.isNumeric(jumin2)) {
		alert("주민등록번호 뒷자리를 숫자로 입력하세요.");
		return false;
	  }

	  // 길이가 7이 아닌 경우
	  if (jumin2.length != 7) {
		alert("주민등록번호 뒷자리를 다시 입력하세요.");
		return false;
	  }
	  
	  // 성별부분이 1 ~ 4 가 아닌 경우
	  if (genda >= "1" && genda <= "4") {
  		// 연도 계산 - 1 또는 2: 1900년대, 3 또는 4: 2000년대
  	  cc = (genda == "1" || genda == "2") ? "19" : "20";
  	  // 첫번째 자료에서 연월일(YYMMDD) 형식 중 날짜 형식 검사
  	  if (isValidDate(cc+yy+mm+dd) == false) {
  		  alert("주민등록번호 앞자리를 다시 입력하세요.");
  		  return false;
  	  }
  	  // Check Digit 검사
	    if (!this.isSSN(jumin1, jumin2)) {
		    alert("입력한 주민등록번호를 검토한 후, 다시 입력하세요.");
		    return false;
	    }
	  }
	  return true;
	},

	isNumeric : function (s) { 
	  for (i=0; i<s.length; i++) { 
		c = s.substr(i, 1); 
		if (c < "0" || c > "9") return false; 
	  } 
	  return true; 
	},

	isSSN : function (s1, s2) {
	  n = 2;
	  sum = 0;
	  for (i=0; i<s1.length; i++)
		sum += parseInt(s1.substr(i, 1)) * n++;
	  for (i=0; i<s2.length-1; i++) {
		sum += parseInt(s2.substr(i, 1)) * n++;
		if (n == 10) n = 2;
	  }
	  
	  c = 11 - sum % 11;
	  if (c == 11) c = 1;
	  if (c == 10) c = 0;
	  if (c != parseInt(s2.substr(6, 1))) return false;
	  else return true;
	}
}

$(document).ready(function(){
	try
	{
		$(".PopupDatepicker").datepicker(
			{ 
				disabled: true,
				altFormat: 'yy-mm-dd',
				dateFormat: 'yy.mm.dd',  
				dayNamesMin : ['월', '화', '수', '목', '금', '토', '일'],
				monthNames : ['1월','2월','3월','3월','5월','6월','7월','8월','9월','10월','11월','12월'],
				nextText: '다음',
				prevText: '이전',
				buttonImage: "http://img.happymoney.dev/www/images/common/ico_month.gif"
			}
		);
	}
	catch (ex)
	{
	}
	
});



function isNull(obj)
{
	if (obj == null || obj == undefined || obj == "undefined")
	{
		return true;
	}
	
	return false;
}
function setFocus(obj)
{
	if (!isNull(obj))
	{
		obj.focus();
	}
}
function getKeyCode(e)
{
	if (jQuery.browser.msie) // IE
    {
		return e.keyCode;
    }
    else // Netscape/Firefox/Opera
    {
		return e.which;
    }
}

function ABTab(e, str, nLen, pObj, nObj)
{
	var	keynum = null;
	//$("#Debug_Str").text(str + " , " + nLen);
	if (isNull(str) || isNull(nLen) || isNaN(nLen))
	{
		return;
	}
	
	keynum = getKeyCode(e);
    //$("#Debug_Str").text(keynum + " , " + str.length);
	if ((keynum == 8 || keynum == 46) && str.length <= 0)
	{
		setFocus(pObj);
	}
    else if (str.length >= nLen)
	{
		setFocus(nObj);
	}
}

function ArrangePin(obj, nOffset, nMaxLength, ext)
{
	var	str = "";
	var	arr = null;
	var nCnt = 0;
	
	if (isNull(nOffset) || isNaN(nOffset))
	{
		nOffset = 4;
	}
	if (isNull(nMaxLength) || isNaN(nMaxLength))
	{
		nMaxLength = 16;
	}
	if (isNull(ext))
	{
		ext = "-";
	}
	
	str = obj.value.replaceAll("-", "");
	
	if (str.length > nMaxLength)
	{
		str = str.substr(0, nMaxLength);
	}
	
	nCnt = Math.ceil(str.length / nOffset);
	arr = new Array(nCnt);
	
	for(var i=0; i < nCnt; i++)
	{
		arr[i] = str.substr(i * nOffset, nOffset);
	}
	
	obj.value = arr.join(ext);
}

function ArrangeDate(obj, ext)
{
	var	str = "";
	var	arr = [];
	
	if (isNull(ext))
	{
		ext = "-";
	}
	
	str = obj.value.replaceAll(ext, "");
	
	if (str.length > 0)
	{
		arr[0] = str.substr(0, 4);
	}
	if (str.length > 4)
	{
		arr[1] = str.substr(4, 2);
	}
	if (str.length > 6)
	{
		arr[2] = str.substr(6, 2);
	}
	
	obj.value = arr.join(ext);
}
