

// This will stop image flickering in IE6 when elements with images are moved
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}


function openWin(url, w, h, name, bScrollbar, t, l) {

    if(bScrollbar == null)
        bScrollbar = 0;

    if(name == null)
        name = "popWin";

    if(t == null)
        t = (screen.height-h)/2;

    if(l == null)
        l = (screen.width-w)/2;

    var PopWin = window.open(url, name, "toolbar=0, channelmode=0, location=0, directories=0, resizable=0, menubar=0, scrollbars="+ bScrollbar +", width=" + w + ", height=" + h +", top="+t+", left="+l);

    if(PopWin == null){
        alert('ÆË¾÷ÀÌ Â÷´ÜµÇ¾î ÀÖ½À´Ï´Ù.\n\nÈ­¸é »ó´ÜÀÇ Â÷´Ü¸Þ¼¼Áö¸¦ Å¬¸¯ÇÏ¿© ÆË¾÷À» Çã¿ëÇØÁÖ¼¼¿ä.');
        return;
    }

    PopWin.focus();

	return PopWin;

}


// µ¿¿µ»ó, »çÁø. À½¼º ÀÚ·á¸¦ ¿­¶÷ÇÑ´Ù.
// mtype¿¡ µû¶ó ¹Ìµð¾î¸¦ ±¸ºÐÇÏ¿© ¿ÀÇÂµÇ´Â À©µµ¿ì¸¦ °áÁ¤ÇÑ´Ù.
// mtype == V ÀÌ¸é µ¿¿µ»ó
// mtype == P ÀÌ¸é »çÁø
// mtype == S ÀÌ¸é À½¼º

// msrc = MEDIASRCGBN
// mid = MEDIAID
// mdtl = MEDIADETAILID
// gbn = MEDIAGBN
// flag = µ¿¿µ»ó ½ÃÃ»½Ã ÀÏ¹ÝÈ­Áú, °íÈ­Áú ¿©ºÎ (0:ÀÏ¹Ý, 1:°íÈ­Áú)

function open_content(mtype, msrc, mid, mdtl, gbn, flag) {

	var url = "";
	var features ="";
	
	features = "width=848, height=590, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";
	
	// µ¿¿µ»óÀÎ °æ¿ì
	if (mtype == "V") {
		url = "/pop/movie_pop.jsp?srcgbn="+msrc+"&mediaid="+mid+"&mediadtl="+mdtl+"&gbn="+gbn+"&quality="+flag;
	}
	// »çÁøÀÎ °æ¿ì
	else if (mtype == "P") {
		if (msrc == "PT") {										// ±¹°¡±â·Ï»çÁøÀÎ °æ¿ì
			url = "/pop/photo_pop.jsp?photo_PhotoSrcGBN="+msrc+"&photo_PhotoID="+mid+"&detl_PhotoDTL="+mdtl;
		}
		else {													// ±¹°¡±â·Ï»çÁø ÀÌ¿ÜÀÇ »çÁø
			url = "/pop/photo_pop2.jsp?photo_PhotoSrcGBN="+msrc+"&photo_PhotoID="+mid+"&detl_PhotoDTL="+mdtl;
		}
		features = "width=848, height=590, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";
	}
	// À½¼ºÀÎ °æ¿ì
	else if (mtype == "S") {
		url = "/pop/audio_pop.jsp?srcgbn="+msrc+"&mediaid="+mid+"&mediadtl="+mdtl+"&gbn="+ gbn;
		features = "width=690, height=525, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";
	}
	else{														// ¿À·ù Ã³¸®
		alert("Àß¸øµÈ ¿äÃ»ÀÔ´Ï´Ù.");
		return;
	}

	// url °ªÀÌ ¼³Á¤µÇ¾úÀ» °æ¿ì¿¡¸¸ À©µµ¿ì ¿ÀÇÂ
	if (url != "")	window.open(url, "ehistory_popup", features);

}

