var g_site = "";
var g_login = "";

function go_site(siteCode) {
	var url;
		
	if(siteCode =='01') {
		url = 'http://www.readingcoach.co.kr';
	} else if(siteCode =='31') {
		url = 'http://www.genture.co.kr';
	} else if(siteCode =='51') {
		url = "http://www.kyoboread.co.kr";
	} else if(siteCode =='91') {
		url = "http://www.ezpia.co.kr";
	}
	
	if(!document.frmLogin) {
  		//·Î±×ÀÎ ÇßÀ»½Ã Ã³¸®
		if(siteCode == "31") {
			url = url + "/common/member/gateway/gentureGateway.jsp?pSiteCode="+siteCode+"&pUserId="+document.all.loginUserIdValue.value+"&pLoginYn=Y";
		} else {
			url = url + "/common/member/gateway/portalGateway.jsp?pSiteCode="+siteCode+"&pUserId="+document.all.loginUserIdValue.value+"&pLoginYn=Y";
		}
  	}
  	
	var win = window.open(url, "_new");
  	return;
}

function openw(url,w,h) {
	window.open(url,'','width='+w+',height='+h+',menubar=no, toolbar=no, location=no, directories=no, resizable=yes, scrollbars=yes, status=yes ');
	return;
}

function openwn(url,w,h) {
	window.open(url,'','width='+w+',height='+h+',menubar=no, toolbar=no, location=no, directories=no, resizable=no, scrollbars=no');
	return;
}

function go(url) {
	document.location.href=url;
}

function popsgo(url) {
	self.close();
	opener.document.location.href=url;
}

function popgo(url) {
	opener.document.location.href=url;
}


function confirmgo(url,msg) {
	if(confirm(msg)!=0){
		document.location.href=url;
	}
}
function del(url){
	if(confirm("»èÁ¦ÇÏ´Â °ÍÀÌ È®½ÇÇÕ´Ï±î?")!=0){
		document.location.href=url;
	}
}

function divPrint(){
	window.open('print.html','','width=735,height=500,menubar=yes, scrollbars=yes, resizable=yes, toolbar=no, location=no, directories=no, status=yes');
	return;
}


function getCookie( name )
{
        var nameOfCookie = name + "=";
        var x = 0;
        while ( x <= document.cookie.length )
        {
                var y = (x+nameOfCookie.length);
                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                        endOfCookie = document.cookie.length;
                        return unescape(document.cookie.substring( y, endOfCookie ));
                }
                x = document.cookie.indexOf( " ", x ) + 1;
                if ( x == 0 )  break;
        }
        return "";
}

function setCookie( name, value, expiredays ){
  var todayDate = new Date();
  todayDate.setDate( todayDate.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}

function trOver(tr){
    tr.style.backgroundColor="#FFFDF7";
    return true;
}

function trOut(tr){
    tr.style.backgroundColor="";
    return true;
}


function tabOn(obj , val){
	if(val != cidx){
		var img = eval("document.all." + obj + val);
		img.src = "images/"+obj+""+val+"_o.gif";
	}
}

function tabOut(obj , val){
	if(val != cidx){
		var img = eval("document.all." + obj + val);
		img.src = "images/"+obj+""+val+".gif";
	}
}

function menuOn(){
	if(cidx){
		var img = eval("document.all.m" + cidx);
		if(img){
		    img.src = "images/m"+cidx+"_o.gif";
		}
	}
}

function init(){
	menuOn();
}

function checkCode(filter) {

	if(filter){
		var key = String.fromCharCode(event.keyCode);
		var re = new RegExp(filter);

		if(!re.test(key)) {
			event.returnValue = false;
		}
	}
}
// ¹®ÀÚ¿­ ÁÂÃøÀÇ °ø¹é Á¦°Å Ã³¸® ÇÔ¼ö
function ltrim(para) {
	while(para.substring(0, 1) == ' ') {
		para = para.substring(1, para.length);
	}

	return para;
}

// ¹®ÀÚ¿­ ¿ìÃøÀÇ °ø¹é Á¦°Å Ã³¸® ÇÔ¼ö
function rtrim(para) {
	while(para.substring(para.length-1, 1) == ' ') {
		para = para.substring(0, para.length-1);
	}

	return para;
}

// ¹®ÀÚ¿­ ÁÂ¿ìÃøÀÇ °ø¹é Á¦°Å Ã³¸® ÇÔ¼ö
function trim(para) {
	return rtrim(ltrim(para));
}
document.title = "±³º¸¹®°í R/E/A/D/";

function setListValue(listObj, value){
  if(listObj == '[object]'){
    var lovListObjLen = listObj.options.length;
    for(var i = 0; i < lovListObjLen; i++){
      if(listObj.options[i].value == value) {
        listObj.options[i].selected = true;
      }
    }
  } else{
    return false;
  }
}

//·¹ÀÌ¾î Ã³¸®°ü·Ã
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//ÀÔ·Â¹Ú½º¿¡ ¹®ÀÚ ±æÀÌ¿­ Á¦ÇÑ (object, Á¦ÇÑ bytes, °æ°í¸Þ½ÃÁö)
function checkLen(obj, len, msg) {
	var str = obj.value;

	if (bytes(str) > len) {
		alert(msg);
		obj.value = cut(str, len);
		obj.focus();
	}  
}

function bytes(str) {
	var l = 0;
	
	for(var i = 0; i < str.length; i++) {
		l += (str.charCodeAt(i) > 128) ? 2 : 1;
	}

	return l;
}

function cut(str, len) {
	var l = 0;

	for(var i = 0; i < str.length; i++) {
		l += (str.charCodeAt(i) > 128) ? 2 : 1;

		if (l > len) {
			return str.substring(0, i);
		}
	}

	return str;
}

//ÀÌ¹ÌÁö°¡ ¾øÀ»¶§ ´ëÃ¼ÇÑ´Ù
function img_error(obj,imgsrc) {
    obj.src = imgsrc;
}