
//Ã¢¿­±â
function OpenWindow(url,windowname,w_size,h_size)
{ 
  newWin=window.open(url,windowname,"width="+w_size+",height="+h_size+",resizable=no,scrollbars=yes,status=1,left=50,top=50");
		if (newWin !=null) {
				newWin.opener=self;
		}
		newWin.focus();
}


//½ºÅ©·Ñ¹Ù ¾ø´Â Ã¢ ¿­±â
function OpenWindow_noscroll(url,windowname,w_size,h_size)
{ 
  newWin=window.open(url,windowname,"width="+w_size+",height="+h_size+",resizable=no,scrollbars=no,status=1,left=50,top=50");
		if (newWin !=null) 
		{
				newWin.opener=self;
		}
		newWin.focus();
}



//ÀüÃ¼ ¼±ÅÃ
function allcheck(theform)
{
	
	var check_box=theform["chk[]"]; 
	
	if(!check_box)
	{
		alert('°ªÀÌ ¾ø½À´Ï´Ù.');
	    	return;
	}
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == false)	ele.checked = true;		
	}
	
	
	return;
}


//¼±ÅÃÃë¼Ò
function discheck(theform)
{
	var check_box=theform["chk[]"]; 
	
	if(!check_box)
	{
		alert('°ªÀÌ ¾ø½À´Ï´Ù.');
	    	return;
	}
	
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		ele.checked = false;	
	}	
	
	return;
}




//¼±ÅÃºÎºÐ ¹ÝÀü
function invert_check(theform)
{
	var check_box=theform["chk[]"]; 
	
	if(!check_box)
	{
		alert('°ªÀÌ ¾ø½À´Ï´Ù.');
	    	return;
	}
	
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == true)		ele.checked = false;
		else 	ele.checked = true;
		
	}
	return;
}