//ÀÓ½Ã ÇÔ¼ö
function open_content_test(mtype, msrc, mid, mdtl, gbn, flag) {

	var url = "";
	var features ="";
	
	features = "width=848, height=590, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";
	
	// µ¿¿µ»óÀÎ °æ¿ì
	if (mtype == "V") {
		url = "/pop/movie_pop.jsp?srcgbn="+msrc+"&mediaid="+mid+"&mediadtl="+mdtl+"&gbn="+gbn+"&quality="+flag;
	}
	// »çÁøÀÎ °æ¿ì
	else if (mtype == "P") {
		if (msrc == "PT") {										// ±¹°¡±â·Ï»çÁøÀÎ °æ¿ì
			url = "/pop/photo_pop_test.jsp?photo_PhotoSrcGBN="+msrc+"&photo_PhotoID="+mid+"&detl_PhotoDTL="+mdtl;
		}
		else {													// ±¹°¡±â·Ï»çÁø ÀÌ¿ÜÀÇ »çÁø
			url = "/pop/photo_pop2.jsp?photo_PhotoSrcGBN="+msrc+"&photo_PhotoID="+mid+"&detl_PhotoDTL="+mdtl;
		}
		features = "width=848, height=590, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";
	}
	// À½¼ºÀÎ °æ¿ì
	else if (mtype == "S") {
		url = "/pop/audio_pop.jsp?srcgbn="+msrc+"&mediaid="+mid+"&mediadtl="+mdtl+"&gbn="+ gbn;
		features = "width=690, height=525, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";
	}
	else{														// ¿À·ù Ã³¸®
		alert("Àß¸øµÈ ¿äÃ»ÀÔ´Ï´Ù.");
		return;
	}

	// url °ªÀÌ ¼³Á¤µÇ¾úÀ» °æ¿ì¿¡¸¸ À©µµ¿ì ¿ÀÇÂ
	if (url != "")	window.open(url, "ehistory_popup", features);

}

// ´ëÇÑ´º½º, ´ëÇÑ´º½º KC È£¼ö ÀüÃ¼ ¿µ»óÀ» º¸±â À§ÇÑ ÇÔ¼ö
function open_contentsall(msrc, mid, gbn, flag) {
	var url = "/pop/movie_popall.jsp?srcgbn="+msrc+"&mediaid="+mid+"&gbn="+gbn+"&quality="+flag;
	var features = "width=500, height=500, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";

	window.open(url, "ehistory_popup", features);
 }


function goto_flashconts(fid, url) {
	document.location.href = "/iframe/flash_count.jsp?flashid="+fid+"&url="+url;
}



// IE Eolas Patch ¿ìÈ¸ ½ºÅ©¸³Æ®
function IE_HtmlRewrite(objParent) {
	if (window.ActiveXObject && objParent) {
		objParent.innerHTML = objParent.innerHTML;
	}
}


// ÇØ´çÀÏÀÇ ¿äÀÏ ±¸ÇÏ±â
// @param date 2007-01-01 Çü½ÄÀ¸·Î ÀÔ·Â

var weeks = new Array("ÀÏ", "¿ù", "È­", "¼ö", "¸ñ", "±Ý", "Åä");

function getWeekName(date) {
	var splitDate = date.split("-");
	var checkDate = new Date(splitDate[0],splitDate[1]-1,splitDate[2]);

	return weeks[checkDate.getDay()];
}


// ±â°üº° ¹®È­ÄÁÅÙÃ÷ º¸±â ÆË¾÷

function popMuseum(url) {
	var features = "width=848, height=624, toolbar=0, directories=0, scrollbars=no, resizable=0, status=0";
	window.open(url, "museum", features);
}


function ajaxPaginate(url, divId){
	new Ajax.Updater(
		divId,
		url,
		{
		asynchronous: true,
		evalScripts: true,
		method: 'get',
		onFailure:function(request){alert("¿À·ù!!\n\nHTTP Error "+ request.status +" \n\n¼­¹ö¿ÍÀÇ Åë½ÅÀ» ±¸¼ºÇÏÁö ¸øÇÏ¿´½À´Ï´Ù.")}
		}
	);
}


/**********************************************************************/

Tree = Class.create();

Tree.prototype = {
   initialize: function( element, options ) {
      this.ul = $(element);
      this.lis = new Array();

      this.options = {
         element: Tree.Node
      }
      Object.extend( this.options, options );

      this.setup();

	  $(element).style.display = "block";
   },

   setup: function() {
      var name = "";
      var children = this.ul.immediateDescendants();

      children.each( function( child ) {
         name = child.tagName || "";
         if( name != "LI" )
            return;

         this.lis.push( new this.options.element( child, this.options ) );

      }.bind( this ) );



   }


};

/**********************************************************************/

