(function($) {

$.colourPickerFloors = {

	verticalOffset: -75,
	horizontalOffset: 0,
	repositionOnResize: true,
	overlayOpacity: .70,                // transparency level of overlay
	overlayColor: '#000',
	okButton: '&nbsp;Delete&nbsp;',         // text for the OK button
	cancelButton: '&nbsp;Cancel&nbsp;',		// text for cancel button
	
	//public methods
	
	
	
	
	// private methods
	
	_init: function(){
		
		var srcArr = Array("assets/images/floors_poppyred.jpg","assets/images/floors_royalblue.jpg","assets/images/floors_mossgreen.jpg","assets/images/floors_sahara.jpg","assets/images/floors_vanilla.jpg");
		var preloaded = $.colourPickerFloors._preloadImages(srcArr,function(result){
		$.colourPickerFloors._show(srcArr);															
	});
		
	},
	
	
	_show: function(srcArr){
		
		var swatches = $("#palette a");
		$(swatches[0]).addClass("active");
		$(".colourpickerfloors .inner").html('<img id="pic" src="'+srcArr[0]+'" alt="" width="636" height="263" />');
		var pic = $("#pic");
		
	swatches.each(function(){
			$(this).click(function(){
			index = $(this).index("#palette a");
			pic.attr("src",srcArr[index]);
			swatches.each(function(){
			$(this).removeClass("active");					   
								   })
			$(this).addClass("active");
				
			
			
						   })
						   
						   })

	},
	
	
_preloadImages: function(_images, callback){


	
	var gotime = _images.length;

	$.each(_images,function(e) {
							src = this;
							
	
		$(new Image()).load(function() {
			if (--gotime < 1){
				callback(true) ;
				
			}
		}).attr('src',src);
	});	  
	
		  
}
	
	
						
}

// Shortcut functions
jColourPickerFloors = function(){
	$.colourPickerFloors._init();
};

})(jQuery);
