// 슬라이드관련 JQUERY
	var index = 0;
	var old_index = index;
	var img_width = 0;
	var org_view_width = 0;
	var view_cnt = 0;
	var margin = 0;

	var class_out = null;
	var class_in = null;
	var class_sub = null;

	var s_point	= 0;
	var e_point	= 0;

	home = {
		starlist : {
			scroll		: 1,
			showspeed	: 500,
			page		: 1,
			totalPage	: null,
	
			getTotalPage : function() {
				if (this.totalPage == null) {
					this.totalPage = Math.ceil(($(class_in + " ul li").length - view_cnt) / this.scroll) + 1 || 1;	
					//alert ();
				}
				return this.totalPage;
			},
			
			prev : function(STARHWABO_WEBIMG) {

				if (this.page > 1) {

					if (this.scroll > parseInt($("input#s_point").val()))
					{
						this.show("+=" + (($(class_out + " " + class_in + " ul li").width() + margin) * ($(class_in + " ul li").length % this.scroll))  + "px" , this.showspeed);	
						s_point	= 0;
						e_point	= parseInt($("input#e_point").val()) - ($(class_in + " ul li").length % this.scroll);
					}
					else 
					{
						this.show("+=" + (($(class_out + " " + class_in + " ul li").width() + margin) * this.scroll) + "px" , this.showspeed);
						s_point	= parseInt($("input#s_point").val()) - this.scroll;
						e_point	= parseInt($("input#e_point").val()) - this.scroll;
					}

					$(class_out + " .next img").attr('src', STARHWABO_WEBIMG + "/main/btn_next_ov.gif");
					$(class_out + " .next").attr('href', "javascript:void(0);");

					this.page--;
				}
				if (this.page == 1) {
					$(class_out + " .prev img").attr('src', STARHWABO_WEBIMG + "/main/btn_prev_on.gif");	
					$(class_out + " .prev").removeAttr("href");
				}
				$("input#page").val(this.page);
				$("input#s_point").val(s_point);
				$("input#e_point").val(e_point);
				//alert (currpg + "&" + s_point + "&" + e_point);
				
			},
			
			next : function(STARHWABO_WEBIMG) {

				if (this.page < this.getTotalPage()) {
					
					if (($(class_in + " ul li").length - parseInt($("input#e_point").val()) - 1) < this.scroll)
					{

						this.show("-=" + (($(class_out + " " + class_in + " ul li").width() + margin) * ($(class_in + " ul li").length % this.scroll))  + "px" , this.showspeed);	
						e_point	= $(class_in + " ul li").length - 1;
						s_point	= parseInt($("input#s_point").val()) + ($(class_in + " ul li").length % this.scroll);
						//alert ("a");
					}
					else 
					{
						this.show("-=" + (($(class_out + " " + class_in + " ul li").width() + margin) * this.scroll)  + "px" , this.showspeed);	
						e_point	= parseInt($("input#e_point").val()) + this.scroll;
						s_point	= parseInt($("input#s_point").val()) + this.scroll;
						//alert ("b");
					}

					$(class_out + " .prev img").attr('src', STARHWABO_WEBIMG + "/main/btn_prev_ov.gif");
					$(class_out + " .prev").attr('href', "javascript:void(0);");

					this.page++;
				}
				if (this.page == this.getTotalPage()) {
					$(class_out + " .next img").attr('src', STARHWABO_WEBIMG + "/main/btn_next_on.gif");
					$(class_out + " .next").removeAttr("href");
				}
				$("input#page").val(this.page);
				$("input#s_point").val(s_point);
				$("input#e_point").val(e_point);
				//alert (s_point + "&" + e_point);
			},

			renext : function(STARHWABO_WEBIMG, point, currpg, s_point, e_point) {

				if (this.page < this.getTotalPage()) {

					this.show("-=" + (($(class_out + " " + class_in + " ul li").width() + margin) * s_point)  + "px" , 500);

					$(class_out + " .prev img").attr('src', STARHWABO_WEBIMG + "/main/btn_prev_ov.gif");
					$(class_out + " .prev").attr('href', "javascript:void(0);");
					
					this.page	= currpg;
				}

				if (this.page == this.getTotalPage()) {
					$(class_out + " .next img").attr('src', STARHWABO_WEBIMG + "/main/btn_next_on.gif");
					$(class_out + " .next").removeAttr("href");
				}
				$("input#page").val(this.page);
				$("input#s_point").val(s_point);
				$("input#e_point").val(e_point);
				//alert (currpg + "&" + s_point + "&" + e_point);
			},
	
			show : function(moveLeft, speed) {
				$(class_out + " " + class_in + " ul").animate({
					left : moveLeft, opacity : 1
				}, speed, "swing", function() {
					$(this).css("opacity", "1");
				});	
			}
		}
	};

	function byule_fadeInOut(objName,index)
	{	
		imgObj = $(objName + ' .img');
		
		imgObj.each(function(i)
		{
			if (imgObj.index(this) != index)
			{
				$(this).animate({opacity:0.5});
			}
		});		
	}


	function init(GV_MENUCODE)
	{	
		if (GV_MENUCODE == 1) {
			class_out = ".albumList";
			class_in = ".listWrap";

			margin = 6;
		}
		else if (GV_MENUCODE == 3 ||GV_MENUCODE == 5) {
			class_out = ".galleryChart";
			class_in = ".chartSec";

			margin = 31;
		}
		else if (GV_MENUCODE == 4) {
			class_out = ".videoList";
			class_in = ".listWrap";

			if ($(class_out + " " + class_in + " ul li").width() == 120) {
				margin = 28;
			}
			else if (($(class_out + " " + class_in + " ul li").width()) == 96) {
				margin = 8;
			}
		}

		img_width = $(class_in + " ul li").length * ($(class_out + " " + class_in + " ul li").width() + margin);
		$(class_out + " " + class_in + " ul").css("width", img_width);

		org_view_width = $(class_out + " " + class_in).width();
		$(class_out + " " + class_in).css("width", $(class_out + " " + class_in).width() - margin);

		view_cnt = (org_view_width / ($(class_out + " " + class_in + " ul li").width() + margin));

		home.starlist.scroll = org_view_width / ($(class_out + " " + class_in + " ul li").width() + margin);

		s_point	= 0;
		e_point	= (home.starlist.scroll) - 1;

		$("input#s_point").val(s_point);
		$("input#e_point").val(e_point);

		//alert (home.starlist.scroll + "," + margin + "," + $(class_out + " " + class_in + " ul li").width() + "," + org_view_width + "," + ($(class_out + " " + class_in + " ul li").width() + margin));
	}


