sDomain=document.domain;
rDomain=sDomain.split('.');
document.domain=rDomain[rDomain.length-2]+"."+rDomain[rDomain.length-1];

window.onload=onLoadInit;
var prevWidth = 0;
var prevHeight = 0;

function onLoadInit() {
	if ( document.getElementById('LoginBox') ) {
		loginFormFocus();
		DetectActiveXControl();
	} else {
		fileboxResize();
		window.onresize=fileboxResize;
		if ( document.getElementById('filebox') && Installed == true ) 
			guage_relod();		
	//	setTimeout("fileboxAutoGuage()", 5000);
	}
}

function fileboxResize() {
	if ( document.getElementById('filebox') && Installed == true ) {
		rewidth = document.body.clientWidth-20;
		reheight = document.body.clientHeight-240;
		if ( rewidth < 1000 ) rewidth = 1000;
			rewidth = (rewidth-(rewidth%2));
		if ( reheight < 522 ) reheight = 522;

		if ( prevWidth != rewidth || prevHeight != reheight) {
			document.getElementById('filebox').SetControlSize(rewidth,reheight);
			document.getElementById('filebox').width = rewidth;
			document.getElementById('filebox').height = reheight;
			prevWidth = rewidth;
			prevHeight = reheight;
		}
	}
	if ( document.getElementById('myFilebox') ) {
			
		rewidth = document.body.clientWidth-40;
		reheight = document.body.clientHeight-260;
		
		if ( rewidth < 1000 ) rewidth = 1000;
			rewidth = (rewidth-(rewidth%2));
		if ( reheight < 533 ) reheight = 533;

		if ( prevWidth != rewidth || prevHeight != reheight) {
			//document.getElementById('myFilebox').SetControlSize(rewidth,reheight);
			document.getElementById('myFilebox').width = rewidth;
			document.getElementById('myFilebox').height = reheight;
			prevWidth = rewidth;
			prevHeight = reheight;
		}

	}

}

function loginFormFocus() {

	if ( document.loginform.userid.value != "" && document.loginform.userid.value != "¾ÆÀÌµð" ) {
		document.loginform.passwd.focus();
	} else {
		document.loginform.userid.focus();
	}
}

function onView(Width, Height, URL)
{
		var viewpage = window.open(URL, 'popup', 'scrollbars=auto, left=0,top=0,width='+Width+',height='+Height);
		viewpage.focus();
}

function changeSecureOpt(oTarget) {

		sSecVal = oTarget.value;
		if ( sSecVal!=2 ) {
				setSecOff();
		} else {
				setSecOn();
		}
}

function setSecOn() {
		document.getElementById('loginformSec').value=1;
		document.getElementById('loginformSecImg').src="http://img.nate.com/filebox/img_200708/logsecurity_on.gif";
}

function setSecOff() {
		document.getElementById('loginformSec').value=2;
		document.getElementById('loginformSecImg').src="http://img.nate.com/filebox/img_200708/logsecurity_off.gif";
}

function getSecVal() {
		return document.getElementById('loginformSec').value;
}

function SetFocus() {
		var f = document.forms[0];

		if ( f.userid.value == "" ) {
				f.userid.focus();
		} else {
				f.passwd.focus();
		}

}

function LoginSubmit(oForm) {
	sID = oForm.userid.value;
	sPW = oForm.passwd.value;
	nSec = oForm.Sec.value;

	if (sID=="" || sID=="¾ÆÀÌµð") {
		alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä');
		oForm.userid.focus();
		return false;
	}
	if (sPW=="" || sPW=="ºñ¹Ð¹øÈ£") {
		alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä');
		oForm.passwd.focus();
		return false;
	}

	if ( nSec == 1 ) {
		oForm.action = oForm.action.replace("http://", "https://");
	} else {
		oForm.action = oForm.action.replace("https://", "http://");
	}
	oForm.ID.value = oForm.userid.value + "@empas.com";
	oForm.PASSWD.value = oForm.passwd.value;
	return true;
}

function guage_relod() {
	//if ( document.getElementById('usage_manager'))
	document.getElementById('usage_manager').src='filebox_usage_man.html';
	//else 
	//document.getElementById('usage_manager').location.reload();
}

function fileboxAutoGuage() { 
	guage_relod();
	setTimeout("fileboxAutoGuage()", 5000);	
}

function Overimg(id){
	var idEl = document.getElementById(id);
	idEl.src =  idEl.src.replace(".gif", "_on.gif");
}

function Outimg(id){
	var idEl = document.getElementById(id);
	idEl.src =  idEl.src.replace("_on.gif", ".gif");
}
