﻿var RollingDisplay=function(cid,count,interval,n) {
	this.cid = cid;
	this.count = count;	
	this.n = (n)? n:"1";
	this.onchange = null;

	for(var k=1; k<=this.count; k++) document.getElementById(this.cid+"_"+k).style.display="none";
	document.getElementById(this.cid+"_"+this.n).style.display="block";

	this.div = document.getElementById(this.cid);//전체div
	this.div.onmouseover = function(){this.isover=true; }
	this.div.onmouseout  = function(){this.isover=false;}
	this.btn_next = document.getElementById("btn_"+this.cid+"_next");
	this.btn_prev = document.getElementById("btn_"+this.cid+"_prev");

	var self=this;
	if(this.btn_next) this.btn_next.onclick=function(){self.next() }
	if(this.btn_prev) this.btn_prev.onclick=function(){self.prev() }
	if(interval>0) setInterval(function(){self.play()}, interval);
}
RollingDisplay.prototype = {
	play : function(){
		if(this.div.isover) return;
		this.next();
	},	
	prev : function(){
		document.getElementById(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==1)?this.count:--this.n;
		document.getElementById(this.cid+"_"+this.n).style.display="block";		
	},
	next : function(){
		document.getElementById(this.cid+"_"+this.n).style.display="none";
		this.n=(this.n==this.count)? 1:++this.n;
		document.getElementById(this.cid+"_"+this.n).style.display="block";		
	}	
};

function getStyle(el, style) {
	var value = el.style[style];
	if(!value)	{
		if(document.defaultView && document.defaultView.getComputedStyle) {
			var css = document.defaultView.getComputedStyle(el, null);
			value = css ? css[style] : null;
		} 
		else if (el.currentStyle) value = el.currentStyle[style];
	}
	return value == 'auto' ? null : value;
}

function familyToggle() {	
	var familyButton = document.getElementById('familyToggle');
	var familyListCon = document.getElementById('familyList');
	familyListCon.style.visibility = "hidden";
	document.documentElement.onclick = function() {	   
		familyListCon.style.visibility = 'hidden'
	}
	familyButton.onclick = function(e) {
		var event = window.event || e;
		if(event.preventDefault){event.preventDefault(); event.stopPropagation();}
		else {event.returnValue = false; event.cancelBubble = true;}
		familyListCon.style.visibility=(getStyle(familyListCon,'visibility')=='hidden') ? 'visible':'hidden';	
	}
	return false;
}

function flashWrite(url,w,h,vars,bg,win){	
	var id=url.split("/")[url.split("/").length-1].split(".")[0];
	if(vars==null) vars='';
	if(bg==null) bg='#FFFFFF';
	if(win==null) win='transparent';
	
	var flashStr= "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
		flashStr+="			codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0'";
		flashStr+="			width='"+w+"'";
		flashStr+="			height='"+h+"'";
		flashStr+="			id='"+id+"'";
		flashStr+="			align='middle'>";

		flashStr+="		<param name='allowScriptAccess' value='always' />";
		flashStr+="		<param name='movie' value='"+url+"' />";
		flashStr+="		<param name='FlashVars' value='"+vars+"' />";
		flashStr+="		<param name='wmode' value='"+win+"' />";
		flashStr+="		<param name='menu' value='false' />";
		flashStr+="		<param name='quality' value='high' />";
		flashStr+="		<param name='bgcolor' value='"+bg+"' />";
	
	
		flashStr+="		<embed src='"+url+"'";
		flashStr+="		       flashVars='"+vars+"'";
		flashStr+="		       wmode='"+win+"'";
		flashStr+="		       menu='false'";
		flashStr+="		       quality='high'";
		flashStr+="		       bgcolor='"+bg+"'";
		flashStr+="		       width='"+w+"'";
		flashStr+="		       height='"+h+"'";
		flashStr+="		       name='"+id+"'";
		flashStr+="		       align='middle'";
		flashStr+="		       allowScriptAccess='always'";
		flashStr+="		       type='application/x-shockwave-flash'";
		flashStr+="		       pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		flashStr+=" </object>";
	
	document.write(flashStr);
}

function redefineFlashWH_main(w, h){
	var parentObj  = document.getElementById('mainVisual');
	var targetObj  = document.getElementById('main');
	
	var fixWidth   = 910; //
	

	var userWidth  = document.documentElement.clientWidth;	

	var widthBool  = false;	

	if(w == undefined) { w = fixWidth; }	

	if(w <= fixWidth) if(userWidth <= fixWidth) widthBool = true;	

	if(widthBool) {
		targetObj.width = fixWidth;
		parentObj.style.width = fixWidth + "px";
	} else {
		targetObj.width = userWidth;
		parentObj.style.width = userWidth + "px";
	}	
}


function regInterval(){
    if(!document.getElementById('mainVisual')) return false;
	else if(document.getElementById('mainVisual')) intervalVariable = setInterval("redefineFlashWH_main()",50);	
}

window.onload = function() {
	regInterval();
}