// Copyright 2010 htmldrive.net Inc.

/**
 * @projectHomepage: http://www.htmldrive.net/go/to/desSlideshow
 * @projectDescription: Stylish featured image slideshow jQuery plugin.
 * @author htmldrive.net
 * More script and css style : htmldrive.net
 * @version 1.0
 * @license http://www.apache.org/licenses/LICENSE-2.0
 	customize: beeworks kansai
 */
 
(function(a){
	a.fn.desSlideshow=function(p){
		var p=p||{};
		var slideshow_width= 918//slideshow window width
		var slideshow_height= 230//slideshow window height
		var thumbnail_width= 300//thumbnail width
		var time_Interval= 4000//Milliseconds
		var directory= 'images/desSlideshow/'//images directory

		var g=a(this);
		var current = -1;
		var y=g.children(".switchBigPic").children("div").length;
		var v;
		var w;
		if(y==0){
			g.append("Require content");
			return null
		}
		init();
		g.find(".switchBigPic").css("display","block");
		g.find(".nav").css("display","block");
		g.css("background","none");
		play();

		g.find(".nav").children("li").hover(
            function(){
                var index = g.find(".nav").children("li").index($(this));
                if(index != current){
                    current = index;
                    showpic();
                }
            },
            function(){

            }
        );
        g.hover(
            function(){

            },
            function(){
                    v=setTimeout(play,time_Interval);
            }
        );
        function init(){
			g.css("width",slideshow_width+"px").css("height",slideshow_height+"px").css("position","relative").css("overflow","hidden");
			g.find("img").css("border","none").css("verticalAlign","bottom");
			g.find("ul").css("margin","0px").css("padding","0px");
			g.find("li").css("margin","0px").css("padding","0px").css("list-style","none");
			g.find(".switchBigPic").children("div").css("position","absolute").css("overflow","hidden");
			g.find(".nav").css("width",thumbnail_width+"px").css("height",slideshow_height+"px").css("margin-left","618px");
			g.find(".nav").children("li").css("height","57.5px");
			g.find(".nav").children("li").children("a").css("height","57.5px").css("display","block");
			g.find(".switchBigPic").children("div").hide();
		}
		function showpic(){
			clearTimeout(v);
			g.find(".nav").children("li").css("opacity","0.5");
			//g.find(".nav").children("li").eq(current).css("opacity","1");
			g.find(".switchBigPic").children("div").fadeOut();
			g.find(".switchBigPic").children("div").eq(current).fadeIn();
			g.find(".nav").children("li").eq(current).animate({opacity: '1.0'}, 200);
			g.find(".nav").children("li").eq(w).animate({opacity: '0.5'}, 200);
			w = current;
		}
		function play(){
			current++;
			if(current>=y){
				current=0
			}
			showpic();
			v=setTimeout(play,time_Interval);
		}
	}
})(jQuery);


