function __eb_movslide_init( id ) {
	$("#"+id+" div.jNavi")
	.css("display", "block")
	.css("margin-left", 20)
	.css("margin-top", $("#"+id).height() - $("#"+id+" div.jNavi").height() - 10);
	
	$( "<div class='jItem'>" + $($("#"+id+" .jItems .jItem").get(0)).html() + "</div>" ).appendTo( "#"+id+" div.jItems " );
	$("#"+id+" div.jItems").css("width", $("#"+id).width()*$("#"+id+" div.jItem img").length )
	
	$("#"+id).attr("current", 1);
	$($("#"+id+" div.jNavi img").get(0)).attr("src", $($("#"+id+" div.jNavi img").get(0)).attr("src").replace(".gif", "_on.gif"));
	
	$("#"+id+" div.jNavi img")
	.css("cursor", "pointer")
	.each( function() {
		$(this)
		.mouseover(function(){
			if( parseInt($("#"+id).attr("current")) != ($(this).parent().find("img").index( $(this) ) + 1) ) { 
				$(this).attr("src", $(this).attr("src").replace(".gif", "_on.gif") );
			}
			$("#"+id).unbind("click");
			
		})
		.mouseleave(function(){
			if( parseInt($("#"+id).attr("current")) != ($(this).parent().find("img").index( $(this) ) + 1) ) {
				$(this).attr("src", $(this).attr("src").replace("_on.gif", ".gif") );
			}
			$("#"+id).click( function() { __eb_movslide_redirect(id); });
			
		})
		.click(function() {
			if( parseInt($("#"+id).attr("current")) != ($(this).parent().find("img").index( $(this) ) + 1) ) {
				__eb_movslide_go( id, ($(this).parent().find("img").index( $(this) ) + 1) );
			}
		});
	});
	$("#"+id)
	.click( function() { __eb_movslide_redirect(id); })
	.mouseover( function() {
		clearTimeout( $("#"+id).attr("interval") );
	})
	.mouseleave( function() {
		$("#"+id).attr("interval",  setTimeout(function(){__eb_movslide_interval(id);}, 3000) );
	});
	__eb_movslide_go(id, 1);
	$("#"+id).attr("interval",  setTimeout(function(){__eb_movslide_interval(id);}, 3000) );
}
function __eb_movslide_go(id, index) {
	$("#"+id+" .jItems").each( function() {
		var position = $(this).position();
		$(this)
		.css({position:"absolute",left:position.left})
		.animate({left:-$("#"+id).width()*(index-1)},"normal",function(){
			if(parseInt($("#"+id).attr("current"))==1) {
				$("#"+id+" .jItems").stop().css({left:0});
			}
		});
	});
	if( parseInt($("#"+id).attr("current")) == $("#"+id+" div.jNavi img").length && index > $("#"+id+" div.jNavi img").length ) {
		$("#"+id).attr("current", 1);
		index = 1;
	}
	$("#"+id+" div.jNavi img").each( function(){
		$(this).attr("src", $(this).attr("src").replace("_on.gif", ".gif") );
	});
	$($("#"+id+" div.jNavi img").get(index-1)).attr("src", $($("#"+id+" div.jNavi img").get(index-1)).attr("src").replace(".gif", "_on.gif") );
	$("#"+id).attr("current", index);
	
	if( ($($("#"+id+" div.jItems div img").get( index-1 )).attr("href")+"") == "" ) {
		$("#"+id).css("cursor", "none");
	} else {
		$("#"+id).css("cursor", "pointer");
	}
}
function __eb_movslide_redirect(id) {
	var c = $($("#"+id+" div.jItems div img").get( parseInt($("#"+id).attr("current"))-1 ));
	if( c.attr("target") == "_self" ) {
		location.href = c.attr("href");
	} else if(c.attr("target") == "_blank") {
		if ( $.trim( c.attr("href") ) != "" ) window.open( c.attr("href"), '', '' );
	}
}
function __eb_movslide_interval(id) {
	__eb_movslide_go(id, parseInt($("#"+id).attr("current"))+1 );
	$("#"+id).attr("interval",  setTimeout(function(){__eb_movslide_interval(id);}, 3000) );
}
function eb_movslide( id ) {
	$(window).load( function() {
		__eb_movslide_init( id );
	});
}

