// tab menu
function DisplayMenu(index) {
        for (i=1; i<=6; i++)
        if (index == i) {
        thisMenu = eval("menu" + index + ".style");
        thisMenu.display = "";
        } 
        else {
        otherMenu = eval("menu" + i + ".style"); 
        otherMenu.display = "none"; 
        }
 }
function move(url) { 
	location.href = url; 
}

function open_win(url, w, h) {
	var win = window.open(url,'','resizable=no,scrollbars=no,status=0,width='+w+',height='+h);
	win.window.focus(); 
}

//»õÃ¢¶ç¿ì±â 
function open_win1(url, w, h, scroll) { 
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var win = window.open(url,'','width='+w+',height='+h+',top=100,left=100,resizable=yes,scrollbars='+scroll); 
	win.window.focus(); 
}

//»õÃ¢¶ç¿ì±â 
function open_win2(url, target, w, h, scroll) { 
	var win = window.open(url,target,'width='+w+',height='+h+',top=0,left=0,scrollbars='+scroll); 
	win.window.focus(); 
}

function open_win3(url, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=no'
	win = window.open(url, '', winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function no_back(url) {
	window.location.replace(url);
}

function urlEncode(val) {
	return escape(encodeURIComponent(val));
}

function enter(callback) {
	var code = window.event.keyCode;
	if(code==13){
		callback();
	}
}

function imgWidthResize(limitSize, obj) {
	var w = obj.width;
	var h = obj.height;
	if(w>limitSize){
		obj.width = limitSize;
		obj.height = h*(limitSize/w);
	}
}

function imgHightResize(limitSize, obj) {
	var w = obj.width;
	var h = obj.height;
	if(h>limitSize){
		obj.height = limitSize;
		obj.width = w*(limitSize/h);
	}
}

function rPad(val, len, char) {
	var temp = "";
	if(val.length<len){
		for(var i=0;i<len-val.length;i++){
			temp += char;
		}
	}
	
	return val+temp;
}

function lPad(val, len, char) {
	var temp = "";
	if(val.length<len){
		for(var i=0;i<len-val.length;i++){
			temp += char;
		}
	}
	return temp+val;
}

function replaceAll(str, searchStr, replaceStr) {
	return str.split(searchStr).join(replaceStr);
}


function removeHttpStr(input) {
	if(input.value.indexOf("http://") != - 1) {
		input.value = input.value.replace("http://", "");
	}
}

function numberFormat(number, decimals, dec_point, thousands_sep) { 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; 
    var d = dec_point == undefined ? "," : dec_point; 
    var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : ""; 
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; 
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); 
} 

function getAbsolutePageFullURL(sub) {
    var x = document.location.href;	
	var y = x.substr(0, x.indexOf("/",7)); // http:// ÀÌÈÄºÎÅÍ
    
    return y + sub;
}


// layer view, hide 
function initViewChg(id, imgEl) {
	var id = document.getElementById(id);
	var imgEl = document.getElementById(imgEl);
	id.style.display = (id.style.display == 'block' ? 'none':'block'); 
	imgEl.src = imgEl.src.replace("_on.gif", "_off.gif");
	if (id.style.display == 'block') {
		imgEl.src = imgEl.src.replace("_off.gif", "_on.gif");
	}
}

// table tr list expand
var preNum;
var flag=1;
function changeLayer(sNum)
{
	if(sNum==preNum && flag==1){
		//alert('a');
		temp = eval("document.all."+sNum);
		if(temp){
			temp.style.display='none';
			flag=0;
		}
	}
	else if(sNum==preNum && flag==0){
		//alert('b');
		temp = eval("document.all."+sNum);
		if(temp){
			temp.style.display='';
			flag=1;
		}
	}
	else if(sNum!=preNum){
		//alert('c');
		temp = eval("document.all."+preNum);
		if(temp)
			temp.style.display='none';

		temp1 = eval("document.all."+sNum);
		if(temp1)
			temp1.style.display='';
		flag=1;


	}
	preNum=sNum;
}

// 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 '';
}