; (function ($) {
	$.fn.slideShow = function(options) {

	  return this.each(function() {
	  
		var $slides  = $(".photoSec .photoImg");								//슬라이드 자식들 가져오기
		var totalcnt = $slides.length;											//슬라이드 자식들 갯수

		var slideShowId = "imgView";											//슬라이드 부모 생성
		var slideWidth  = $(".photoSec .photoImg").width();						//가로 사이즈
		var slideHeight = $(".photoSec .photoImg").height();					//세로 사이즈

		var currentPosition = 0;												//현재위치
		var textPosition	= 0;												//텍스트 위치
		
//		$(".diary_text .scroll03").hide();
//		$(".diary_text .scroll03").css({'visibility': visible });

		if (options == "fashion")
		{
			$(".diary_text .scroll03").eq(textPosition).show();
		}

		$(".photoSec a.prev").click(function(event) {
			Slide('prev');
		});

		$(".photoSec a.next").click(function(event) {
			//alert (options);
			Slide('next');
		});

		//자식노드를 새로운 div 에 담기
		$slides.wrapAll('<div class="'+slideShowId+'"></div>').css({'width': slideWidth, 'height': slideHeight });
		
		//새 객체 담기
		var $sliderInner = $('.'+slideShowId);
		$sliderInner.css('width', slideWidth * totalcnt);
		
		$slides.css({'float':'left'});
		$sliderInner.animate({'marginLeft' : slideWidth * (-currentPosition)});

			
		//버튼 클릭시 실행 함수
		function Slide(preNext) 
		{
			if( preNext == 'prev' )
			{
				currentPosition = currentPosition - 1;

				//현재 위치가 0보다 작을 경우
				if( currentPosition < 0 )
				{
					currentPosition = 1;
					$sliderInner.css( 'marginLeft', slideWidth * (-currentPosition) );

					$('.'+slideShowId +' div:last-child').insertBefore($('.'+slideShowId +' div:first-child'));
					currentPosition = 0;
				}

				if (options == "fashion")
				{
					$(".diary_text .scroll03").eq(textPosition).hide();
					textPosition = (totalcnt+(--textPosition))%totalcnt;
					$(".diary_text .scroll03").eq(textPosition).show();
				}
			}
			else
			{
				currentPosition = currentPosition + 1;

				//현재위치가 전체보다 클 경우
				if( currentPosition > totalcnt - 1 )
				{
					currentPosition = totalcnt - 2;
					$sliderInner.css( 'marginLeft', slideWidth * (-currentPosition) );

					$('.'+slideShowId +' div:first-child').insertAfter($('.'+slideShowId +' div:last-child'));
					currentPosition = currentPosition + 1;
				}

				if (options == "fashion")
				{
					$(".diary_text .scroll03").eq(textPosition).hide();
					textPosition = (totalcnt+(++textPosition))%totalcnt;
					$(".diary_text .scroll03").eq(textPosition).show();
				}
			}
			$sliderInner.animate({'marginLeft' : slideWidth * (-currentPosition)},300);
		}
	  });
	};
}) (jQuery);




