// JavaScript Document
//<![CDATA[

window.onresize = function() {
	//if(module!="home") {
	//	footerPosition();
	//}
};

$(document).ready(function(){ 

	/*$('.filter .modal_head').on('click',function(){
		$(this).next().slideToggle(500);
		$('body').toggleClass('hidden');
	});*/
	
	$('.filter .modal_close.icon-close').on('click',function(e){
		e.preventDefault();
	});
	
	if ($(window).width() < 901) {
		$('#buttonCloseFilter').css({'position': 'relative'});
		window.scroll(0,1);
		$('#buttonCloseFilter').css({'position': 'fixed'});
	}
	
	$('.options .tab_title').click(function() {
		var thisID = $(this).data('parent'),
			thisID2 = $(this).data('parent2')
		$(this).addClass('active');
		$(this).parents('.options').find('.tab_title').not($(this)).removeClass('active');
		if($(this).parents('.options').hasClass('prop')){	
			$('.options.prop .tab_item').each(function(){
				if(thisID == $(this).data('child')){
					$(this).slideDown(500);
				} else{
					$(this).slideUp(500);
				}
			})
		} else {
			$('.options.cat .tab_item').each(function(){
				if(thisID2 == $(this).data('child2')){
					$(this).fadeIn(500);
				} else{
					$(this).fadeOut(500);
				}
			})
		}
	})
	
	
	$(window).scroll(function() {
	  if($(this).scrollTop() > 100) {
		  console.log('>100');
	  } else {
		 console.log('<100');
	  }
	});
	
	
	$("a[rel=external]").attr('target', '_blank');
	$("a").click(function(event){ this.blur() });
	$("object").click(function(event){ this.blur() });
	$("embed").click(function(event){ this.blur() });

	$("#header .menu li .submenu").each(function(index) {
    //alert(index + ': ' + $(this).text());
		$(this).width( $(".col", $(this)).length*105 + 20 );
	});
  														
	$("#header .languages").hover(
			function () {
				var elem = $('.layer', $(this));
				elem.stop(true, true).slideDown("400", "easeOutQuart");//(300);
			}, 
			function () {
				var elem = $('.layer', $(this));
				elem.stop(true, true).slideUp("400", "easeOutQuart");//(300);
			}
	);
	
	$("#header .menu li, .icon-search").stop(true, true).mouseenter(function() {
			$('.submenu', $(this)).stop(true, true).fadeIn("300", "easeOutQuart");
	}).stop(true, true).mouseleave(function() {
			$('.submenu', $(this)).stop(true, true).delay(300).fadeOut("200", "easeOutQuart");
	});
	/*.hover(
			function () {
				var elem = $('.submenu', $(this));
				elem.stop(true, true).slideDown("200", "easeOutQuart");//(300);
			}, 
			function () {
				var elem = $('.submenu', $(this));
				elem.stop(true, true).slideUp("200", "easeOutQuart");//(300);
			}
	);*/

	$('#isearch').focus(function() {
		var rel = $(this).attr('rel');
		if(this.value == rel) { this.value = ''; }
	});
	$('#isearch').blur(function() {
		var rel = $(this).attr('rel');
		if(this.value == '') { this.value = rel; }
	});
	
	
	
	
	//footerPosition();
});

window.onload = footerPosition;

/* controlliamo se l'altezza della finestr del browser Р“РЃ superiore all'altezza del contenuto della
	pagina. In questo caso fissiamo il footer in basso */
function footerPosition() {
	if( ($('#header').height()+$('#main').height()+$('#footer').height()) < $(window).height() ) {
		$('#footer').addClass('fixed');
	}
	else {
		$('#footer').removeClass('fixed');
	}
}




/*
Per la condivisione su facebook
*/
function fbShare(url, txt, picture) {
		var shareUrl = page_uri;
		var shareText = "";
		var share_picture = "";
		if(url!=null) shareUrl = url;
		if(txt!=null) shareText = txt;
		if(picture!=null) share_picture = picture;
		
		// calling the API ...
		var obj = {
			method: 'feed',
			//redirect_uri: page_uri,
			link: shareUrl,
			picture: share_picture,
			name: 'Helen Seward',
			//caption: '', // testo visualizzato sotto il titolo
			description: shareText
		};
		
		function callback(response) {
			//document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
		}
		
		FB.ui(obj, callback);
		
		return false;
}