//»èÁ¦È®ÀÎ
function ask_del(target,t_field,t_var,re_url) 
{
	
  	if(confirm("Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) 
  	{
  	  document.location.href = "../lib/del_list.php?target="+target+"&t_field="+t_field+"&t_var="+t_var+"&re_url="+re_url+"";
  	}
  	else
  	{
  		return;
  	}
}


//ÀüÃ¼ »èÁ¦ È®ÀÎ
function all_del(theform) 
{
  	if(confirm("Á¤¸» ¸ðµÎ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) 
  	{
		 theform.mode.value="delete"; 
		 theform.submit();
  	}
  	else 
  	{
		  return ;
  	}
}

function all_del_new(theform,reVars) 
{
  	if(confirm("Á¤¸» ¸ðµÎ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) 
  	{
		 theform.method="post";
		 theform.mode.value="delete";		 
		 theform.del_re_vars.value=reVars;
		 theform.submit();
  	}
  	else 
  	{
		  return ;
  	}
}

//¼ýÀÚ ÀÔ·Â Ã¼Å©
function chk_digi(elem)
{
	var str1 = elem.value;
  	
  	for(i=0; i<str1.length; i++)
  	{
	  	if ((str1.charAt(i) < "0") || (str1.charAt(i) > "9"))
	  	{  
	    		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
	    		elem.focus();
	   		 	return false;
    	}
	}
	return true;
}




//¼¿·ºÆ®¹Ú½º ¼±ÅÃ½Ã URL·Î ÀÌµ¿
function jump_Menu(selObj)
{
 	eval("location.href='"+selObj.options[selObj.selectedIndex].value+"'");
}



//Ã¢´Ý±â
function win_c()
{ 
	window.close();
    opener.focus();
}


//¸ðµå¸¦ ¼öÁ¤ÇÏ°í Àü¼ÛÇÑ´Ù.
function is_run(theform,vars) 
{
 	 theform.mode.value=vars; 
	 theform.submit();
  
}


function chk_date(elem,opt)
{
	var str1 = elem.value;
  	if(str1 == "")
  	{
  		return true;
  	}
  	
  		
  	for(i=0; i<str1.length; i++){
	  	if ((str1.charAt(i) < "0") || (str1.charAt(i) > "9")){  
	    		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
	    		elem.focus();
	   	 return false;
    		}
	}
	
	
	if (opt == "year"){  
    		
    		if(str1 < 1900 || str1 > 2100){
    			alert("³âµµ´Â 1900³â¿¡¼­ 2100³â ±îÁö¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
    			elem.focus();
	   	 	return false;
	   	}
	   	else
	   	{
	   		return true;
	   	}
	}
	
	if (opt == "month"){  
    		
    		if(str1 < 1 || str1 > 12){
    			alert("   Àß¸øµÈ ³¯Â¥ ÀÔ´Ï´Ù. \nÁ¤È®ÇÏ°Ô ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.");
    			elem.focus();
	   	 	return false;
	   	}
	   	else
	   	{
	   		return true;
	   	}
	}
	
	if (opt == "day"){  
    		
    		if(str1 < 1 || str1 > 31){
    			alert("    Àß¸øµÈ ³¯Â¥ ÀÔ´Ï´Ù. \nÁ¤È®ÇÏ°Ô ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.");
    			elem.focus();
	   	 	return false;
	   	}
	   	else
	   	{
	   		return true;
	   	}
	}
}




function zoomWin(imgName) 
{
	newWin=window.open("../lib/zoom.php?img="+imgName,"Detail_view","width=20,height=10,scrollbars=0,resizable=0,left=50,top=50");
	if (newWin !=null) 
	{
		newWin.opener=self;
	}
	newWin.focus();

}




function makeDigi(str)
{
	newStr = String(str);
	newStr = newStr.replace(/[^0-9]/g,""); 
	return 	Number(newStr);
}

function Number_Format(str)
{
	var NewStr = String(str);
	
	//¼ýÀÚ ÀÌ¿Ü ¹®ÀÚ Á¦°Å
	var Re = /[^0-9\.]/g; 
	var NewStr = NewStr.replace(Re,''); 
	
	
	var ReN = /(-?[0-9]+)([0-9]{3})([^\.0-9]*)/;
	
	while (ReN.test(NewStr)) 
	{ 
		NewStr = NewStr.replace(ReN, "$1,$2$3"); 
	}
	return NewStr;
}

function MoveNext(tElem,tKey) 
{
	var keyValue = event.keyCode;
		
	if (keyValue == tKey) 
	{
		tElem.focus();
		return true; 
	}
	else 
	{
		return true; 
	}
		
	
}

//-------------------------------------- Ä«Å×°í¸® ¸¶¿ì½º¿À¹ö Ãß°¡ ³»¿ë-----------------------------//
var activeButton=null;
function browser_type()
{
	var ua,s,i;
	this.isIE=false;
	this.isNS=false;
	this.version=null;
	ua=navigator.userAgent;
	s="MSIE";
	
	if((i=ua.indexOf(s))>=0){
	this.isIE=true;
	this.version=parseFloat(ua.substr(i+s.length));
	return;
	}
	s="Netscape6/";
	if((i=ua.indexOf(s))>=0){
	this.isNS=true;
	this.version=parseFloat(ua.substr(i+s.length));
	return;
	}
	s="Gecko";
	if((i=ua.indexOf(s))>=0){
	this.isNS=true;
	this.version=6.1;return;
	}
}

var browser_type=new browser_type();


function DropDownLayers(button,menuName,onImgSrc)
{
	
	if(button.tagName != "IMG")
	{
		button = document.getElementById(button);
	}
	if(button.tagName != "IMG") return false;
	
	if(activeButton!=button && menuName)
	{	
		if(!button.menu) button.menu=document.getElementById(menuName);
		if(!button.offSrc) button.offSrc=button.src;
		if(!button.onSrc) button.onSrc=onImgSrc;
		if(activeButton && activeButton!=button) hide_submenu(activeButton);
		show_submenu(button);
	}
	return false;
}

function show_submenu(button)
{
	var h,x,y;	
	var tSpace = 20
	button.src = button.onSrc;	
	if(browser_type.isIE && !button.menu.firstChild.style.height)
	{
		h=button.menu.firstChild.offsetHeight;
		button.menu.firstChild.style.height=h+"px";			
	}

	x=calculat_x(button)+120;
	y=calculat_y(button); //+(button.offsetHeight/2);	
	
	if(browser_type.isNS && browser_type.version < 6.1)		y--;
	
	var menuY = y;// - (button.menu.firstChild.offsetHeight /2);	
	var menuX = x;	
		
	var menuBottom = y + button.menu.firstChild.offsetHeight ;
	
	var parentTable =  FindTable(button);
	
	var pTop = calculat_y(parentTable);
	var pBottom = pTop + parentTable.offsetHeight + tSpace;
	
	if(pBottom < menuBottom)	menuY -= menuBottom-pBottom ;
	if(menuY < pTop+21)	menuY = y;
	
	button.menu.style.left=menuX+"px";
	button.menu.style.top=menuY+"px";
	//button.menu.style.visibility="visible";
	button.menu.style.display="";
	
	activeButton=button;

}

function FindTable(obj)
{
	return obj.tagName == "TABLE" ? obj:FindTable(obj.parentElement);
}
function HideActLayer()
{
	if(activeButton ) hide_submenu(activeButton);
}

function hide_submenu(button)
{
	if(button.offSrc) button.src = button.offSrc;	
	//if(button.menu)	button.menu.style.visibility="hidden";
	if(button.menu)	button.menu.style.display="none";
	activeButton=null;
}

function calculat_x(el)
{
	return el.offsetLeft+(el.offsetParent?calculat_x(el.offsetParent):0);
}

function calculat_y(el)
{
	return el.offsetTop+(el.offsetParent?calculat_y(el.offsetParent):0);
}
function GoList(cID)
{
	document.location.href="../main/goods_list.php?c_code="+cID;
}

function PreloadImg()
{
    var img_list = PreloadImg.arguments;
    if (document.preloadlist == null)     document.preloadlist = new Array();
    var top = document.preloadlist.length;

    for (var i=0; i < img_list.length; i++) 
    {
        document.preloadlist[top+i]     = new Image;
        if(img_list[i] != undefined)    document.preloadlist[top+i].src = img_list[i];
    }
}