Tree.Node = Class.create();
Tree.Node.prototype = {
   initialize: function( element, options ) {
      this.li = $( element );
      this.uls = new Array();
      this.root = false;

      this.options = {
         more: '/images/plus.png',
         less: '/images/minus.png'
      }
      Object.extend( this.options, options );

      this.setup();


   },

   setup: function() {
      var name = "";
      var children = this.li.immediateDescendants();

      children.each( function( child ) {
         name = child.tagName || "";
         if( name != "UL" )
            return;

         this.uls.push( new Tree( child, this.options ) );
		 child.style.display = "none";
      }.bind( this ) );


      this.checkRoot();
   },

   checkRoot: function( ) {
      if( this.uls.length == 0 ) {
		  Element.addClassName( this.li, 'bullet' );
		  this.tog = Builder.node( 'img',
			 { className: 'bullet', src: this.options.less , alt: '¸¶Áö¸·¸Þ´º'} );
		  this.li.insertBefore( this.tog, this.li.childNodes[0] );

		  return;
	  }

      this.root = true;
      Element.addClassName( this.li, 'root' );
      //this.tog = Builder.node( 'img',{ className: 'toggle', src: this.options.more, alt: 'ÇÏÀ§¸Þ´ºÇ¥½Ã' });
      //this.tog = Builder.node('a',{href: '#', onclick: 'return false;'},Builder.node( 'img',{ id:'toggle' , className: 'toggle', src: this.options.more, alt: 'ÇÏÀ§¸Þ´ºÇ¥½Ã' }));
      this.tog= Builder.node( 'input',{ className: 'toggle' ,type: 'image', src: this.options.more, title: 'ÇÏÀ§¸Þ´ºÇ¥½Ã',onclick: 'return false;' });
      this.li.insertBefore( this.tog, this.li.childNodes[0] );
      this.tog.onclick = this.closeChildren.bindAsEventListener( this );
   },

   closeChildren: function( event ) {
      var node;
	   event.cancelBubble = true;

	  this.uls.each( function( ul ) {
         node = ul.ul;
         if( node.visible() ) {
            new Effect.SwitchOff(node);
           this.tog.src = this.options.more;
           
         }
         else {
           new Effect.BlindDown(node);
            this.tog.src = this.options.less;
            
         }
      }.bind( this ) );
   }




};



// playerWrite(ÆÄÀÏ°æ·Î, °¡·Î, ¼¼·Î, ¾ÆÀÌµð)
function playerWrite(src, pid, options){

	// ¹Ìµð¾î ÄÚµå Ãâ·Â
	document.writeln(getPlayer(src, pid, options));

}

function getPlayer(src, pid, options){

	//±×¿Ü embed
	var MEDIA_TYPE = "video/x-ms-asf-plugin";
	var PLUGIN_PAGE = "http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/";

	var objectStr = "<object id='"+ pid +"' data='"+ src +"' "+ ((options.width) ? ("width='"+ options.width +"' ") : "") + ((options.height) ? ("height='"+ options.height +"' ") : "") +"type='video/x-ms-asf-plugin'>";

	try{

		var features = options.features.split(/\s*,\s*/);

		for(var i=0;i<features.length;i++){
			var temp = features[i].split(/\s*=\s*/);
			objectStr += "<param name='"+ temp[0] +"' value='"+ temp[1] +"'>";
		}

	}catch(e){/*alert(e.message);*/}

	objectStr += "<embed id='"+ pid +"' type='"+ MEDIA_TYPE +"' pluginspage = '"+ PLUGIN_PAGE +"' src='"+ src +"' "+ ((options.width) ? ("width='"+ options.width +"' ") : "") + ((options.height) ? ("height='"+ options.height +"' ") : "") +"autostart='true' controller='true'></embed></object>";

	/*
	//var objectStr = "<object id='"+ customId +"Object' "+ ((w) ? ("width='"+ w +"' ") : "") + ((h) ? ("height='"+ h +"' ") : "") +"classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>" ;
	//var objectStr = "<object id='"+ customId +"Object' "+ ((w) ? ("width='"+ w +"' ") : "") + ((h) ? ("height='"+ h +"' ") : "") +"classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>" ;
	objectStr += "<param name='AutoStart' value='"+ ((autoStart) ? '1' : '0') +"'>";
	objectStr += "<param name='AutoSize' value='1'>";
	objectStr += "<param name='AutoReSize' value='1'>";
	//objectStr += "<param name='uiMode' value='full'>";
	if(src != null)objectStr += "<param name='FileName' value='"+ src +"'>";
	objectStr += "<param name='ShowStatusBar' value='1'>";
	objectStr += "<param name='EnableContextMenu' value='1'>";
	objectStr += "<param name='AnimationAtStart' value='1'>";
	//objectStr += "<PARAM NAME='rate' VALUE='1'><PARAM NAME='balance' VALUE='0'>";
	objectStr += "<embed id='"+ customId +"Embed' type='' pluginspage = '' "+ ((src != null) ? ("src='"+ src +"' ") : " ") + ((w) ? ("width='"+ w +"' ") : "") + ((h) ? ("height='"+ h +"' ") : "") +"autostart='"+ autoStart +"' controller='true'></embed>";
	objectStr += "</object>";*/

	return objectStr;

}