//]]>




var helpers = {
    TwoD: function (num) {
        return num > 9 ? num : ('0' + num);
    },

    strings: {
        depilate: function (str) {
            return str.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi, '$1\n').replace(/^ *([\s\S]*?)[ \r\n]*$/, '$1');
        },
        ucfirst: function (str) {
            return str.length ? str.substr(0, 1).toUpperCase() + str.substr(1) : '';
        }
    },

    numbers: {
        padded: function (num, size) {
            return (new Array(num ? size - Math.floor(Math.log(num) / Math.log(10)) : size).join('0')) + num;
        },
        separated: function (sum) {
            if (sum > 1000000) {
                return Math.floor(sum / 1000000) + ' ' + helpers.numbers.padded(Math.floor(sum / 1000) % 1000, 3) + ' ' + helpers.numbers.padded(sum % 1000, 3);

            } else if (sum > 1000) {
                return Math.floor(sum / 1000) + ' ' + helpers.numbers.padded(sum % 1000, 3);

            } else {
                return sum;
            }
        },
        verbal: function (sum, one, four, many, skipNumber, separated) {
            var perSum = sum % 100;
            var prefix = skipNumber ? '' : ((separated ? helpers.numbers.separated(sum) : sum) + ' ');

            if (perSum <= 10 || perSum >= 20) {
                switch (perSum % 10) {
                    case 1:
                        return prefix + one;
                        break;

                    case 2:
                    case 3:
                    case 4:
                        return prefix + four;
                }
            }

            return prefix + many;
        },
        filesize: function (num) {
            if (num > 1000000) {
                return Math.round(num / 100000) / 10 + ' Мб';

            } else if (num > 10000) {
                return Math.round(num / 1000) + ' Кб';

            } else if (num > 1000) {
                return Math.round(num / 100) / 10 + ' Кб';

            } else {
                return helpers.numbers.verbal(num, 'байт', 'байта', 'байт');
            }
        }
    },

    time: {
        monthNames: ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'],
        monthNamesBy: ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'],
        weekdays: ['воскресенье', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота'],
        weekday: function (date) {
            var cd = helpers.time.fromDate(date);
            return helpers.time.weekdays[cd.getDay()];
        },
        toDate: function (cd) {
            return (cd.getYear() > 1900 ? cd.getYear() : cd.getYear() + 1900) + '-' + helpers.TwoD(cd.getMonth() + 1) + '-' + helpers.TwoD(cd.getDate());
        },
        toDateHuman: function (cd, sep, withTime) { // лол
            if (typeof cd == 'string') {
                cd = helpers.time.fromDate(cd);
            }
            if (typeof sep == 'undefined') sep = '.';

            return helpers.TwoD(cd.getDate()) + sep + helpers.TwoD(cd.getMonth() + 1) + sep + (cd.getYear() > 1900 ? cd.getYear() : cd.getYear() + 1900)
                + (withTime ? ', ' + helpers.TwoD(cd.getHours()) + ':' + helpers.TwoD(cd.getMinutes()) : '');
        },
        toDateTime: function (cd, separator) {
            return (cd.getYear() > 1900 ? cd.getYear() : cd.getYear() + 1900) + '-' + helpers.TwoD(cd.getMonth() + 1) + '-' + helpers.TwoD(cd.getDate()) + ' ' + helpers.TwoD(cd.getHours()) + ':' + helpers.TwoD(cd.getMinutes()) + ':' + helpers.TwoD(cd.getSeconds());
        },
        toVerbal: function (date) {
            if (date instanceof Date) {
                date = helpers.time.toDate(date);
            }

            var dateParts = date.split('-');

            return dateParts[2] + ' ' + helpers.time.monthNamesBy[dateParts[1] - 1] + ' ' + dateParts[0];
        },
        currentYear: function () {
            if (typeof helpers.time._currentYear != 'undefined') {
                return helpers.time._currentYear;
            }

            helpers.time._currentYear = (new Date()).getYear();
            if (helpers.time._currentYear < 1900) {
                helpers.time._currentYear += 1900;
            }
        },
        toVerbalTime: function (date, separator, noSameYear) {
            if (date instanceof Date) {
                date = helpers.time.toDateTime(date);
            }

            var dateParts = date.split(/[-: ]/)
                , year = ' ' + dateParts[0];

            if (typeof separator == 'undefined') separator = ', ';
            if (noSameYear && helpers.time.currentYear() == dateParts[0]) {
                year = '';
            }

            return dateParts[2] + ' ' + helpers.time.monthNamesBy[dateParts[1] - 1] + year + separator + dateParts[3] + ':' + dateParts[4];
        },

        fromDateParts: function(year, month, day, hour, minute, second) {
            var cd = new Date();
            cd.setYear(year);
            cd.setMonth(month - 1);
            cd.setDate(day);

            cd.setHours(hour);
            cd.setMinutes(minute);
            cd.setSeconds(typeof second == 'undefined' ? 0 : second);

            return cd;

        },
        fromDate: function (date) {
            var cd = new Date();
            console.log(date);
            var mainParts = date.split(' ');
            var dateParts = mainParts[0].split('-');
            cd.setYear(dateParts[0] - 0);
            cd.setMonth(dateParts[1] - 1);
            cd.setDate(dateParts[2] - 0);

            if (mainParts.length) {
                var timeParts = mainParts[1].split(':');
                cd.setHours(timeParts[0] - 0);
                cd.setMinutes(timeParts[1] - 1);
                cd.setSeconds(timeParts[2] - 0);
            }

            return cd;
        },
        nextDate: function (date) {
            var cd = helpers.time.fromDate(date);
            cd.setTime(cd.getTime() + (86400 + 3600) * 1000);

            return helpers.time.toDate(cd);
        },
        range: function (from, to) {
            var fromDate = new Date(from);
            var toDate = new Date(to);
            var result = 0;

            while (fromDate.getTime() <= toDate.getTime()) {
                fromDate.setTime(fromDate.getTime() + 86400 * 1000);
                ++result;
            }

            return result;
        },
        verbalSpan: function (from, to) {
            var fromSplit = from.split('-');
            var toSplit = to.split('-');

            if (from == to) {
                return fromSplit[2] + ' ' + helpers.time.monthNamesBy[fromSplit[1] - 1];
            }

            if (fromSplit[1] == toSplit[1]) {
                return 'с ' + fromSplit[2] + ' по ' + toSplit[2] + ' ' + helpers.time.monthNamesBy[fromSplit[1] - 1];
            }

            if (fromSplit[0] == toSplit[0]) {
                return 'с ' + fromSplit[2] + ' ' + helpers.time.monthNamesBy[fromSplit[1] - 1] + ' по ' + toSplit[2] + ' ' + helpers.time.monthNamesBy[toSplit[1] - 1];
            }

            return 'с ' + fromSplit[2] + ' ' + helpers.time.monthNamesBy[fromSplit[1] - 1] + ' ' + fromSplit[0] + ' по ' + toSplit[2] + ' ' + helpers.time.monthNamesBy[toSplit[1] - 1] + ' ' + toSplit[0];
        },
        secondsToTime: function (seconds) {
            seconds = Math.round(seconds);

            if (seconds > 3600) {
                return helpers.TwoD(Math.floor(seconds / 3600)) + ':' + helpers.TwoD(Math.floor((seconds % 3600) / 60)) + ':' + helpers.TwoD(seconds % 60);
            } else {
                return helpers.TwoD(Math.floor((seconds % 3600) / 60)) + ':' + helpers.TwoD(seconds % 60);
            }
        }
    }
};

	
	
	

	

	$(function() {
		var $filters = $('.filter');
		var filterOptions = typeof catalogData === 'undefined' ? {} : catalogData.filterOptions;
		var id2verbal = {};
		var verbal2id = {};
		var baseUrl = 'https://hamamsuite.ru/shop/';
		var $catalog = $('#divItems,#prodotto_dett');
		var $modalAdded = $('.modal_add');
		var filterItems = {};
		var $filterTextBlock = $('.text-block');
		
		$filters.find('[data-code]').each(function() {
			verbal2id[$(this).attr('data-code')] = this.value;
			verbal2id[this.value] = this.value;
			filterItems[this.name + ':' + this.value] = $(this).closest('label')
		});		
		
		
		
		$(document).on({
			click: function() {
				var $this = $(this);
				var $item = $this.closest('.item');				
				var itemId = $item.attr('data-item-id');
				var color = 0;
				
				if ($this.hasClass('inactive')) return false;
				
				var $select = $item.find('select.item-subtype');
				if ($select.length) {
					itemId = $select.val();
				}
				
				$select = $item.find('select.select-color');
				if ($select.length) {
					color = $select.val();
				}
				
				if($item.find('select.item-subtype').length == 0){
					itemId = $(this).data('item-id');
				}
				
				
				
				$.post('/system/api/basket/add-item', {id: itemId, color: color}, function(data) {
					if (data.result == 'success') {
						$('.icon-cart').html('<span>' + data.basket.count + '</span>');
						$this.addClass('selected');
						$modalAdded.show();
						setTimeout(function() {
							$modalAdded.fadeOut(1000);					
						}, 500);
						
						
					} else {
						alert(data.reason);	
					}
					
				}, 'json');
				
				return false;
			}
		}, '.add-to-basket');
		
		$('.more-items').on({
			click: function() {
				RequestItems(false, true);				
				return false;
			}				
		});
		
		
		
		
		
		
		
		
		$catalog.on({
			change: function() {
				console.log('change');
				var $select = $(this);
				var $option = $select.find('option[value="' + $select.val() + '"]');				
				if ($option.length) {
					var $item = $select.closest('.item');
					$item.find('.price').text(helpers.numbers.separated($option.attr('data-price') * 1) + ' руб.');
				}
				
			}
					
		}, 'select.item-subtype');
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		


		function RenderPossibilities() {			
			
			var possibilities = {};
			var filters = ['collection', 'bath', 'bed', 'plotnost', 'color', 'size', 'sostav'];			
			var fitting = catalogData.propertiesData.filter(function(item) {
				for (var i = 0; i < filters.length; ++i) {
					var filter = filters[i];					
					if (typeof filterOptions[filter] === 'undefined' || filterOptions[filter] == '') continue;
					
					var gotIntersection = false;
					filterOptions[filter].split(',').map(function(filterOption) {
						if (item[filter].split(',').indexOf(verbal2id[filterOption]) != -1) {
							gotIntersection = true;
						}
					});
					
					
					if (!gotIntersection) return false;
				}
				
				return true;
			});
			
			fitting.map(function(item) {
				for (var i = 0; i < filters.length; ++i) {
					var filter = filters[i];
					var possibility = item[filter];
					if (possibility == '') continue;
					
					possibility.split(',').map(function(possibilityOption) {
						possibilities[filter + ':' + possibilityOption] = true;
					});
				}
			});
			
			for (var i in filterItems) {
			console.log(i);
				filterItems[i].toggleClass('hidden',
					typeof possibilities[i] === 'undefined' && 
					i.indexOf('bath') === -1 &&
					i.indexOf('bed') === -1 &&
					i.indexOf('collection') === -1
				);
			}			
			
			$filterTextBlock.empty();
			$filters.find('input:checked').each(function() {
				var $this = $(this);
				var $label = $this.closest('label');
				if ($this.attr('data-description') != '') {
					$filterTextBlock.append('<p class="p1"><b>' + $label.find('span').text() + '</b> - ' + $this.attr('data-description') + '</p>');
				}				
			});			
		}
		
		
		function RequestItems(withoutNavigation, append) {
			var params = {goods: 1125};
			console.log('reqndw');
			
			if (!withoutNavigation) {
				console.log('render');		
				RenderQueryString(filterOptions);	
			}
			
			for (var i in filterOptions) {
				params[i] = filterOptions[i];
			}
			
			if (append) {
				params.start = $catalog.find('.item').length;
			}

			$.get('/system/php/scripts/filtered_goods.php', params, function(data) {
				if (append) {
					$catalog.append(data);
				} else {
					$catalog.html(data);
				}
				$('select').StyledSelect();
				RenderPossibilities();			
			});
		}
		
		
		function RenderQueryString(options) {
			var queryItems = [];
			console.log(options);
			
			for (var i in options) {
				if (i == 'goods') continue;
				var paramStr = options[i].split(',').map(function(id) {
					return typeof id2verbal[id] === 'undefined' ? id : id2verbal[id];
				});
				if (paramStr.length) {
					queryItems.push(i + '/' + paramStr.join(','));
				}
			}
			
			urlStr = queryItems.length ? 'filter/' + queryItems.join('/') : '';
			// document.location.hash = '#!' + urlStr;
			window.history.pushState("", document.title, baseUrl + urlStr);
		}
		
		
		
		$('.filter_block input').change(function() {
			var $block = $(this).closest('.filter_block');
			var code = $block.attr('data-filter');
			
			var params = [];
			$block.find('input:checked').each(function() {
				var $input = $(this);
				params.push($input.attr('data-code'));			
			});
			
			if (params.length) {
				filterOptions[code] = params.join(',');
				
			} else {
				delete filterOptions[code];
			}
						
			RequestItems();
		});
	
	
		function RenderFilterFromUrl() {
			$filterItems.filter('.active').removeClass('active');
			
			filterOptions = {};
			
			var matches = document.location.href.match(/\/index\/(.+)(\?|$)/);
			if (matches) {
				var pairs = matches[1].split('/');
				
				for (var i = 0, l = pairs.length; i < l; i += 2) {
					var code = pairs[i]; 
					var values = pairs[i + 1];
					//filterOptions[code] = values;	
					var filterValues = [];
								
					values.split(',').map(function(filter) {
						$filterItems.filter('[data-key="' + code + ':' + filter +'"]').addClass('active');					
						filterValues.push(typeof verbal2id[filter] === 'undefined' ? filter : verbal2id[filter][1].attr('item'));
					});
					
					filterOptions[code] = filterValues.join(',');
				}
			}	
			
			console.log(filterOptions);
		}
		
		function RenderFromOptions(options) {
			for (var filterCode in options) {
				var filterData = options[filterCode];
				
				var $filterBlock = $filters.find('[data-filter="' + filterCode + '"]');
				if ($filterBlock.length) {
					console.log('fondo');
					filterData.split(',').map(function(key) {
						$filterBlock.find('[data-code="' + key + '"]').attr('checked', 'checked');					
						$filterBlock.find('[value="' + key + '"]').attr('checked', 'checked');
					});
					
				
				} else {
					console.log('nofondo ' + filterCode);
				}
			}
			
		}
		
		
		if ($filters.length) {
			RenderFromOptions(filterOptions);
			RenderPossibilities();
			
		
			window.onpopstate = function(e) {
				// RenderFilterFromUrl();
				RequestItems(true);		
			}
		}
	});
	
	
	$.fn.StyledSelect = function() {
		return this.each(function() {
			var $this = $(this)
				, numberOfOptions = $(this).children('option').length
		  
		  	if ($this.hasClass('select-hidden')) return;		  	
		    $this.addClass('select-hidden'); 
		    $this.wrap('<div class="select"></div>');
		    $this.after('<div class="select-styled"></div>');
		
		    var $styledSelect = $this.next('div.select-styled');
		    
		  	var $selectedOption = $this.children('option:selected');
		  	if ($selectedOption.length == 0) {
		  		$selectedOption = $this.children('option').eq(0);
		  	}
		    $styledSelect.text($selectedOption.text());
		  
		    var $list = $('<ul />', {
		        'class': 'select-options'
		    }).insertAfter($styledSelect);
		  
		    for (var i = 0; i < numberOfOptions; i++) {
		        $('<li />', {
		            text: $this.children('option').eq(i).text(),
		            rel: $this.children('option').eq(i).val()
		        }).appendTo($list);
		    }
		  
		    var $listItems = $list.children('li');
		  
		    $styledSelect.click(function(e) {
		        e.stopPropagation();
		        $('div.select-styled.active').not(this).each(function(){
		            $(this).removeClass('active').next('ul.select-options').hide();
		        });
		        $(this).toggleClass('active').next('ul.select-options').toggle();
		    });
		  
		    $listItems.click(function(e) {
		        e.stopPropagation();
		        $styledSelect.text($(this).text()).removeClass('active');
		        $this.val($(this).attr('rel')).trigger('change');
		        $this.closest('div.select').nextAll('div.actions-size').find('div.line[value!=' + $this.val() + ']').hide();
				$this.closest('div.select').nextAll('div.actions-size').find('div.line[value=' + $this.val() + ']').show();
		        $list.hide();
		        //console.log($this.val());
		    });
		    
		    $list.children('li').eq(0).trigger('click');
		  
		    $(document).click(function() {
		        $styledSelect.removeClass('active');
		        $list.hide();
		    });
		});	
	}  


