//¸µÅ©ÀÇ Æ÷Ä¿½º¸¦ ¾ø¾Ø´Ù
function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=bluring;



//·Ñ¿À¹ö ÀÌ¹ÌÁö
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_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_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];}
}



//»õÃ¢¶ç¿ì±â
var win = null;
function NewWin(url,winname,w,h,scroll){
winToTop = (screen.height) ? (screen.height-h)/2 : 0;
winToLeft = (screen.width) ? (screen.width-w)/2 : 0;

making =
'height='+h+',width='+w+',top='+winToTop+',left='+winToLeft+',scrollbars='+scroll+',resizable=no'
win = window.open(url,winname,making)
}



//ÇÏ´Ü ·¹ÀÌ¾î ¶ç¿ì±â
function layer() { //v2.0
  var i, visStr, args, theObj,br;
  args = layer.arguments;
  for (i=0; i<(args.length-1); i+=2) {
    visStr   = args[i+1];
    if (navigator.appName == 'Netscape' && document.layers != null) {
      theObj = eval('document.layers[\''+args[i]+'\']');
      if (theObj) theObj.visibility = visStr;
    } 
    else if (document.all != null) { //IE
      if (visStr == 'show') visStr = 'visible'; //convert vals
      if (visStr == 'hide') visStr = 'hidden';
      theObj = eval('document.all[\''+args[i]+'\']');
      if (theObj) theObj.style.visibility = visStr;
    } 
  }
return false;
}
function view(a) {
  if (a==1) {
  	layer('Layer_map','hide','Layer_schedule','hide');
  }
  if (a==2) {
  	layer('Layer_map','show','Layer_schedule','hide');
  }
  if (a==3) {
  	layer('Layer_map','hide','Layer_schedule','show');
  }
  if (a==4) {
  	layer('Layer_map_main','hide','Layer_schedule_main','hide');
  }
  if (a==5) {
  	layer('Layer_map_main','show','Layer_schedule_main','hide');
  }
  if (a==6) {
  	layer('Layer_map_main','hide','Layer_schedule_main','show');
  }
}



/**
 * »õÃ¢À» Áß¾Ó¿¡ ¶ç¿ì±â
 */
function OpenNewWindowAtCenter( url , windowName , vWinWidth , vWinHeight , alertMsg , confirmMsg , isScroll ) {
	var xPos = (screen.width  - vWinWidth) / 2 ;
	var yPos = (screen.height - vWinHeight) / 2 ;	
	var urlOption  = "toolbar=no, status=no, location=no, menubar=no, scrollbars="+isScroll+", resizable=no, copyhistory=no";
	    urlOption += ", title=" + windowName ;
	    urlOption += ", width=" + vWinWidth + ", height=" + vWinHeight ;
	    urlOption += ", top=" + yPos + ", left=" + xPos ;
	    
	var newWindow = null;
	if ( confirmMsg != null && confirmMsg.length > 0 ) {
		if ( confirm(confirmMsg) )
			newWindow = window.open( url , windowName , urlOption );
		
	} else if ( alertMsg != null && alertMsg.length > 0 ) {
		alert(alertMsg);
		newWindow = window.open( url , windowName , urlOption );
		
	} else {
		newWindow = window.open( url , windowName , urlOption );
		
	}
	//return newWindow;
}

// ·Î±äÃ¢
function openLoginWin() {
	var url        = "login2.asp";
	var windowName = "loginWin";
	var vWinWidth  = 450;
	var vWinHeight = 300;
	OpenNewWindowAtCenter( url , windowName , vWinWidth , vWinHeight , null , null , 'no' );
}
// ·Î±×¾Æ¿ôÃ¢
function openLogoutWin() {
	var url        = "/htm/common/logout.asp";
	var windowName = "loginWin";
	var vWinWidth  = 450;
	var vWinHeight = 300;
	OpenNewWindowAtCenter( url , windowName , vWinWidth , vWinHeight , null , null , 'no' );
}

// change url
function changeURL( pURL ) {
	if ( pURL != null && pURL.length > 0 )
	{
		location.href = pURL;
	}
}

// ÀÔ·Â ºÒ°¡ Ã³¸®
function noInput() {
	event.returnValue = false;
}

// Return the file size 
function _GetFileSize(selectedFileFullPath) {
    var len = 0;
    // ¸ðÁú¶ó
    if ( navigator.appName.indexOf("Netscape") != -1) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
        } catch(e) {
            alert("signed.applets.codebase_principal_support¸¦ ¼³Á¤ÇØÁÖ¼¼¿ä!\n"+e);
            return -1;
        }
        try {
            var file = Components.classes["@mozilla.org/file/local;1"]
                                 .createInstance(Components.interfaces.nsILocalFile);
            file.initWithPath ( selectedFileFullPath );
            
            len = file.fileSize;
        } catch(e) {
            alert("¿¡·¯ ¹ß»ý:"+e);
        }
// IE
    } else if (navigator.appName.indexOf('Microsoft') != -1) {
        var img = new Image();
        img.dynsrc = selectedFileFullPath;
        len = img.fileSize;
    }
    return len;
}
// ÆÄÀÏ Å©±â¸¦ Ã¼Å©ÇÑ´Ù.
function checkLimitedFilesize( fileObj, limitedSize ) {
	var selectedFile = fileObj.value;
	var selectedSize = _GetFileSize(selectedFile);
	if ( limitedSize <  selectedSize ) {
		alert("ÃÖ´ë Å©±â¸¦ ³Ñ¾î ¾÷·Îµå ÇÒ ¼ö ¾ø½À´Ï´Ù.\n[ÃÖ´ëÅ©±â:"+ limitedSize +", ¼±ÅÃÇÑ ÆÄÀÏÅ©±â:"+ selectedSize +"]");
		fileObj.value = "";
	}
}

// ÆÄÀÏÀÇ È®ÀåÀÚ Å¸ÀÔÀÌ ¸Â´ÂÁö
function isRightExtName( type , filename ) {
	var rtVal  = true;
	var ext_nm = "";
	var extpos = filename.indexOf(".");
	if ( extpos == -1 ) {
		return false;
	}
	extpos = filename.substring(extpos+1);
	
	
	// µ¿¿µ»ó :: MOVIE
	if ( type == 'MOVIE' ) {
		switch(extpos.toLowerCase()) {
			case 'wmv': 
			case 'mpg': 
			case 'asf': 
			case 'avi': 
			case 'asx': 
				rtVal = true;
				break;
				
			default:
				rtVal = false;
				break;
		}
		
	// ÀÌ¹ÌÁö :: IMAGE
	} else {
		switch(extpos.toLowerCase()) {
			case 'gif': 
			case 'png': 
			case 'jpg': 
				rtVal = true;
				break;
				
			default:
				rtVal = false;
				break;
		}
	}
	return rtVal;
}

// ÆÄÀÏ È®ÀåÀÚ °Ë»ç & ÆÄÀÏÀÇ Å©±â Á¦ÇÑ °Ë»ç¸¦ µ¿½Ã¿¡...
function AttachCheck( fileObj, limitedSize , type ) {
	var fname     = fileObj.value;
	var idx       = fname.lastIndexOf("\\");
	    fname     = fname.substring(idx+1);
	
	if ( isRightExtName(type, fname) ) {
		checkLimitedFilesize( fileObj, limitedSize ) ;
	} else {
		alert("ÆÄÀÏ À¯Çü¿¡ ¸ÂÁö ¾Ê½À´Ï´Ù. ´Ù½Ã ¼±ÅÃÇØ ÁÖ½Ê½Ã¿ä.");
		fileObj.value = "";
		fileObj.focus();
	}
}

