/*
 *
 * Copyright 2011, jeong jin Yoon, godrium@naver.com
 * Date: 2011.08
 * codeValue : 1
 */

// contentSlide function 	
//init
	var autoPlaySlide = "yes";
	var startImg = 1;	
	var changeTime = 4000;
	var listLength;	
	var nowShowImg = 1;
	var onEvent = "no";

	function contentSlideInit() {
		listLength = jQuery(".bannerList > li").length;
		nowShowImg = startImg;
		ImgSwitch(nowShowImg);		
		autoPlayVal = setInterval("autoPlay()",changeTime);
		eventSwith();
		jQuery(".thumList").fadeIn("fast");
	}
	function ImgSwitch(showImg) {
		if ( onEvent == "no" )
		{
			onEvent = "yes";
			var offSrc = jQuery(".selectItem").attr("offSrc");
			jQuery(".selectItem").attr("src",offSrc);
			jQuery(".selectItem").removeClass("selectItem");
			var objThum = jQuery(".thumList > li:nth-child("+showImg+") > img");
			var onImg = objThum.attr("onSrc");
			jQuery(".mnspot > .bannerList > li").fadeOut(700);
			jQuery(".mnspot > .bannerList > li:nth-child("+showImg+")").fadeIn(700);
			objThum.attr("src",onImg);
			objThum.attr("class","selectItem");
			onEvent = "no";
		}
		
	}	
	function autoPlay() {
		if (autoPlaySlide == "yes" && onEvent == "no")
		{
			if ( nowShowImg == listLength )
			{
				nowShowImg = 0;
			}
			nowShowImg++;
			ImgSwitch(nowShowImg);
		}
	}
	function eventSwith() {
		jQuery(".thumList > li").mouseover(function(){
			clearInterval(autoPlayVal);
			if (onEvent == "no")
			{
				nowShowImg =  testnum = jQuery( this ).index() + 1;
				ImgSwitch(nowShowImg);
			}
		});
		jQuery(".bannerList > li").mouseout(function(){	
			autoPlayVal = setInterval("autoPlay()",changeTime);
		});
		jQuery(".bannerList > li").mouseover(function(){	
			clearInterval(autoPlayVal);
		});

	}
