var sl_id = 0;
var sl_timer = null;
var sl_stp = false;
var sl_count = 0;

function animate_slide(offset)
{   
  if (sl_timer)
  { 
    clearTimeout(sl_timer);
  }
  $('#slide_content').animate({marginLeft: "-" + (sl_id * offset) + "px"}, 1000);
  if (!sl_stp)
  {
    width = offset;
    sl_timer = setTimeout('left_slide(width)', 3500);
  }
}

function left_slide(offset)
{
  sl_id++;
  if (sl_id > sl_count)
  {
    sl_id = 1;
    $('#slide_content').animate({marginLeft: "0px"}, 0);
  }
  animate_slide(offset);
}

function right_slide(offset)
{
  sl_id--;
  if (sl_id < 0)
  {
    sl_id = sl_count - 1;
    $('#slide_content').animate({marginLeft: "-" + (sl_count * offset) + "px"}, 0);
  }
  animate_slide(offset);
}

function stop_slide()
{
  if (sl_timer)
  {
    clearTimeout(sl_timer);
  }
  sl_stp = true;
}

function start_slide(offset)
{
  width = offset;
  sl_timer = setTimeout('left_slide(width)', 3500);
  sl_stp = false;
}

//----------------------------------------------
$(document).ready(function(){
  $("div.inner").hover(function() {
  	$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
  	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
  		.animate({
  			marginTop: '-23px', /* The next 4 lines will vertically align this image */ 
  			marginLeft: '-23px',
  			top: '50%',
  			left: '50%',
  			width: '175px', /* Set new width */
  			//height: '174px', /* Set new height */
  			padding: '20px'
  		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
  	$(this).find('div').fadeIn("slow");
                                         		
  	} , function() {
  	$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
  	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
  		.animate({
  			marginTop: '0', /* Set alignment back to default */
  	   	marginLeft: '0',
  		  top: '0',
  			left: '0',
  			width: '169px', /* Set width back to default */
  			//height: '100px', /* Set height back to default */
  			padding: '5px'
  		}, 400);
  		$(this).find('div').fadeOut("slow");
  		
  });
})
