// html5shiv MIT @rem remysharp.com/html5-enabling-script
// iepp v1.6.2 MIT @jon_neal iecss.com/print-protector
/*@cc_on(function(m,c){var z="abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video";function n(d){for(var a=-1;++a<o;)d.createElement(i[a])}function p(d,a){for(var e=-1,b=d.length,j,q=[];++e<b;){j=d[e];if((a=j.media||a)!="screen")q.push(p(j.imports,a),j.cssText)}return q.join("")}var g=c.createElement("div");g.innerHTML="<z>i</z>";if(g.childNodes.length!==1){var i=z.split("|"),o=i.length,s=RegExp("(^|\\s)("+z+")",
"gi"),t=RegExp("<(/*)("+z+")","gi"),u=RegExp("(^|[^\\n]*?\\s)("+z+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),r=c.createDocumentFragment(),k=c.documentElement;g=k.firstChild;var h=c.createElement("body"),l=c.createElement("style"),f;n(c);n(r);g.insertBefore(l,
g.firstChild);l.media="print";m.attachEvent("onbeforeprint",function(){var d=-1,a=p(c.styleSheets,"all"),e=[],b;for(f=f||c.body;(b=u.exec(a))!=null;)e.push((b[1]+b[2]+b[3]).replace(s,"$1.iepp_$2")+b[4]);for(l.styleSheet.cssText=e.join("\n");++d<o;){a=c.getElementsByTagName(i[d]);e=a.length;for(b=-1;++b<e;)if(a[b].className.indexOf("iepp_")<0)a[b].className+=" iepp_"+i[d]}r.appendChild(f);k.appendChild(h);h.className=f.className;h.innerHTML=f.innerHTML.replace(t,"<$1font")});m.attachEvent("onafterprint",
function(){h.innerHTML="";k.removeChild(h);k.appendChild(f);l.styleSheet.cssText=""})}})(this,document);@*/
$(function() {
    /*	clearInputs();*/
    initGalleries();
    initLightbox();
    navDrop();
    newsBar();
    sidePanel();
    newsOverlay();
    slideBlock();
    initZoom();
    initCustomForms();
    initTabs();
    initCustomScroll();
    addClass();
    pressedState();
    searchDrop();
    /*initLoadingBlock();*/
    langDrop();
    coverflipInit();
    initFixedPanel();
    clearFields();
    changeAddress();
    otherLooks();
    shopDrop();
    removeItemRow();
    initDropFix();
    colorDrop();

})

function initDropFix(){
	$('.look-collateral .scroll-hold>ul>li:last').each(function(){
		var holder = $(this);
		$('.color-drop, .sex-drop', holder).addClass('alt');
	})
}
function initLoadingBlock(){
	var links = $('.pager a.prev, .pager a.next');
	var selects = $('#sort-by, #size, #color');
	var overlay = $('<div class="overlay">');
	var loader = $('<span class="loader"></span>').text('loading');
	overlay.css({
		width: $('#wrapper').width(),
		height: $('#wrapper').height(),
		backgroundColor: 'white',
		opacity: 0,
		position: 'absolute',
		left:0,
		top:0,
		zIndex: 1000
	});
	$(window).scroll(function(){
		var scrollPosition = $(window).scrollTop();
		loader.css({top:scrollPosition+$(window).height()/2})
	})
	loader.css({opacity: 0})
	var wait = true;

	links.each(function(){
		var _this = $(this);
		_this.click(function(){
			loadBox();
			return false;
		});
	});
	
	selects.change(loadBox);
	function loadBox(){
		if(wait){
			wait = false;
			var t1 = overlay.clone();
			var t2 = loader.clone();
			t1.appendTo($('body')).stop().animate({opacity:0.7}, {queue:false, duration: 300});
			t2.appendTo($('body')).stop().animate({opacity:1}, {queue:false, duration: 300});
			setTimeout(function(){
				t1.fadeOut(300, function(){t1.remove()});
				t2.fadeOut(300, function(){t2.remove(); wait=true});
			}, 1000);
		}
	}
}

/*---- clear inputs ---*/
function clearInputs(){
	$('input:text, input:password, textarea').each(function(){
		var _el = $(this);
		var _val = _el.val();
		_el.bind('focus', function(){
			if(this.value == _val) this.value = '';
			$(this).filter('input:text,input:password').parents('.text').addClass('active');
			$(this).filter('textarea').parents('.textarea').addClass('active');
		}).bind('blur', function(){
			if(this.value == '') this.value = _val;
			$(this).filter('input:text,input:password').parents('.text').removeClass('active');
			$(this).filter('textarea').parents('.textarea').removeClass('active');
		});
	});
}
/* coverflip init */
function coverflipInit(){
	if($('.coverflip').length){
		var coverflipSection = $('.coverflip-section');
		var btnPrev = coverflipSection.find('.btn-prev');
		var btnNext = coverflipSection.find('.btn-next');
		var currentSlide = coverflipSection.find('.current-slide');
		var totalSlides = coverflipSection.find('.total-slides');
		var coverflipSlides = coverflipSection.find('li');
		var t;
		var autoRoationSpeed = 2000;
		totalSlides.text(coverflipSlides.length);
		var slideIndex = 1;
		$('.coverflip').jcoverflip({
			current:0,
			beforeCss: function( el, container, offset ){
				$(el).css('z-index', 2);
				return [
					$.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 490 - 300*offset + 20*offset )+'px', bottom: '75px' }, { } ),
					$.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,270-10*offset*offset) + 'px' }, {} )
				];
			},
			afterCss: function( el, container, offset ){
				$(el).css('z-index', 2);
				return [
					$.jcoverflip.animationElement( el, { left: ( container.width( )/2 + 215 + 300*offset )+'px', bottom: '75px' }, { } ),
					$.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,270-10*offset*offset) + 'px' }, {} )
				];
			},
			currentCss: function( el, container ){
				$(el).css('z-index', 3);
				return [
					$.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 190 )+'px', bottom: 13 }, { } ),
					$.jcoverflip.animationElement( el.find( 'img' ), { width: '370px' }, { } )
				];
			},
			change: function(){
				slideIndex = $('.coverflip').jcoverflip('current');
				currentSlide.text(slideIndex+1);
				return slideIndex;
			},
			time:800
		});
		var currentIndex = $('.coverflip').jcoverflip('current')
		currentSlide.text(currentIndex+1);
		btnPrev.click(function(){
			$('.coverflip').jcoverflip('previous')
			return false;
		});
		btnNext.click(function(){
			$('.coverflip').jcoverflip('next')
			return false;
		})
		coverflipSection.hover(function(){clearTimeout(t)})
		function autoRotation(){
			clearTimeout(t);
			t = setTimeout(autoRotation, autoRoationSpeed);
			setTimeout(function(){
				$('.coverflip').jcoverflip('next')
			},1000)
		}
		autoRotation();
	}
}
/* remove item row */
function removeItemRow(){
	var shoppingTable = $('.shopping-table');
	var shoppingRow = shoppingTable.find('tbody tr');
	var animSpeed = 500;
	shoppingRow.each(function(){
		var currentRow = $(this);
		var removeLink = currentRow.find('.remove');
		removeLink.click(function(){
			currentRow.fadeOut(animSpeed,function(){currentRow.remove()})
		})
	})
}
/* shop drop */
/*function shopDrop(){
	var shopDropHolder = $('.quick-access ul li').has('.shop-drop');
	var shopDrop = shopDropHolder.find('.shop-drop');
	shopDrop.hide();
	var animSpeed = 300;
	var delay = 300;
	var show;
	var hide;
	function showDrop(){shopDrop.stop(true,true).slideDown(animSpeed);}
	function hideDrop(){shopDrop.stop(true,true).slideUp(animSpeed);}
	shopDropHolder.mouseenter(function(){
		if(hide) clearTimeout(hide);
		showDrop();
	})
	shopDropHolder.mouseleave(function(){
		hide = setTimeout(hideDrop,delay);
	})
	
	//initScroll
	shopDrop.show();
	var scroll = $('.scrolled-list .holder');
	scroll.customScrollV();
	shopDrop.hide();
	/*setInterval(function(){
		if (shopDrop.is(':hidden')){
			shopDrop.show();
			scroll.get(0).scrollResize();
			shopDrop.hide();
		}
		else {
			scroll.get(0).scrollResize();
		}
	}, 2500)
}*/
function shopDrop() {
    var shopDropHolder = $('.quick-access ul li').has('.shop-drop');
    var shopDrop = shopDropHolder.find('.shop-drop');
    shopDrop.hide();
    var animSpeed = 300;
    var delay = 300;
    var show;
    var hide;
    function showDrop() { shopDrop.stop(true, true).slideDown(animSpeed); }
    function hideDrop() { shopDrop.stop(true, true).slideUp(animSpeed); }
    shopDropHolder.mouseenter(function() {
        if (hide) clearTimeout(hide);
        showDrop();
    })
    shopDropHolder.mouseleave(function() {
        hide = setTimeout(hideDrop, delay);
    })

    //initScroll
    shopDrop.show();
    var scroll = $('.scrolled-list .holder');
    scroll.customScrollV();
    shopDrop.hide();
    setInterval(function() {
        if (shopDrop.is(':hidden')) {
            shopDrop.show();
            if (scroll.find('.scroll-content').length == 0) {
                scroll.customScrollV();
            }
            else {
                scroll.get(0).scrollResize();
            }
            shopDrop.hide();
        }
        else {
            if (scroll.find('.scroll-content').length == 0) {
                scroll.customScrollV();
            }
            else {
                scroll.get(0).scrollResize();
            }
        }
    }, 2500)
}

