//==============================================================================================//
//									Global														//
//==============================================================================================//

var BShirt = BShirt || {};

jQuery.extend(BShirt, {
	memory: {
		currentPage: null,
		currentIndex: -1,
		menuItems: null,
		animNavComplete: true,
		navComplete: true,
		idealWidth: 1404,
		idealHeight: 936,
		idealFontSize: 72
	},
	
	initialize: function(){
		this.initMemory();
	},
	
	initMemory: function(){
		var memory = this.memory,
			menuItems = $('#menu').find('li a'),
			currentPage = document.getElementById('home');
		
		var vendor = (/webkit/i).test(navigator.appVersion) ? 'webkit' : (/firefox/i).test(navigator.userAgent) ? 'Moz' : 'opera' in window ? 'O' : '',
			has3d = 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix(),
			hasTouch = 'ontouchstart' in window,
			hasTransform = vendor + 'Transform' in document.documentElement.style,
			isIDevice = (/iphone|ipad/gi).test(navigator.appVersion),
			chromeOnMac = /mac/i.test(navigator.userAgent) && /chrome/i.test(navigator.userAgent),
			trnOpen = 'translate' + (has3d ? '3d(' : '('),
			trnClose = has3d ? ',0)' : ')';
			
		memory.menuItems = menuItems;
		memory.currentPage = currentPage;
		memory.vendor = vendor;
		memory.hasTransform = hasTransform;
		memory.isIDevice = isIDevice;
		memory.chromeOnMac = chromeOnMac;
		memory.trnOpen = trnOpen;
		memory.trnClose = trnClose;
		
		if(hasTransform){
			memory.startAnimation = function(elm, fromX, fromY, toX, toY, elm2, fromX2, fromY2, toX2, toY2, time){
				elm.style[vendor + 'TransitionDuration'] = time + 'ms';
				elm2.style[vendor + 'TransitionDuration'] = time + 'ms';
				
				elm.style[vendor + 'Transform'] = trnOpen + toX + 'px,' + toY + 'px' + trnClose;
				elm2.style[vendor + 'Transform'] = trnOpen + toX2 + 'px,' + toY2 + 'px' + trnClose;
			};
			
			memory.setPosition = function(elm, x, y){
				elm.style[vendor + 'TransitionProperty'] = '-' + vendor.toLowerCase() + '-transform';
				elm.style[vendor + 'TransitionDuration'] = '0ms';
				elm.style[vendor + 'Transform'] = trnOpen + x + 'px,' + y + 'px' + trnClose;
			};
		}
	},
	
	navigateTo: function(info){
		if(!this.memory.animNavComplete){
			return false;
		}
		
		var nextPage = $($(info).attr('href')),
			memory = this.memory;
			
		if(nextPage.length){
			var nextIndex = memory.menuItems.index(info);
			
			if(nextIndex == memory.currentIndex){
				return false;
			}
			
			if(memory.currentIndex == -1){
				if($.browser.msie && parseInt($.browser.version) < 9){
					$('#header img:first').addClass('hidden').next().removeClass('hidden');
				}else{
					$('#header img:first').stop(true).fadeTo(500, 0, function(){
						$(this).addClass('hidden').next().removeClass('hidden').stop(true).fadeTo(500, 1);
					});
				}
			}else{
				if($.browser.msie && parseInt($.browser.version) < 9){
					$('#header img:last').addClass('hidden').prev().removeClass('hidden');
				}else{
					$('#header img:last').stop(true).fadeTo(500, 0, function(){
						$(this).addClass('hidden').prev().removeClass('hidden').stop(true).fadeTo(500, 1);
					});
				}
			}
			
			if(memory.currentPage && memory.currentPage._onExit){
				memory.currentPage._onExit();
			}
			
			memory.animNavComplete = false;
			
			if(memory.currentPage){
				$(memory.currentPage).stop(true);
			}
			
			$(nextPage).stop(true);
			
			var slideFrom = $(window).width(),
				slideTo = 0;
			
			if(nextIndex < memory.currentIndex){
				slideFrom = -slideFrom;
				slideTo = 0;
			}
			
			if(memory.currentPage){
				if($.browser.safari && parseFloat($.browser.version) > 500 && memory.hasTransform && !memory.isIDevice && !memory.chromeOnMac){
					$(nextPage).css({
						left: 0,
						zIndex: 1
					});
					$(memory.currentPage).css({
						left: 0,
						zIndex: 0
					});
					
					memory.setPosition(nextPage[0], slideFrom, 0);
					memory.setPosition(memory.currentPage, 0, 0);
					
					setTimeout(function(){
						memory.startAnimation(nextPage[0], slideFrom, 0, 0, 0, memory.currentPage, 0, 0, -slideFrom, 0, 1000);
					}, 0);
					
					setTimeout(function(){
						memory.animNavComplete = true;
						memory.navComplete = true;
						memory.currentPage = nextPage[0];
						memory.currentIndex = nextIndex;
					}, 1000);
				}else{
				
					$(nextPage).removeClass('hidden').css({
						left: slideFrom,
						zIndex: 1
					}).animate({
						left: 0
					}, 950, function(){
						$(memory.currentPage).addClass('hidden');
						
						memory.animNavComplete = true;
						memory.navComplete = true;
						memory.currentPage = nextPage[0];
						memory.currentIndex = nextIndex;
						
						if($.browser.msie && parseInt($.browser.version) < 9){
							nextPage.css('filter', '');
						}
					});
				
					$(memory.currentPage).css({
						zIndex: 0
					}).animate({
						left: -slideFrom
					}, 1000);
				}
				
				if(nextPage[0]._onEnter){
					nextPage[0]._onEnter();
				}
			}
		}
	}
});

//==============================================================================================//
//									Utility														//
//==============================================================================================//