$(document).ready(function(){
	$('select').StyledSelect();
	
	/**
	  * init sliders for product gallery
	 */
	 
	$('.main-image-slider').slick({
	  slidesToShow: 1,
	  slidesToScroll: 1,
	  arrows: false,
	  fade: true,
	  asNavFor: '.nav-image-slider'
	});
	
	$('.nav-image-slider').slick({
	  slidesToShow: 3,
	  slidesToScroll: 1,
	  asNavFor: '.main-image-slider',
	  dots: false,
	  centerMode: true,
	  focusOnSelect: true,
	  infinity: true
	});
	
	/**
	  * go to current slider ID
	 */
	 
	var currentSliderID = $('.active-variation.slick-slide:not(".slick-cloned")');
	if(currentSliderID.length > 0) {
		$('.nav-image-slider').slick('slickGoTo', currentSliderID.data('slick-index'));
	}
	console.log(currentSliderID);
	
	/**
	  * change product type
	 */
	 
	$('#color').change(function(){
		var colorID = $(this).val();
		$('.nav-image-slider img[data-color="' + colorID + '"]').parent().trigger('click');
	});
	
	$('.nav-image-slider img').click(function(){
		var colorID = $(this).data('color');
		$('.select-options').find('li[rel="'+ colorID +'"]').trigger('click');
	});
	
	/**
	  * zoomer for product main image
	 */
	 
	if($( window ).width() > 989){
		var $easyzoom = $('.easyzoom').easyZoom();
		var api = $easyzoom.data('easyZoom');
	}
	
	/**
	  * popup for product main image
	 */
	 
	$('.main-image-slider .slick-slide.slick-current').click(function(e){
		e.preventDefault();
	});
	
	$('.product-zoom-btn').click(function(){
		$('.main-image-slider .slick-slide.slick-current a').trigger('click');
	});
	 
	$('.main-image-slider').magnificPopup({
		delegate: 'a',
		type: 'image',
		tLoading: 'Loading image #%curr%...',
		mainClass: 'mfp-img-mobile',
		gallery: {
			enabled: true,
			navigateByImgClick: true,
			preload: [0,1] // Will preload 0 - before current, and 1 after the current image
		},
		image: {
			tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
			titleSrc: function(item) {
				return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';
			}
		}
	});

/*
	$('select').each(function(){
	    var $this = $(this), numberOfOptions = $(this).children('option').length;
	  
	    $this.addClass('select-hidden'); 
	    $this.wrap('<div class="select"></div>');
	    $this.after('<div class="select-styled"></div>');
	
	    var $styledSelect = $this.next('div.select-styled');
	    $styledSelect.text($this.children('option').eq(0).text());
	  
	    var $list = $('<ul />', {
	        'class': 'select-options'
	    }).insertAfter($styledSelect);
	  
	    for (var i = 0; i < numberOfOptions; i++) {
	        $('<li />', {
	            text: $this.children('option').eq(i).text(),
	            rel: $this.children('option').eq(i).val()
	        }).appendTo($list);
	    }
	  
	    var $listItems = $list.children('li');
	  
	    $styledSelect.click(function(e) {
	        e.stopPropagation();
	        $('div.select-styled.active').not(this).each(function(){
	            $(this).removeClass('active').next('ul.select-options').hide();
	        });
	        $(this).toggleClass('active').next('ul.select-options').toggle();
	    });
	  
	    $listItems.click(function(e) {
	        e.stopPropagation();
	        $styledSelect.text($(this).text()).removeClass('active');
	        $this.val($(this).attr('rel'));
	        $list.hide();
	        //console.log($this.val());
	    });
	  
	    $(document).click(function() {
	        $styledSelect.removeClass('active');
	        $list.hide();
	    });
	
	});

*/
})