var baseScript = true;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function selectedBox(obj, val)
{
    var selectedIndexNum = 0;

    for (i = 0; i < obj.length; i++)
    {
        if (obj.options[i].value == val)
            selectedIndexNum = i;
    }
    obj.selectedIndex = selectedIndexNum;
}

function checkedBox(obj, val)
{
    if (obj.length == null)
    {
        if (obj.value == val)
            obj.checked = true;

        return;
    }

    for (i = 0; i < obj.length; i++)
    {
        if (obj[i].value == val)
        {
            obj[i].checked = true;
            return;
        }
    }
}

function getRadioValue(obj)
{

    for (i = 0; i < obj.length; i++)
    {
        if (obj[i].checked == true)
            return obj[i].value;
    }
    return '';
}


function wopen(url)
{

    if (self.newwin && !newwin.closed)
    {
        newwin.close();
        newwin = null;
    }

    newwin = window.open(url, "newwin", "width=800,height=600,scrollbars=yes");
}

function wopen(url, wt, ht)
{

    if (self.newwin && !newwin.closed)
    {
        newwin.close();
        newwin = null;
    }
    newwin =
        window.open(
            url,
            "newwin",
            "width=" + wt + ",height=" + ht + ",scrollbars=yes");
}

function wopen3(url, wt, ht, winName)
{

    if (self.winName && !winName.closed)
    {
        winName.close();
        winName = null;
    }
    winName =
        window.open(
            url,
            winName,
            "width=" + wt + ",height=" + ht + ",scrollbars=no");
}

function wopen(url, wt, ht, scrl)
{

    if (self.newwin && !newwin.closed)
    {
        newwin.close();
        newwin = null;
    }

    newwin =
        window.open(
            url,
            "newwin",
            "width=" + wt + ",height=" + ht + ",scrollbars=" + scrl);
}

// For Date Formatting append by yakjin.
function dateFormat(obj, mode)
{
    d = obj.value;
    if (mode == 'off')
    {
        while (d.indexOf('/') >= 0)
        {
            d =
                d.substring(0, d.indexOf('/'))
                    + d.substring(d.indexOf('/') + 1);
        }
    }
    else if (mode == 'on')
    {
        d = d.substring(0, 4) + '/' + d.substring(4, 6) + '/' + d.substring(6);
    }
    obj.value = d;
    if (mode == 'off')
    {
        obj.select();
    }
}

/**
 * ???? left? trim()
 * @return trim? ???
 */
function ltrim(str)
{
    var i;
    var ch;
    var retStr = '';
    if (str.length == 0)
        return str;
    for (i = 0; i < str.length; i++)
    {
        ch = str.charAt(i);
        if (retStr.length == 0 && (ch == ' ' || ch == '\r' || ch == '\n'))
            continue;
        retStr += ch;
    }
    return retStr;
}

/**
 * ???? right? trim()
 * @return trim? ???
 */
function rtrim(str)
{
    var i;
    var ch;
    var retStr = '';
    if (str.length == 0)
        return str;
    for (i = str.length - 1; i >= 0; i--)
    {
        ch = str.charAt(i);
        if (ch != ' ' && ch != '\r' && ch != '\n')
        {
            break;
        }
    }
    retStr = str.substring(0, i + 1);
    return retStr;
}

/**
 * ???? ?? trim()
 * @return trim? ???
 */
function trim(str)
{
    var retStr;
    retStr = ltrim(str);
    retStr = rtrim(retStr);
    return retStr;
}

/**
 * ?????
 * @return trim? ???
 */
function replaceStr(str, oldstr, newstr)
{
    var index = 1;
    var temp = String(str);

    if (newstr == null)
        newstr = "";

    while (index > 0)
    {
        temp = temp.replace(oldstr, newstr);
        index = temp.indexOf(oldstr);
    }

    return temp;
}


function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	if(expiredays==null)
	    expiredays = 7;
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}


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 "";
}
/**
 * ???? ???? ??????? ?? ??
 * @return boolean
 */
function isNumStr(str) {
    var i;
    var ch;
    for (i=0;i<str.length;i++) {
        ch = str.charAt(i);
        if (isNum(ch) == false) {
            return false;
        }
    }
    return true;
}

function isNum(ch) {
    return (ch >= '0' && ch <= '9');
}