(function($){
	
	$.fn.fullscreenSlide = function(options){
	
		var defaults = {
			autoplay: 1,
			random: 0,
			slideInterval: 5000,
			transitionDuration:	750,
			pauseOnHover: 0,
			keyboardNav: 1,
			performance: 1,
			minWidth: 10,
			minHeight: 10,
			verticalCenter: 1,
			horizontalCenter: 1,
			fitPortrait: 0,
			fitLandscape: 0,
			slideCounter: 1,
			instanceId: 'zunique'
    	};
		
		options = $.extend(defaults, options);
		
		return this.each(function(){
			var jcontainer = $(this),
				jdisplay = jcontainer.find('.fullSlide'),
				jpaging = jcontainer.find('.paging'),
				jcounter = jcontainer.find('.slideCounter'),
				jloader = jcontainer.find('.fullSlideLoader'),
				slideshowIntervalId = null,
				animating = false,
				availableNext = false,
				availablePrev = false,
				forceNext = false,
				forcePrev = false,
				isPaused = false,
				counterLen = 0,
				currentSlide = 0,
				preloadImages = [];
				
			if(!options.slides.length || !jdisplay.length){
				return false;
			}
				
			if (options.performance == 3){
				jdisplay.addClass('speed');
			} else if ((options.performance == 1) || (options.performance == 2)){
				jdisplay.addClass('quality');
			}
			
			if(options.random){
				arr = options.slides;
				for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
				options.slides = arr;
			}
			
			var resizeFullScreen = function(){				
				var browserWidth = $(window).width();
				var browserHeight = $(window).height();
					
				jdisplay.find('img').each(function(){
					var jimage = $(this);
						//ratio = (jimage.height() / jimage.width());
					
					var imageInst = new Image();
					
					imageInst.onload = function(){
						var ratio = 1400 / 933;
						
						if(this.naturalWidth && this.naturalHeight){
							ratio = this.naturalHeight / this.naturalWidth;
						}else if(this.width && this.height){
							ratio = this.height / this.width;
						}

						if ((browserHeight <= options.minHeight) && (browserWidth <= options.minWidth)){
						
							if ((browserHeight / browserWidth) > ratio){
								options.fitLandscape && ratio <= 1 ? resizeWidth(true) : resizeHeight(true);
							} else {
								options.fitPortrait && ratio > 1 ? resizeHeight(true) : resizeWidth(true);
							}
						
						} else if (browserWidth <= options.minWidth){
						
							if ((browserHeight/browserWidth) > ratio){
								options.fitLandscape && ratio <= 1 ? resizeWidth(true) : resizeHeight();
							} else {
								options.fitPortrait && ratio > 1 ? resizeHeight() : resizeWidth(true);
							}
							
						} else if (browserHeight <= options.minHeight){
						
							if ((browserHeight/browserWidth) > ratio){
								options.fitLandscape && ratio <= 1 ? resizeWidth() : resizeHeight(true);
							} else {
								options.fitPortrait && ratio > 1 ? resizeHeight(true) : resizeWidth();
							}
						
						} else {
							
							if ((browserHeight/browserWidth) > ratio){
								options.fitLandscape && ratio <= 1 ? resizeWidth() : resizeHeight();
							} else {
								options.fitPortrait && ratio > 1 ? resizeHeight() : resizeWidth();
							}
						}
						
						function resizeWidth(minimum){
							if (minimum){
								if(jimage.width() < browserWidth || jimage.width() < options.minWidth ){
									if (jimage.width() * ratio >= options.minHeight){
										jimage.width(options.minWidth);
										jimage.height(jimage.width() * ratio);
									}else{
										resizeHeight();
									}
								}
							}else{
								if (options.minHeight >= browserHeight && !options.fitLandscape){
									if (browserWidth * ratio >= options.minHeight || (browserWidth * ratio >= options.minHeight && ratio <= 1)){
										jimage.width(browserWidth);
										jimage.height(browserWidth * ratio);
									} else if (ratio > 1){
										jimage.height(options.minHeight);
										jimage.width(jimage.height() / ratio);
									} else if (jimage.width() < browserWidth) {
										jimage.width(browserWidth);
										jimage.height(jimage.width() * ratio);
									}
								}else{
									jimage.width(browserWidth);
									jimage.height(browserWidth * ratio);
								}
							}
						};
						
						function resizeHeight(minimum){
							if (minimum){
								if(jimage.height() < browserHeight){
									if (jimage.height() / ratio >= options.minWidth){
										jimage.height(options.minHeight);
										jimage.width(jimage.height() / ratio);
									}else{
										resizeWidth(true);
									}
								}
							}else{
								if (options.minWidth >= browserWidth){
									if (browserHeight / ratio >= options.minWidth || ratio > 1){
										jimage.height(browserHeight);
										jimage.width(browserHeight / ratio);
									} else if (ratio <= 1){
										jimage.width(options.minWidth);
										jimage.height(jimage.width() * ratio);
									}
								}else{
									jimage.height(browserHeight);
									jimage.width(browserHeight / ratio);
								}
							}
						};
						
						if (options.horizontalCenter){
							jimage.css('left', (browserWidth - jimage.width())/2);
						}
						
						if (options.verticalCenter){
							jimage.css('top', (browserHeight - jimage.height())/2);
						}
						
						imageInst.onload = null;
						imageInst = null;
					};
					
					imageInst.src = jimage.attr('src');
				});
			},
			
			nextSlide = function(){
				if(animating || !availableNext){
					return false;
				}else{
					animating = true;
				}
				
				var slides = options.slides,
					currentslide = jdisplay.find('.activeSlide').removeClass('activeSlide');

				if(currentslide.length == 0){
					currentslide = jdisplay.find('a:last');
				}
				
				var nextslide = currentslide.next().length ? currentslide.next() : jdisplay.find('a:first'),
					prevslide = nextslide.prev().length ? nextslide.prev() : jdisplay.find('a:last');
				
				jdisplay.find('.prevSlide').removeClass('prevSlide');
				prevslide.addClass('prevSlide');
				
				currentSlide + 1 == slides.length ? currentSlide = 0 : currentSlide++;
				
				if(options.performance == 1){
					jdisplay.removeClass('quality').addClass('speed');
				}
				
				var loadSlide = false;
				
				availableNext = false;
				availablePrev = true;
				currentSlide == slides.length - 1 ? loadSlide = 0 : loadSlide = currentSlide + 1;
				$('<img/>').bind('load', readyNext).attr('src', options.slides[loadSlide].image).appendTo(jdisplay).wrap('<a></a>');
				
				currentslide.prev().remove();

				if(options.slideCounter){
					jcounter.find('.slideNumber').text(padText(currentSlide + 1, counterLen));
				}
				
				jloader.hide('fast');
				
				var memory = BShirt.memory;
				if($.browser.safari && parseFloat($.browser.version) > 500 && memory.hasTransform && !memory.isIDevice && !memory.chromeOnMac){
					nextslide.addClass('activeSlide');
					
					memory.setPosition(nextslide[0], $(window).width(), 0);
					memory.setPosition(currentslide[0], 0, 0);
					memory.startAnimation(nextslide[0], $(window).width(), 0, 0, 0, currentslide[0], 0, 0, -$(window).width(), 0, options.transitionDuration);
					
					setTimeout(afterAnimation, options.transitionDuration);
				}else{
					nextslide.hide().addClass('activeSlide').css({left: $(window).width()}).show().animate({left: 0}, options.transitionDuration, afterAnimation);
					currentslide.animate({ left: -$(window).width() }, options.transitionDuration);
				}
			},
			
			prevSlide = function(){
				if(animating || !availablePrev){
					return false;
				}else{
					animating = true;
				}
		
				var slides = options.slides,
					currentslide = jdisplay.find('.activeSlide').removeClass('activeSlide');
				
				if (currentslide.length == 0){
					currentslide = $(jdisplay).find('a:first');
				}
				
				var nextslide = currentslide.prev().length ? currentslide.prev() : $(jdisplay).find('a:last'),
					prevslide = nextslide.next().length ? nextslide.next() : $(jdisplay).find('a:first');
				
				jdisplay.find('.prevSlide').removeClass('prevSlide');
				prevslide.addClass('prevSlide');
						
				currentSlide == 0 ? currentSlide = slides.length - 1 : currentSlide--;

				if(options.performance == 1){
					jdisplay.removeClass('quality').addClass('speed');
				}
						
				var loadSlide = false;
				availablePrev = false;
				availableNext = true;
				currentSlide - 1 < 0  ? loadSlide = slides.length - 1 : loadSlide = currentSlide - 1;
				$('<img/>').bind('load', readyPrev).attr('src', options.slides[loadSlide].image).prependTo(jdisplay).wrap('<a></a>');
				
				currentslide.next().remove();

				if (options.slideCounter){
					jcounter.find('.slideNumber').text(padText(currentSlide + 1, counterLen));
				}
				
				jloader.hide('fast');
				
				var memory = BShirt.memory;
				if($.browser.safari && parseFloat($.browser.version) > 500 && memory.hasTransform && !memory.isIDevice && !memory.chromeOnMac){
					nextslide.addClass('activeSlide');
					
					memory.setPosition(nextslide[0], -$(window).width(), 0);
					memory.setPosition(currentslide[0], 0, 0);
					memory.startAnimation(nextslide[0], -$(window).width(), 0, 0, 0, currentslide[0], 0, 0, $(window).width(), 0, options.transitionDuration);
					
					setTimeout(afterAnimation, options.transitionDuration);
				}else{
					nextslide.hide().addClass('activeSlide').css({left : -$(window).width()}).show().animate({left: 0}, options.transitionDuration, afterAnimation);
					currentslide.animate({left: $(window).width()}, options.transitionDuration);
				}
			},
			
			afterAnimation = function(){
				animating = false; 
				
				if (options.performance == 1){
					jdisplay.removeClass('speed').addClass('quality');
				}
				
				resizeFullScreen();
			},
			
			readyNext = function(){
				availableNext = true;
				if(forceNext){
					jloader.hide('fast');
					nextSlide();
					forceNext = false;
				}
			},
			
			readyPrev = function(){
				availablePrev = true;
				
				if(forcePrev){
					jloader.hide('fast');
					prevSlide();
					forcePrev = false;
				}
			},
			
			padText = function(num, len){
				var text = num.toString();
				while(text.length < len){
					text = '0' + text;
				}
				
				return text;
			};
			
			var loadPrev = currentSlide - 1 < 0 ? options.slides.length - 1 : loadPrev = currentSlide - 1;
				loadNext = 0;
				
			$('<img/>').bind('load', readyPrev).attr('src', options.slides[loadPrev].image).appendTo(jdisplay).wrap('<a></a>');
			$('<img/>').bind('load', resizeFullScreen).attr('src', options.slides[currentSlide].image).appendTo(jdisplay).wrap('<a class="activeSlide"></a>');
			
			if (options.slides.length > 1){
				loadNext = (currentSlide == options.slides.length - 1) ? 0 : currentSlide + 1;
				$('<img/>').bind('load', resizeFullScreen).bind('load', readyNext).attr('src', options.slides[loadNext].image).appendTo(jdisplay).wrap('<a></a>');
			}
			
			jloader.hide();
			jdisplay.fadeIn('fast');
			jpaging.show();
			jcounter.show();
			
			if(options.slideCounter){
				counterLen = options.slides.length.toString().length;
				
				jcounter.find('.slideNumber').text(padText(currentSlide + 1, counterLen));
				jcounter.find('.totalSlides').text(options.slides.length);
			}
			
			if(options.slides.length > 1){
			
				if(!options.autoplay){
					clearInterval(slideshowIntervalId);
					isPaused = true;
				}else{
					slideshowIntervalId = setInterval(nextSlide, options.slideInterval);
				}
				
				jpaging.find('.nextSlideBtn').unbind('click.zslide').bind('click.zslide', function(){
					if(animating){
						return false;
					}
					
					forceNext = false;
					if(!availableNext){
						jloader.show('fast');
						forceNext = true;
						return false;
					}
					
					clearInterval(slideshowIntervalId);
					nextSlide();
					
					if(!isPaused){
						slideshowIntervalId = setInterval(nextSlide, options.slideInterval);
					}
					
					return false;
				});
				
				jpaging.find('.prevSlideBtn').unbind('click.zslide').bind('click.zslide', function() {
					if(animating){
						return false;
					}
					
					forcePrev = false;
					if(!availablePrev){
						jloader.show('fast');
						forcePrev = true;
						return false;
					}

					clearInterval(slideshowIntervalId);
					prevSlide();
					
					if(!isPaused){
						slideshowIntervalId = setInterval(nextSlide, options.slideInterval);
					}
					
					return false;
				});
			}
			
			if (options.keyboardNav && options.slides.length > 1){
				$(document.documentElement).unbind('keyup.zslide' + options.instanceId).bind('keyup.zslide' + options.instanceId, function(event){
					
					clearInterval(slideshowIntervalId);
					
					if(jdisplay.closest('section').hasClass('hidden')){
						return true;
					}
					
					if((event.keyCode == 37) || (event.keyCode == 40)){
						
						if(animating){
							return false;
						}
								
						clearInterval(slideshowIntervalId);
						prevSlide();
						
						if(!isPaused){
							slideshowIntervalId = setInterval(nextslide, options.slideInterval);
						}
						
						return false;
					
					}else if((event.keyCode == 39) || (event.keyCode == 38)){
						
						if(animating){
							return false;
						}
								
						clearInterval(slideshowIntervalId);
						nextSlide();
						
						if(!isPaused){
							slideshowIntervalId = setInterval(nextslide, options.slideInterval);
						}
					   
						return false;
					
					}
				});
			}
			
			if(options.pauseOnHover  && options.slides.length > 1){
				$(jdisplay).unbind('.zslide').bind('mouseenter.zslide', function(){
					if(animating){
						return false;
					}
						
					if(!isPaused && options.navigation){
						if ($(pauseplay).attr('src')) $(pauseplay).attr('src', image_path + 'pause.png');
						clearInterval(slideshowIntervalId);
					}
				}).bind('mouseleave.zslide', function() {
					if(!isPaused && options.navigation){
						if ($(pauseplay).attr('src')) $(pauseplay).attr('src', image_path + 'pause_dull.png');
						slideshowIntervalId = setInterval(nextslide, options.slideInterval);
					}
				});
			}
			
			$(window).unbind('resize.zslide' + options.instanceId).bind('resize.zslide' + options.instanceId, resizeFullScreen);
		});
		
		jcontainer[0]._onEnter = resizeFullScreen;
	};

	$.fn.slideMenu = function(options){
		var defaults = {
			overallDelay: 1000,
			durationBetween: 150,
			slideOutDuration: 350,
			slideInDuration: 500,
			direction: 'right',
			onComplete: false
		};
		
		options = $.extend(defaults, options);
		
		return this.each(function(){  
			var jcontainer = $(this),
				jitems = jcontainer.find('li');
				
			if(!jcontainer.data('initialized')){
				jcontainer.removeClass('hidden');
				
				$(window).unbind('resize.zslmenu').bind('resize.zslmenu', function(){
					var wndWidth = $(window).width(),
						wndHeight = $(window).height(),
						initialized = jcontainer.data('initialized');
						
					if((wndWidth < BShirt.memory.minWidth || wndHeight < BShirt.memory.minHeight) && initialized){
						return false;
					}
					
					var ratioW = wndWidth / BShirt.memory.idealWidth,
						ratioH = wndHeight / BShirt.memory.idealHeight,
						ratio = Math.min(ratioW, ratioH),
						fontSize = Math.round(BShirt.memory.idealFontSize * ratio),
						applyNewSize = function(){
							var oldDisplay = jcontainer.css('display');
							jcontainer.css('display', 'block');
							
							jitems.each(function(){
								var jitem = $(this),
									jcontent = jitem.find('a:first');
									
								jitem.stop(true).css({
									width: '',
									height: ''
								});
								jcontent.css({
									width: '',
									height: '',
									display: '',
									fontSize: fontSize,
									lineHeight: fontSize + 'px'
								});
								
								var contentWidth = jcontent.width() + 8,
									contentHeight = jcontent.height(),
									itemWidth = jitem.width(),
									itemHeight = jitem.height();
								
								jitem.data('originalSize', {
									width: contentWidth,
									height: itemHeight
								}).css({
									width: (!initialized || !(BShirt.memory.currentIndex == -1)) ? 0 : contentWidth,
									height: itemHeight
								});
								
								jcontent.css({
									width: contentWidth,
									height: contentHeight,
									display: 'block'
								});
							});
							jcontainer.css('display', oldDisplay);
						};
					
					
					
					if($.browser.msie && parseInt($.browser.version) < 9 && initialized){
						clearTimeout(BShirt.memory.resizeMenuId);
						BShirt.memory.resizeMenuId = setTimeout(applyNewSize, 100);
					}else{
						applyNewSize();
					}
					
				}).triggerHandler('resize.zslmenu');
				
				jcontainer.data('initialized', 1);
			}
			
			jcontainer.css('display', 'block');

			if(jitems.length){
				jitems.each(function(idx){
					var jitem = $(this);
					clearTimeout(jitem.data('mySlideTimeout'));
					
					jitem.data('mySlideTimeout', setTimeout(function(){
						var originalSize = jitem.data('originalSize');
					
						jitem.stop(true).css({
							width: options.direction == 'right' ? 0 : originalSize.width
						}).animate({
							width: options.direction == 'right' ? originalSize.width : 0
						}, (options.direction == 'right' ? options.slideInDuration : options.slideOutDuration));
						
						if(idx == jitems.length -1){
							jitem.queue(function(){
								if(options.direction == 'left'){
									jcontainer.css('display', 'none');
								}
								
								if(options.onComplete){
									options.onComplete();
								}
							});
						}
						
					}, idx * options.durationBetween + options.overallDelay));
				});
			}
		});
	};
	
	$.fn.mouseMoveBg = function(options){
		var defaults = {
				offsetX: 0,
				offsetY: 0
			};
			
		options = $.extend(defaults, options);
			
		return this.each(function(){
			var jcontainer = $(this),
				jmask = jcontainer.find('.wrapMask');
			
			if(jmask.length){
				var resposition = function(e){
					var mouseX = e.pageX,
						mouseY = e.pageY,
						offset = jcontainer.offset(),
						offsetX = mouseX - offset.left,
						offsetY = mouseY - offset.top,
						top = Math.max(0, Math.min(jcontainer.height() - jmask.height(), offsetY - (jmask.height() / 2)));
					
					jmask.css({
						top: top
					});
				};
				
				jcontainer.unbind('.zbgmove').one('mouseover.zbgmove', resposition).bind('mousemove.zbgmove', resposition);
			}
		});
	};
	
	$.fn.initNavigator = function(options){
		var defaults = {
		};
			
		options = $.extend(defaults, options);
			
		return this.each(function(){
			var jcontainer = $(this),
				jitems = jcontainer.find('li a');
				
			if(jitems.length){
				jitems.each(function(){
					$(this).unbind('click.znavigate').bind('click.znavigate', function(){
						
						if(!BShirt.memory.navComplete){
							return false;
						}
						
						BShirt.memory.navComplete = false;
					
						var navToElm = this,
							navToPageId = $(this).attr('href'),
							navToPage = $(navToPageId.substr(navToPageId.indexOf('#')));
							
						if(navToPage.length){
							$('#menu').slideMenu({
								direction: 'left',
								overallDelay: 100,
								durationBetween: 70,
								slideOutDuration: 350,
								onComplete: function(){
									BShirt.navigateTo(navToElm);
								}
							});
						}else{
							BShirt.memory.navComplete = true;
						}
						
						return false;
					});
				});
			}
		});
	};
	
	$.fn.resizeBg = function(options){
		var defaults = {
			minWidth: 10,
			minHeight: 10,
			fitLandscape: 0,
			fitPortrait: 1,
			horizontalCenter: 0,
			verticalCenter: 0
		};

		options = $.extend(defaults, options);
		
		var collections = this.find('.rzbackground'),
			browserWidth = $(window).width(),
			browserHeight = $(window).height(),
		
		resizeWidth = function(jimage, ratio, minimum){
			if (minimum){
				if(jimage.width() < browserWidth || jimage.width() < options.minWidth ){
					if (jimage.width() * ratio >= options.minHeight){
						jimage.width(options.minWidth);
						jimage.height(jimage.width() * ratio);
					}else{
						resizeHeight(jimage, ratio);
					}
				}
			}else{
				if (options.minHeight >= browserHeight && !options.fitLandscape){
					if (browserWidth * ratio >= options.minHeight || (browserWidth * ratio >= options.minHeight && ratio <= 1)){
						jimage.width(browserWidth);
						jimage.height(browserWidth * ratio);
					} else if (ratio > 1){
						jimage.height(options.minHeight);
						jimage.width(jimage.height() / ratio);
					} else if (jimage.width() < browserWidth) {
						jimage.width(browserWidth);
						jimage.height(jimage.width() * ratio);
					}
				}else{
					jimage.width(browserWidth);
					jimage.height(browserWidth * ratio);
				}
			}
		},
		
		resizeHeight = function(jimage, ratio, minimum){
			if (minimum){
				if(jimage.height() < browserHeight){
					if (jimage.height() / ratio >= options.minWidth){
						jimage.height(options.minHeight);
						jimage.width(jimage.height() / ratio);
					}else{
						resizeWidth(jimage, ratio, true);
					}
				}
			}else{
				if (options.minWidth >= browserWidth){
					if (browserHeight / ratio >= options.minWidth || ratio > 1){
						jimage.height(browserHeight);
						jimage.width(browserHeight / ratio);
					} else if (ratio <= 1){
						jimage.width(options.minWidth);
						jimage.height(jimage.width() * ratio);
					}
				}else{
					jimage.height(browserHeight);
					jimage.width(browserHeight / ratio);
				}
			}
		},
		
		resizeMe = function(image){
			var jimage = $(image),
				ratio = (jimage.height() / jimage.width());

			if(image.height && image.width){		
				ratio = (image.height / image.width);
			}

			if ((browserHeight <= options.minHeight) && (browserWidth <= options.minWidth)){
			
				if ((browserHeight / browserWidth) > ratio){
					options.fitLandscape && ratio <= 1 ? resizeWidth(jimage, ratio, true) : resizeHeight(jimage, ratio, true);
				} else {
					options.fitPortrait && ratio > 1 ? resizeHeight(jimage, ratio, true) : resizeWidth(jimage, ratio, true);
				}
			
			} else if (browserWidth <= options.minWidth){
				if ((browserHeight/browserWidth) > ratio){
					options.fitLandscape && ratio <= 1 ? resizeWidth(jimage, ratio, true) : resizeHeight(jimage, ratio);
				} else {
					options.fitPortrait && ratio > 1 ? resizeHeight(jimage, ratio) : resizeWidth(jimage, ratio, true);
				}
			} else if (browserHeight <= options.minHeight){
				if ((browserHeight/browserWidth) > ratio){
					options.fitLandscape && ratio <= 1 ? resizeWidth(jimage, ratio) : resizeHeight(jimage, ratio, true);
				} else {
					options.fitPortrait && ratio > 1 ? resizeHeight(jimage, ratio, true) : resizeWidth(jimage, ratio);
				}
			} else {
				if ((browserHeight/browserWidth) > ratio){
					options.fitLandscape && ratio <= 1 ? resizeWidth(jimage, ratio) : resizeHeight(jimage, ratio);
				} else {
					options.fitPortrait && ratio > 1 ? resizeHeight(jimage, ratio) : resizeWidth(jimage, ratio);
				}
			}
			
			if (options.horizontalCenter){
				$(this).css('left', (browserWidth - $(this).width())/2);
			}
			
			if (options.verticalCenter){
				$(this).css('top', (browserHeight - $(this).height())/2);
			}
		};
		
		$(window).unbind('resize.zrzbg').bind('resize.zrzbg', function(){
			browserWidth = $(window).width();
			browserHeight = $(window).height();
			
			collections.each(function(){
				var imageBg = this;
				if(imageBg._loaded){
					resizeMe(imageBg);
				}else{
					var image = new Image();
					image.onload = function(){
						imageBg._loaded = true;
						resizeMe(imageBg);
					};
					image.src = imageBg.getAttribute('src');
				}
			});
		}).trigger('resize.zrzbg');
		
		var hiddenImages = collections.filter('.hidden'),
			totalHImage = hiddenImages.length,
			hImgLoaded = 0;
		
		hiddenImages.each(function(){
			var himage = this,
				image = new Image();
			
			image.onload = function(){
				this._loaded = true;
				resizeMe(himage);
				
				hImgLoaded++;
				
				$(himage).css('opacity', 0).removeClass('hidden').fadeTo(1000, 1);
				
				if($.browser.msie && parseInt($.browser.version) < 9){
					$('#header img:first').removeClass('hidden');
				}else{
					$('#header img:first').css('opacity', 0).removeClass('hidden').fadeTo(1000, 1);
				}
				
				if(hImgLoaded >= totalHImage && options.onComplete){
					options.onComplete();
				}
			};

			if($.browser.opera){
				setTimeout(function(){
					image.src = himage.getAttribute('src');
				}, 10);
			}else{
				image.src = himage.getAttribute('src');
			}
		});
	};
	
	$.fn.centerText = function(options){
		var defaults = {
			minWidth: 10,
			minHeight: 10
		};

		options = $.extend(defaults, options);
		
		var jtexts = this,
			
		alignVerticleCenter = function(){
			var browserHeight = $(window).height();	
				
			jtexts.each(function(){
				var jtext = $(this);

				jtext.css({
					top: Math.max(0, (browserHeight - jtext.height()) / 2)
				});
			});
		};
		
		
		this.each(function(){
			var jcontainer = $(this).closest('section');
			
			jcontainer[0]._onEnter = alignVerticleCenter;
		});
		
		$(window).unbind('resize.zvtext').bind('resize.zvtext', alignVerticleCenter);
	};
	
	$.fn.navitoHomepage = function(options){
		var defaults = {
			
		};
		
		options = $.extend(defaults, options);
			
		return this.each(function(){
			$(this).unbind('click.ztohome').bind('click.ztohome', function(){
				if(!BShirt.memory.animNavComplete || BShirt.memory.currentIndex == -1){
					return false;
				}
				
				BShirt.navigateTo(this);
				
				$('#menu').slideMenu({
					direction: 'right',
					overallDelay: 1000
				});

				return false;
			});
		});
	};
	
	$.fn.resizeBySize = function(options){
		var defaults = {
			idealWidths: [257, 257, 159, 384, 279, 279, 292, 292, 384, 279, 279, 292, 292, 40, 40, 40, 40, 40, 40, 40, 40, 279, 292],
			idealHeights: [86, 86, 27, 171, 82, 82, 82, 82, 171, 82, 82, 82, 82, 102, 102, 102, 102, 102, 102, 102, 102, 82, 82]
		};
		
		options = $.extend(defaults, options);
			
		if(this.length){
			var jelms = this;
			$(window).unbind('resize.zbysize').bind('resize.zbysize', function(){
				var wndWidth = $(window).width(),
					wndHeight = $(window).height();
				
				var ratioW = wndWidth / BShirt.memory.idealWidth,
					ratioH = wndHeight / BShirt.memory.idealHeight,
					ratio = Math.min(ratioW, ratioH);
				
				jelms.each(function(idx){
					$(this).css({
						width: options.idealWidths[idx] * ratio,
						height: options.idealHeights[idx] * ratio
					});
				});
				
				$('.totalSlides').css('margin-right', 36 * ratio);
				$('.nextSlideBtn').css('margin-left', 105 * ratio);
				
			}).triggerHandler('resize.zbysize');
		};
	};
	
	$.fn.resizeByFontSize = function(options){
		var defaults = {
			idealFontSizes: [37, 26, 89, 89, 36, 22, 36, 24],
			idealLineHeights: [37, 28, 89, 89, 36, 24, 36, 26]
		};
		
		options = $.extend(defaults, options);
		
		if(this.length){
			var jelms = this;
			$(window).unbind('resize.zbyfontsize').bind('resize.zbyfontsize', function(){
				var wndWidth = $(window).width(),
					wndHeight = $(window).height();
				
				var ratioW = wndWidth / BShirt.memory.idealWidth,
					ratioH = wndHeight / BShirt.memory.idealHeight,
					ratio = Math.min(ratioW, ratioH);
				
				jelms.each(function(idx){
					$(this).css({
						fontSize: Math.round(options.idealFontSizes[idx] * ratio) + 'px',
						lineHeight: Math.round(options.idealLineHeights[idx] * ratio) + 'px'
					});
				});
			}).triggerHandler('resize.zbyfontsize');
		};
	};
	
	$.fn.hoverSupport = function(options){
		var defaults = {
		};
		
		options = $.extend(defaults, options);
			
		return this.each(function(){
			$(this).unbind('mouseenter.zhover').unbind('mouseleave.zhover').bind('mouseenter.zhover', function(){
				if(!this._zDisabled){
					$(this).find(':last').removeClass('hidden').prev().addClass('hidden');
				}
			}).bind('mouseleave.zhover', function(){
				$(this).find(':first').removeClass('hidden').next().addClass('hidden');
			});
		});
	};
	
	$.fn.hoverSupportLb = function(options){
		var defaults = {
		};
		
		options = $.extend(defaults, options);
			
		return this.each(function(){
			$(this).unbind('mouseenter.zhover').unbind('mouseleave.zhover').bind('mouseenter.zhover', function(){
				if($(this).css('display') != 'none'){
					$(this).find('img').removeClass('hidden');
				}
			}).bind('mouseleave.zhover', function(){
				$(this).find(':first').addClass('hidden');
			});
		});
	};
	
	$.fn.storeXmlRender = function(options){
		var defaults = {
			xmlFilePath: 'xml/stores.xml',
			outlineTemplate: '<li><a href="#{regionId}" title="{regionId}">{regionId}</a></li>',
			displayTemplate: '<li>' +
								'<header>{fullname}</header>' +
								'<p>{genre}</p>' +
								'<address>{address}</address>' +
								'<p>{telephone}</p>' +
								'<a href="mailto:{email}" title="{email}">{email}</a>' +
							'</li>'
		};
		
		options = $.extend(defaults, options);

		var xmlload = function(xmlstr){
			var root;
			if ($.browser.msie){
				root = new ActiveXObject('Microsoft.XMLDOM');
				root.async = false;
				root.loadXML(xmlstr);
			}else{
				root = new DOMParser().parseFromString(xmlstr, 'text/xml');
			}
			
			return root;	
		},
		substitute = function(str, obj){
			return str.replace((/\\?\{([^{}]+)\}/g), function(match, name){
				if (match.charAt(0) == '\\') return match.slice(1);
				return (obj[name] != null) ? obj[name] : '';
			});
		},
		
		render = function(xmldoc, joutline, jdisplay){
			if(!xmldoc){
				return '';
			}
			
			renderOutline(xmldoc, joutline);
			renderDisplay(xmldoc, jdisplay, 0);
		},
		
		renderDisplayElm = function(xmlnode){
			if(!xmlnode){
				return '';
			}
			
			var result = '',
				data = {};
					
			for(var i = 0, il = xmlnode.childNodes.length; i < il; i++){
				var cnode = xmlnode.childNodes[i],
					cnodeType = cnode.nodeType,
					cnodeName = cnode.localName || cnode.nodeName,
					cnodeValue = cnode.text || cnode.nodeValue || cnode.textContent || '';
					
				if(cnodeType == 8){
					continue;
				}else if(cnodeType == 3 || cnodeType == 4 || !cnodeName){
					continue;
				}else{
					data[cnodeName] = cnodeValue;
				}
			}
			
			
			result = substitute(options.displayTemplate, data);
			
			return result;
		},
		
		renderDisplay = function(xmldoc, jdisplay, index){
			if(!xmldoc){
				return '';
			}
			
			var storesElms = xmldoc.getElementsByTagName('stores'),
				indexStoreElm = null;
			
			if(typeof index == 'number'){
				indexStoreElm = storesElms[index];
			}else{
				index = index.substr(1);
				
				for(var i = 0, il = storesElms.length; i < il; i++){
					if(storesElms[i].getAttribute('region') == index){
						indexStoreElm = storesElms[i];
						break;
					}
				}
			}
				
			if(indexStoreElm){
				var storeElms = indexStoreElm.getElementsByTagName('store'),
					finalHtml = '';
				
				for(var i = 0, il = storeElms.length; i < il; i+=3){
					var displayHtml = '';
					
					for(var j = i, jl = Math.min(i + 3, il); j < jl; j++){
						displayHtml += renderDisplayElm(storeElms[j]);
					}
					
					if(displayHtml != ''){
						finalHtml += '<ul ' + ((i + 3 >= il)? 'class="last"' : '') + '>' + displayHtml + '</ul>';
					}
				}
				
				jdisplay.empty().html(finalHtml);
			}
		},
		
		renderOutline = function(xmldoc, joutline){
			if(!xmldoc){
				return '';
			}
			
			var storesElms = xmldoc.getElementsByTagName('stores'),
				outlineHtml = '<ul>';
			for(var i = 0, il = storesElms.length; i < il; i++){
				outlineHtml += substitute(options.outlineTemplate, {regionId: storesElms[i].getAttribute('region')});
			}
			
			if(outlineHtml != '<ul>'){
				outlineHtml += '</ul>';
			}
			
			joutline.empty().html(outlineHtml);
		},
		
		initOutline = function(joutline, jdisplay){
			var joutlines = joutline.find('ul li'),
				activeOutline = joutlines[0];
			joutlines.unbind('click.zxmlrender').bind('click.zxmlrender', function(){
				if(this != activeOutline){
					$(activeOutline).removeClass('active');
					$(this).addClass('active');
					activeOutline = this;
					
					var dispIdx = $(this).find('a').attr('href');
					dispIdx = dispIdx.substr(dispIdx.indexOf('#'));
					
					renderDisplay(options.xmlData, jdisplay, dispIdx);
					$(window).triggerHandler('resize.zvtext');
					jdisplay.stop().css('opacity', 0.3).fadeTo(500, 1, function(){
						if($.browser.msie && parseInt($.browser.version) < 9){
							jdisplay.css('filter', '');
						}
					});
				}
				
				if($.browser.msie){
					document.body.focus();
				}
				
				return false;
			}).eq(0).addClass('active');
		};
	
		return this.each(function(){
			var jcontainer = $(this),
				joutline = jcontainer.find('.lstRegion'),
				jdisplay = jcontainer.find('.cntStore');
				
			$.ajax({
				url: options.xmlFilePath,
				type: 'GET',
				dataType: 'xml',
				cache: false,
				complete: function(xmlreq){
					var xmldoc = xmlreq.responseXML;
						
					if(!xmldoc){
						xmldoc = xmlload(xmlreq.responseText);
					}
					
					options.xmlData = xmldoc;
					
					render(xmldoc, joutline, jdisplay);
					
					initOutline(joutline, jdisplay);
				}
			});
		});
	};
	
	$.fn.initSlideVideoGallery = function(options){
		var defaults = {
			opacityDisable: 0.3,
			totalVisible: 7,
			slideDuration: 500,
			idealThumpMargin: 20,
			idealThumbWidth: 214,
			idealThumbHeight: 120,
			idealVideoWidth: 640,
			idealVideoHeight: 360,
			idealNavMarginTop: 17
		};
		
		options = $.extend(defaults, options);  
		
		return this.each(function(){  
			var jcontainer = $(this),
				jnav = jcontainer.find('.lstNav'),
				jprev = jnav.find('a:first'),
				jnext = jnav.find('a:last');
			
			if(jprev.length && jnext.length){
				var jwrapper = jcontainer.find('.lstVideo'),
					jitems = jwrapper.children(),
					nitems = jitems.length,
					previdx = 0,
					curridx = 0,
					actived = false,
					videoPlayer = null,
					disableNav = false,
					animCompleted = true,
					thumpMargin = options.idealThumpMargin,
					thumbWidth = options.idealThumbWidth,
					thumbHeight = options.idealThumbHeight,
					videoWidth = options.idealVideoWidth,
					videoHeight = options.idealVideoHeight,
					navMarginTop = options.idealNavMarginTop;
				
				if(nitems){
					jnext.unbind('click.zrgal').bind('click.zrgal', function(){
						if(!animCompleted || disableNav){
							return false;
						}
						animCompleted =  false;
						
						var itemWidth = thumbWidth + thumpMargin,
							leftIndent = parseInt(jwrapper.css('marginLeft')) - itemWidth;
						
						curridx = curridx < nitems -1 ? curridx +1 : 0;
						
						if(actived){
							if(videoPlayer){
								videoPlayer.css('display', 'none');
								videoPlayer.remove();
								videoPlayer = null;
							}
								
							$('img', actived).stop().css('visibility', 'visible').animate({
								width: thumbWidth,
								height: thumbHeight
							}, function(){
								var jdup = jwrapper.find('> li:first').clone().appendTo(jwrapper);
								jwrapper.stop(true).css('marginLeft', 0).animate({'marginLeft' : -itemWidth}, options.slideDuration, function(){
									jdup.remove();
									jdup = null;
									
									jwrapper.find('> li:last').after(jwrapper.find('> li:first'));
									
									jwrapper.css({'marginLeft' : 0});
									animCompleted =  true;
								});
								
								actived = false;
							});
						}else{
							var jdup = jwrapper.find('> li:first').clone().appendTo(jwrapper);
							jwrapper.stop(true).css('marginLeft', 0).animate({'marginLeft' : -itemWidth}, options.slideDuration, function(){
								jdup.remove();
								jdup = null;
								
								jwrapper.find('> li:last').after(jwrapper.find('> li:first'));
								
								jwrapper.css({'marginLeft' : 0});
								animCompleted =  true;
							});
						}
						
						return false;
					});
					
					jprev.unbind('click.zrgal').bind('click.zrgal', function(){
						if(!animCompleted || disableNav){
							return false;
						}
						animCompleted =  false;
						
						curridx = curridx > 0 ? curridx - 1 : nitems -1;
						
						var itemWidth = thumbWidth + thumpMargin,
							leftIndent = parseInt(jwrapper.css('marginLeft')) + itemWidth;
							
						if(actived){
							if(videoPlayer){
								videoPlayer.css('display', 'none');
								videoPlayer.remove();
								videoPlayer = null;
							}
								
							$('img', actived).stop().css('visibility', 'visible').animate({
								width: thumbWidth,
								height: thumbHeight
							}, function(){
								jwrapper.find('> :first').before(jwrapper.find('> :last'));
							
								var jdup = jwrapper.find('> :first').clone().appendTo(jwrapper);
								
								jwrapper.stop(true).css('marginLeft', -itemWidth).animate({'marginLeft' : 0}, options.slideDuration, function(){
									jdup.remove();
									jdup = null;
									
									jwrapper.css({'marginLeft' : 0});
									animCompleted =  true;
								});
								
								actived = false;
							});
						}else{
							jwrapper.find('> :first').before(jwrapper.find('> :last'));
							
							var jdup = jwrapper.find('> :first').clone().appendTo(jwrapper);
							
							jwrapper.stop(true).css('marginLeft', -itemWidth).animate({'marginLeft' : 0}, options.slideDuration, function(){
								jdup.remove();
								jdup = null;
								
								jwrapper.css({'marginLeft' : 0});
								animCompleted =  true;
							});
						}
						
						return false;
					});
					
					jitems.unbind('click.zshvideo').bind('click.zshvideo', function(){
						if(!animCompleted){
							return false;
						}
						
						if(actived == this){
							if(videoPlayer){
								videoPlayer.css('display', 'none');
								videoPlayer.remove();
								videoPlayer = null;
							}
							
							$('img', actived).css('visibility', 'visible').stop().animate({
								width: thumbWidth,
								height: thumbHeight
							});
							
							actived = false;
						}else{
						
							animCompleted = false;
							
							if(actived){
								if(videoPlayer){
									videoPlayer.css('display', 'none');
									videoPlayer.remove();
									videoPlayer = null;
								}
							
								$('img', actived).stop().css('visibility', 'visible').animate({
									width: thumbWidth,
									height: thumbHeight
								});
							}
						
							var jitem = $(this),
								jitemimg = jitem.find('img'),
								wndWidth = $(window).width(),
								overflowWidth = jitemimg.offset().left + videoWidth - wndWidth,
								jdups = [],
								timeout = 0;
								
							if(overflowWidth > 0){
								var ndupitem = Math.ceil(overflowWidth / (thumbWidth + thumpMargin)),
									jcuritems = jwrapper.children();
									
								for(var i = 0; i < ndupitem; i++){
									jdups.push(jcuritems.eq(i).clone(true).appendTo(jwrapper));
								}
								
								jwrapper.stop(true).animate({'marginLeft' : -(ndupitem) * (thumbWidth + thumpMargin)}, options.slideDuration, function(){
									for(var i = 0; i < ndupitem; i++){
										jcuritems.eq(i).appendTo(jwrapper);
									}
									
									for(var i = 0; i < ndupitem; i++){
										jdups[i].remove();
										jdups[i] = null;
									}

									jwrapper.css({'marginLeft' : 0});
								});
								
								timeout = 750;
							}
							
							setTimeout(function(){
								jitemimg.stop().animate({
									width: videoWidth,
									height: videoHeight
								}, function(){
									
									jitemimg.css('visibility', 'hidden');
									
									videoPlayer = $('<div class="videoContainer"><div id="playerPlaceholder"></div></div>').appendTo(document.body);
									swfobject.embedSWF('swf/player.swf', 'playerPlaceholder', videoWidth, videoHeight + 32, '9.0.0', 'swf/expressInstall.swf', {
											/*flashvars*/
											skin: 'swf/modieus.swf',
											image: $(this).attr('src'),
											file: $(this).closest('a').attr('href')
										}, {
											wmode: 'opaque',
											allowFullScreen: true,
											bgcolor: '#000'
											/*param*/
										}, {/*atribute*/});

									videoPlayer.css({
										top: $(this).offset().top -1,
										left: $(this).offset().left -2
									});
									
									animCompleted = true;
								});
								
							}, timeout);
							
							actived = this;
						}
						
						return false;
					});
					
					$(window).unbind('resize.zvidgal').bind('resize.zvidgal', function(){
						var wndWidth = $(window).width(),
							wndHeight = $(window).height(),
							ratio = Math.min(wndWidth / BShirt.memory.idealWidth, wndHeight / BShirt.memory.idealHeight);
						
						thumpMargin	= Math.floor(ratio * options.idealThumpMargin);
						
						navMarginTop = Math.floor(ratio * options.idealNavMarginTop);
						
						thumbWidth = Math.floor(ratio * options.idealThumbWidth);
						thumbHeight = Math.floor(ratio * options.idealThumbHeight);
						
						videoWidth = Math.floor(ratio * options.idealVideoWidth);
						videoHeight = Math.floor(ratio * options.idealVideoHeight);
						
						jitems.css({
							marginRight: thumpMargin
						}).find('img').css({
							width: thumbWidth,
							height: thumbHeight
						});
						
						jwrapper.css({'marginLeft' : 0});
						
						if(actived){
							var jactiveimg = $('img', actived).css({
								width: videoWidth,
								height: videoHeight
							});
							
							if(videoPlayer){
								videoPlayer.css({
									top: jactiveimg.offset().top -1,
									left: jactiveimg.offset().left -2
								}).find(':first').attr({
									width: videoWidth,
									height: videoHeight + 32
								});
							}
						}
						
						jcontainer.css('height', videoHeight + 10);
						jnav.css('top', thumbHeight + navMarginTop);
						
						if(nitems * (thumbWidth + 4 + thumpMargin) - thumpMargin < wndWidth){
							disableNav = true;
							jnext.css('opacity', options.opacityDisable)[0]._zDisabled = 1;
							jprev.css('opacity', options.opacityDisable)[0]._zDisabled = 1;
						}else{
							disableNav = false;
							jnext.css('opacity', '')[0]._zDisabled = 0;
							jprev.css('opacity', '')[0]._zDisabled = 0;
						}
						
					}).triggerHandler('resize.zvidgal');
					
					jcontainer.closest('section').unbind('click.zvidclose').bind('click.zvidclose', function(){
						if(!animCompleted){
							return false;
						}
						
						if(actived){
							if(videoPlayer){
								videoPlayer.css('display', 'none');
								videoPlayer.remove();
								videoPlayer = null;
							}
							
							$('img', actived).stop().css('visibility', 'visible').animate({
								width: thumbWidth,
								height: thumbHeight
							});
							
							actived = false;
						}
					})[0]._onExit = function(){
						if(actived){
							if(videoPlayer){
								videoPlayer.css('display', 'none');
								videoPlayer.remove();
								videoPlayer = null;
							}
							
							$('img', actived).stop().css('visibility', 'visible').animate({
								width: thumbWidth,
								height: thumbHeight
							});
							
							actived = false;
						}
					};
				}
			}
		});
	};
	
	$.fn.initSlideImageGallery = function(options){
		var defaults = {
			opacityDisable: 0.3,
			totalVisible: 7,
			slideDuration: 500,
			idealThumpMargin: 20,
			idealThumbWidth: 214,
			idealThumbHeight: 120,
			idealGalHeight: 360,
			idealNavMarginTop: 17
		};
		
		options = $.extend(defaults, options);  
		
		return this.each(function(){  
			var jcontainer = $(this),
				jnav = jcontainer.find('.lstNav'),
				jprev = jnav.find('a:first'),
				jnext = jnav.find('a:last');
			
			if(jprev.length && jnext.length){
				var jwrapper = jcontainer.find('.lstImg'),
					jitems = jwrapper.children(),
					nitems = jitems.length,
					previdx = 0,
					curridx = 0,
					actived = false,
					videoPlayer = null,
					disableNav = false,
					animCompleted = true,
					thumpMargin = options.idealThumpMargin,
					thumbWidth = options.idealThumbWidth,
					thumbHeight = options.idealThumbHeight,
					galleryHeight = options.idealGalHeight,
					navMarginTop = options.idealNavMarginTop;
				
				if(nitems){
					jnext.unbind('click.zrgal').bind('click.zrgal', function(){
						if(!animCompleted || disableNav){
							return false;
						}
						animCompleted =  false;
						
						var itemWidth = thumbWidth + thumpMargin,
							leftIndent = parseInt(jwrapper.css('marginLeft')) - itemWidth;
						
						curridx = curridx < nitems -1 ? curridx +1 : 0;
						
						
						var jdup = jwrapper.find('> li:first').clone().appendTo(jwrapper);
						jwrapper.stop(true).css('marginLeft', 0).animate({'marginLeft' : -itemWidth}, options.slideDuration, function(){
							jdup.remove();
							jdup = null;
							
							jwrapper.find('> li:last').after(jwrapper.find('> li:first'));
							
							jwrapper.css({'marginLeft' : 0});
							animCompleted =  true;
						});
						
						
						return false;
					});
					
					jprev.unbind('click.zrgal').bind('click.zrgal', function(){
						if(!animCompleted || disableNav){
							return false;
						}
						animCompleted =  false;
						
						curridx = curridx > 0 ? curridx - 1 : nitems -1;
						
						var itemWidth = thumbWidth + thumpMargin,
							leftIndent = parseInt(jwrapper.css('marginLeft')) + itemWidth;
							
						
						jwrapper.find('> :first').before(jwrapper.find('> :last'));
						
						var jdup = jwrapper.find('> :first').clone().appendTo(jwrapper);
						
						jwrapper.stop(true).css('marginLeft', -itemWidth).animate({'marginLeft' : 0}, options.slideDuration, function(){
							jdup.remove();
							jdup = null;
							
							jwrapper.css({'marginLeft' : 0});
							animCompleted =  true;
						});
						
						
						return false;
					});
					
					$(window).unbind('resize.zimggal').bind('resize.zimggal', function(){
						var wndWidth = $(window).width(),
							wndHeight = $(window).height(),
							ratio = Math.min(wndWidth / BShirt.memory.idealWidth, wndHeight / BShirt.memory.idealHeight);
						
						thumpMargin	= Math.floor(ratio * options.idealThumpMargin);
						
						navMarginTop = Math.floor(ratio * options.idealNavMarginTop);
						
						thumbWidth = Math.floor(ratio * options.idealThumbWidth);
						thumbHeight = Math.floor(ratio * options.idealThumbHeight);
						
						galleryHeight = Math.floor(ratio * options.idealGalHeight);
						
						jitems.css({
							marginRight: thumpMargin
						}).find('img').css({
							width: thumbWidth,
							height: thumbHeight
						});
						
						jwrapper.css({'marginLeft' : 0});
												
						jcontainer.css('height', galleryHeight + 10);
						jnav.css('top', thumbHeight + navMarginTop);
						
						if(nitems * (thumbWidth + 4 + thumpMargin) - thumpMargin < wndWidth){
							disableNav = true;
							jnext.css('opacity', options.opacityDisable)[0]._zDisabled = 1;
							jprev.css('opacity', options.opacityDisable)[0]._zDisabled = 1;
						}else{
							disableNav = false;
							jnext.css('opacity', '')[0]._zDisabled = 0;
							jprev.css('opacity', '')[0]._zDisabled = 0;
						}
						
					}).triggerHandler('resize.zvidgal');
				}
			}
		});
	};
	
	$.fn.initChangeTab = function(options){
		var defaults = {
			headSel: '.lstCatetories li',
			contSel: '.jtabContent'
		};
		
		options = $.extend(defaults, options);
			
		return this.each(function(){
			var jcontainer = $(this),
				jheads = jcontainer.find(options.headSel),
				jconts = jcontainer.find(options.contSel);
			
			if(jheads.length > 0 && jheads.length == jconts.length){
				
				jheads.each(function(idx){
					$(this).unbind('click.ztab').bind('click.ztab', function(){
						if($(this).hasClass('active')){
							return false;
						}
						
						jconts.stop(true).removeClass('active').fadeTo(500, 0, function(){
							$(this).css('display', '').addClass('hidden');
						});
						
						jconts.eq(idx).removeClass('hidden').stop().fadeTo(500, 1, function(){
							$(this).css('filter', '');
						});
						
						$(window).triggerHandler(idx > 0 ? 'resize.zimggal' : 'resize.zvidgal');
						$(window).triggerHandler('resize.zvtext');
						
						jheads.removeClass('active');
						$(this).addClass('active');
						
						if(idx > 0){
							var jmedia = $('#media');
							if(jmedia.length && jmedia[0]._onExit){
								jmedia[0]._onExit();
							}
						}
						
						if($.browser.msie){
							document.body.focus();
						}
						
						return false;
					});
				});
			}
		});
	};
	
	$.fn.hoverMoveContent = function(options){
		var defaults = {
		};
		
		options = $.extend(defaults, options);
			
		return this.each(function(){
			var jmove = $(this),
				jlimit = $(this).closest('section') || $(document.body);
				
			jlimit.unbind('mousemove.zcntmove').bind('mousemove.zcntmove', function(e){
				
				var limitHeight = jlimit.height(),
					padding =  Math.round(limitHeight * 0.10),
					moveHeight = Math.round(jmove.height() + padding * 2),
					top = (limitHeight - moveHeight) / 2;
					
				if(moveHeight > limitHeight){
					top += (limitHeight / 2 - e.pageY) / limitHeight * (moveHeight - limitHeight) + padding;
					jmove.css('top', top);
				}
			});
		});
	};
	
})(jQuery);