/* search drop */
function searchDrop(){
	var search = $('.search');
	searchOpener = search.find('.opener');
	var searchInput = search.find('input:text');
	searchOpener.click(function(event){
	event.stopPropagation();
	document.getElementById(searchInput.attr('id')).focus();
		if(search.hasClass('active')) search.removeClass('active');
		else search.addClass('active');
	})
	search.click(function(e){e.stopPropagation();})
	$('html').click(function(){search.removeClass('active')})
}
/* other looks */
function otherLooks(){
	var otherLooks = $('.other-looks');
	var otherLooksDrop = otherLooks.find('.drop');
	var animSpeed = 500;
	otherLooks.mouseenter(function(){otherLooksDrop.stop(true,true).slideDown(animSpeed);})
	otherLooks.mouseleave(function(){otherLooksDrop.stop(true,true).slideUp(animSpeed);	})
}
function colorDrop(){
	var colorDrop = $('.color-drop .drop');
	var maxQuantity = 5;
	colorDrop.each(function(){
		var currentColorDrop = $(this);
		var colorDropItem = currentColorDrop.find('li');
		var colorDropItemWidth = colorDropItem.outerWidth();
		var colorDropItemLength = colorDropItem.length;
		if(colorDropItemLength > maxQuantity){
			currentColorDrop.css({width:colorDropItemWidth*maxQuantity})
		}
		else{
			currentColorDrop.css({width:colorDropItemWidth*colorDropItemLength})
		}
	})
}
/* add class */
function addClass(){
	var opener = $('.view-options ul li > a,.product-heading .category .opener,.color-drop .opener,.sex-drop .opener');
	var activeClass = 'active';
	opener.each(function(){
		var currentOpener = $(this);
		currentOpener.click(function(event){
			event.stopPropagation();
			if(currentOpener.parent().hasClass(activeClass)){
				currentOpener.parent().removeClass(activeClass);
			}
			else { currentOpener.parent().addClass(activeClass) };
			try {

			    if (currentOpener.attr('id') == 'ctl00_PageContent_hyplarge' || currentOpener.attr('id') == 'ctl00_PageContent_hypmedium' || currentOpener.attr('id') == 'ctl00_PageContent_lnkshowall' || currentOpener.attr('id') == 'ctl00_PageContent_lnknext' || currentOpener.attr('id') == 'ctl00_PageContent_lnkprev' || currentOpener.attr('id') == 'ctl00_PageContent_lnkbottomshowall' || currentOpener.attr('id') == 'ctl00_PageContent_lnkbottomprevious' || currentOpener.attr('id') == 'ctl00_PageContent_lnkbottomnext') {
			        return true;
			    }
			    else {

			        return false;
			    }
			}
			catch (ex) { return false; }
			//return false;
		})
		var drop = currentOpener.siblings('ul,.drop');
		drop.parent().mouseleave(function(){
			$(this).removeClass(activeClass);
		})
		$('html').click(function(){currentOpener.parent().removeClass(activeClass);})
	})
}
/* pressed state */
function pressedState(){
	var button = $('.product-info .add-to-bag,.product-info .add-to-list,.product-bar ul a,.contact-cols .submit,.contact-cols .btn-reset,.sign-register .submit,.sign-register .btn-register,.thank-you .btn,.btn-set .btn-action,.btn-set .btn-action-grey,.checkout-submit,.account-cols .submit,.account-cols .btn-unsubscribe,.account-cols .btn-cancel,.wish-list .btn-save,.wish-list-tools a,.look-collateral .btn-add ,.look-collateral .btn-view,.shop-drop .btn-checkout,.promotion .submit,#shipping-billing-address .submit');
	button.each(function(){
		currentButton = $(this);
		currentButton.mousedown(function(){$(this).addClass('pressed')})
		currentButton.mouseleave(function(){$(this).removeClass('pressed')})
	})
}
/* init galleries */
function initGalleries(){
	$('.product-visual .tab-content').fadeGallery({
		slideElements:'ul.slideset > li',
		pagerLinks:'ul.product-thumbnails a',
		IE:true
	});
	$('#product-full-screen').fadeGallery({
		slideElements:'ul.slideset > li',
		pagerLinks:'ul.product-thumbnails a',
		IE:true
	});
	$('div.news-gallery').scrollGallery({
		sliderHolder: '>div',
		slider: '>ul',
		slides: '>li',
		btnPrev: 'a.btn-prev',
		btnNext: 'a.btn-next',
		circleSlide: true
	});
	$('div.product-gallery').scrollGallery({
		sliderHolder: '>div',
		slider: '>ul',
		slides: '>li',
		btnPrev: 'a.btn-prev',
		btnNext: 'a.btn-next',
		circleSlide: true
	});
	$('div.side-panel').scrollGallery({
		sliderHolder: '.holder',
		slider: '>ul',
		slides: '>li',
		btnPrev: 'a.btn-prev',
		btnNext: 'a.btn-next',
		circleSlide: true,
		step:1
	});
	$('div.other-looks').scrollGallery({
		sliderHolder: '.holder',
		slider: '>ul',
		slides: '>li',
		btnPrev: 'a.btn-prev',
		btnNext: 'a.btn-next',
		circleSlide: true
	});
}
/* init custom forms */
function initCustomForms(){
    $('.filter select,.contact-cols select,.store-locator-filter select,.sign-register select,.shipping-address select,.shipping-method select,.card-cols select,.account-cols select,.shipping-billing-cols select').customSelect({ maxHeight: 150 });
    $('.sign-register .remember input,.sign-register .check-list input,.gift-cols .check-list input,.gift-box .check-box input,.card-cols .check-list input,.address-usage input').customCheckbox();
    //$('.store-locator-filter input:checkbox,.sign-register .remember input,.sign-register .check-list input,.gift-cols .check-list input,.gift-box .check-box input,.card-cols .check-list input,.address-usage input').customCheckbox();
    
}
/* init custom scroll */
function initCustomScroll(){
    //$('.product-text .holder,.look-collateral .box,.order-items-holder,.scrolled-list .holder').customScrollV();
    $('.product-text .holder,.look-collateral .box,.order-items-holder,.scrolled-list .holder,.lightbox .product-text .holder').customScrollV();
}
/* fixed panel */
function initFixedPanel() {
	jQuery(".checkout-columns").each(function () {
		function a() {
			i = e.scrollTop();
			j = b.offset().top;
			l = d.offset().left;
			origPositionLeft = d.position().left;
			if (h) {
				clearTimeout(f);
				f = setTimeout(function () {
					if (i > j) {
						d.css({
							position: "absolute",
							left: origPositionLeft
						});
						d.stop().animate({
							top: i - j
						}, {
							duration: c,
							queue: false
						})
					} else d.stop().animate({
						top: 0
					}, {
						duration: c,
						complete: function () {
							d.css({
								position: "static"
							})
						}
					})
				}, g)
			} else i > j ? d.css({
				position: "fixed",
				top: 0,
				left: l
			}) : d.css({
				position: "static"
			})
		}
		var b = jQuery(this),
			d = b.find(".aside"),
			e = jQuery(window),
			h = jQuery.browser.msie && jQuery.browser.version < 7,
			c = 300,
			f, g = 50,
			i, j, l;
		e.scroll(a).resize(a).scroll()
	})
}
/* init tabs */
function initTabs(){
	$('.side-panel ul').jqueryTabs({
		addToParent: false,
		holdHeight: false,
		activeClass: 'active',
		tabLinks: 'a.tab',
		fadeSpeed: 0,
		event:'click'
	});
	$('#nav .drop').jqueryTabs({
		addToParent: false,
		holdHeight: false,
		activeClass: 'active',
		tabLinks: 'a.tab',
		fadeSpeed: $.browser.msie ? 0 : 300,
		event:'mouseenter'
	});
	$('#nav .drop .tab-content > div').addClass('tab-holder');
	$('.color-choice').jqueryTabs({
		addToParent: false,
		holdHeight: false,
		activeClass: 'active',
		tabLinks: 'a.tab',
		fadeSpeed: 300,
		event:'click'
	});
	$('.payment-tabs').jqueryTabs({
		addToParent: false,
		holdHeight: false,
		activeClass: 'active',
		tabLinks: 'a.tab',
		fadeSpeed: 300,
		event:'click'
	});
}
/* init zoom */
function initZoom(){
	if(typeof $.jqzoom !='undefined'){
		$('.product-visual .tab-content .slideset a').jqzoom({
			zoomType: 'reverse',
			lens:true,
			preloadImages: false,
			alwaysOn:false,
			fadeinSpeed:300,
			fadeoutSpeed:300,
			showEffect:'fadein',
			hideEffect:'fadeout',
			zoomWidth:501,
			zoomHeight:576,
			xOffset:1
		});
		$('div.zoomWindow').mouseover(function(e){ e.stopPropagation(); $(this).parent().trigger('mouseout'); }); 
	}
}
/* lang drop */
function langDrop(){
	var langSelect = $('#footer .lang');
	var langDrop = langSelect.find('.drop');
	var animSpeed = 500;
	langSelect.hover(
		function(){
			langDrop.stop(true,true).fadeIn(animSpeed);
		},
		function(){
			langDrop.stop(true,true).fadeOut(animSpeed);
		}
	)
}
/* nav drop */
function navDrop(){
	var nav = $('#nav');
	var navItem = nav.find('>ul>li');
	var navDrops = navItem.find('.drop');
	var navSlide = navItem.find('.slide');
	var box = $('.drop-box');
	var footer = $('#footer');
	var bar = $('.news-bar');
	var animSpeed = 350;
	//var fadeSpeed = $.browser.msie ? 0 : 500;
	var maxHeight = 0;
	var time = 200;
	var _to;
	navDrops.each(function(){
		if($(this).height() > maxHeight) {
			maxHeight = $(this).height();
		}
	});
	navSlide.css({
		marginTop:-maxHeight,
		top:0
	});
	navItem.each(function(ind){
		var curItem = $(this);
		var item = this;
		var _t;
		
		curItem.mouseenter(function(){
			navItem.removeClass('active');
			curItem.addClass('active');
			
			if (_to) clearTimeout(_to)
			if (item._t) clearTimeout(item._t)
			item._t = setTimeout(function(){
				if(curItem.find('.drop').length){
					var drop = curItem.find('.drop');
					var dropSlide = drop.find('.slide');
					var dropHeight = dropSlide.show().height();
					dropSlide.hide();
					box.stop(true,true).animate({height:dropHeight},{duration:animSpeed,queue:false, complete:function(){
						if(parseInt(dropSlide.css('margin-top')) != 0) {
							dropSlide.show().css({
								'margin-top':0,
								'opacity': 0
				}).stop(true, true).animate({ opacity: 1 }, { duration: animSpeed, queue: false });
						}
						else dropSlide.show().stop(true,true).animate({opacity:1},{duration:animSpeed,queue:false});
					}});
				}else{
					box.stop(true,true).animate({height:0},{duration:animSpeed,queue:false});
					navSlide.show().stop(true,true).animate({marginTop:-maxHeight},{duration:animSpeed,queue:false,complete:function(){
						navSlide.show().css({opacity: 'auto'});
					}});
				}
			},time)
		}).mouseleave(function(){
			if (item._t) clearTimeout(item._t)
			item._t = setTimeout(function(){
				if(curItem.find('.drop').length){
					var drop = curItem.find('.drop');
					var dropSlide = drop.find('.slide');
					dropSlide.stop(true, true).animate({ opacity: 0 }, { duration: animSpeed, queue: false, complete: function() {
						$(this).hide();
					}});
				}
			}, time);
		})
	})
	
	nav.mouseleave(function(){
		if (_to) clearTimeout(_to)
		_to = setTimeout(function(){
			navItem.each(function(){
				var _this = this;
				$(this).removeClass('active');
				if (_this._t) clearTimeout(_this._t);
			})
			box.stop(true,true).animate({height:0},{duration:animSpeed,queue:false});
			navSlide.stop(true,true).animate({marginTop:-maxHeight},{duration:animSpeed,queue:false,complete:function(){
				navSlide.show().css({opacity: ''});
			}});
			bar.stop(true,true).animate({bottom:0},{duration:animSpeed,queue:false});
		}, time)
		
	});
}
// jquery tabs plugin
jQuery.fn.jqueryTabs = function(_options){
	// default options
	var _options = jQuery.extend({
		addToParent:false,
		holdHeight:false,
		activeClass:'active',
		tabLinks:'a.tab',
		fadeSpeed:0,
		event:'click'
	},_options);

	return this.each(function(){
		var _holder = jQuery(this);
		var _fadeSpeed = _options.fadeSpeed;
		var _activeClass = _options.activeClass;
		var _addToParent = _options.addToParent;
		var _holdHeight = _options.holdHeight;
		var _tabLinks = jQuery(_options.tabLinks, _holder);
		var _tabset = (_addToParent ? _tabLinks.parent() : _tabLinks);
		var _event = _options.event;
		var _animating = false;
		var _t;

		var loc=window.location.hash.toString();
		
		// tabs init
		_tabLinks.each(function(){
			var _tmpLink = jQuery(this);
			var _tmpTab = jQuery(_tmpLink.attr('href'));
			var _classItem = (_addToParent ? _tmpLink.parent() : _tmpLink);
			if(_tmpTab.length) {
				if (_tmpLink.attr('href') == loc){
					_tmpTab.css('display', 'none').css('display', 'block');
					_tabLinks.removeClass(_activeClass); 
					_classItem.addClass(_activeClass);
				}
				else if(_classItem.hasClass(_activeClass) && (loc == '' || $(loc).length == 0)) {
					_tmpTab.css('display', 'none').css('display', 'block');
				}
				else {
					_tmpTab.hide().css('opacity', 0);
					_classItem.removeClass('active');
				}
			}
		});


		// tab switcher
		function switchTab(_switcher) {
			var _link = jQuery(_switcher);
			var _newItem = (_addToParent ? _link.parent() : _link);
			var _newTab = jQuery(_link.attr('href'));
			if(_newItem.hasClass(_activeClass)) return;

			var _oldItem = jQuery(_addToParent ? _tabset : _tabLinks).filter('.'+_activeClass);
			var _oldTab = jQuery(jQuery(_addToParent ? _oldItem.children('a') : _oldItem).attr('href'));
			if(_newTab.length) {
				_animating = true;
				if(_oldItem.length) {
					_newItem.addClass(_activeClass);
					_oldItem.removeClass(_activeClass);

					var _parent = _oldTab.parent();
					if(_holdHeight) _parent.css({height:_parent.height()});

					_oldTab.stop().animate({
						'opacity':0
					},_fadeSpeed, function(){
						_oldTab.hide();
					});
					if (_t) clearTimeout(_t);
					_t = setTimeout(function(){
						_newTab.show().stop().animate({
							'opacity':1
						}, _fadeSpeed);
						if(_holdHeight) _parent.css({height:'auto'});
					},_fadeSpeed)
				} else {
					_newItem.addClass(_activeClass);
					_newTab.show().stop().animate({
						'opacity':1
					}, _fadeSpeed);
				}
			}
		}

		// control
		_tabLinks.each(function(){
			jQuery(this).bind(_event,function(){
				switchTab(this);
				return false;
			});
		});
	});
}

