var address="http://www.bountyfreshchicken.com/";
function slideShow() {
	//alert(1);
    //Set the opacity of all images to 0
    $('#gallery img').css({opacity: 0.0});
	var a=$('#gallery img').css({opacity: 0.0});
	//alert(a);
    //Get the first image and display it (set it to full opacity)
    $('#gallery img:first').css({opacity: 1.0});
	
	$("#banner_filename").val($('#gallery img:first').attr("alt"));
	//alert($('#gallery img:last').attr("alt"));
	var myVal=$("#banner_filename").val();
	//alert(myVal);
	if(!myVal){
		myVal=1;
	}
	if ($('#gallery img.show').attr("name")== "" )
		{
			$('#gallery img').css('cursor','default');
			$('#gallery img').attr({
			onClick:""
			});
		}
		else
		{
			$('#gallery img').css('cursor','pointer');
			$('#gallery img').attr({
			onClick:"window.open('"+$('#gallery img.show').attr("name")+"')"
			});
		}
    setInterval('gallery()',5000);
     
}
 
function gallery() {
    //if no IMGs have the show class, grab the first image
	
    var current = ($('#gallery img.show')?  $('#gallery img.show') : $('#gallery img:first'));
	
    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery img:first') :current.next()) : $('#gallery img:first'));
	
    //Set the fade in effect for the next image, show class has higher z-index
    next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2000);
    //Hide the current image
    current.animate({opacity: 0.0}, 2000).removeClass('show');
	$("#banner_filename").val($('#gallery img.show').attr("alt"));
	//alert($('#gallery img.show').attr("alt"));
	var myVal=$("#banner_filename").val();
	//alert(myVal);
	if(!myVal){
		myVal=1;
	}
	if ($('#gallery img.show').attr("name")== "" )
		{
			$('#gallery img').css('cursor','default');
			$('#gallery img').attr({
			onClick:""
			});
		}
		else
		{
			$('#gallery img').css('cursor','pointer');
			$('#gallery img').attr({
			onClick:"window.open('"+$('#gallery img.show').attr("name")+"')"
			});
		}
	//onClick:"window.location='"+address+"?page_id="+myVal+"&page="+myVal+"'"
}
