﻿/* ////////////////////////////////////////////////////////////////////////////////
//  Common Function
//////////////////////////////////////////////////////////////////////////////// */
var Window = {
    open: function(url, name, pars) {
        var win = window.open(url, name, pars);
        if (win == null)
            window.alert("차단된 팝업창을 허용해 주세요.");
        else
            if (parseInt(navigator.appVersion) >= 4) win.focus();
    },
    popup: function(url, name, width, height, scroll, top, left, resize) {
        var top = (top) ? top : 0; 
        var left = (left) ? left : 0; 
        var resize = (resize) ? resize : 0; 
        scroll = (scroll === undefined) ? 0 : scroll;
        var pars = "width="+ width +",height="+ height +",top="+ top +",left="+ left +",scrollbars="+ scroll +", resizable="+ resize +", status=no, menubar=no, titlebar=no, toolbar=no, directories=no";
        this.open(url, name, pars);
    },
    center: function(url, name, width, height, scroll) { 
        var ww = (screen.width - width) / 2; 
        var wh = (screen.height - height) / 2;
        scroll = (scroll === undefined) ? 0 : scroll;
        var pars = "width="+ width +",height="+ height +",top="+ wh +",left="+ ww +",scrollbars="+ scroll +", resizable=0, menubar=no, titlebar=no, toolbar=no, status=no, directories=no";
        this.open(url, name, pars);
    },
    full: function(url, name, scroll) { 
        scroll = (scroll === undefined) ? 0 : scroll;
        var pars = "fullscreen, scrollbars="+ scroll;
        this.open(url, name, pars);
    },
    max: function(url, name, scroll) {
        var ww = (screen.width) - 10;
        var wh = (screen.height) - 50;
        scroll = (scroll === undefined) ? 0 : scroll;
        var pars = "width="+ ww +",height="+ wh +",left=0,top=0,screenX=0,screenY=0,scrollbars="+ scroll +", resizable=0, menubar=no, titlebar=no, toolbar=no, status=no, directories=no";
        this.open(url, name, pars);
    },
    iframe: function(url, name, option) {
        new FlushPopup(url, name, option); // instead of vgtUtilz.js
    }
};

var FlushError = { 
    msgbox: function(msg) {
        if (msg && msg.length > 0) window.alert(msg);
    },
    option: function(pars) {
        if (pars && pars.length > 0 && pars != null)  
        {
            var ownProperty = pars.substring(0, pars.indexOf('('));
            (!this.hasOwnProperty(ownProperty)) ? eval(pars) : eval("this."+ pars);
        }
    },
    back: function(msg, i) {
        this.msgbox(msg);
        (i && i.length > 0 && !isNaN(i)) ? history.go(i) : history.back();
    },
    close: function(msg) {
        this.msgbox(msg);
        winclose(); // user function
    },
    location: function(msg, loc, winobj) {
        this.msgbox(msg);
        if (winobj && winobj !== undefined ) 
        {   
            try {
                var winObj = eval(winobj+".window");
                winObj.location.href = loc; 
            } catch(e) {  }
        }
        else
            document.location.href = loc;
    },
    winlocation: function(msg, loc, winobj, pars) {  // win - opener, parent , top, frames[]
        this.msgbox(msg);
        this.location(null, loc, winobj);
        this.option(pars);
    }
}

/* COOKIES */
// Cookies[name]   - get
// Cookies.create(name, value, days)  - set
// Cookies.erase(name) - del
var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
};
Cookies.init();

/* INITIALISE PREFERENCES (needs cookies) */
var Preferences = {
	init: function () {
		if (!Cookies.sitePrefs) return;
		sitePrefs = Cookies.sitePrefs.split(',,');
		for (var i=0;i<sitePrefs.length;i++) {
			var oneSitePref = sitePrefs[i].split(':');
			this[oneSitePref[0]] = oneSitePref[1];
		}	
	}
};
Preferences.init();