function checkIdNum(idbox1, idbox2) {
    idbox1.value = alltrim(idbox1.value);
    idbox2.value = alltrim(idbox2.value);

    var today = new Date();
    var chkYear1 = today.getYear();
    var chkYear2 = 0;
    if (chkYear1 < 2000)
        chkYear1 += 1900;
    var chk = 0;
    var chk2 = 0;
    var chk3 = 0;
    var yy = idbox1.value.substring(0,2);
    var mm = idbox1.value.substring(2,4);
    var dd = idbox1.value.substring(4,6);
    var chkSex = 0 + idbox2.value.substring(0,1);

    if ((idbox1.value.length != 6 ) ||
        (mm < 1 || mm > 12 || dd < 1) )
    {
        alert ("??????? ?? ???? ????.");
        idbox1.focus();
        return false;
    }

    if ((chkSex != 1 && chkSex !=2 && chkSex !=3 && chkSex !=4)
        || (idbox2.value.length != 7 )) {
        alert ("??????? ?? ???? ????.");
        idbox2.focus();
        return false;
    }

    chkYear2 = parseInt(yy,10);
    if (chkSex == 1  || chkSex == 2)
        chkYear2 += 1900;
    else if (chkSex == 3  || chkSex == 4)
        chkYear2 += 2000;

    //"14? ??? ??? ? ????."
    if (arguments.length > 2)
    {
        if ((chkYear1 - chkYear2) < arguments[2]) {
            alert(arguments[2] + "? ??? ??? ? ????.");
            idbox1.focus();
            return false;
        }
    }

    for (var i = 0; i <=5 ; i++) {
        chk = chk + ((i%8+2) * parseInt(idbox1.value.substring(i,i+1)))
    }
    for (var i = 6; i <=11 ; i++){
        chk = chk + ((i%8+2) * parseInt(idbox2.value.substring(i-6,i-5)))
    }

    chk = 11 - (chk %11)
    chk = chk % 10

    //"???? ?? ?????????."
    if (chk != idbox2.value.substring(6,7)) {
        alert ("???? ?? ?????????.");
        idbox1.focus();
        return false;
    }
    return true;
}

function checkPassword( pwdbox, pwdRebox ) {
    pwdbox.value = alltrim(pwdbox.value);

    if (pwdbox.value.length == 0) {
        alert("????? ?????.");
        pwdbox.focus();
        return false;
    }

    if (pwdbox.value.length < 4 || pwdbox.value.length > 10) {
        alert("????? 4?? ?? 10?? ?????.");
        pwdbox.focus();
        return false;
    }
    if (pwdRebox.value.length == 0)
    {
        alert("???? ??? ?????.");
        pwdRebox.focus();
        return false;
    }
    if (pwdbox.value != pwdRebox.value)
    {
        alert("????? ???? ?????.");
        pwdRebox.focus();
        return false;
    }
    return true;
}

function alltrim(str) {
    var i;
    var ch;
    var retStr = '';
    var retStr1 = '';
    if (str.length == 0)
        return str;
    for (i=0;i<str.length;i++) {
        ch = str.charAt(i);
        if (ch == ' ' || ch == '\r' || ch == '\n')
            continue;
         retStr += ch;
    }
    return retStr;
}

function checkCellPhone(phone1, phone2, phone3)
{
    phone1.value = alltrim(phone1.value);
    phone2.value = alltrim(phone2.value);
    phone3.value = alltrim(phone3.value);
    if (phone1.value.length == 0) {
        alert("?? ??? ????? ??? ???? ????.");
        phone1.focus();
        return false;
    }
    if (isNumStr(phone1.value) == false) {
        alert("?? ??? ????? ??? ????? ???.");
        phone1.focus();
        return false;
    }
    if (phone1.value.charAt(0) != "0") {
        alert("?? ??? ????? ??? 0?? ????? ???.");
        phone1.focus();
        return false;
    }
    if (phone1.value.length != 3) {
        alert("?? ??? ????? ??? 3????? ???.");
        phone1.focus();
        return false;
    }
    if (phone2.value.length == 0) {
        alert("?? ??? ??? ???? ????.");
        phone2.focus();
        return false;
    }
    if (isNumStr(phone2.value) == false) {
        alert("?? ??? ??? ????? ???.");
        phone2.focus();
        return false;
    }
    if (phone2.value.length != 3 && phone2.value.length != 4) {
        alert("?? ??? ??? 3?? ?? 4????? ???.");
        phone2.focus();
        return false;
    }
    if (isNumStr(phone3.value) == false) {
        alert("?? ??? ????? ????? ???.");
        phone3.focus();
        return false;
    }
    if (phone3.value.length != 4) {
        alert("?? ??? ????? 4????? ???.");
        phone3.focus();
        return false;
    }
    if (phone3.value.length == 0) {
        alert("?? ??? ????? ???? ????.");
        phone3.focus();
        return false;
    }
    return true;
}


