//플래쉬 삽입 스크립트
function SWFLoader() {
	var obj = new String;
	var parameter = new String;
	var embed = new String;
	
	var classId = new String;
    var codeBase = new String;
	var pluginSpage = new String;
	var embedType = new String;	
	var allParameter = new String;	
	
	var src = new String;
	var width = new String;
	var height = new String;
	var id = new String;
	var title = new String;
	var layer = new String;
	var arg = new String;
	var altText = new String;
	var wmode = new String;

	this.init = function ( w, h, s, a ) {
		width = w; 
		height = h; 
		src = s; 
		arg = a; 
		wmode = 'transparent'; 

		classId = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
		codeBase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';
		pluginSpage = 'http://www.macromedia.com/go/getflashplayer';
		embedType = 'application/x-shockwave-flash';

		parameter += "<param name='allowScriptAccess' value='always'>\n";
		parameter += "<param name='allowFullScreen' value='false'\n>";
		parameter += "<param name='movie' value='"+ s + "'>\n";
		parameter += "<param name='quality' value='best'/>\n";
		parameter += "<param name='base' value='.'>\n";
		parameter += "<param name='scale' value='noscale'/>\n";
		parameter += "<param name='expressinstall' value='Scripts/expressInstall.swf' />\n";
	}
	
	this.parameter = function ( param, value ) {
		 parameter += "<param name='"+param +"' value='"+ value + "'>\n";
	}

	this.wmode = function ( value ) {
		wmode = value;
	}

	this.id = function ( value ) {
		id = value;
	}
	this.title = function ( value ) {
		title = value;
	}

	this.shocknone = function ( value ) {
		altText = value;
	}

	this.layer = function ( value ) {
		if(value == undefined) {
			layer = "";
		} else {
			layer = value;
		}
	}

	this.show = function () {
		obj = '<object id="'+id+'" width="'+width+'" height="'+height+'" title="'+title+'" classid="'+classId+'" codebase="'+codeBase+'">\n'+
			parameter +
			'<param name="wmode" value="'+wmode+'">\n'+
			'<!--[if !IE]>-->\n' +
			'<object type="application/x-shockwave-flash" data="' + src + '" width="' + width + '" height="' + height + '" id="' + id + '2">\n' +
				parameter +
				'<param name="wmode" value="'+wmode+'">\n'+
			'<!--<![endif]-->\n' +
				'<div class="alt-content alt-' + id + '2">' + altText + '</div>\n' +
			'<!--[if !IE]>-->\n' +
			'</object>\n' +
			'<!--<![endif]-->\n' +
		'</object>';

		if(layer == "") {
			document.write(obj);

		}else{
			var div = document.getElementById( layer);
			div.style.display = "";
			div.innerHTML = obj;
		}
	}
}

//png 사용 자바스크립트
function setPng24(obj) { 
	obj.width=obj.height=1; 
	obj.className=obj.className.replace(/\bpng24\b/i,''); 
	objtmp=obj.src.replace("http://iace.or.kr","http://210.109.98.204");
	objtmp=objtmp.replace("http://www.iace.or.kr","http://210.109.98.204");
	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ objtmp +"',sizingMethod='image');" 
	obj.src='';  
	return ''; 
}

// 팝업
function OpenPopup(url, w, h){
	var winl = (screen.width - w) / 2; 
	var wint = (screen.height - h) / 3; 
	var winform = window.open(url,'_blank', 'top='+wint+',left='+winl+'toolbar=0, status=0, scrollbars=1, location=0, menubar=0, resizable=no, width='+w+', height='+h); 
}

// scrolling layer
function initMoving(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;

	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 30)
}
//scrolling layer end


/* 프린트 팝업 */
function printContents(tit){
	var ww = "730";
	var hh = "577";
	var obj=document.getElementById("content");
	document.footerform.titles.value=tit;
	document.footerform.contents.value=obj.innerHTML;

	var Printwin = window.open("","printContentsWindow","width="+ww+",height="+hh+",status=0,scrollbars=yes");
	document.footerform.submit();
}
/* 프린트 팝업 */
function printPop(){
	var ww = "730";
	var hh = "577";
	var obj=document.getElementById("content");
	document.footerform.contents.value=obj.innerHTML;

	var Printwin = window.open("","printContentsWindow","width="+ww+",height="+hh+",status=0,scrollbars=yes");
	document.footerform.submit();
}