/* side panel */
function sidePanel(){
	var sidePanel = $('.side-panel');
	var sidePanelSlide = sidePanel.find('.slide');
	var btnCloseLeft = sidePanel.find('.btn-close-left');
	var btnCloseRight = sidePanel.find('.btn-close-right');
	var sidePanelWidth = sidePanelSlide.width();
	sidePanelSlide.css({marginTop:-sidePanel.height()})
	var animSpeed = 500;
	var flag = false;
	function mouseMove(){
		$('html').mousemove(function(event){
			if (event.clientX >= $(window).width() - 300){
				if (!flag) {
					if (sidePanelSlide.is(':animated')) {
						setTimeout(function(){
							sidePanel.removeClass('left');
							sidePanel.addClass('right');
							sidePanelSlide.css({
								marginRight: -sidePanelWidth,
								marginTop: 0,
								marginLeft: 0
							});
							sidePanel.css({
								left: 'auto',
								right: 0,
								display: 'block'
							});
							sidePanelSlide.animate({
								marginRight: 0
							}, {
								queue: false,
								duration: animSpeed
							});
						},animSpeed)
					}
					else{
						sidePanel.removeClass('left');
						sidePanel.addClass('right');
						sidePanelSlide.css({
							marginRight: -sidePanelWidth,
							marginTop: 0,
							marginLeft: 0
						});
						sidePanel.css({
							left: 'auto',
							right: 0,
							display: 'block'
						});
						sidePanelSlide.animate({
							marginRight: 0
						}, {
							queue: false,
							duration: animSpeed
						});
					}
					flag = true;
				}
			}
			if (event.clientX <= 300){
				if (!flag) {
					sidePanel.removeClass('right');
					sidePanel.addClass('left');
					if (sidePanelSlide.is(':animated')) {
						setTimeout(function(){
							sidePanel.css({
								right: 'auto',
								left: 0,
								display: 'block'
							})
							sidePanelSlide.css({
								marginRight: 0,
								marginLeft: -sidePanelWidth,
								marginTop: 0
							});
							sidePanelSlide.animate({
								marginLeft: 0
							}, {
								queue: false,
								duration: animSpeed
							});
						}, animSpeed)
					}
					else {
						sidePanel.css({
							right: 'auto',
							left: 0,
							display: 'block'
						})
						sidePanelSlide.css({
							marginRight: 0,
							marginLeft: -sidePanelWidth,
							marginTop: 0
						});
						sidePanelSlide.animate({
							marginLeft: 0
						}, {
							queue: false,
							duration: animSpeed
						});
					}
					flag = true;
				}
			}
			
			if(event.clientX < $(window).width() - 300 && event.clientX > 300){
				flag = false;
				if (sidePanel.hasClass('left')){
					sidePanel.removeClass('right');
					sidePanelSlide.animate({marginLeft:-sidePanelWidth},{queue:false,duration:animSpeed,complete:function(){sidePanel.removeClass('left');}});
				}
				else{
					if (sidePanel.hasClass('right')){
					sidePanel.removeClass('left');
						sidePanelSlide.animate({marginRight:-sidePanelWidth},{queue:false,duration:animSpeed,complete:function(){sidePanel.removeClass('right');}});
					}
				}
			}
		})
	}
	mouseMove();
}
function newsBar(){
	var newsBar = $('.news-bar');
	var animSpeed = 500;
	var opener = newsBar.find('.opener');
	var slideBox = newsBar.find('.slide');
	var slideBoxHeight = slideBox.height();
	setTimeout(function(){
		slideBox.css({display:'block',height:0}).animate({height:slideBoxHeight},animSpeed);
	},1000)
	newsBar.addClass('active');
	opener.click(function(){
		if (newsBar.hasClass('active')){
			slideBox.animate({height:0},{duration:animSpeed,complete:function(){newsBar.removeClass('active');}});
		}
		else{
			slideBox.animate({height:slideBoxHeight},animSpeed);
			newsBar.addClass('active');
		}
		return false;
	});
	newsBar.hover(function(){
			if(!($(this).hasClass('active'))){
				slideBox.stop(true,true).animate({height:20},animSpeed);
			}
		},
		function(){
			if(!($(this).hasClass('active'))){
				slideBox.stop(true,true).animate({height:0},animSpeed);
			}
		}
	)
};
function newsOverlay(){
	var newsGallery = $('.news-gallery ul');
	var newsItem = newsGallery.find('li');
	var newsOverlay = newsItem.find('.overlay');
	newsOverlay.hide();
	var animSpeed = 500;
	if(jQuery.browser.msie) animSpeed = 0;
	newsItem.each(function(){
		var currentItem = $(this);
		var currentOverlay = currentItem.find('.overlay');
		var mask = currentItem.find('.mask');
		currentItem.hover(function(){
				mask.fadeOut(animSpeed);
				currentOverlay.stop(true,true).slideDown(animSpeed);
			},
			function(){
				currentOverlay.stop(true,true).slideUp(animSpeed,function(){mask.fadeIn(animSpeed)});
			}
		)
	})
}
function slideBlock(){
	$('.product-collateral .holder').each(function(){
		var slideSpeed = 500;
		var slideHolder = $(this);
		var opener = slideHolder.find('.opener');
		var slideBox = slideHolder.find('.slide');
		if(slideHolder.hasClass('active')) slideBox.show();
		else slideBox.hide();
		opener.click(function(){
			if (slideHolder.hasClass('active')){
				slideBox.slideUp(slideSpeed);
				slideHolder.removeClass('active');
			}
			else{
				slideBox.slideDown(slideSpeed);
				slideHolder.addClass('active');
			}
			return false;
		})
	});
};
function clearFields(){
	var form = $('.contact-cols form');
	form.each(function(){
		var currentForm = $(this);
		var currentFormItems = currentForm.find('input:text, textarea');
		var buttonReset = currentForm.find('.btn-reset');
		buttonReset.click(function(){
			currentFormItems.val('');
			return false;
		})
	})
}
function changeAddress(){
	var addressHolder = $('.shipping-address');
	var addressSelect = addressHolder.find('.holder select');
	var billingBox = addressHolder.find('.billing-form');
	var addressOptions = addressSelect.find('option');
	var changeOption;
	addressOptions.each(function(){
		var currentOption = $(this);
		if (currentOption.val() == 'other-address'){
			changeOption = currentOption;
		}
	})
	addressSelect.change(function(){
		if(changeOption.is(':selected')) billingBox.show();
		else billingBox.hide()
	})
}
// slideshow plugin
jQuery.fn.fadeGallery = function(_options){
	var _options = jQuery.extend({
		slideElements:'div.slideset > div',
		pagerLinks:'div.pager a',
		btnNext:'a.btn-next',
		btnPrev:'a.btn-prev',
		btnPlayPause:'a.play-pause',
		btnPlay:'a.play',
		btnPause:'a.pause',
		pausedClass:'paused',
		disabledClass: 'disabled',
		playClass:'playing',
		activeClass:'active',
		currentNum:false,
		allNum:false,
		startSlide:null,
		noCircle:false,
		pauseOnHover:true,
		autoRotation:false,
		autoHeight:false,
		onChange:false,
		switchTime:3000,
		duration:650,
		event:'click',
		IE:false
	},_options);

	return this.each(function(){
		// gallery options
		var _this = jQuery(this);
		var _slides = jQuery(_options.slideElements, _this);
		var _pagerLinks = jQuery(_options.pagerLinks, _this);
		var _btnPrev = jQuery(_options.btnPrev, _this);
		var _btnNext = jQuery(_options.btnNext, _this);
		var _btnPlayPause = jQuery(_options.btnPlayPause, _this);
		var _btnPause = jQuery(_options.btnPause, _this);
		var _btnPlay = jQuery(_options.btnPlay, _this);
		var _pauseOnHover = _options.pauseOnHover;
		var _autoRotation = _options.autoRotation;
		var _activeClass = _options.activeClass;
		var _disabledClass = _options.disabledClass;
		var _pausedClass = _options.pausedClass;
		var _playClass = _options.playClass;
		var _autoHeight = _options.autoHeight;
		var _duration = _options.duration;
		if (_options.IE && $.browser.msie) {
			if ($.browser.version < 9) _duration = 0;
		}
		var _switchTime = _options.switchTime;
		var _controlEvent = _options.event;
		var _currentNum = (_options.currentNum ? jQuery(_options.currentNum, _this) : false);
		var _allNum = (_options.allNum ? jQuery(_options.allNum, _this) : false);
		var _startSlide = _options.startSlide;
		var _noCycle = _options.noCircle;
		var _onChange = _options.onChange;

		// gallery init
		var _hover = false;
		var _prevIndex = 0;
		var _currentIndex = 0;
		var _slideCount = _slides.length;
		var _timer;
		if(_slideCount < 2) return;

		_prevIndex = _slides.index(_slides.filter('.'+_activeClass));
		if(_prevIndex < 0) _prevIndex = _currentIndex = 0;
		else _currentIndex = _prevIndex;
		if(_startSlide != null) {
			if(_startSlide == 'random') _prevIndex = _currentIndex = Math.floor(Math.random()*_slideCount);
			else _prevIndex = _currentIndex = parseInt(_startSlide);
		}
		_slides.hide().eq(_currentIndex).show();
		if(_autoRotation) _this.removeClass(_pausedClass).addClass(_playClass);
		else _this.removeClass(_playClass).addClass(_pausedClass);

		// gallery control
		if(_btnPrev.length) {
			_btnPrev.bind(_controlEvent,function(){
				prevSlide();
				return false;
			});
		}
		if(_btnNext.length) {
			_btnNext.bind(_controlEvent,function(){
				nextSlide();
				return false;
			});
		}
		if(_pagerLinks.length) {
			_pagerLinks.each(function(_ind){
				jQuery(this).bind(_controlEvent,function(){
					if(_currentIndex != _ind) {
						_prevIndex = _currentIndex;
						_currentIndex = _ind;
						switchSlide();
					}
					return false;
				});
			});
		}

		// play pause section
		if(_btnPlayPause.length) {
			_btnPlayPause.bind(_controlEvent,function(){
				if(_this.hasClass(_pausedClass)) {
					_this.removeClass(_pausedClass).addClass(_playClass);
					_autoRotation = true;
					autoSlide();
				} else {
					_autoRotation = false;
					if(_timer) clearTimeout(_timer);
					_this.removeClass(_playClass).addClass(_pausedClass);
				}
				return false;
			});
		}
		if(_btnPlay.length) {
			_btnPlay.bind(_controlEvent,function(){
				_this.removeClass(_pausedClass).addClass(_playClass);
				_autoRotation = true;
				autoSlide();
				return false;
			});
		}
		if(_btnPause.length) {
			_btnPause.bind(_controlEvent,function(){
				_autoRotation = false;
				if(_timer) clearTimeout(_timer);
				_this.removeClass(_playClass).addClass(_pausedClass);
				return false;
			});
		}

		// gallery animation
		function prevSlide() {
			_prevIndex = _currentIndex;
			if(_currentIndex > 0) _currentIndex--;
			else {
				if(_noCycle) return;
				else _currentIndex = _slideCount-1;
			}
			switchSlide();
		}
		function nextSlide() {
			_prevIndex = _currentIndex;
			if(_currentIndex < _slideCount-1) _currentIndex++;
			else {
				if(_noCycle) return;
				else _currentIndex = 0;
			}
			switchSlide();
		}
		function refreshStatus() {
			if(_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentIndex).addClass(_activeClass);
			if(_currentNum) _currentNum.text(_currentIndex+1);
			if(_allNum) _allNum.text(_slideCount);
			_slides.eq(_prevIndex).removeClass(_activeClass);
			_slides.eq(_currentIndex).addClass(_activeClass);
			if(_noCycle) {
				if(_btnPrev.length) {
					if(_currentIndex == 0) _btnPrev.addClass(_disabledClass);
					else _btnPrev.removeClass(_disabledClass);
				}
				if(_btnNext.length) {
					if(_currentIndex == _slideCount-1) _btnNext.addClass(_disabledClass);
					else _btnNext.removeClass(_disabledClass);
				}
			}
			if(typeof _onChange === 'function') {
				_onChange(_this, _currentIndex);
			}
		}
		function switchSlide() {
			_slides.eq(_prevIndex).fadeOut(_duration);
			_slides.eq(_currentIndex).fadeIn(_duration);
			if(_autoHeight) _slides.eq(_currentIndex).parent().animate({height:_slides.eq(_currentIndex).outerHeight(true)},{duration:_duration,queue:false});
			refreshStatus();
			autoSlide();
		}

		// autoslide function
		function autoSlide() {
			if(!_autoRotation || _hover) return;
			if(_timer) clearTimeout(_timer);
			_timer = setTimeout(nextSlide,_switchTime+_duration);
		}
		if(_pauseOnHover) {
			_this.hover(function(){
				_hover = true;
				if(_timer) clearTimeout(_timer);
			},function(){
				_hover = false;
				autoSlide();
			});
		}
		refreshStatus();
		jQuery(window).focus(function(){
			autoSlide();
			}).blur(function(){
			clearTimeout(_timer);
		});
	});
}
function initLightbox() {
	function a() {
	    $('#product-full-screen').css({ width: $('body').width() });
	    $('#product-full-screen').css({ height: $('body').height() });
		$('#lightbox-overlay').css({width: $('body').width()});
		if (g) {
			var o = jQuery(window).height(),
				v = jQuery(window).width();
			g.outerWidth();
			var p = g.outerHeight(),
				r = j.height();
			v < l ? f.css("width", l) : f.css("width", "100%");
			o < r ? f.css("height", r) : f.css("height", o);
			g.css({
				position: "absolute",
				zIndex: e + 1
			});
			if (o > p) jQuery.browser.msie && jQuery.browser.version < 7 ? g.css({
				position: "absolute",
				top: parseInt(jQuery(window).scrollTop()) + (o - p) / 2
			}) : g.css({
				position: "fixed",
				top: (o - p) / 2
			});
			else {
				o = f.height();
				o < p && f.css("height", p);
				if (!m) if (o - p > parseInt(jQuery(window).scrollTop())) m = o = parseInt(jQuery(window).scrollTop());
				else m = o - p;
				g.css({
					position: "absolute",
					top: m
				})
			}
			f.width() > g.outerWidth() ? g.css({
				left: (f.width() - g.outerWidth()) / 2
			}) : g.css({
				left: 0
			})
		}
	}

	function b(o) {
		if (g) if (o) {
			f.fadeIn(h, function () {
				g.fadeIn(h)
				$('#terms-conditions .holder').customScrollV();
				$('#policy .holder').customScrollV();
				$('#shipping-billing-address select').customSelect({ maxHeight: 150 });
				$('.product-text .holder').customScrollV();
			});
			m = false;
			a()
		} else g.fadeOut(h, function () {
			f.fadeOut(h);
			m = false
		})
	}

	function d(o) {
		if (!o.get(0).jsInit) {
			o.get(0).jsInit = true;
			o.find(c).click(function () {
				g = o;
				b(false);
				return false
			})
		}
	}
	var e = 1E3,
		h = 500,
		c = "a.btn-close, a.close, a.cancel, a.submit",
		f, g = null,
		i = jQuery("a.open-popup"),
		j = jQuery(document),
		l = jQuery("body > div:eq(0)").outerWidth(),
		m = false;
	f = jQuery("#lightbox-overlay");
	if (!f.length) {
		f = jQuery("<div />");
		f.attr("id", "lightbox-overlay");
		jQuery("body").append(f)
	}
	f.css({
		opacity: 0.65,
		backgroundColor: "#000",
		position: "absolute",
		overflow: "hidden",
		display: "none",
		top: 0,
		left: 0,
		zIndex: e
	});
	if (jQuery.browser.msie && jQuery.browser.version < 7) if (!f.children().length) {
		var k = jQuery('<iframe src="javascript:false" frameborder="0" scrolling="no" />');
		k.css({
			opacity: 0,
			width: "100%",
			height: "100%"
		});
		var s = jQuery("<div>");
		s.css({
			top: 0,
			left: 0,
			zIndex: 1,
			opacity: 0,
			background: "#595959",
			position: "absolute",
			width: "100%",
			height: "100%"
		});
		f.empty().append(k).append(s)
	}
	i.each(function() {
	    var o = jQuery(this),
			v = o.attr("href");
	    if (o.hasClass("ajax-load")) o.click(function() {
	        if (jQuery('div[rel*="' + v + '"]').length == 0) jQuery.ajax({
	            url: v,
	            type: "POST",
	            dataType: "html",
	            success: function(r) {
	               
	                g = jQuery(r);
	                g.find("img").load(a);
	                g.attr("rel", v).hide().css({
	                    position: "absolute",
	                    zIndex: e + 1,
	                    top: -9999,
	                    left: -9999
	                });
	                jQuery("body").append(g);
	                d(g);
	                b(true)
	            },
	            error: function() {
	                alert("AJAX error!");
	                return false
	            }
	        });
	        else {
	            g = jQuery('div[rel*="' + v + '"]');
	            b(true)
	        }
	        return false
	    });
	    else if (jQuery(v).length) {
	        var p = jQuery(v);
	        d(p);
	        o.click(function() {
	            if (g) g.fadeOut(h, function() {
	                g = p.hide();
	                b(true)
	            });
	            else {
	                g = p.hide();
	                b(true)
	            }
	            return false
	        })
	    }
	});
	jQuery(window).resize(a);
	jQuery(window).scroll(a);
	jQuery(document).keydown(function (o) {
		if (!o) evt = window.event;
		o.keyCode == 27 && b(false)
	});
	f.click(function () {
		f.is(":animated") || b(false);
		return false
	})
}
jQuery.fn.scrollGallery = function(_options){
	var _options = jQuery.extend({
		sliderHolder: '>div',
		slider:'>ul',
		slides: '>li',
		pagerLinks:'div.pager a',
		btnPrev:'a.prev',
		btnNext:'a.next',
		activeClass:'active',
		disabledClass:'disabled',
		generatePagination:'div.pg-holder',
		curNum:'em.scur-num',
		allNum:'em.sall-num',
		circleSlide:true,
		pauseClass:'gallery-paused',
		pauseButton:'none',
		pauseOnHover:true,
		autoRotation:false,
		stopAfterClick:false,
		switchTime:5000,
		duration:650,
		easing:'swing',
		event:'click',
		afterInit:false,
		beforeInit: false,
		onChange: false,
		beforeAnimation: false,
		afterAnimation: false,
		vertical:false,
		step:false,
		startElement : 0,
		autoHeight: false
	},_options);

	return this.each(function(){
		var _this = jQuery(this);
		var _sliderHolder = jQuery(_options.sliderHolder, _this);
		var _slider = jQuery(_options.slider, _sliderHolder);
		var _slides = jQuery(_options.slides, _slider);
		var _btnPrev = jQuery(_options.btnPrev, _this);
		var _btnNext = jQuery(_options.btnNext, _this);
		var _pagerLinks = jQuery(_options.pagerLinks, _this);
		var _generatePagination = jQuery(_options.generatePagination, _this);
		var _curNum = jQuery(_options.curNum, _this);
		var _allNum = jQuery(_options.allNum, _this);
		var _pauseButton = jQuery(_options.pauseButton, _this);
		var _pauseOnHover = _options.pauseOnHover;
		var _pauseClass = _options.pauseClass;
		var _autoRotation = _options.autoRotation;
		var _activeClass = _options.activeClass;
		var _disabledClass = _options.disabledClass;
		var _easing = _options.easing;
		var _duration = _options.duration;
		var _switchTime = _options.switchTime;
		var _controlEvent = _options.event;
		var _step = _options.step;
		var _vertical = _options.vertical;
		var _circleSlide = _options.circleSlide;
		var _stopAfterClick = _options.stopAfterClick;
		var autoHeight = _options.autoHeight;
		var _afterInit = _options.afterInit;
		var beforeInit = _options.beforeInit;
		var onChange = _options.onChange;
		var beforeAnimation = _options.beforeAnimation;
		var afterAnimation = _options.afterAnimation;
		
		if(!_slides.length) return;
		var _currentStep = _options.startElement;
		var _sumWidth = 0;
		var _sumHeight = 0;
		var _hover = false;
		var _stepWidth;
		var _stepHeight;
		var _stepCount;
		var _offset;
		var _timer;

		
		if(beforeInit && typeof beforeInit === 'function') beforeInit(_this, _slides, _slides.eq(_currentStep));
		function reCalc(){
			_sumWidth = 0;
			_sumHeight = 0;
			_slides.each(function(){
				_sumWidth+=jQuery(this).outerWidth(true);
				_sumHeight+=jQuery(this).outerHeight(true);
			});
			_slider.css({ width: _sumWidth });
			 if (_sumWidth <= _sliderHolder.width()){
				_btnPrev.css('visibility', 'hidden');
				_btnNext.css('visibility', 'hidden');
				_slider.css('margin-left', '0 !important');
			}
		}
		reCalc();
		// jQuery(window).bind('resize', reCalc);
		function recalcOffsets() {
			if(_vertical) {
				if(_step) {
					_stepHeight = _slides.eq(_currentStep).outerHeight(true);
					_stepCount = Math.ceil((_sumHeight-_sliderHolder.height())/_stepHeight)+1;
					_offset = -_stepHeight*_currentStep;
				} else {
					_stepHeight = _sliderHolder.height();
					_stepCount = Math.ceil(_sumHeight/_stepHeight);
					_offset = -_stepHeight*_currentStep;
					if(_offset < _stepHeight-_sumHeight) _offset = _stepHeight-_sumHeight;
				}
			} else {
				if(_step) {
					_stepWidth = _slides.eq(_currentStep).outerWidth(true)*_step;
					_stepCount = Math.ceil((_sumWidth-_sliderHolder.width())/_stepWidth)+1;
					_offset = -_stepWidth*_currentStep;
					if(_offset < _sliderHolder.width()-_sumWidth) _offset = _sliderHolder.width()-_sumWidth;
				} else {
					_stepWidth = _sliderHolder.width();
					_stepCount = Math.ceil(_sumWidth/_stepWidth);
					_offset = -_stepWidth*_currentStep;
					if(_offset < _stepWidth-_sumWidth) _offset = _stepWidth-_sumWidth;
				}
			}
		}
		if(_btnPrev.length) {
			_btnPrev.bind(_controlEvent,function(){
				if(_stopAfterClick) stopAutoSlide();
				prevSlide();
				return false;
			});
		}
		if(_btnNext.length) {
			_btnNext.bind(_controlEvent,function(){
				if(_stopAfterClick) stopAutoSlide();
				nextSlide();
				return false;
			});
		}
		if(_generatePagination.length) {
			_generatePagination.empty();
			recalcOffsets();
			for(var i=0; i<_stepCount; i++) jQuery('<li><a href="#">'+(i+1)+'</a></li>').appendTo(_generatePagination);
			_pagerLinks = _generatePagination.children();
		}
		if(_pagerLinks.length) {
			_pagerLinks.each(function(_ind){
				jQuery(this).bind(_controlEvent,function(){
					if(_currentStep != _ind) {
						if(_stopAfterClick) stopAutoSlide();
						_currentStep = _ind;
						switchSlide();
					}
					return false;
				});
			});
		}
		function prevSlide() {
			recalcOffsets();
			if(_currentStep > 0) _currentStep--;
			else if(_circleSlide) _currentStep = _stepCount-1;
			switchSlide();
		}
		function nextSlide() {
			recalcOffsets();
			if(_currentStep < _stepCount-1) _currentStep++;
			else if(_circleSlide) _currentStep = 0;
			switchSlide();
		}
		function refreshStatus() {
			if(_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentStep).addClass(_activeClass);
			if(!_circleSlide) {
				_btnPrev.removeClass(_disabledClass);
				_btnNext.removeClass(_disabledClass);
				if(_currentStep == 0) _btnPrev.addClass(_disabledClass);
				if(_currentStep == _stepCount-1) _btnNext.addClass(_disabledClass);
			}
			if(_curNum.length) _curNum.text(_currentStep+1);
			if(_allNum.length) _allNum.text(_stepCount);
			if(autoHeight) _slider.css({ height: _slides.eq(_currentStep).outerHeight(true) });
		}
		function switchSlide() {
			if(beforeAnimation && typeof beforeAnimation === 'function') beforeAnimation(_this, _slides, _slides.eq(_currentStep));
			recalcOffsets();
			if(_vertical) _slider.stop().animate({marginTop:_offset},{duration:_duration,queue:false,easing:_easing, complete: function(){
				if(afterAnimation && typeof afterAnimation === 'function') afterAnimation(_this, _slides, _slides.eq(_currentStep));
			}});
			else _slider.stop().animate({marginLeft:_offset},{duration:_duration,queue:false,easing:_easing, complete: function(){
				if(afterAnimation && typeof afterAnimation === 'function') afterAnimation(_this, _slides, _slides.eq(_currentStep));
			}});
			refreshStatus();
			if(onChange && typeof onChange === 'function') onChange(_this, _slides, _slides.eq(_currentStep));
			autoSlide();
		}
		function stopAutoSlide() {
			if(_timer) clearTimeout(_timer);
			_autoRotation = false;
		}
		function autoSlide() {
			if(!_autoRotation || _hover) return;
			if(_timer) clearTimeout(_timer);
			_timer = setTimeout(nextSlide,_switchTime+_duration);
		}
		if(_pauseOnHover) {
			_this.hover(function(){
				_hover = true;
				if(_timer) clearTimeout(_timer);
			},function(){
				_hover = false;
				autoSlide();
			});
		}
		
		recalcOffsets();
		refreshStatus();
		autoSlide();
		if(_vertical){
			_slider.css({ marginTop:_offset });
		}
		else {
			_slider.css({ marginLeft:_offset });
		}
		
		if(_pauseButton.length) {
			_pauseButton.click(function(){
				if(_this.hasClass(_pauseClass)) {
					_this.removeClass(_pauseClass);
					_autoRotation = true;
					autoSlide();
				} else {
					_this.addClass(_pauseClass);
					stopAutoSlide();
				}
				return false;
			});
		}
		if(_afterInit && typeof _afterInit === 'function') _afterInit(_this, _slides, _slides.eq(_currentStep));
	});
};
/*--- custom checkbox's ---*/
jQuery.fn.customCheckbox = function(_options){
	var _options = jQuery.extend({
		checkboxStructure: '<div></div>',
		checkboxDisabled: 'disabled',
		checkboxDefault: 'checkboxArea',
		checkboxChecked: 'checkboxAreaChecked'
	}, _options);
	return this.each(function(){
		var checkbox = jQuery(this);
		if(!checkbox.hasClass('outtaHere') && checkbox.is(':checkbox')){
			var replaced = jQuery(_options.checkboxStructure);
			this._replaced = replaced;
			if(checkbox.is(':disabled')) replaced.addClass(_options.checkboxDisabled);
			else if(checkbox.is(':checked')) replaced.addClass(_options.checkboxChecked);
			else replaced.addClass(_options.checkboxDefault);
			
			replaced.click(function(){
				if(checkbox.is(':checked')) checkbox.removeAttr('checked');
				else checkbox.attr('checked', 'checked');
				changeCheckbox(checkbox);
			});
			checkbox.click(function(){
				changeCheckbox(checkbox);
			});
			replaced.insertBefore(checkbox);
			checkbox.addClass('outtaHere');
		}
	});
	function changeCheckbox(_this){
		if(_this.is(':checked')) _this.get(0)._replaced.removeClass().addClass(_options.checkboxChecked);
		else _this.get(0)._replaced.removeClass().addClass(_options.checkboxDefault);
		if(typeof(_this.change) == 'function') _this.change();
		if(typeof(_this.get(0).onchange) == 'function') _this.get(0).onchange();
	}
}
/*--- custom radio's ---*/
jQuery.fn.customRadio = function(_options){
	var _options = jQuery.extend({
		radioStructure: '<div></div>',
		radioDisabled: 'disabled',
		radioDefault: 'radioArea',
		radioChecked: 'radioAreaChecked'
	}, _options);
	return this.each(function(){
		var radio = jQuery(this);
		if(!radio.hasClass('outtaHere') && radio.is(':radio')){
			var replaced = jQuery(_options.radioStructure);
			this._replaced = replaced;
			if(radio.is(':disabled')) replaced.addClass(_options.radioDisabled);
			else if(radio.is(':checked')) replaced.addClass(_options.radioChecked);
			else replaced.addClass(_options.radioDefault);
			replaced.click(function(){
				if($(this).hasClass(_options.radioDefault)){
					radio.attr('checked', 'checked');
					changeRadio(radio.get(0));
				}
			});
			radio.click(function(){
				changeRadio(this);
			});
			replaced.insertBefore(radio);
			radio.addClass('outtaHere');
		}
	});
	function changeRadio(_this){
		$('input:radio[name='+$(_this).attr("name")+']').not(_this).each(function(){
			if(this._replaced && !$(this).is(':disabled')) this._replaced.removeClass().addClass(_options.radioDefault);
		});
		_this._replaced.removeClass().addClass(_options.radioChecked);
		if(typeof($(_this).change) == 'function') $(_this).change();
		if(typeof(_this.onchange) == 'function') _this.onchange();
	}
}
/*--- custom scroll ---*/
var types = ['DOMMouseScroll', 'mousewheel'];
$.event.special.mousewheel = {
	setup: function() {
		if ( this.addEventListener ) for ( var i=types.length; i; ) this.addEventListener( types[--i], handler, false );
		else this.onmousewheel = handler;
	},
	teardown: function() {
		if ( this.removeEventListener ) for ( var i=types.length; i; ) this.removeEventListener( types[--i], handler, false );
		else this.onmousewheel = null;
	}
};
$.fn.extend({
	mousewheel: function(fn) {
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
	},
	unmousewheel: function(fn) {
		return this.unbind("mousewheel", fn);
	}
});
function handler(event) {
	var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
	event = $.event.fix(event || window.event);
	event.type = "mousewheel";
	if ( event.wheelDelta ) delta = event.wheelDelta/120;
	if ( event.detail     ) delta = -event.detail/3;
	args.unshift(event, delta);
	return $.event.handle.apply(this, args);
}
jQuery.fn.customScrollV = function(_options) {
    var _options = jQuery.extend({
        lineWidth: 12
    }, _options);
    return this.each(function() {
        var _box = jQuery(this);
        if (_box.is(':visible')) {
            
            if (_box.children('.scroll-content').length == 0) {
                var line_w = _options.lineWidth;
                /*--- init part ---*/
                var scrollBar = jQuery('<div class="scroll-bar"><div class="scroll-up"></div><div class="scroll-line"><div class="scroll-slider"></div></div><div class="scroll-down"></div></div>');
                _box.wrapInner('<div class="scroll-content"><div class="scroll-hold"></div></div>').append(scrollBar);
                var scrollContent = _box.children('.scroll-content');
                var scrollSlider = scrollBar.find('.scroll-slider');
                var scrollSliderH = scrollSlider.parent();
                var scrollUp = scrollBar.find('.scroll-up');
                var scrollDown = scrollBar.find('.scroll-down');
                /*--- different variables ---*/
                var box_h = _box.height();
                var slider_h = 0;
                var slider_f = 0;
                var cont_h = scrollContent.height();

                var _f = false;
                var _f1 = false;
                var _f2 = true;
                var _t1, _t2, _s1, _s2;
                /*--- set styles ---*/
                _box.css({
                    position: 'relative',
                    overflow: 'hidden',
                    height: box_h
                });
                scrollContent.css({
                    position: 'absolute',
                    top: 0,
                    left: 0,
                    zIndex: 1,
                    height: 'auto'
                });
                scrollBar.css({
                    position: 'absolute',
                    top: 0,
                    right: 0,
                    zIndex: 2,
                    width: line_w,
                    height: box_h,
                    overflow: 'hidden'
                });
                scrollUp.css({
                    width: line_w,
                    height: line_w,
                    overflow: 'hidden',
                    cursor: 'pointer'
                });
                scrollDown.css({
                    width: line_w,
                    height: line_w,
                    overflow: 'hidden',
                    cursor: 'pointer'
                });
                slider_h = scrollBar.height();
                if (scrollUp.is(':visible')) slider_h -= scrollUp.height();
                if (scrollDown.is(':visible')) slider_h -= scrollDown.height();
                scrollSliderH.css({
                    position: 'relative',
                    width: line_w,
                    height: slider_h,
                    overflow: 'hidden'
                });
                slider_h = 0;
                scrollSlider.css({
                    position: 'absolute',
                    top: 0,
                    left: 0,
                    width: line_w,
                    height: slider_h,
                    overflow: 'hidden',
                    cursor: 'pointer'
                });
                box_h = _box.height();
                cont_h = scrollContent.height();
                if (box_h < cont_h) {
                    _f = true;
                    slider_h = Math.round(box_h / cont_h * scrollSliderH.height());
                    if (slider_h < 5) slider_h = 5;
                    scrollSlider.height(slider_h);
                    slider_h = scrollSlider.outerHeight();
                    slider_f = (cont_h - box_h) / (scrollSliderH.height() - slider_h);
                    _s1 = (scrollSliderH.height() - slider_h) / 10;
                    _s2 = (scrollSliderH.height() - slider_h) / 3;
                    scrollContent.children('.scroll-hold').css('padding-right', scrollSliderH.width());
                }
                else {
                    _f = false;
                    scrollBar.hide();
                    scrollContent.css({ width: _box.width(), top: 0, left: 0 });
                    scrollContent.children('.scroll-hold').css('padding-right', 0);
                }
                var _top = 0;
                /*--- element's events ---*/
                scrollUp.mousedown(function() {
                    _top -= _s1;
                    scrollCont();
                    _t1 = setTimeout(function() {
                        _t2 = setInterval(function() {
                            _top -= 4 / slider_f;
                            scrollCont();
                        }, 20);
                    }, 500);
                }).mouseup(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                }).mouseleave(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                });
                scrollDown.mousedown(function() {
                    _top += _s1;
                    scrollCont();
                    _t1 = setTimeout(function() {
                        _t2 = setInterval(function() {
                            _top += 4 / slider_f;
                            scrollCont();
                        }, 20);
                    }, 500);
                }).mouseup(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                }).mouseleave(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                });
                scrollSliderH.click(function(e) {
                    if (_f2) {
                        _top = e.pageY - scrollSliderH.offset().top;
                        /*
                        if(scrollSlider.offset().top + slider_h < e.pageY) _top += _s2;
                        else if(scrollSlider.offset().top > e.pageY) _top -= _s2;
                        */
                        scrollCont();
                    }
                    else {
                        _f2 = true;
                    }
                });
                var t_y = 0;
                scrollSlider.mousedown(function(e) {
                    t_y = e.pageY - $(this).position().top;
                    _f1 = true;
                }).mouseup(function() {
                    _f1 = false;
                });
                $('body').mousemove(function(e) {
                    if (_f1) {
                        _f2 = false;
                        _top = e.pageY - t_y;
                        scrollCont();
                    }
                }).mouseup(function() {
                    _f1 = false;
                });
                document.body.onselectstart = function() {
                    if (_f1) return false;
                }
                _box.bind('mousewheel', function(event, delta) {
                    if (_f) {
                        _top -= delta * _s1;
                        scrollCont();
                        if ((_top > 0) && (_top + slider_h < scrollSliderH.height())) return false;
                    }
                });
                function scrollCont() {
                    if (_top < 0) _top = 0;
                    else if (_top + slider_h > scrollSliderH.height()) _top = scrollSliderH.height() - slider_h;
                    scrollSlider.css('top', _top);
                    scrollContent.css('top', -_top * slider_f);
                }
                this.scrollResize = function() {
                    box_h = _box.height();
                    cont_h = scrollContent.height();

                    if (box_h < cont_h) {

                        _f = true;
                        scrollBar.show();
                        slider_h = Math.round(box_h / cont_h * scrollSliderH.height());
                        if (slider_h < 5) slider_h = 5;
                        scrollSlider.height(slider_h);
                        slider_h = scrollSlider.outerHeight();
                        slider_f = (cont_h - box_h) / (scrollSliderH.height() - slider_h);
                        if (cont_h + scrollContent.position().top < box_h) scrollContent.css('top', -(cont_h - box_h));
                        _top = -scrollContent.position().top / slider_f;
                        scrollSlider.css('top', _top);
                        _s1 = (scrollSliderH.height() - slider_h) / 15;
                        _s2 = (scrollSliderH.height() - slider_h) / 3;
                        scrollContent.children('.scroll-hold').css('padding-right', scrollSliderH.width());

                    }
                    else {

                        _f = false;
                        scrollBar.hide();
                        scrollContent.css({ top: 0, left: 0 });
                        scrollContent.children('.scroll-hold').css('padding-right', 0);
                    }
                }
                /*
                setInterval(function(){
                if(_box.is(':visible') && cont_h != scrollContent.height()) _box.get(0).scrollResize();
                }, 200);
                */
            }
            else {
             
                this.scrollResize();
            }
        }
    });
}
/*--- custom select's ---*/
jQuery.fn.customSelect = function(_options){
var _options = jQuery.extend({
	selectStructure: '<div class="selectArea"><div class="left"></div><div class="center"></div><a href="#" class="selectButton">&nbsp;</a><div class="disabled"></div></div>',
	selectText: '.center',
	selectBtn: '.selectButton',
	selectDisabled: '.disabled',
	optStructure: '<div class="selectOptions"><div class="select-top"></div><div class="select-list"><ul></ul></div><div class="select-bottom"></div></div>',
	optList: 'ul',
	maxHeight: 99999
}, _options);
return this.each(function(){
	var select = jQuery(this);
	if(!select.hasClass('outtaHere')){
		if(select.is(':visible')){
			var replaced = jQuery(_options.selectStructure);
			var selectText = replaced.find(_options.selectText);
			var selectBtn = replaced.find(_options.selectBtn);
			var selectDisabled = replaced.find(_options.selectDisabled).hide();
			var optHolder = jQuery(_options.optStructure);
			var optList = optHolder.find(_options.optList);
			var maxH = _options.maxHeight;
			if(select.attr('disabled')) selectDisabled.show();
			select.find('option').each(function(){
				var selOpt = $(this);
				var _opt = jQuery('<li><a href="#"><span>' + selOpt.html() + '</span></a></li>');
				if(selOpt.attr('selected')){
					selectText.html(selOpt.html());
					_opt.addClass('selected');
				}
				_opt.children('a').click(function(){
					optList.find('li').removeClass('selected');
					select.find('option').removeAttr('selected');
					$(this).parent().addClass('selected');
					selOpt.attr('selected', 'selected');
					selectText.html(selOpt.html());
					select.change();
					optHolder.hide();
					replaced.removeClass('selectAreaActive');
					if(typeof(select.change) == 'function') select.change();
					if(typeof(select.get(0).onchange) == 'function') select.get(0).onchange();
					return false;
				});
				optList.append(_opt);
			});
			replaced.width(select.outerWidth());
			replaced.insertBefore(select);
			optHolder.css({
				width: select.outerWidth(),
				display: 'none',
				position: 'absolute'
			});
			 if(select.attr('class') && select.attr('class') != '')
			optHolder.addClass('drop-'+select.attr('class').split(' ')[0]);
			jQuery(document.body).append(optHolder);
			
			var optTimer;
			replaced.hover(function(){
				if(optTimer) clearTimeout(optTimer);
			}, function(){
				optTimer = setTimeout(function() {
					optHolder.hide();
					replaced.removeClass('selectAreaActive');
				}, 200);
			});
			optHolder.hover(function(){
				if(optTimer) clearTimeout(optTimer);
			}, function() {
				optTimer = setTimeout(function() {
					optHolder.hide();
					replaced.removeClass('selectAreaActive');
				}, 200);
			});
			selectBtn.click(function(){
				if(optHolder.is(':visible')){
					optHolder.hide();
					replaced.removeClass('selectAreaActive');
				}
				else{
					replaced.addClass('selectAreaActive');
					optHolder.css({
						top: replaced.offset().top + replaced.outerHeight(),
						left: replaced.offset().left,
						display: 'block'
					});
					if(optHolder.children('div.select-list').height() > maxH) optHolder.children('div.select-list').css({'height':maxH, 'overflow':'auto', 'overflow-x': 'hidden'});
				}
				return false;
			});
			select.addClass('outtaHere');
		}
	}
});
}
// browser detect script
browserDetect = {
	matchGroups: [
		[
			{uaString:'win', className:'win'},
			{uaString:'mac', className:'mac'},
			{uaString:['linux','x11'], className:'linux'}
		],
		[
			{uaString:'msie', className:'trident'},
			{uaString:'applewebkit', className:'webkit'},
			{uaString:'gecko', className:'gecko'},
			{uaString:'opera', className:'presto'}
		],
		[
			{uaString:'msie 9.0', className:'ie9'},
			{uaString:'msie 8.0', className:'ie8'},
			{uaString:'msie 7.0', className:'ie7'},
			{uaString:'msie 6.0', className:'ie6'},
			{uaString:'firefox/2', className:'ff2'},
			{uaString:'firefox/3', className:'ff3'},
			{uaString:'firefox/4', className:'ff4'},
			{uaString:['opera','version/11'], className:'opera11'},
			{uaString:['opera','version/10'], className:'opera10'},
			{uaString:'opera/9', className:'opera9'},
			{uaString:['safari','version/3'], className:'safari3'},
			{uaString:['safari','version/4'], className:'safari4'},
			{uaString:['safari','version/5'], className:'safari5'},
			{uaString:'chrome', className:'chrome'},
			{uaString:'safari', className:'safari2'},
			{uaString:'unknown', className:'unknown'}
		]
	],
	init: function() {
		this.detect();
		return this;
	},
	addClass: function(className) {
		this.pageHolder = document.documentElement;
		document.documentElement.className += ' '+className;
	},
	detect: function() {
		for(var i = 0, curGroup; i < this.matchGroups.length; i++) {
			curGroup = this.matchGroups[i];
			for(var j = 0, curItem; j < curGroup.length; j++) {
				curItem = curGroup[j];
				if(typeof curItem.uaString === 'string') {
					if(this.uaMatch(curItem.uaString)) {
						this.addClass(curItem.className);
						break;
					}
				} else {
					for(var k = 0, allMatch = true; k < curItem.uaString.length; k++) {
						if(!this.uaMatch(curItem.uaString[k])) {
							allMatch = false;
							break;
						}
					}
					if(allMatch) {
						this.addClass(curItem.className);
						break;
					}
				}
			}
		}
	},
	uaMatch: function(s) {
		if(!this.ua) {
			this.ua = navigator.userAgent.toLowerCase();
		}
		return this.ua.indexOf(s) != -1;
	}
}.init();
function initPage() {
	initAutoScalingNav({
		menuId: "account-list",
		tag: "a",
		sideClasses:true
	});
}
function initAutoScalingNav(o) {
	if (!o.menuId) o.menuId = "nav";
	if (!o.tag) o.tag = "a";
	if (!o.spacing) o.spacing = 0;
	if (!o.constant) o.constant = 0;
	if (!o.minPaddings) o.minPaddings = 0;
	if (!o.liHovering) o.liHovering = false;
	if (!o.sideClasses) o.sideClasses = false;
	if (!o.equalLinks) o.equalLinks = false;
	if (!o.flexible) o.flexible = false;
	var nav = document.getElementById(o.menuId);
	if(nav) {
		nav.className += " scaling-active";
		var lis = nav.getElementsByTagName("li");
		var asFl = [];
		var lisFl = [];
		var width = 0;
		for (var i=0, j=0; i<lis.length; i++) {
			if(lis[i].parentNode == nav) {
				var t = lis[i].getElementsByTagName(o.tag).item(0);
				asFl.push(t);
				asFl[j++].width = t.offsetWidth;
				lisFl.push(lis[i]);
				if(width < t.offsetWidth) width = t.offsetWidth;
			}
			if(o.liHovering) {
				lis[i].onmouseover = function() {
					this.className += " hover";
				}
				lis[i].onmouseout = function() {
					this.className = this.className.replace("hover", "");
				}
			}
		}
		var menuWidth = nav.clientWidth - asFl.length*o.spacing - o.constant;
		if(o.equalLinks && width * asFl.length < menuWidth) {
			for (var i=0; i<asFl.length; i++) {
				asFl[i].width = width;
			}
		}
		width = getItemsWidth(asFl);
		if(width < menuWidth) {
			var version = navigator.userAgent.toLowerCase();
			for (var i=0; getItemsWidth(asFl) < menuWidth; i++) {
				asFl[i].width++;
				if(!o.flexible) {
					asFl[i].style.width = asFl[i].width + "px";
				}
				if(i >= asFl.length-1) i=-1;
			}
			if(o.flexible) {
				for (var i=0; i<asFl.length; i++) {
					width = (asFl[i].width - o.spacing - o.constant/asFl.length)/menuWidth*100;
					if(i != asFl.length-1) {
						lisFl[i].style.width = width + "%";
					}
					else {
						if(navigator.appName.indexOf("Microsoft Internet Explorer") == -1 || version.indexOf("msie 8") != -1 || version.indexOf("msie 9") != -1)
							lisFl[i].style.width = width + "%";
					}
				}
			}
		}
		else if(o.minPaddings > 0) {
			for (var i=0; i<asFl.length; i++) {
				asFl[i].style.paddingLeft = o.minPaddings + "px";
				asFl[i].style.paddingRight = o.minPaddings + "px";
			}
		}
		if(o.sideClasses) {
			lisFl[0].className += " first-child";
			lisFl[0].getElementsByTagName(o.tag).item(0).className += " first-child-a";
			lisFl[lisFl.length-1].className += " last-child";
			lisFl[lisFl.length-1].getElementsByTagName(o.tag).item(0).className += " last-child-a";
		}
		nav.className += " scaling-ready";
	}
	function getItemsWidth(a) {
		var w = 0;
		for(var q=0; q<a.length; q++) {
			w += a[q].width;
		}
		return w;
	}
}
if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
    window.attachEvent("onload", initPage);

