(function(jQuery){

jQuery.fn.slideshow = function(options){
	
	
	var defaults = {			
			
			speed :									800,
			showStrip :								true,
			imagestripClass :						"imageStrip",
			imagestripHitClass :					"imageHitStrip",
			stripImageWidth : 						80,
			slideActiveClass : 						"active",
			currentImgActive :	 					1,
			productViewWidth :						"100%",
			imageHitStripclip :						"imageHitStripclip"
		}; 		
		var options = jQuery.extend(defaults, options); 
		
		// Creating Object for this
		var element = this;
		jQuery(element).each(function(){
								 
		
		
		var _imageListing = jQuery(element).children("ul.imageList");
		var _imageListingItem = jQuery(_imageListing).children("li");
		var _imageListingItem_total = _imageListingItem.length;
		
		jQuery(_imageListingItem).each(function(i){		
			var zindex = (_imageListingItem_total - i) + 1;
			jQuery(this).css("z-index",zindex);								   
		})
		
			
		// Creating Image Strip		
		if (options.showStrip)
		{
			jQuery(element).append('<div class="' + options.imagestripHitClass + '"><div class="' + options.imageHitStripclip + '"><ul class=' + options.imagestripClass + '></ul></div></div>');			
			// Append Image in Image Strip
			jQuery(_imageListingItem).each(function(i){											   
				var _imageListingItemImage = jQuery(this).children("img");					
				jQuery(document.createElement("li"))
				.html('<img src=' + jQuery(_imageListingItemImage).attr("src") + ' width=' + options.stripImageWidth + ' id=' + jQuery(element).attr("id") + jQuery(element).attr("class") + "-" + i + ' />')
				.appendTo("." + options.imagestripClass)
				.click(function(){
	 					var imgID = jQuery(this).find("img").attr("id");
						var newActiveImgraw = imgID.substring(imgID.indexOf("-") + 1, imgID.length);
						var newActiveImg = Number(newActiveImgraw) + 1;
						jQuery('ul.imageList li').not(jQuery('ul.imageList li:nth-child(' + options.currentImgActive + ')')).css("display","none");						
					    jQuery(jQuery('ul.imageList li:nth-child(' + options.currentImgActive + ')')).css("z-index",0);
						jQuery(jQuery('ul.imageList li:nth-child(' + newActiveImg + ')')).css("z-index",1000);
						jQuery(jQuery('ul.imageList li:nth-child(' + newActiveImg + ')')).fadeIn(500);					
						options.currentImgActive = newActiveImg;						
						 		
				}); 					
			})
			
			
		}
		
		// Creating Image Animation	
		
		jQuery("." + options.imagestripHitClass).hover(function(){
														   
					jQuery('.' + options.imageHitStripclip).stop().animate({width:options.productViewWidth},1000);
				},
				function() {
					jQuery('.' + options.imageHitStripclip).stop().animate({width:0},1000);
				}
			);		
		});
	
	};

})(jQuery);

jQuery(document).ready(function(){
								
								
	// Product Listing Starts
	jQuery('.listing-item a').children('.hover-state-details,.hover-state-bg').animate({opacity: 0.0}, { "duration": 500, "easing": "linear" });
	jQuery('.listing-item a').hover(function(){
	jQuery(this).children('.hover-state-bg ,.hover-state-details,').stop();								
		jQuery(this).children('.hover-state-details,').animate({opacity: 1.0}, { "duration": 500, "easing": "linear" });
		jQuery(this).children('.hover-state-bg').animate({opacity: 0.5}, { "duration": 500, "easing": "linear" });
		
										},
	function(){
		jQuery(this).children('.hover-state-bg ,.hover-state-details,').stop();
		jQuery(this).children('.hover-state-details,.hover-state-bg').animate({opacity: 0.0}, { "duration": 500, "easing": "linear" });
	
											
	})
	
	// Product Listing Ends
	
	// Mini Cart Starts
	
	var timed;	
	function timedDNone(){		
		timed = setTimeout(function(){jQuery(".mini-shopping-top").slideUp(500);}, 1000) 
	}	
	
	jQuery(".mini-shopping-top-cont .mini-shopping-top-hit").hover(
	function(){ 
	
		jQuery(".mini-shopping-top").slideDown(500);
																			
	},
	function(){ 
	
		timedDNone();
																			
	})
	
	jQuery(".mini-shopping-top-cont .mini-shopping-top").hover(
	function(){ 
		
		clearTimeout(timed);
		jQuery(".mini-shopping-top").slideDown(500);
																			
	},
	function(){ 
	
		timedDNone();
																			
	})	
	// Mini Cart Ends
			
})

