/* Javascript Document */

/*---------------------------------------------------
 * 특정개체 이미지 바꾸기
 * change_img_src(name, nsdoc, rpath)
 * param name 이미지 개체 이름
 * param nsdoc 브라우저 체크 (ex : document)
 * param rpath 이미지 경로
-------------------------------------------------------*/
function change_img_src(name, nsdoc, rpath)
{
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img) {
    img.altsrc = img.src;
    img.src    = rpath;
  }
}

/*---------------------------------------------------
 * 특정개체 이미지 복구시키기
 * restore_img_src(name, nsdoc)
 * param name 이미지 개체 이름
 * param nsdoc 브라우저 체크 (ex : document)
-------------------------------------------------------*/
function restore_img_src(name, nsdoc)
{
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img && img.altsrc) {
    img.src    = img.altsrc;
    img.altsrc = null;
  }
}


/*---------------------------------------------------
 * CBN 서브메뉴 롤오버
 * roll(name, rpath)
 * param name 이미지 개체 이름
 * param part 서브폴더 이름 (homepage)
 * param num 동작상태 (1:오버, 2:복구)
-------------------------------------------------------*/
function roll(name, part, mode)
{
	switch(mode){
		case 1:
			var img_src = '/contents/common/'+ part +'_On.png';
			change_img_src(name, 'document', img_src);
		break;
		default:
			restore_img_src(name, 'document');
	}
}

/*---------------------------------------------------
 * 이미지 점선 없애기
 * document.onfocusin=bluring;
-------------------------------------------------------*/
function bluring(){
// input box Key Event 캐취를 취소 시키므로 INPUT 관련 점선은 빼도록 수정(김경규-071122)
// input type를 검사해 image일경우에만 점선을 없애도록 수정 (백형주-071122)
//if(event.srcElement.tagName=="INPUT"||event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") 
//if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") 
	if(event.srcElement.type=="image"||event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") 
		document.body.focus();
}
document.onfocusin=bluring;


/**
 * 플래시 및 미디어 오브젝트 삽입
 * ex) 예제소스
 * --------------------------------------------
 * ObjectName = new setEmbed();
 * ObjectName.init(mode, url, width, height);
 * ObjectName.parameter(paramName,paramValue);
 * ObjectName.show();
 * --------------------------------------------
 * @param mode 오브젝트의 종류 (flash 또는 media)
 * @param url 오브젝트 소스의 경로(주소)
 * @param width 오브젝트의 가로크기
 * @param height 오브젝트의 세로크기
 * @param paramName 오브젝트 파라메터 이름
 * @param paramValue 오브젝트 파라메터 값
*/

function setEmbed()
{
  var obj = new String;
  var parameter = new String;
  var embed = new String;
  var html = new String;
  var allParameter = new String;
  var clsid = new String;
  var codebase = new String;
  var pluginspace = new String;
  var embedType = new String;
  var width = new String;
  var height = new String;
  var objectId = new String;

  //## 오브젝트 초기화
  this.init = function( getType , s ,w , h ) {
  	getType = (getType != undefined)? getType :'flash';

      if ( getType == "flash" ) //##플래시
      {
		clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
		codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
		pluginspage = "http://www.macromedia.com/go/getflashplayer";
		embedType = "application/x-shockwave-flash";

		parameter += "<param name='movie' value='"+ s + "'>";
		parameter += "<param name='quality' value='best'>";
		parameter += "<param name='menu' value='false'>";
		parameter += "<embed src="+s+" quality=best type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"transparent\" allowScriptAccess=\"always\" width="+w+" height="+h+">";
      }
      else if ( getType == "media" ) //## 미디어 플레이어
      {
        clsid = "6BF52A52-394A-11d3-B153-00C04F79FAA6";
        codebase = "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701";
        pluginspage = "http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/";
        embedType = "application/x-oleobject";

		parameter += "<PARAM NAME='URL' VALUE='" + s + "'>";
      }

      width = w;
      height = h;
  }

  //## 오브젝트 파라메터 생성
  this.parameter = function( parm , value ) {
      parameter += "<param name='"+parm +"' value='"+ value + "'>";
      allParameter += " "+parm + "='"+ value+"'";
  }

  //## 오브젝트 객체이름 지정
  this.id = function( id ) {
      objectId = 'id="'+ id +'" name="'+ id +'"';
  }

  //## 오브젝트 HTML출력
  this.show = function() {
      if ( clsid )
      {
				if(objectId != null) objectId = objectId; else objectId = '';

        obj = "<object classid=\"clsid:"+ clsid +"\" codebase=\""+ codebase +"\" width='"+ width +"' height='"+ height +"' type='"+ embedType +"' " + objectId + ">";
      }

      if ( obj )
      {
        embed += "</object>";
      }

      html = obj + parameter + embed;

      document.write(html);
  }
}


/**---------------------------------------------------------
 * 새창 팝업
 * ex) popWin('../popup.php','popup',300,300,'no','no','no');
 * @param url 새창에 뛰울 페이지 경로
 * @param name 새창이름
 * @param width 새창 width
 * @param height 새창 height
 * @param status 새창 상태바 유무
 * @param scrollbars 새창 스크롤바 유무
 * @return null
-----------------------------------------------------------*/
function popWin(url, name, width, height, status, scrollbars, resize) {
	var window_left = (screen.width-width)/2;
	var window_top = (screen.height-height)/2;
	openwin = window.open(url,name,'resizable='+resize+',width='+width+',height='+height+',status='+status+',scrollbars='+scrollbars+',top='+ window_top+',left='+ window_left+'');
	if (openwin == null){
		alert("차단된 팝업창을 허용해 주십시오.");
	}
}

