// 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
     setTimeout( function() {
            $("nav").animate({  top: desSlideshow },700);
        },
        1100
    );
 */
 
$(function() {
      $("#desSlideshow1").desSlideshow({
          autoplay: 'enable',//option:enable,disable
          slideshow_width: '800',//slideshow window width
          slideshow_height: '399',//slideshow window height
          thumbnail_width: '200',//thumbnail width
          time_Interval: '4000'//Milliseconds
      });
});
	 
	 
(function(a){
		  
    a.fn.desSlideshow=function(p){
        var p=p||{};
        var autoplay=p&&p.autoplay?p.autoplay:"enable";
        var slideshow_width=p&&p.slideshow_width?p.slideshow_width:"800";
        var slideshow_height=p&&p.slideshow_height?p.slideshow_height:"399";
        var thumbnail_width=p&&p.thumbnail_width?p.thumbnail_width:"200";
        var time_Interval = p&&p.time_Interval?p.time_Interval:"4000";
        var directory=p&&p.directory?p.directory:"images";
        slideshow_height = parseInt(slideshow_height);
        slideshow_width = parseInt(slideshow_width);
        time_Interval = parseInt(time_Interval);
        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();
        if(autoplay == "enable"){
            g.find(".switchBigPic").css("display","block");
            g.find(".nav_g").css("display","block");
            
            play();
        }else{
            g.find(".switchBigPic").css("display","block");
            g.find(".nav_g").css("display","block");
           
            current = 0;
            showpic();
        }
        g.find(".nav_g").children("span").children("a").hover(
            function(){
                var index = g.find(".nav_g").children("span").children("a").index($(this));
                if(index != current){
                    current = index;
                    showpic();
                }
            },
            function(){

            }
        );
        g.hover(
            function(){

            },
            function(){
                if(autoplay == "enable"){
                    v=setTimeout(play,time_Interval);
                }
            }
        );
        function init(){
			g.find(".switchBigPic").children("div").css("position","absolute").css("overflow","hidden");
			g.find(".switchBigPic").css("position","relative").css("height","304px");
			g.find(".nav_g").animate({ top: 337 },850);			
			g.find(".nav_g").css("margin","0px").css("padding","0px").css("text-align","center").css("width","800px");    
			g.find(".nav_g").children("span").children("a").children("img").css("opacity","1");
			g.find(".nav_g").children("span").children("img").css("opacity","0");
            g.find(".switchBigPic").children("div").hide();
        }
        function showpic(){
            clearTimeout(v);
            g.find(".switchBigPic").children("div").fadeOut();
            g.find(".switchBigPic").children("div").eq(current).fadeIn();
			g.find(".nav_g").children("span").children("img").animate({opacity: '1'}, "fast");
			g.find(".nav_g").children("span").children("a").children("img").animate({opacity: '1'}, "fast");
            g.find(".nav_g").children("span").children("a").children("img").eq(current).animate({opacity: '0'}, "fast");
            w = current;

        }
        function play(){
            current++;
            if(current>=y){
                current=0
            }
            showpic();
            v=setTimeout(play,time_Interval);
        }
    }
})(jQuery);

