//Thanks to Ragulan Rajaratnam for most of the code to this
//http://ragulan.co.uk/articles/view/30

$(function() { 
objImage =
  {
    index : 1,
	
    // an array of images
    images : ["image-shop-2.jpg", "image-shop-3.jpg", "image-shop-4.jpg", "image-shop-5.jpg", "image-shop-7.jpg"],
	
    // function to increase the index value, and reset it if we are at the end of the array
    inc_index : function() {
      this.index++; 
      
      if (this.index == this.images.length) {
        this.index = 0;
      }
    },
	
    // getting function to return the current index
    get_index : function() { return this.index; },
	
    // function  to fade out, swap the image, increase the index and fade in the image
    swap : function() {
		//set the background image to the enclosing div
		$("#image-holder").css("background-image", "url(/media/image/" + 
          objImage.images[objImage.index] + ")");
      // first fade the image out
      $("#image-shop").fadeOut(2000, function() {
        
        // change the image
        $("#image-shop").attr("src", "/media/image/" + 
          objImage.images[objImage.index]);
        
        // fade the image back in
        $("#image-shop").fadeIn(2000);
        
       // increase the index
       objImage.inc_index();
      });
    }
  };

  // swap the image every n seconds
  setInterval(objImage.swap, 5000);
  
		   });

$(document).ready(function(){
	var gobutton=$('input.go');
	gobutton.click(function(){
		var pattern=$('#pattern').val();
		if (pattern=='Search by Pattern Number') {
			alert('Please Specify a Pattern Number');
			return false;
		}
	});
});