//==============================================================================================//
//									Bootstrap													//
//==============================================================================================//
function errorHandler(){
	return true;
};

window.onerror = errorHandler;

//==============================================================================================//
jQuery(window).load(function(){
	
	setTimeout(function(){
		$('#menu').slideMenu().initNavigator();
	}, 200);
	
	$('.nextSlideBtn, .prevSlideBtn, #media .lstNav li a').hoverSupport();
	
	$('#collection').fullscreenSlide({
		instanceId: 'collection',
		autoplay: 0,
		random: 0,
		slideInterval: 4000,
		transitionDuration:	1000,
		pauseOnHover: 0,
		keyboardNav: 1,
		performance: 2,
		
		minWidth: 10,
		minHeight: 10,
		verticalCenter: 1,
		horizontalCenter: 1,
		fitPortrait: 1,
		fitLandscape: 0,
		
		navigation: 1,
		slideCounter: 1,
		slides: [
			{image : 'images/collection/visu_bshirt_01.jpg'},
			{image : 'images/collection/visu_bshirt_02.jpg'},
			{image : 'images/collection/visu_bshirt_03.jpg'},
			{image : 'images/collection/visu_bshirt_04.jpg'},
			{image : 'images/collection/visu_bshirt_05.jpg'},
			{image : 'images/collection/visu_bshirt_06.jpg'},
			{image : 'images/collection/visu_bshirt_07.jpg'},
			{image : 'images/collection/visu_bshirt_08.jpg'},
			{image : 'images/collection/visu_bshirt_09.jpg'},
			{image : 'images/collection/visu_bshirt_10.jpg'},
			{image : 'images/collection/visu_bshirt_11.jpg'},
			{image : 'images/collection/visu_bshirt_12.jpg'},
			{image : 'images/collection/visu_bshirt_13.jpg'},
			{image : 'images/collection/visu_bshirt_14.jpg'},
			{image : 'images/collection/visu_bshirt_15.jpg'},
			{image : 'images/collection/visu_bshirt_16.jpg'},
			{image : 'images/collection/visu_bshirt_17.jpg'},
			{image : 'images/collection/visu_bshirt_18.jpg'},
			{image : 'images/collection/visu_bshirt_19.jpg'},
			{image : 'images/collection/visu_bshirt_20.jpg'},
			{image : 'images/collection/visu_bshirt_21.jpg'},
			{image : 'images/collection/visu_bshirt_22.jpg'},
			{image : 'images/collection/visu_bshirt_23.jpg'},
			{image : 'images/collection/visu_bshirt_24.jpg'},
			{image : 'images/collection/visu_bshirt_25.jpg'},
			{image : 'images/collection/visu_bshirt_26.jpg'},
			{image : 'images/collection/visu_bshirt_27.jpg'},
			{image : 'images/collection/visu_bshirt_28.jpg'},
			{image : 'images/collection/visu_bshirt_29.jpg'},
			{image : 'images/collection/visu_bshirt_30.jpg'},
			{image : 'images/collection/visu_bshirt_31.jpg'},
			{image : 'images/collection/visu_bshirt_32.jpg'},
			{image : 'images/collection/visu_bshirt_33.jpg'},
			{image : 'images/collection/visu_bshirt_34.jpg'},
			{image : 'images/collection/visu_bshirt_35.jpg'},
			{image : 'images/collection/visu_bshirt_36.jpg'},
			{image : 'images/collection/visu_bshirt_37.jpg'},
			{image : 'images/collection/visu_bshirt_38.jpg'},
			{image : 'images/collection/visu_bshirt_39.jpg'},
			{image : 'images/collection/visu_bshirt_40.jpg'},
			{image : 'images/collection/visu_bshirt_41.jpg'},
			{image : 'images/collection/visu_bshirt_42.jpg'},
			{image : 'images/collection/visu_bshirt_43.jpg'},
			{image : 'images/collection/visu_bshirt_44.jpg'},		
			{image : 'images/collection/visu_bshirt_45.jpg'}				
		]
	}); 
	
	$('#kids').fullscreenSlide({
		instanceId: 'kids',
		autoplay: 0,
		random: 0,
		slideInterval: 4000,
		transitionDuration:	1000,
		pauseOnHover: 0,
		keyboardNav: 1,
		performance: 2,
		
		minWidth: 10,
		minHeight: 10,
		verticalCenter: 1,
		horizontalCenter: 1,
		fitPortrait: 1,
		fitLandscape: 0,
		
		navigation: 1,
		slideCounter: 1,
		slides: [
			{image : 'images/kids/visu_bshirt_kit_effected_01.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_02.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_03.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_04.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_05.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_06.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_07.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_08.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_09.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_10.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_11.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_12.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_13.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_14.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_15.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_16.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_17.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_18.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_19.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_20.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_21.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_22.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_23.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_24.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_25.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_26.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_27.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_28.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_29.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_30.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_31.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_32.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_33.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_34.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_35.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_36.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_37.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_38.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_39.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_40.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_41.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_42.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_43.jpg'},
			{image : 'images/kids/visu_bshirt_kit_effected_44.jpg'}
		]
	}); 
	
	$('#about, #stores, #media, #contact').mouseMoveBg();
	
	$('#header a').navitoHomepage();
	
	$('#header a img, #home .lnkFacebook img, .paging, .nextSlideBtn img, .prevSlideBtn img, #media .lstNav li img, #lbPrevLink img, #lbNextLink img').resizeBySize();

	$('#home .lnkFacebook img').removeClass('hidden');
	
	$('#about p, #about .wrapMask h3, #collection .slideCounter, #kids .slideCounter, #stores .lstRegion, #stores .cntStore, #media .lstCatetories, #contact .contactInfo').resizeByFontSize();
	
	$('#about p, #stores .cntStore, #media .galleryVideo, #media .galleryImg').centerText();
	
	$('#stores').storeXmlRender();
	
	$('#stores .cntStore').hoverMoveContent();
	
	$('#media').initChangeTab();
	
	$('#media .galleryVideo').initSlideVideoGallery();
	
	$('#media .galleryImg').initSlideImageGallery();
	
	$('#lbPrevLink, #lbNextLink').hoverSupportLb();
});

jQuery(document).ready(function(){
	BShirt.initialize();
	
	$('#home, #about, #stores, #media, #contact, #shoppingOnline').resizeBg();
});
