// ¼­ºê ¸Þ´º ÀÌ¹ÌÁö ¼±ÅÃÀ» À§ÇÑ ½ºÅ©¸³Æ®
//ÀÌ¹ÌÁöÀÇ id´Â ÀÌ¹ÌÁö ÆÄÀÏ¸í°ú µ¿ÀÏÇÏ°ÔÇÔ
function  SelectMenu(nIdx, myMenu)
{
    for( i =0; i < myMenu.length; i++)
    {
        if(nIdx == i)
        {
            document.getElementById(myMenu[i]).src = document.getElementById(myMenu[i]).getAttribute("ori") + "_on.gif";
        }
        else if(document.getElementById(myMenu[i]) != null)
        {
            document.getElementById(myMenu[i]).src = document.getElementById(myMenu[i]).getAttribute("ori") + ".gif";	    
        }
    }
}


///[2007-05-08] °¢ ¸ðµâ Default.aspxÈ­¸éÀ¸·Î ÀÌµ¿
function goModuleDefault()
{
    location.href = "default.aspx";
}

// ¹®ÀÚ¿­ÀÇ ¿ÞÂÊ °ø¹é Á¦°Å
function ltrim(str){	
	while(''+str.charAt(0) == ' '){
		str = str.substring(1,str.length);
	}
	return str;
}

//[2007-05-20] window.open
function openWindow(url, title, param){
    window.open(url, title, param);
}

//[2007-05-09] ÀÌµ¿ÇÒ ÆäÀÌÁö Url
function goPageUrl(pageUrl)
{
    location.href =  pageUrl;    
} 

//[2007-05-10] ´Ù¿î·Îµå ÆäÀÌÁö·Î ÀÌµ¿ÇÑ´Ù. 
function goDownLoad(){
    location.href = "../Download/";
}

//[2007-05-10] ´Ù¿î·Îµå ÆäÀÌÁö·Î ÀÌµ¿ÇÑ´Ù. 
function goBuy(mode){
    var pageName = "";

    if(mode == "public"){
        pageName = "Government.aspx";
    } 
    else if(mode == "education"){
        pageName = "Education.aspx"
    }
    location.href = "../Buy/" + pageName ;
}

function onlyNumber (el) {
	el.value = el.value.replace(/\D/g,'');
}

function OpenALCoin()
{
	height=675;
	width=880;
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
	etc = size + ',resizable=no,scrollbars=yes,status=no';
	reval = window.top.open('https://secure.altools.co.kr/coin','ALCoinWindow',etc);
	reval.focus();
}

function openALToolbarFlash()
{
    height=660;
    width=1024;
    wid = ( screen.availwidth - width ) / 2;
    hei = ( screen.availheight - height ) / 2;
    size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
    etc = size + ',resizable=no,scrollbars=no,status=no,padding=0';    
    reval = window.top.open('http://www.altools.co.kr/Product/altoolbarswf/index.html' , '' , etc);
    reval.focus();
} 

function OpenSiteMapALCoin(url)
{
    var siteUrl = 'https://secure.altools.co.kr/coin' + url;
	height=675;
	width=880;
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
	etc = size + ',resizable=no,scrollbars=yes,status=no';
	reval = window.top.open(siteUrl,'ALCoinWindow',etc);
	reval.focus();
}

function openSubWin(openurl,winID,width,height)
{
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
	etc = size + ',resizable=no,scrollbars=no,status=no';
	reval = window.top.open(openurl,winID,etc);
	reval.focus();
}

function openSubWinR(openurl,winID,width,height)
{
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
	etc = size + ',resizable=no,scrollbars=auto,status=no';
	reval = window.top.open(openurl,winID,etc);
	reval.focus();
}

function openSubWinY(openurl,winID,width,height)
{
	wid = ( screen.availwidth - width ) / 2;
	hei = ( screen.availheight - height ) / 2;
	size = 'width=' + width + ',height=' + height + ',top=' + hei + ',left=' + wid;
	etc = size + ',resizable=no,scrollbars=yes,status=no';
	reval = window.top.open(openurl,winID,etc);
	reval.focus();
}

