$(document).ready(function() {

			 //slideInterval = 7000;
             //slideSwitch('notclicked', 'null');
             //setInterval( "slideSwitch('notclicked', 'null')", slideInterval );
			 
             $(".slideshow").each(function(){
               var SlideShowId = $(this).attr('id');
			   //alert(SlideShowId);
               $("#"+ SlideShowId + "Next").click(function(){
                  slideSwitch('next', 'null', SlideShowId);
                  return false;
               });
               $("#"+ SlideShowId + "Pre").click(function(){
                  slideSwitch('previous', 'null', SlideShowId);
                  return false;
               });
               
               $("#"+ SlideShowId + "Next").click();
               $("#"+ SlideShowId + "Total").text($('#'+ SlideShowId +' > div').size());
			   
			   if ($("#"+ SlideShowId ).attr('slidePlay')== 'yes'){
				
				$("#"+ SlideShowId + "Play").click(function(){
				  if( $(this).attr('default') == 'play') {
					  $(this).attr("default", 'pause');
					  $("#playPauseButton").attr("src","templates/Beauty/images/idumpit/banner-controls-pause.gif");
				  }else {
					$(this).attr("default", 'play');
					$("#playPauseButton").attr("src","templates/Beauty/images/idumpit/banner-controls-play.gif");
				  }
				  return false;
				});
				
				//$('#'+ SlideShowId + 'Next').click();
				
			   }
			   setInterval("slideShowDelay()", 4000);
			   
			   $("#"+ SlideShowId + "Play").click();
			   
             });
			 
});


function slideShowDelay () {
  
  if($("#bannerSlidePlay").attr('default') == 'pause') {
	$('#bannerSlideNext').click();
  }

}


function slideSwitch(clicked, imagePos, SlideShowId) {
             
	
    
    
	if (clicked == 'previous') {
		var $active = $('#'+SlideShowId+' DIV.active');
		if ( $active.length == 0 ) $active = $('#'+ SlideShowId +' DIV:first');
		var $next =  $active.prev().length ? $active.prev(): $('#'+ SlideShowId +' DIV:last');
		$active.addClass('last-active');
		//$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
		//  $active.removeClass('active last-active');
		//});
		
		$next.addClass('active').css({opacity: 1});
		$active.removeClass('active last-active');
		
		$("#" +SlideShowId+"Curr").text($next.attr('links'));
	}
	
	if (clicked == 'next') {
             
    var $active = $('#'+ SlideShowId +' DIV.active');
    if ( $active.length == 0 ){
		$active = $('#'+SlideShowId+' DIV:last');
	}
    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#'+SlideShowId+' DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');
    
//    $next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
//	  $active.removeClass('active last-active');
//    });
    
	$next.addClass('active');
	$active.removeClass('active last-active');

    //alert(parseInt($next.attr('links')));
	
    //$("#imageLinks a").eq(parseInt($next.attr('links'))).addClass("current");
    //$("#imageLinks a").eq(parseInt($active.attr('links'))).removeClass("current");
    
    /*alert($("#imageLinks a").eq(0).text());*/
    
    //$("#imageLinks a").each(function(){ $(this).css("background-color","white")});
    //$("#imageLinks a.current").css("background-color","red");
	
	$("#" +SlideShowId+"Curr").text($next.attr('links'));
	
	}
    $('#'+ SlideShowId +' DIV.active');
	
}