
/*
marking first-child and last-child by className
*/
com._startup_items.push(function(){
	
	var fc = new com.Array();
	var lc = new com.Array();
	
	
	com.E("ul").each(function(){
		var li = this.E("li");
		fc.push(li[0]);
		lc.push(li[li.length - 1]);
	});
	
	com.E("ol").each(function(){
		alert(this);
		var li = this.E("li");
		fc.push(li[0]);
		lc.push(li[li.length - 1]);
	});
	
	com.E("dl").each(function(){
		var dt = this.E("dt");
		var dd = this.E("dd");
		fc.push(dt[0]);
		fc.push(dd[0]);
		lc.push(dt[dt.length - 1]);
		lc.push(dd[dd.length - 1]);
	});
	
	fc.each(function(){ this.setClass("first-child"); });
	lc.each(function(){ this.setClass("last-child"); });
});





/*
flash alternative contents
*/
com._startup_items.push(function(){
	
	var alt  = com.E("div.alt");
	if(alt.length < 1) return;
	alt = alt[0];
	
	var wrap = alt.E("div.wrap")[0];
	var ul = wrap.E("ul")[0];
	var prev = com.G("img").setClass("pnButton prev");
	var next = com.G("img").setClass("pnButton next");
	var step = 218;
	var ww = wrap.getSize().w;
	var uw = ul.getSize().w;
	var SL = wrap.scrollLeft;
	var min_SL = 0;
	var max_SL = uw - ww;
	var isMove = false;
	var dec = com.decelerate();
	var timerID = null;
	var isAuto = false;
	var AutoSpan = 4;
	
	if(uw <= ww) return;
	
	prev.src = "image/corp/home/hom_swf_alt_scr_pre.jpg";
	next.src = "image/corp/home/hom_swf_alt_scr_nex.jpg";
	wrap.setStyle({ overflow : "hidden" });
	
	/*
	moving animation
	*/
	function Move(p,t,callback){
		var d = t - p;
		isMove = true;
		dec.Stop();
		dec.Ease(function(n){
			wrap.scrollLeft = p + d * n;
		},0.5,function(){
			SL = t;
			isMove = false;
			if(!!callback) callback();
		});
		dec.Start();
	}
	
	/*
	step
	*/
	function Step(){
		if(isMove) return;
		
		if(arguments.length == 1 && arguments[0] == -1){
			var li = ul.lastChild;
			ul.remove(li);
			SL += step;
			wrap.scrollLeft = SL;
			ul.insertBefore(li,ul.firstChild);
			var t = SL - step;
			if(t >= min_SL) Move(SL,t,null);
		}
		else{
			var t = SL + step;
			if(t <= max_SL) Move(SL,t,function(){
				var li = ul.firstChild;
				ul.remove(li);
				SL -= step;
				wrap.scrollLeft = SL;
				ul.append(li);
			});
		}
	}
	
	/*
	start auto step
	*/
	function Start(){
		if(!!isAuto) return;
		isAuto = true;
		clearInterval(timerID);
		timerID = setInterval(function(){
			Step();
		},AutoSpan * 1000);
	}
	
	/*
	stop auto step
	*/
	function Stop(){
		clearInterval(timerID);
		isAuto = false;
	}
	
	/*
	set event
	*/
	prev.addEventListener("click",function(evt){ if(!isMove) Step(-1); });
	next.addEventListener("click",function(evt){ if(!isMove) Step(); });
	
	wrap.addEventListener("mouseover",function(evt){ Stop(); });
	prev.addEventListener("mouseover",function(evt){ Stop(); });
	next.addEventListener("mouseover",function(evt){ Stop(); });
	wrap.addEventListener("mouseout",function(evt){ Start(); });
	prev.addEventListener("mouseout",function(evt){ Start(); });
	next.addEventListener("mouseout",function(evt){ Start(); });
	
	/*
	exec
	*/
	alt.append(prev);
	alt.append(next);
	Start();
	
	
	
	
	/*
	rollover effect for IE6 wiz AlphaImageLoader
	*/
	if(com._browser.nav == "MSIE" && com._browser.ver.major < 7){
		var span = ul.E("span");
		span.addEventListener("mouseover",function(){
			this.style.filter = this.style.filter.replace("_f1.","_f2.");
		});
		span.addEventListener("mouseout",function(){
			this.style.filter = this.style.filter.replace("_f2.","_f1.");
		});
	}
});