// email 체크
function EmailValid(email)
{
	re = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;

	if (re.test(email))
		return true;
	else
		return false;
}

 /* STANDALONE */
function winclose()
{
    (opener) ? window.close() : (parent) ? (typeof IfrmLayer != "undefined") ? new IfrmLayer().destroy() : self.close() : self.close();
}

// CheckBox ALL Check :: ex) checkAll(checkboxNameObj, flag) flag (true : false) 설정시 반전 효과 없음)
function checkAll(obj)
{
	if (typeof obj != undefined)
	{
		for( i=0; i<obj.length; i++) 
		{
			if (obj[i] != undefined) 
			{
			    if (arguments.length > 1) 
			        obj[i].checked = arguments[1];
			    else
			        obj[i].checked = (obj[i].checked) ? false : true;
			}
		}
    }
}

// checkbox obj -> target 으로 넘김 (this.checked) ? "1" : "0" ->   targetObj.value = "000111";
// checkbox obj (this.checked) ? "1" : "0" - return "000111";
function checkValue(obj, targetObj)
{
    var cBox = "";
	if (typeof obj != undefined)
	{
		for( i=0; i<obj.length; i++) 
		{
			cBox += (obj[i].checked) ? "1" : "0";
		}
    }
    if (targetObj && targetObj != null) targetObj.value = cBox;
    return cBox;
}

// 이메일 셀렉트 (this, 타켓 input box)
function emailSelected(obj, target) 
{
    if (obj)
    {
        if (obj.value == "etc") {			
		    $(target).value = "";
		    $(target).style.display = "inline";		
		    $(target).focus();
	    } else {
		    $(target).style.display = "none";
	        $(target).value = obj.value;
	    }
	}
}


/* Utilz */
function $NAME(obj) { return document.getElementsByName(obj); }
function $TAG(obj) { return document.getElementsByTagName(Obj); }
function isArray(o) { return Object.prototype.toString.call(o) == '[object Array]'; }  

/* MISC */
function imgcopy(imgid)
{
    var _img = document.getElementById(imgid);     
    _cr = document.body.createControlRange(); 
    _cr.addElement(_img); 
    _cr.execCommand('copy'); 
    window.alert('이미지가 복사되었습니다.\nCTRL+V를 이용하여 붙여넣기 하세요!');
    return false;
}

function copy_clip(meintext) // clipboard copy
{
    if (window.clipboardData)
    {
         window.clipboardData.setData("Text", meintext);
    }
    else if (window.netscape)
    {
        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip) return;

        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans) return;

        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext=meintext;
        str.data=copytext;
        trans.setTransferData("text/unicode",str,copytext.length*2);
        var clipid=Components.interfaces.nsIClipboard;
        if (!clip) return false;

        clip.setData(trans,null,clipid.kGlobalClipboard);
    }
    
    if (arguments[1] != false) {
        window.alert("클립보드에 저장되었습니다.\nCTRL+V를 이용하여 붙여넣기 하세요.\n"+ meintext);
    }
    return false;
}

// 3자리마다 쉼표(,) 변환 (소수점 지원) <input onKeyup="addComma(this)">  form 넘길때 obj.value.replace(/,/,'') 로 ,(comma) 제거 후 전송
// @fLen - 소수점 자리 숫자까지 - 2자리 디폴트
function addComma(obj, fLen) 
{ 
    //if(event.keyCode == 37 || event.keyCode == 39 ) return;
    var fLen = fLen || 2; 
    var strValue = obj.value.replace(/,|\s+/g,'');
    var strBeforeValue = Math.ceil((strValue.indexOf('.') != -1)? strValue.substring(0,strValue.indexOf('.')) :strValue).toString();
    var strAfterValue  = (strValue.indexOf('.') != -1)? strValue.substr(strValue.indexOf('.'),fLen+1) : '' ;

    if(isNaN(strValue))
    {
       alert(strValue.concat(' -> 숫자가 아닙니다.'));
       return false;
    }

    var intLast =  strBeforeValue.length-1;
    var arrValue = new Array;
    var strComma = '';

    for(var i=intLast,j=0 ; i >= 0; i--,j++)
    { 
       strComma = (j !=0 && j%3 == 0) ? ',' : '';
       arrValue[arrValue.length] = strBeforeValue.charAt(i) + strComma  ;
    }
    obj.value = arrValue.reverse().join('') +  strAfterValue;
    return true;
}

