function changeLocale(locale)
{
        SetCookie("locale", locale, null, "/");
        window.location.reload();
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) { //while open
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
   } //while close
   return null;
}

function SetCookie(name, value) {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
      ((expires == null) ? "" :
         ("; expires=" + expires.toGMTString())) +
      ((path == null) ? "" : ("; path=" + path)) +
      ((domain == null) ? "" : ("; domain=" + domain)) +
      ((secure == true) ? "; secure" : "");
}

function isNull(str){
	if(str == "") return true;
	var len = str.length;
	for(var i = 0; i < len; i++)
	{
		if(str.substring(i,i+1) != " ") return false;
	}
	return true;
}

//trim
function trim(Str){
	 var tempStr = "";
	 
	 for (i = 0 ; i < Str.length; i++){
	  if(Str.charAt(i) == " "){
	   tempStr = tempStr;
	  }else{
	   tempStr = tempStr + Str.charAt(i);
	  }
	 }
	 
	 return tempStr;
}

//error alert
function errorAlert(msg) {
	alert(msg) ;
	history.back() ;
}

/**
 * popup window open use
 * URL : page url, width : window width, height : window height, scrl : scroll check(yes or no), win_nm : window name
 */
function openWindow(URL, width, height, scrl, win_nm) 
{
	var windowFeatures ="'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrl+",resizable=no,copyhistory=no";
	windowFeatures  += ",width=" + width + ",height=" + height + "'";
	return window.open(URL, win_nm, windowFeatures);

}

function goListen(root,gubun,type,prdId,itemId,idx)
{
	if( gubun == 'N' ) {
		openWindow(root+"/rbt/listen_pop.jsp?type="+type+"&prdId="+prdId+"&itemId="+itemId, 410, 300, "yes", "listen_pop") ;	
	}else if( gubun == 'P' ) {
		openWindow(root+"/rbt/listen_package_pop.jsp?type="+type+"&prdId="+prdId+"&itemId="+itemId+"&idx="+idx, 410, 330, "yes", "listen_pop") ;
	}
}

function openHelp(root)
{
	openWindow(root+"/help_main_pop.jsp", 400, 300, "yes", "help_pop") ;
}

	// show DIV
	function showLayer(lname) {
		
		eval(layerRef+'["'+lname+'"]'+styleRef+'visibility="visible"');
	}
	
	// hide DIV
	function hideLayer(lname) {
		
		eval(layerRef+'["'+lname+'"]'+styleRef+'visibility="hidden"');
	}
	
	function helpmenu(lname) {
	
		var layerName = "helplist"+lname;
	
		if (document.all["helplist"+lname].style.visibility == "hidden") {
	
			showLayer(layerName);
	
		} else if (document.all["helplist"+lname].style.visibility == "visible") {
	
			hideLayer(layerName);
		}			
	} // end of toggleLayerEXP()
	
function onlyNumber()
{
  if ( ((event.keyCode < 48) || (57 < event.keyCode)) && (45 != event.keyCode) && 46 != event.keyCode ) event.returnValue=false;
}

function removeATag(obj)
{
	var innerStr = "";
	for (i = 0; i < (obj.childNodes).length; i++)
	{
		if (obj.childNodes[i].tagName == "A")
			innerStr += obj.childNodes[i].innerHTML;
	}
	return innerStr;	
}