(function($){
	 $.fn.extend({
	 
	 	customStyleSelect : function(options) {
		  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
		  return this.each(function() {
		  
				var currentSelected = $(this).find(':selected');
				$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
				var selectBoxSpan = $(this).next();
				var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
				var selectBoxSpanInner = selectBoxSpan.find(':first-child');
				selectBoxSpan.css({display:'inline-block'});
				selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
				var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
				$(this).height(selectBoxHeight).change(function(){
					// selectBoxSpanInner.text($(this).val()).parent().addClass('changed');   This was not ideal
					
				selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
					// Thanks to Juarez Filho & PaddyMurphy
				});
			
		  });
		  }
		}
	 });
	})(jQuery);


var select ='';
(function($) {
	$.fn.extend({
		customStyle : function(options) {
						return this
								.each(function() {

									var currentSelected = $(this).find(':selected');
									//$(this).attr('id','slselectCustom');
									$(this).after('<span class="SelectBox"><span class="SelectBoxInner">'+ currentSelected.text()+ '</span></span>').css({position : 'absolute',display : 'none'});
									$('.SelectBox').click(function(){
										select	=	jQuery(this).prev();
										if (select.attr('disabled')){
											
										}else{
											
										jQuery('#boxListSelect').remove();
										jQuery(this).parent().append('<div id="boxListSelect"></div>');
										var position = jQuery(this).position();
										jQuery('#boxListSelect').css({'top':position.top-20, 'left':position.left+20,'position':'absolute'});
										html	=	'<ul>';
										jQuery(this).prev().find('option').each(function(){
											var text	= jQuery(this).text(); 	  
											image=jQuery(this).attr('image');
											
											if (image!=undefined && image!='' && image!=null){
												html	= html +	'<li>'+'<img src="' + image + '"/>'+text+'</li>';
											}else{
												html	= html +	'<li>'+text+'</li>';	   
											}
										});
											
										html	= html +	'</ul>';
										jQuery('#boxListSelect').html(html);
										
											
										$('#boxListSelect li').click(function(event){ 
										
												 var option = jQuery(this).text();
												
												jQuery(select).find(' :contains('+option+')').attr("selected", true);
												if (select.hasClass('super-attribute-select')){
													spConfig.configureElement(document.getElementById(jQuery(select).attr('id')));
											 	}else{
											 		select.trigger('change');
											 	}
												jQuery(select).next().find('.SelectBoxInner').html(option);
											 });  
											
										}	
										
									});
									jQuery('.color-option').show();
									jQuery('.size-option').show();
								});
				}
			});
})(jQuery);
jQuery(document).click(function(e) {	
	  if (jQuery(e.target).filter('#boxListSelect').length != 1 &&  jQuery(e.target).filter('.SelectBox').length!=1 && jQuery(e.target).filter('.SelectBoxInner').length!=1 ) {
		  jQuery('#boxListSelect').remove();
	  }
});