// 쉼표, 없애줌 ex) strValue.delComma();
String.prototype.delComma = function(str) {
    str = this != window ? this : str;
    if (str.length > 0) str = (str.indexOf(',') != -1) ? str.replace(/,/g,"") : str;
    return str;
}
String.prototype.trim = function() {
    return this.replace(/^\s+(.*?)\s+$/,'$1');
};
String.prototype.trimAll = function() {
    return this.replace(/^\s+|(\s+(?!\S))/mg,"");
};

// 문자열 byte로  string.byte()
String.prototype.bytes = function(str) {
    str = this != window ? this : str;
    var len = 0; 
    for(j=0; j<str.length; j++) {
        var chr = str.charAt(j);
        len += (chr.charCodeAt() > 128) ? 2 : 1
    }
    return len;
}

function DateAdd(Interval, Number, date) 
{
    var NewDate = null;
    var RtnDate = null;
    var year = null;
    var month = null;
    var day = null;
    var Ryear = null;
    var Rmonth = null;
    var Rday = null;
    Number = parseInt(Number, 10);

    //date가 Date 객체일 경우
    if(date instanceof Date) {
        NewDate = date;
        year = NewDate.getYear();
        month = NewDate.getMonth();
        day = NewDate.getDate();
    }
    //date가 문자열일경우
    else {
        var temp = date.split("-");
        NewDate = new Date(temp[0],(temp[1]-1),temp[2]);
        year = temp[0];
        month = temp[1]-1;
        if (month == 0) { month = "00"; } 
        day = temp[2];
    }
    
    if(Interval == "y" || Interval == "Y") { year = parseInt(year) + Number; }
    else if(Interval == "m" || Interval == "M") { month = (month < '10') ? month.toString().replace('0', '') : month; month = parseInt(month.toString()) + Number; }
    else if(Interval == "d" || Interval == "D") { day = (day < '10') ? day.toString().replace('0', '') : day; day = parseInt(day) + Number; }
    
    
    RtnDate = new Date(year, month, day);
    Ryear = RtnDate.getFullYear();
    Rmonth = RtnDate.getMonth()+1;
    Rday = RtnDate.getDate();

    if(Rmonth < 10) { Rmonth = "0" + Rmonth; }
    if(Rday < 10) { Rday = "0" + Rday; }

    return Ryear + "-" + Rmonth + "-" + Rday;
}


function DateDiff( start, end, interval, rounding ) {

 var temp = start.split("-");
    var startate = new Date(temp[0],(temp[1]-1),temp[2]);
    
    temp = end.split("-");
    var endtate = new Date(temp[0],(temp[1]-1),temp[2]);
    
    
 var iOut = 0;
    
    // Create 2 error messages, 1 for each argument. 
    var startMsg = "Check the Start Date and End Date\n"
        startMsg += "must be a valid date format.\n\n"
        startMsg += "Please try again." ;
  
    var intervalMsg = "Sorry the dateAdd function only accepts\n"
        intervalMsg += "d, h, m OR s intervals.\n\n"
        intervalMsg += "Please try again." ;

    var bufferA = Date.parse( startate ) ;
    var bufferB = Date.parse( endtate ) ;
     
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        alert( startMsg ) ;
        return null ;
    }
 
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        alert( intervalMsg ) ;
        return null ;
    }
    
    var number = bufferB-bufferA ;
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(rounding) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(rounding) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the d,h,m,s criteria.  Handle
        // the error.   
        alert(intervalMsg) ;
        return null ;
    }
    
    return iOut ;
}