function EntireDownload()
{
	CheckALDown('ALTools', '7.0');
	fileDownAltools('http://aldn.altools.co.kr/ALTOOLSsetup_free.exe');
}


function DownloadMgr(nId)
{
    frmDown.location.href = "/EstLab/DownloadManage.aspx?idx=" + nId;
}
function fileDownV(strUrl)
{
    if(strUrl.indexOf("http")>-1)
    {
        location.href = strUrl;
    }
    else
    {
        location.href = 'http://aldn.altools.co.kr/altools/'+strUrl;
    }
    
}
function fileDownAltools(strUrl)
{
    if(strUrl.indexOf("http")>-1)
    {
        location.href = strUrl;
    }
    else
    {
        location.href = 'http://aldn.altools.co.kr/altools/'+strUrl;
    }
    
}
function CheckALDown(strApp, strVer)
{
    frmDown.location.href = "/Download/Research.aspx?App="+strApp+"&Ver="+strVer+"&Flag=D";
}
/* Now ALTools¿¡¼­ ´Ù¿î·Îµå ¹ÞÀ»°æ¿ì */
function CheckALDownNow(strApp, strVer)
{
    frmDown.location.href = "/Download/Research.aspx?App="+strApp+"&Ver="+strVer+"&Flag=N";
}

/* Event page¿¡¼­ ´Ù¿î·Îµå ¹ÞÀ»°æ¿ì */
function CheckALDownEvent(strApp, strVer)
{
    frmDown.location.href = "/Download/Research.aspx?App="+strApp+"&Ver="+strVer+"&Flag=E";
}

function CheckLabDown(nId)
{
    frmDown.location.href = "/EstLab/DownloadManage.aspx?idx=" + nId;
}


String.prototype.trim = function () { return this.ltrim().rtrim();  }
String.prototype.ltrim = function () { return this.replace(/^s*/g, ""); }
String.prototype.rtrim = function () { return this.replace(/s*$/g, ""); }

String.prototype.numberFormat = function(decimals,dec_point,thousands_sep)
{
	if(decimals==null){decimals=999;}	
	if(dec_point==null){dec_point='.';}
	if(thousands_sep==null){thousands_sep=',';}	
	var arr = this.toString().replace(/[^-\.\+\d]/g,'').split(dec_point);
	if(arr[1] && arr[1].length>0){arr[1] = arr[1].substr(0,decimals);}
	arr[0] = arr[0].replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1'+thousands_sep);
	if(arr[1] && decimals>0 && arr[1].length>0){return arr[0] + dec_point + arr[1];}
	else {return arr[0];}
}
Number.prototype.numberFormat = function(decimals,dec_point,thousands_sep){
	return this.toString().number_format(decimals,dec_point,thousands_sep)
}
function numberFormat(str,decimals,dec_point,thousands_sep){
	return str.toString(decimals,dec_point,thousands_sep);
}

String.prototype.replaceAll = function(str1, str2)
{
  var temp_str = "";

  if (this.trim() != "" && str1 != str2)
  {
    temp_str = this.trim();

    while (temp_str.indexOf(str1) > -1)
    {
      temp_str = temp_str.replace(str1, str2);
    }
  }

  return temp_str;
}




function checkInputBox(strObjId, strMessage)
{
    if(document.getElementById(strObjId).value.trim() != "")
	{
	    return true;
	}
	else if (strMessage != null && strMessage != "")
	{
	    alert(strMessage);
	}
	
	document.getElementById(strObjId).focus();
		            
    return false;
}

function Request(valuename)    //javascript·Î ±¸ÇöÇÑ Request
{
    var rtnval;
    var nowAddress = unescape(location.href);
    var parameters = new Array();
    parameters = (nowAddress.slice(nowAddress.indexOf("?")+1,nowAddress.length)).split("&");
    for(var i = 0 ; i < parameters.length ; i++){
        if(parameters[i].indexOf(valuename) != -1){
            rtnval = parameters[i].split("=")[1];   
            if(rtnval == undefined || rtnval == null){
                rtnval = "";
            }
            return rtnval;
        }
    }
}