var	frm = document.frmList;
var chkname = 'chk';
var	nowUrl = document.location.href;

function setFormname(v_formname,v_target)
{
	frm = eval("document." + v_formname);
	frm.target = v_target;		
	return true;
}
function goSearch()
{
	setFormname("frmList","_self");
	frm.action = "#";
	frm.submit();	
	return true;
}
function goRefresh()
{
	document.location.href = nowUrl;
	return true;
}
/*
function goDelete(v_url,v_idx)
{
	if(confirm("Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		document.all.frmHid.src = v_url + "?p_type=delete&p_idx="+ v_idx;
	}
	return true;
}
function goDelete2(v_url,v_idx)
{
	if(confirm("Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		document.location.href = v_url + v_idx + "&p_type=delete";
	}
	return true;
}
*/
function goView(v_url,v_idx)
{
	document.location.href = v_url + v_idx;
	return true;
}
function openDiv(v_element,v_top,v_left)
{  
	div	= document.getElementById(v_element);
	div.style.top = v_top;
	div.style.left = v_left;
	div.style.display = ""; 	
	return true;	
}
function openDivW(v_element,v_frmName,v_tagName)
{
	div	= document.getElementById(v_element);	
	div.style.display = "block"; 
	v_focus = eval("document."+ v_frmName + "." + v_tagName);
	v_focus.focus();
	
	return true;
}
function openDivU(v_element,v_formname,v_focus)
{
  var x = event.x;
  var y = event.y;		
	div	= document.getElementById(v_element);	
	div.style.top = x;
	div.style.left = y;
	div.style.display = ""; 
	//frmfocus = eval("document.all." + v_formname + "." + v_focus);
	//frmfocus.focus();	
	return true;
}
function closeDiv(v_element)
{
	div	= document.getElementById(v_element);	
	div.style.display = "none"; 
	return true;
}
function nextpre(current) 
{
	setFormname("frmList","_self");	
	frm.action = "#";
	frm.now_page.value = current;
	frm.submit();
	return true;
}
function changeOrderby(v_orderby)
{
	setFormname("frmList","_self");	
	var temp = frm.orderby.value
	if(temp.indexOf("desc")!=-1)
	{
		frm.orderby.value = v_orderby + " asc";
	}
	else
	{
		frm.orderby.value = v_orderby + " desc";
	}
	
	frm.action = "#"
	frm.submit();
	return true;	
}
function setChkAll(chkname)
{
		chk = document.getElementsByName(chkname);
		
		var i = 0;
		var cnt = 0;
		
		while(chk[i])
		{
			if(chk[i].checked == true)
			{
				cnt++;
			}			
			i++;
		}
		
		i = 0;
		while(chk[i])
		{
			if(cnt == 0)
			{ 
				chk[i].checked = true;
			}
			else
			{
				chk[i].checked = false;
			}		
								
			i++;
		}
}
function getChkAll(chkname)
{ 		
		chk = document.getElementsByName(chkname);
		var i = 0;
		var msg = "";
		while(chk[i])
		{
			if(chk[i].checked == true)
			msg+=chk[i].value + "/";
			i++;
		}
		return msg;
}
function getPost(v_element)
{
	v_reAddress = document.getElementsByName('reAddress');
	v_reAddress[0].value = v_element;	
	defaultOpen("/custom/post_pop.php", "PostPop", 368, 458 , "yes");
}	
function goGoodsView(v_goods_idx , v_goods_type)
{
	if(v_goods_type == 'download')
	{
		document.location.href = "/download/download_view.php?p_goods_idx=" + v_goods_idx + "&p_goods_type=" + v_goods_type;
	}
	else
	{
		document.location.href = "/goods/goods_v.php?p_goods_idx=" + v_goods_idx + "&p_goods_type=" + v_goods_type;		
	}		
}
function goGoodsViewBlank(v_goods_idx , v_goods_type)
{
	var openNewWindow = window.open("about:blank");
	
	if(v_goods_type == 'download')
	{
		openNewWindow.location.href = "/download/download_view.php?p_goods_idx=" + v_goods_idx + "&p_goods_type=" + v_goods_type;
		//document.location.href = "/download/download_view.php?p_goods_idx=" + v_goods_idx + "&p_goods_type=" + v_goods_type;
	}
	else
	{
		openNewWindow.location.href = "/goods/goods_v.php?p_goods_idx=" + v_goods_idx + "&p_goods_type=" + v_goods_type;
		//document.location.href = "/goods/goods_v.php?p_goods_idx=" + v_goods_idx + "&p_goods_type=" + v_goods_type;
	}		
}

function pageInit()
{
}	

function openWin_noResize2(url,w,h)
{
    //var left_pos = (document.body.clientWidth-932) / 2;
    if (screen.height <= 800){
        var left_pos = 0;
        var top_pos = 0;
    }else{
        //var top_pos = (document.body.clientHeight-538-105) / 2 + 50;
        var left_pos = 100;
        var top_pos = 50;
    }
    winName = open(url,"",'width='+w+',height='+h+',left='+left_pos+',top='+top_pos+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
    if(winName==null)   {
        alert("Â÷´ÜµÈ ÆË¾÷Ã¢À» Çã¿ëÇØ ÁÖ¼¼¿ä.");
    }
    else    {
        winName.focus();
    }
}


 function getHttprequest(URL) {
  var xmlhttp = null;
  if(window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
  } else {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.open('GET', URL,false);
  xmlhttp.onreadystatechange = function() {
   if(xmlhttp.readyState==4 && xmlhttp.status == 200 && xmlhttp.statusText=='OK') {
    responseText = xmlhttp.responseText;
   }
  }
  xmlhttp.send('');
  return responseText = xmlhttp.responseText;
 }