// iframe resize :: same domain
function calcHeight(FrameName) {
    try { 
        var the_height = (document.all) ? frames[FrameName].document.body.scrollHeight : document.getElementById(FrameName).contentWindow.document.documentElement.scrollHeight;
    }catch(e){}
    
    document.getElementById(FrameName).height = (the_height && the_height != undefined) ? the_height + 'px' : '';
}

function calcListHeight(FrameName) {

	try {

		var the_height = (document.all) ? frames[FrameName].document.body.scrollHeight : document.getElementById(FrameName).contentWindow.document.documentElement.scrollHeight;
		if (the_height > 320) { the_height = 320; }
		
	
	} catch (e) { }

	document.getElementById(FrameName).height = (the_height && the_height != undefined) ? the_height + 'px' : '';
} 


function IfrmAutoResize(ifrmObj) 
{
    var h = self.document.body.scrollHeight;
    if (top.document.getElementById(ifrmObj)) {
        h = (!arguments[1]) ? h : parseInt(h) + parseInt(arguments[1]);
        top.document.getElementById(ifrmObj).height = (h + 50) + "px";
    }
}

// mousePosition return array - x,y
function mousePosition(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return [posx, posy];
}

// PageSize return array - pageX, pageY
function getPageSize() {
     var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}


// 오직 숫자만
function onlyNum(e)
{
    if (!e) var e = window.event;
    var key = event.keyCode;
    if(!(key==8||key==9||key==13||key==46||key==144||(key>=48&&key<=57)||key==110||key==190))
    {
        alert(String.fromCharCode(key).concat(' -> 숫자가 아닙니다.'));
        e.returnValue = false;
        return false;
    }
}
function onlyNumber(e)//숫자키가 아니면 입력이 되지않음 pricecomma와 같이쓰기 위해 keydown 이벤트시 발생하도록 합니다.
{
    if (!e) var e = window.event;
    var key = event.keyCode;
    if(!(key>=48&&key<=57))
    {
        if (!(key>=96&&key<=105))
        {
            if (key!=8 && key!=9 && key!=13 && key!=46 && key!=37 && key!=39 && key!=144 && key!=190 && key!=110)
            {
                e.returnValue = false;
                return false;
            }
        }
    }
}

// xml dom  - loadxml
function getXMLDOM(data)
{
    var x = new Object();
    try { x = new ActiveXObject("Microsoft.XMLDOM");  } catch(e) { 
		try { x = document.implementation.createDocument("","",null); }
        catch(e) { alert(e.message); return; }
    }
    try { x.async = false; x.loadXML(data); }
    catch(e) { try { x.parseFromString(data, "text/xml") } catch(e) { } }
    return x;
}


//중간에 콜론 삽입(00:00)
function getRealInsertChar(obj) {
    var strInputValue = obj.value;   //입력된 값 저장
    obj.value = (strInputValue.length) == 2 ? strInputValue + ":" : strInputValue;
}

/**
 * input, textarea, select Element Event Behavior
 */
Event.addBehavior({
  'input': function(){
    switch(this.type.toLowerCase())
    {
        case "text":
        case "password":
            if (!this.readOnly && !this.disabled)
            {   
                var clsName = this.className.toLowerCase();

                if (clsName.indexOf('pricecomma') > -1) 
                {
                    this.observe('blur', function() { addComma(this); });
                    this.observe('focus', function() { if (this.value.length < 3) this.select(); });
                }
                if (clsName.indexOf('onlynum') > -1) 
                {
                    this.observe('keypress', function() { onlyNum(event); });
                    this.observe('focus', function() { if (this.value.length < 3) this.select(); });
                }
                if (clsName.indexOf('numberonly') > -1) 
                {
                    this.observe('keypress', function() { onlyNumber(event); });
                }
                
            } 
        break;
        case "checkbox":
        case "radio":
            if (!this.disabled)
            {
                this.observe('focus', function() { this.blur(); });
            }
        break;
        
        default:
        break;
    }
  }
});