function checkLinePhone(phone1, phone2, phone3, msg) {
    phone1.value = alltrim(phone1.value);
    phone2.value = alltrim(phone2.value);
    phone3.value = alltrim(phone3.value);
    if (phone1.value.length == 0) {
        alert(msg + " ????? ???? ????.");
        phone1.focus();
        return false;
    }
    if (isNumStr(phone1.value) == false) {
        alert(msg + "? ????? ????? ???.");
        phone1.focus();
        return false;
    }
    if (phone1.value.charAt(0) != "0") {
        alert(msg + "? ????? 0?? ????? ???.");
        phone1.focus();
        return false;
    }
    if (phone1.value.length < 2) {
        alert(msg + "? ????? 2?? ????? ???.");
        phone1.focus();
        return false;
    }
    if (phone2.value.length == 0) {
        alert(msg + " ??? ???? ????.");
        phone2.focus();
        return false;
    }
    if (isNumStr(phone2.value) == false) {
        alert(msg + " ??? ????? ???.");
        phone2.focus();
        return false;
    }
    if (phone2.value.length < 2) {
        alert(msg + " ??? 2?? ????? ???.");
        phone2.focus();
        return false;
    }
    if (phone3.value.length == 0) {
        alert(msg + " ????? ???? ????.");
        phone3.focus();
        return false;
    }
    if (isNumStr(phone3.value) == false) {
        alert(msg + " ????? ????? ???.");
        phone3.focus();
        return false;
    }
    if (phone3.value.length != 4) {
        alert(msg + " ????? 4????? ???.");
        phone3.focus();
        return false;
    }
    return true;
}

function checkEmail( emailbox ) {
    emailbox.value = alltrim(emailbox.value);

    if (emailbox.value.length == 0) {
        alert("????? ???? ?????.");
        emailbox.focus();
        return false;
    }

    if (isAllowStr(emailbox.value, "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_") == false) {
        alert("?????? ??? ?? - _ ? ??? ? ????.");
        return false;
    }
/*
    var atCnt = 0;
    var dotCnt = 0;
    for (i = 0; i < emailbox.value.length ; i++) {
        ch = emailbox.value.charAt(i);
        if (ch == "@")
            atCnt++;
        if (ch == ".") {
            dotCnt++;
        }
    }

    if (atCnt != 1 || dotCnt < 1) {
        alert ("???? ?? ???????.");
        emailbox.focus();
        return false;
    }

    var atIndex = 0;
    atIndex = emailbox.value.indexOf("@");

    if (atIndex <= 0) {
        alert ("???? ?? ???????.");
        emailbox.focus();
        return false;
    }
*/
    return true;
}

function isAllowStr(str, allowStr) {
    var i;
    var ch;
    for (i=0;i<str.length;i++) {
        ch = str.charAt(i);
        if (allowStr.indexOf(ch) < 0) {
            return false;
        }
    }
    return true;
}

//============ Top button===============
function setVariables(){
if (navigator.appName == "Netscape") {
v=".top=";h=".left=";dS="document.";sD="";
y="window.pageYOffset";x="window.pageXOffset";iW="window.innerWidth";iH="window.innerHeight"

}

else {h=".pixelLeft=";v=".pixelTop=";dS="";sD=".style";
y="document.body.scrollTop";x="document.body.scrollLeft";iW="document.body.clientWidth";iH="document.body.clientHeight"

}
xyz=500


object="logo";
checkLocationA()
}
movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0
function checkLocation(){
innerX=905
innerY=eval(iH)-50
if (document.layers){innerY-=0;innerX-=0}
yy=eval(y);
xx=eval(x);
ydiff=ystart-yy;
xdiff=xstart-xx;
if ((ydiff<(-1))||(ydiff>(1))) movey=Math.round(ydiff/10),ystart-=movey
if ((xdiff<(-1))||(xdiff>(1))) movex=Math.round(xdiff/10),xstart-=movex
eval(dS+object+sD+v+(ystart+innerY));
eval(dS+object+sD+h+(xstart+innerX));
setTimeout("checkLocation()",10)}

function checkLocationA(){ystart=eval(y);xstart=eval(x);}

function delayLogo(){
eval(dS+object+sD+v+0);          //
eval(dS+object+sD+h+0);      //and these three too
object='logo'                     //
}

function openWin(url){
	if ( url != null )
		AnotherWin = window.open(url,"AnotherWin","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
}

function sendMail() {
	winobject = window.open('','pop','width=500,height=546');
	document.pop.target = "pop";
	document.pop.action = "/cutility/emailPage.jsp";
	document.pop.submit();
}

function goURL(gURL) {

	document.urlForm.gURL.value = gURL;
	document.urlForm.action = "/cutility/otherSites.jsp";
	document.urlForm.submit();
}

function goCeo(co_id)
{
	document.pForm.co_id.value = co_id;
	document.pForm.cmd.value = "cView";
	document.pForm.action = "/cabout/ceo/list/affiliate.jsp";
	document.pForm.submit();
}
function openWorldPrint(url)
{
	window.open(url,'printResult','scrollbars=yes,width=463,height=500');
}
function openMail(tid, type) {
	window.open('/ccommon/protectEmail.jsp?cmd=noSpam&tid='+tid+'&type='+type,'noSpam','width=250,height=300,left=350,top=250');
}
