//-------------- Megazone SAT --------------
// Flash publishing with Cross Browsing
function swfprint(furl,fwidth,fheight,transoption)	{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">');
	document.write('<param name="movie" value="'+ furl +'"/>');
	if (transoption == "t")	{
		document.write('<param name="wmode" value="transparent"/>');
	} else if	(transoption == "o")	{
		document.write('<param name="wmode" value="opaque"/>');
	}
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<object type="application/x-shockwave-flash" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"');
	if (transoption == "t")	{
		document.write(' wmode="transparent"');
	} else if	(transoption == "o")	{
		document.write(' wmode="opaque"');
	}
	document.write('></object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}

//imageOver
function imageOver(objImg) {objImg.src = objImg.src.replace("off.gif", "on.gif");}
function imageOut(objImg) {objImg.src = objImg.src.replace("on.gif", "off.gif");}

// Embeded function image Over
function menuOver() {this.src = this.src.replace("_off.gif", "_on.gif");}
function menuOut() {this.src = this.src.replace("_on.gif", "_off.gif");}

// Tabbed menu
function initTabMenuClick(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", "_off.gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" on", "off");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace("_off.gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

// Layer Show-Hide
function showLayer(tgtEl)    {    document.getElementById(tgtEl).style.display = "block";    }
function hideLayer(tgtEl)    {    document.getElementById(tgtEl).style.display = "none";    }


//Print
function wprint()     {
    window.print();
}

// 가로,세로 사이즈에 맞는 센터지점의 속성값을 반환한다.
function getCenterOption(winwidth, winheight) {
    var winx = Math.ceil((screen.availWidth - winwidth) / 2);
    var winy = Math.ceil((screen.availHeight - winheight) / 2);
    return "left=" + winx + ",top=" + winy;
}

//png
function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}

//소스 복사
function encodeforFlash(str)
{
   var SAFECHARS = "0123456789" +
                 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
                 "abcdefghijklmnopqrstuvwxyz" +
                 "-_.!~*'()";

   var HEX = "0123456789ABCDEF";

   var plaintext = str;
   var encoded = "";
   for (var i = 0; i < plaintext.length; i++ ) {
       var ch = plaintext.charAt(i);
       if (ch == " ") {
           encoded += "+";
       } else if (SAFECHARS.indexOf(ch) != -1) {
           encoded += ch;
       } else {
           var charCode = ch.charCodeAt(0);
           if (charCode > 255) {
               encoded += ch;
           } else {
               encoded += "%";
               encoded += HEX.charAt((charCode >> 4) & 0xF);
               encoded += HEX.charAt(charCode & 0xF);
           }
       }
   }
   return encoded;
};

/*function copyUrl(url){        
   if(isIE) {
       window.clipboardData.setData('Text',url);
       window.alert("이메일 주소가 복사되었습니다");
   } else {
       url = encodeforFlash(url);
       var flashcopier = 'flashcopier';
       if(!document.getElementById(flashcopier))
       {
           var divholder = document.createElement('div');
           divholder.id = flashcopier;
           document.body.appendChild(divholder);
       }
       document.getElementById(flashcopier).innerHTML = '';
       var divinfo = '<embed src="/DTB/images/common/_clipboard.swf" FlashVars="clipboard='+url+'" width="1" height="1"type="application/x-shockwave-flash"></embed>';
       document.getElementById(flashcopier).innerHTML = divinfo;
       window.alert("이메일 주소가 복사되었습니다");
   }
}
*/
/* screen zoom */
function zoomInOut(how) {
	var zoomRate = 10;			
	var maxRate = 140;			
	var minRate = 100;
	var resetRate = 100;
	if (!document.body.style.zoom){
		document.body.style.zoom = '100%'; 
	}
	if (((how == "in") && (parseInt(document.body.style.zoom) >= maxRate)) || ((how == "out") && (parseInt(document.body.style.zoom) <= minRate)) || ((how == "reset") && (document.body.style.zoom = '100%'))) {
		return; 
	}
	if (how == "in"){
		document.body.style.zoom = parseInt(document.body.style.zoom)+zoomRate+'%' ;
	}
	else{
		document.body.style.zoom = parseInt(document.body.style.zoom)-zoomRate+'%' ;
	}
}

/* stylesheet change */
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



/* 0000000000000000000000 */
// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
// 클립보드 파이어폭스에서 실행이 안되는 경우
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function isExplore() {
	return sUserAgent.indexOf("compatible") > -1 
           && sUserAgent.indexOf("MSIE") > -1
           && !isOpera;	
}

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}




function changeDivDisplay(contents) {
        var divObj = document.getElementById(contents);
        if(divObj.style.display == "block") {
            divObj.style.display = "none";
        } else {
            divObj.style.display = "block";
        }

    }




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_showHideLayers() { //v6.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 viewImgLayer(obj, layer) {
	var objId = document.getElementById(obj);
	var objPop = document.getElementById(layer);
	objLis = objId.getElementsByTagName('li');
	var objEvent = function (num) {
		objLis[num].getElementsByTagName('a')[0].onclick = function () {
			objPop.getElementsByTagName('img')[1].src = this.href;
			objPop.getElementsByTagName('img')[1].alt = this.getElementsByTagName('img')[0].alt;
			objPop.style.display = 'block';
			if (num <= parseInt(objLis.length/2)-1) objPop.style.left = this.offsetLeft + 'px';
			else objPop.style.left = this.offsetLeft - (objPop.offsetWidth - this.offsetWidth) + 'px';
			objPop.style.bottom = this.offsetHeight + 'px';

			objPop.getElementsByTagName('a')[0].onclick = function () { objPop.style.display = 'none'; return false; }
			return false;
		}

	}
	for (var i=0; i<objLis.length; i++) objEvent(i);
}



