/*
----------------------------------------------------
* 파일 이름  : script.js
* 버전 정보 : 1.0
* 메뉴 : 공통
* 작성자 : 윤소정(sommi@empascorp.com)
* 작성일 : 2007.09.20
* 설명 : 공통 스크립트
* 수정일 : 
* 수정자 : 
----------------------------------------------------
*/

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.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; }
}

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_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];}
}

// 페이지 focus blur
function bluring(){
	if (event.srcElement!=null) {
		if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
	}
}
document.onfocusin=bluring;

// 이미지 온,오프 처리
function imgOnOff(obj, bln_act) {
	var objsrc = obj.src;
	if(bln_act) {
		if(objsrc.indexOf("_on.gif")<0) obj.src = objsrc.replace(".gif", "_on.gif");
	}
	else{
		if(objsrc.indexOf("_on.gif")>0) obj.src = objsrc.replace("_on.gif", ".gif");
	}
}

//플래시 
function writeObject (files, name, width, height) {
//		 + '<param name="allowScriptAccess" value="always" />'
//		 + '<embed wmode="opaque" src="' + files + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="'+ height +'" name="'+ name +'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" autostart="true" /></object>';
	var sTag = '' 
	 + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ width + '" height="'+ height + '" id="'+ name +'" align="middle">'
		 + '<param name="allowScriptAccess" value="never" />'	 
		 + '<param name="FlashVars" value="" />'
		 + '<param name="movie" value="' + files + '" />'
		 + '<param name="quality" value="high" />'
		 + '<param name="bgcolor" value="#ffffff" />'
		 + '<param name="wmode" value="opaque" />'
		 + '<param name="menu" value="false" />'
		 + '<embed wmode="opaque" src="' + files + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="'+ height +'" name="'+ name +'" align="middle" allowScriptAccess="never" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" autostart="true" /></object>';
		document.write (sTag);
	}

function writeObject2(buf) {
    document.write(buf) ;
}
function aviPlay(_src,_w,_h) {
	document.write('<embed src="'+_src+'" type="audio/mpeg" width='+_w+' height='+_h+' style=\"background:#000;\" animationAtStart=\"0\" TransparentAtStart=\"1\"></embed>')
}

function vi_Layer() {
obj2.style.display = "";
}
function ex_Layer() {
obj2.style.display = "none";
}
var obj2 = document.getElementById("layerNotes");
var vReceiverId ='';
var vReceiverNick = '';
var vUserId = '';
var vFlag = '';

// 삼국사기에서 사용하는 주석 레이어 표시
function show_Layer(obj, receiverNick, evt, x, y) {
  obj2 = document.getElementById("layerNotes");
  vReceiverNick = receiverNick;

	if (document.getElementById){ 
        x = evt.clientX; 
        y = evt.clientY; 
    } 

	//alert(x+","+y);
	//x = MB_GetObjectLeft(obj); 
	//y = MB_GetObjectTop(obj); 
	obj2.style.left=x+220;
	obj2.style.top=y+215;
	
	if(obj2.style.display==""){
	  obj2.style.display=""; //마우스아웃이나 재클릭시 효과
  } else {
	  obj2.style.display="";
  }
  document.getElementById("ListUserName").innerHTML = "\"" + receiverNick + "\"";
}

// 청구야담에서 사용하는 주석 레이어 표시
function show_Layer2(obj, receiverNick, evt, x, y) {
  obj2 = document.getElementById("layerNotes");
  vReceiverNick = receiverNick;

	if (document.getElementById){ 
        x = evt.clientX; 
        y = evt.clientY; 
    } 

	//x = MB_GetObjectLeft(obj); 
	//y = MB_GetObjectTop(obj); 
	obj2.style.left = x + 10;
	obj2.style.top = document.body.scrollTop + y + 15;
	
	if(obj2.style.display==""){
	  obj2.style.display=""; //마우스아웃이나 재클릭시 효과
  } else {
	  obj2.style.display="";
  }
  document.getElementById("ListUserName").innerHTML = "\"" + receiverNick + "\"";
}

function MB_GetObjectTop(obj) { 
  if(obj.offsetParent == document.body) 
	return obj.offsetTop; 
  else 
	return obj.offsetTop + MB_GetObjectTop(obj.offsetParent); 
} 
function MB_GetObjectLeft(obj) { 
  if(obj.offsetParent == document.body) 
	return obj.offsetLeft; 
  else 
  return obj.offsetLeft + MB_GetObjectLeft(obj.offsetParent); 
} 