/*function shopDrop1() {
    
   var shopDropHolder = $('.quick-access ul li').has('.shop-drop');
    var shopDrop = shopDropHolder.find('.shop-drop');
    
    var animSpeed = 300;
    var delay = 300;
    var show;
    var hide;    
    function showDrop() { shopDrop.stop(true, true).slideDown(animSpeed); }
    function hideDrop() { shopDrop.stop(true, true).slideUp(animSpeed); }
    if (hide) clearTimeout(hide);
    showDrop();
    var scroll = $('.scrolled-list .holder');
    scroll.customScrollV();
}*/
/*function shopDrop1() {
    var shopDropHolder = $('.quick-access ul li').has('.shop-drop');
    var shopDrop = shopDropHolder.find('.shop-drop');
    shopDrop.hide();
    var animSpeed = 300;
    var delay = 300;
    var show;
    var hide;
    function showDrop() { shopDrop.stop(true, true).slideDown(animSpeed); }
    function hideDrop() { shopDrop.stop(true, true).slideUp(animSpeed); }   
        if (hide) clearTimeout(hide);
        showDrop();
        shopDrop.show();


    }*/


function shopDrop1() {

    //document.getElementById('mainminicart').style.display = "block";

    var shopDropHolder = $('.quick-access ul li').has('.shop-drop');
    var shopDrop = shopDropHolder.find('.shop-drop');
    shopDrop.hide();
    var animSpeed = 300;
    var delay = 300;
    var show;
    var hide;
    function showDrop() { shopDrop.stop(true, true).slideDown(animSpeed); }
    function hideDrop() { shopDrop.stop(true, true).slideUp(animSpeed); }
 
        if (hide) clearTimeout(hide);
        showDrop();
 
    //initScroll
    shopDrop.show();
    
   
   
  
    
}


