/* flash */
function commonFlash(pSwfUrl, w,h,id){	
	var pathArr = pSwfUrl.split("/");
	var flashID = pathArr[pathArr.length-1].split(".")[0];

	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>");
	document.write("<param name='allowScriptAccess' value='always' />");
	document.write("<param name='movie' value='"+pSwfUrl+"' />");
	document.write("<param name='quality' value='high' />");
	document.write("<param name='wmode' value='transparent' />");
	document.write("<embed src='"+pSwfUrl+"' quality='high' wmode='transparent' width='"+w+"' height='"+h+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write("</object>"); 
}

/* zoom in out */
function jf_setFontSize(param,id) {
	var defaultFontSize = 1;//em
	var minFontSize = 1;//em
	var maxFontSize = 2;//em
	obj = document.getElementById(id);

	switch (param) {
		case "magnify" :		// 크게보기
			a = 1;
			break;
		case "reduce" :			// 작게보기
			a = -1;
			break;
		case "restore" :		// 원래대로
			a = 0;
			break;
		case "initial" :
			break;
		default :						// 불법접근
			alert("불법적인 접근입니다.");
			break;
	}

	var objFontSize = obj.style.fontSize;

	if (!objFontSize) { 
		objFontSize = parseFloat(defaultFontSize)+"em"; 
	}
	
	if (a==0) {
		var checkFontSize = parseFloat(defaultFontSize);
	}
	else {
		var checkFontSize = (Math.round(12*parseFloat(objFontSize))+(a))/12;
	}
	

	if (checkFontSize > maxFontSize) { 
		checkFontSize = maxFontSize; 
		obj.style.fontSize = checkFontSize+"em"; 
		alert("최대사이즈입니다."); 
	}
	else if (checkFontSize < minFontSize) { 
		checkFontSize = minFontSize; 
		obj.style.fontSize = checkFontSize+"em"; 
		alert("최소사이즈입니다."); }
	else { 
		obj.style.fontSize = checkFontSize+"em"; 
	}
}


// 글자수 크기 구하기
function jf_updateChar(length_limit, objContent, objTarget)
{
	var length = jf_calculate_msglen(objContent.value);
   objTarget.innerText = length;
   if (length > length_limit) {
       alert("최대 " + length_limit + "byte이므로 초과된 글자수는 자동으로 삭제됩니다.");
       objContent.value = objContent.value.replace(/\r\n$/, "");
       objContent.value = jf_assert_msglen(objContent.value, length_limit, objTarget);
   }
}

//
function jf_calculate_msglen(message)
{
   var nbytes = 0;

   for (i=0; i<message.length; i++) {
       var ch = message.charAt(i);
       if(escape(ch).length > 4) {
           nbytes += 2;
       } else if (ch == '\n') {
           if (message.charAt(i-1) != '\r') {
               nbytes += 1;
           }
       } else if (ch == '<' || ch == '>') {
           nbytes += 4;
       } else {
           nbytes += 1;
       }
   }

   return nbytes;
}

function jf_assert_msglen(message, maximum, objTarget)
{
   var inc = 0;
   var nbytes = 0;
   var msg = "";
   var msglen = message.length;

   for (i=0; i<msglen; i++) {
       var ch = message.charAt(i);
       if (escape(ch).length > 4) {
           inc = 2;
       } else if (ch == '\n') {
           if (message.charAt(i-1) != '\r') {
               inc = 1;
           }
       } else if (ch == '<' || ch == '>') {
           inc = 4;
       } else {
           inc = 1;
       }
       if ((nbytes + inc) > maximum) {
           break;
       }
       nbytes += inc;
       msg += ch;
   }
   objTarget.innerText = nbytes;
   return msg;
}


/* rolling */
var roll_Class=function(){this.initialize.apply(this,arguments);}
roll_Class.prototype={

initialize:function(){

this.className=arguments[0]?arguments[0]:null;
this.foundit(arguments[1],'',false);
this.contents=new Array('0');
this.contents_delay=null;
this.nowdelay=null;
this.foundit(
this.roll.childNodes,this.foundvalue ,
function(rt,that){

if(that.constrain_size !== null) that.foundit(rt.childNodes,'IMG',function(rt,that){rt.style[(this.moving != 'left' ? 'width' : 'height')] = that.constrain_size;});
that.contents_delay=that.contents[that.contents.length]=that.contents_delay+-rt[(that.moving=='left'?'offsetWidth':'offsetHeight')];});

{
this.rollHeight=this.proll.style[(this.moving=='left'?'width':'height')]=Math.abs(this.contents[this.contents.length-1]);
this.roll.appendChild(this.roll.cloneNode(true));
};},


foundit:function(tg,n){

var temp=new Array();

	for(var v in tg)
		switch(typeof arguments[2]){
		case 'object':if(arguments[2].initialize(tg[v],n,this)==true) return; else break;
		case 'function':if(tg[v].nodeName==n) arguments[2](tg[v],this); break;
		case 'boolean':this[v]=tg[v]; break;
		default:if(tg[v].nodeName==n) return tg[v];
	}

return temp;},

inaction:function(time){

this.roll.style[this.moving]=time=time < 0 ?(this.fall==false && time <= -this.rollHeight?0:time):-this.rollHeight,null;
this.foundit(this.contents,time,{initialize:function(rt,vrt,that){if(Math.abs(rt - vrt) <(that.fast==false?that.tick:that.ftick)){that.roll.style[that.moving]=rt; that.nowdelay=that.fast==true?that.lengthen:that.delay; that.fast=false; return true;} else that.nowdelay=that.lengthen;}});
{var ticks=this.fast==true?this.ftick:this.tick;}
this.control=setTimeout(this.className+".inaction("+(parseInt(this.roll.style[this.moving])+(this.fall==true?ticks:-ticks))+");",this.nowdelay);},

stop:function(){

this.temp=parseInt(this.roll.style[this.moving]);
clearTimeout(this.control);}    };


function dtxtview(num){
	max=document.getElementById("tab").getElementsByTagName("a").length;

	for(i=1;i<=max;i++){
		document.getElementById("dtabv"+i).style.display = "none";
	}
	document.getElementById("dtabv"+num).style.display = "block";
}
