// 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.slideshow=function(p){
        var p=p||{};
		var slideshow_width= 700//slideshow window width
		var slideshow_height= 315//slideshow window height
		var thumbnail_width= 105//thumbnail width
		var time_Interval= 4000//Milliseconds

        var g=a(this);
        var current = -1;
        var y=g.children(".slide-banner").children("div").length;
        var v;
        var w;
        if(y==0){
            g.append("Require content");
            return null
        }
        init();
        g.find(".slide-banner").css("display","block");
        g.find(".slide-nav").css("display","block");
        g.css("background","none");
        play();

        g.find(".slide-nav").children("li").hover(
            function(){
                var index = g.find(".slide-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(".slide-banner").css("position","relative").css("margin-left","160px");
            g.find(".slide-banner").children("div").css("position","absolute").css("overflow","hidden");
            g.find(".slide-nav").css("width",thumbnail_width+"px").css("height",slideshow_height+"px");
            g.find(".slide-nav").children("li").children("a").css("height","50px").css("display","block");
            g.find(".slide-banner").children("div").hide();
			*/
        }
        function showpic(){
            clearTimeout(v);
            g.find(".slide-nav").children("li").css("opacity","0.5");
            g.find(".slide-banner").children("div").fadeOut();
            g.find(".slide-banner").children("div").eq(current).fadeIn();
			g.find(".slide-nav").children("li").eq(current).animate({opacity: '1.0'}, 200);
			g.find(".slide-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);

$(function() {
	$(".index-head .slideshow").slideshow();
});