Event.observe(window, 'load', function() {
    //var mycheckboxes = new MyCheckBoxes(document.forms['aspnetForm']);
    if (!Browser.isWinIE6)
    {
        if (document.URL.toLowerCase().indexOf('packagedetail') == -1 && document.URL.toLowerCase().indexOf('reserve') == -1)
        {
            if (typeof MyRadioButtons == "function") new MyRadioButtons(document.forms['aspnetForm']);
        }
    }
    
    // packagelist init
    //if ($('masterCode_0')) toggleProductList($('masterCode_0').innerHTML.stripScripts().unescapeHTML(), 0, (document.URL.toLowerCase().indexOf('&simple=y') > 0) ? "Y" : "N") // first product more view

//    $$('table').each(function(el) { 
//        if (el.width >= 760) $('mainContent').style.margin = "0 0 0 210px";
//    });  
});



if (typeof blankImg == undefined) var blankImg = "/images/blank.gif";



// 환율 팝업
function popCurrency() 
{
	var loc = "http://ebank.keb.co.kr/IBS/b2c/cspecial/csexchange/csex001r.jsp";
	window.open(loc,"vgtCurrency","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=610,height=660");
}

// 신문광고 팝업
function popNewspaper() {
	var loc = "http://www.verygoodtour.com/customer/popNewspaper.asp";
	window.open(loc,"vgtNewspaper","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=0,top=0,width=100,height=100");
}

// eBook 팝업
function ecatalog(docu, kd, dir){
	if(screen.width < 800){
		alert("The screen resolution should be over 800*600");
		return;
	}

	if(kd == "fixed"){ x = 1024; y = 768; wname = "fixed_ecatalog"; }
	else if(screen.width > 1280 || screen.height > 1024){ x = 1280; y = 1024; wname = "ecatalog"; }
	else{ x = screen.width; y = screen.height; wname = "ecatalog"; }

	x = x - 10;
	y = y - 58;

	property = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,copyhistory=no,";
	property += "width=" + x + ",height=" + y + ",left=" + 0 + ",top=" + 0;
	docu = docu + "/ecatalog.asp?Dir=" + dir;

	ecawin = window.open(docu, wname, property);
}
function popLoadingBar() {
    new FlushPopup('/Common/LoadingBar.aspx', null, { width: 600,
        height: 200, showTitle: false, overlay: false , iframe: false, dragable: true
    });
   }

//항공 조회중 레이어
function popLoadingSearchBar() {
    new FlushPopup('/Product/AirFare/AirLoading.html', null, { width: 800,
        height: 650, showTitle: false, overlay: false, iframe: false, dragable: true
	});
}

//항공 처리중 레이어
function popLoadingDataBar() {
    new FlushPopup('/Product/AirFare/AirLoadingData.html', null, { width: 800,
        height: 400, showTitle: false, overlay: false, iframe: false, dragable: true
    });
}

function popValidateDate(url) {

    var calLayer = $("CalendarLayerAir");
    var calIframe = $("CalendarFrameAir");
    //alert(event.clientX + " " + event.clientY);
    
    
    if (calLayer != null && calIframe != null ) {

        calIframe.src = url;
        calIframe.style.width = "200px";
        calIframe.style.height = "220px";

        var objTmp = event.srcElement;
        var layerX = 0;
        var layerY = 0;
        while (objTmp) {
            layerX += objTmp.offsetLeft;
            layerY += objTmp.offsetTop;
            objTmp = objTmp.offsetParent;
        }
        
        calLayer.style.position = "absolute";
        calLayer.style.width = "200px";
        calLayer.style.height = "220px";
        calLayer.style.left = (layerX -150)+ "px";
        calLayer.style.top = (layerY + 20 )+ "px";
        calLayer.style.display = "block";
    }

//    new FlushPopup(url, null, { width: 280,
//        height: 240, showTitle: false, overlay: false, iframe: true , dragable: true
//    });
}