function SetPos(){

	var h="560";
	if(document.documentElement.clientHeight){
		y = document.documentElement.clientHeight;
	}else if(document.body.clientHeight){
		y = document.body.clientHeight;
	}
	
    var t=(y-h)/2 - 20;
	if(t > 0){
	document.getElementById("wrapper_intro").style.top=t+"px";
	}else{
	document.getElementById("wrapper_intro").style.top="0px";
	}
}


function setCookie( name, value, opt, expireTime, domain )
{
	var todayDate = new Date();
	if(opt == 1){		
		todayDate.setSeconds(todayDate.getSeconds() + expireTime); 
	}else if(opt == 2){		
		todayDate.setMinutes( todayDate.getMinutes() + expireTime );	
	}else if(opt == 3){		
		todayDate.setHours( todayDate.getHours() + expireTime );	
	}else if(opt == 4){		
		todayDate.setDate( todayDate.getDate() + expireTime );
	}else if(opt == 5){		
		todayDate.setMonth( todayDate.getMonth() + expireTime );
	}else{		
		todayDate.setYear( todayDate.getYear() + expireTime );
	}		
	
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + "; domain="+domain + ";";
}

function getCookie( name ){
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ){
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
			endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
		break;
	}
	return "";
}
function getPosition(){
 var start, end, scale, term;
 start = parseInt (document.getElementById('quick_open2').style.top, 0);
 end = document.documentElement.scrollTop + 260;
 term = 1;

 if ( start != end ) {
 scale = Math.ceil( Math.abs( end - start ) / 20 );
  if ( end < start ) scale = -scale;
  document.getElementById('quick_open2').style.top = parseInt (document.getElementById('quick_open2').style.top, 0)+ scale + "px";
  term = 1;
 }
 setTimeout ("getPosition()", term);
}

function moveBanner() {
	if (!document.getElementById('quick_open2')) return false;
 document.getElementById('quick_open2').style.top = document.documentElement.scrollTop + 500 + "px"; 
 getPosition();
 return true;
}



function getPosition2(){
 var start, end, scale, term;
 start = parseInt (document.getElementById('quickmenu').style.top, 0);
 end = document.documentElement.scrollTop + 260;
 term = 1;

 if ( start != end ) {
 scale = Math.ceil( Math.abs( end - start ) / 20 );
  if ( end < start ) scale = -scale;
  document.getElementById('quickmenu').style.top = parseInt (document.getElementById('quickmenu').style.top, 0)+ scale + "px";
  term = 1;
 }
 setTimeout ("getPosition2()", term);
}

function moveBanner2() {
	if (!document.getElementById('quickmenu')) return false;
 document.getElementById('quickmenu').style.top = document.documentElement.scrollTop + 500 + "px";
 getPosition2();
 return true;
}




/*********************************************************/
// 슬라이드 퀵메뉴
var scroll_act = true; // 마우스 롤아웃시 변수값
var viewstart; // 위쪽 여백 (메뉴가 위에서 ''픽셀 떨어진 곳에 보여집니다)
var viewscroll = 100; // 스크롤시 브라우저 위쪽과 떨어지는 거리
var viewbottom; // 스크롤시 마지막 바닥값
var quickbase = 500; // 스크롤 시작위치
var activatespeed = 10;
var scrollspeed = 20;

var quicktimer;
var quick_obj;

function refresh_quick(){
	var quickstartpoint;
	var quickendpoint;
	bottomlimit = document.documentElement.scrollHeight - 250;
	quickstartpoint = parseInt(quick_obj.style.top, 10);
	quickendpoint = Math.max(document.documentElement.scrollTop, document.body.scrollTop) + viewscroll;

	if(scroll_act){
		if (quickendpoint < viewstart){
			quickendpoint = viewstart;
		}
		if (quickendpoint > bottomlimit){
			quickendpoint = bottomlimit;
		}
		if (quickstartpoint != quickendpoint){
			stmnScrollAmount = Math.ceil( Math.abs( quickendpoint - quickstartpoint ) / 15 );
			quick_obj.style.top = parseInt(quick_obj.style.top, 10) + ( ( quickendpoint < quickstartpoint ) ? -stmnScrollAmount : stmnScrollAmount ) + 'px';
		}
	}
	quicktimer = setTimeout("refresh_quick();", activatespeed);
}

function initializequick(obj,right,starttop,stopbottom){
	quick_obj = document.getElementById(obj);
	viewstart = starttop;
	viewbottom = stopbottom;
	quick_obj.style.position = 'absolute';
	quick_obj.style.right = right + 'px';
	quick_obj.style.top = document.body.scrollTop + quickbase + 'px';
	refresh_quick();
}

function ScrollTop(){
	self.window.scroll(0,0);
}

