// JavaScript Document
var myInterval=5000;
var AsetInterval;
function slideSwitch() {
		
		
    		var $active = $('#slideshow DIV.active');
	
		if ($active.length == 0 ) $active = $('#slideshow DIV:last');

  		  // use this to pull the divs in the order they appear in the markup
   		 var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');
		
		$active.addClass('last-active');
		$next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
		
		
    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    
}
function slideSwitch1(id) {
		
			myInterval=0;
			AsetInterval=clearInterval(AsetInterval);
			var $active = $('#slideshow DIV.active');
		//	var $active =$("#slideshow div").slice(0,id);
			//var $active =$("#slideshow div").eq(id);
		//alert($active.length);
			
		//if ($active.length == 0 ) $active = $('#slideshow DIV:last');

  		  // use this to pull the divs in the order they appear in the markup
   		/// var $next =  $active.next().length ? $active.next()
        //: $('#slideshow DIV:first');
		$active.addClass('last-active');
		//var $next =  $("#slideshow div").slice(0,id+1);
		var $next =  $("#slideshow div").eq(id);
		$next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
		setTimeOn();
			/*if(id==0 || id==1 || id==2 || id==3 || id==4 || id==5 || id==6)
		{
				
		   // myInterval=setInterval( "slideSwitch()", 5000 );
		}*/
	
    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    
}
function setTimeOn() 
{
	myInterval=5000;
    AsetInterval=setInterval( "slideSwitch()", myInterval );
}
$(document).ready(function(){
	setTimeOn();
	$("#p1").mouseover(function () {
		slideSwitch1(0);
 	});
	$("#p2").mouseover(function () {
		slideSwitch1(1);
 	});
	$("#p3").mouseover(function () {
		slideSwitch1(2);
 	});
	$("#p4").mouseover(function () {
		slideSwitch1(3);
 	});
	$("#p5").mouseover(function () {
		slideSwitch1(4);
 	});
	$("#p6").mouseover(function () {
		slideSwitch1(5);
 	});
	$("#p7").mouseover(function () {
		slideSwitch1(6);
 	});
});