//로딩바 없애기
function stopLoadingLayer() {
	try { $$('body')[0].removeChild($("popWrapper_2")); } catch (e) { }
}
	


function resizeImage()
{
    return true;
}

// 소수점 이하 지정된 자리 수 이외에 반올림한다.
function fn_Round(vAmount, vRoundCnt) 
{
    var vCnt = 0;
    var vLoopCnt = 0;
    var vFixedNum = 0;

    var vReturnAmount = vAmount;

    if (vAmount == "") 
    {
        vReturnAmount = 0;
    }

    if (vReturnAmount.toString().indexOf(".") > -1) 
    {
        var vAmountSplit = vAmount.toString().split(".");

        if (vAmountSplit.length > 1 && vAmountSplit[1].length > 0) 
        {
            if (vAmountSplit[1].length > vRoundCnt)
            {
                vLoopCn = vRoundCnt;
            }
            else
            {
                vLoopCn = vAmountSplit[1].length;
            }

            for (var i = 0; i < vLoopCn; i++)
            {
                if (vAmountSplit[1].substring(i, i + 1) > 0) 
                {
                    vCnt++;

                    vFixedNum = i + 1;
                }
            }

            if (vCnt > 0)
            {
                vReturnAmount = parseFloat(vAmount).toFixed(vFixedNum);
                
                if (vReturnAmount.substring(vReturnAmount.length - 1, vReturnAmount.length) == 0)
                {
                    vReturnAmount = fn_Round(vReturnAmount, vRoundCnt);
                }
            }
            else 
            {
                vReturnAmount = Math.round(vAmount);
            }
        }
    }

    return vReturnAmount;
}
// 만나이 계산
function getWAge(socNum1,socNum2) {

	var ret = 0;
	if (socNum1 != null && socNum1.length >= 6
		&& socNum2 != null && socNum2.length > 1 ) {

		var socDiv = parseInt(socNum2.substring(0, 1));

		if (socDiv == 3 || socDiv == 4) {
			socNum1 = "20" + socNum1;
		}
		else {
			socNum1 = "19" + socNum1;
		}
		var bYear = socNum1.substr(0, 4);
		var bMonthDate = socNum1.substr(4, 4);
		
		var nowDateTime = new Date();
		var nowMonth = String(nowDateTime.getMonth() + 1) ;
		if(nowMonth.length == 1 )nowMonth ="0"+nowMonth;
		var nowDate = String(nowDateTime.getDate()) ;
		if(nowDate.length == 1 )nowDate ="0"+nowDate;

		//한국나이
		var kAge = nowDateTime.getFullYear() - parseInt(bYear) + 1;
		var mAge = 0;
		//생일 안지남
		if (nowMonth + nowDate < bMonthDate) {
			mAge = kAge - 2;
		}
		else {
			mAge = kAge - 1;
		}
		return mAge; 
	}

}

//파라미터값 추가,수정
function setParamValue(url, key, value) {

    var retParam;
    if (url.indexOf("?") == -1) {
        retParam = "?" + key + "=" + value;
    }
    else {
        var pageUrl = url.split("?")[0];
        var param = url.split("?")[1];
        var sIdx = param.toLowerCase().indexOf("&" + key.toLowerCase() + "=");
        if (sIdx == -1) {
            retParam = pageUrl + "?" + param + "&" + key + "=" + value;
            
        }
        else {
            var param1 = param.substring(0, sIdx + 1);
            var param2 = param.substring(sIdx + 1, param.length); //삭제될값
            var s2Index = param2.indexOf("&");
            var param3 = (s2Index == -1 ? "" : param2.substring(param2.indexOf("&"), param2.length));

            retParam = pageUrl + "?" + param1 + key + "=" + value + param3;
        }
    }
    return retParam;
}
	