/**
 main js file of hugoboss.com
 @projectDescription HugoBoss javascript library
 @author Werbewelt (biki)
 @version 1.0
 @namespace HugoBoss
 */
/**
 * @classDescription HugoBoss javascript base
 */
var HugoBoss = {
	/**
	 * initialize HugoBoss,
	 * add CSS class for special CSS cases when javascript is activated,
	 * initialize utils,
	 * check for browser version/check for flash player and version,
	 * initialize page,
	 * @alias HugoBoss.init()
	 */
	init : function() {
		$('body').addClass('js');
		HugoBoss.utils.init();

		if(HugoBoss.utils.browserAndVersion() === 'ie6') {
			HugoBoss.utils.showErrorSceen('browser');
		} else if(!swfobject.hasFlashPlayerVersion(HugoBoss.flash.version)) {
			HugoBoss.utils.showErrorSceen('flash');
		} else {
			HugoBoss.flash.init();
			HugoBoss.events.init();
		}
	},
	/**
	 * Helper
	 */
	utils : {
		/**
		 * initialize helper
		 */
		init : function() {
			HugoBoss.utils.setInputField('search');
			HugoBoss.utils.setInputField('newsletter');
			HugoBoss.utils.setBrowserSpecs();
			HugoBoss.utils.clearNoScript();
			HugoBoss.utils.initSoundButton();
			HugoBoss.utils.initShoppingCart();
			HugoBoss.utils.special.tinker.init();
			HugoBoss.utils.glossar.init();

		},
		/**
		 * returns a timestamp the of client system. only used as an unique number
		 * @return {number} timestamp.getTime()
		 */
		getTimestamp : function() {

			var timestamp = new Date();
			return timestamp.getTime();

		},
		/**
		 * returns location hash cutting of the '#'
		 * @return {string} hash
		 * @deprecated
		 */
		getHash : function() {

			var tempHash = window.location.hash;
			var hash = tempHash.substring(1);

			return hash;
		},
		/**
		 * returns the name of the php file without folders
		 * @return {string} fileName
		 */
		getFileName : function() {

			var tempHref = window.location.href;
			var lastSlash = tempHref.lastIndexOf('/');
			var fileName = tempHref.substring(lastSlash + 1);

			return fileName;
		},
		/**
		 * specials
		 */
		special : {
			/**
			 * tinker box special for fashion show 2010
			 */
			tinker : {
				/**
				 * initialize tinker
				 */
				init : function() {

					if($('#socialLayer').lenght !== 0) {

						setTimeout(function() {

							$('#socialLayer').css({
								opacity : 0,
								visibility : 'visible'
							}).animate({
								opacity : 0.99
							}, {
								duration : 300
							});

						}, 3000);
					}

				},
				/**
				 * fade in call
				 */
				fadeIn : function() {

					$('#socialLayer').children().animate({
						opacity : 0.99
					}, {
						duration : 80
					});

				},
				/**
				 * fade out call
				 */
				fadeOut : function() {

					$('#socialLayer').children().animate({
						opacity : 0.45
					}, {
						duration : 180
					});

				}
			},
			/**
			 * fashion show special code
			 */
			fashionShow : {
				/**
				 * backdoor to reload fashionshow via flash/xml if something goes wrong
				 */
				reloadStream : function() {

					var swfObjectData = {
						source : '/assets/mainLoader.swf?' + HugoBoss.utils.getTimestamp(),
						id : 'moduleFlashSwf',
						width : '100%',
						height : '100%',
						center : false,
						flashvars : {
							stageWidth : $('#content').width(),
							stageHeight : $(window).height(),
							moduleCSS : '/css/style_hugo.css',
							moduleXML : path + 'data/hugo_fashionShow2011.xml',
							layoutXML : ''
						},
						params : {
							wmode : 'transparent',
							allowFullscreen : true
						},
						attributes : {
							id : 'moduleFlashSwf'
						}
					};

					HugoBoss.flash.initSwfObject(swfObjectData);

				}
			},
			/**
			 * mc laren f1 special 2010/11
			 */
			mcLaren : {
				/**
				 * tracking via flash
				 * @param {Object} country
				 */
				tracking : function(country) {

					var axel = Math.random() + "";
					var a = axel * 10000000000000;

					var trackingPixel;

					switch (country) {
						case 'FR':
						case 'fr':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=2278297;type=thank179;cat=mclar297;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'DE':
						case 'de':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=2278274;type=thank552;cat=mclar364;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'IT':
						case 'it':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=2923167;type=thank809;cat=mclar381;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'JP':
						case 'jp':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=3067749;type=thank574;cat=mclar582;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'NL':
						case 'nl':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=2278283;type=thank750;cat=mclar391;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'ES':
						case 'es':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=2923265;type=thank737;cat=mclar650;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'GB':
						case 'gb':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=2278280;type=thank939;cat=mclar948;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'CA':
						case 'ca':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=3067754;type=thank683;cat=mclar472;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						case 'US':
						case 'us':
							trackingPixel = '<iframe src="http://fls.doubleclick.net/activityi;src=2228464;type=thank114;cat=mclar157;ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>'
							break;
						default:
							trackingPixel = '';
							break;
					}

					$('#moduleFlashSwf').append(trackingPixel);

				}
			}

		},
		/**
		 * return browser and version
		 * @return {string}
		 */
		browserAndVersion : function() {
			if($.browser.msie && $.browser.version <= 6) {
				return 'ie6';
			} else if($.browser.msie && $.browser.version > 6 && $.browser.version < 8) {
				return 'ie7';
			} else if($.browser.msie && $.browser.version > 7 && $.browser.version < 9) {
				return 'ie8';
			} else if($.browser.opera) {
				return 'opX';
			} else {
				return 'zz';
			}

		},
		/**
		 * info text in searchfield is set/unset via title-tag and highlighted
		 * @param {Object} input
		 */
		setInputField : function(input) {
			/**
			 * @type {Object} info fields to toggle
			 */
			var $infoTextTemp = $('#searchInput').add('#newsletterInput');

			$infoTextTemp.unbind('focus', 'blur').bind('focus', function() {
				//on focus remove info text
				if($(this)[0].title) {
					if($(this).val() === $(this)[0].title) {
						$(this).val('');
					}
				}

				$(this).addClass('active');
				$(this).parent('div').addClass('active');

			}).bind('blur', function() {
				//in blur show info text if input field is empty
				if($(this)[0].title) {
					if($(this).val() === '') {
						$(this).val($(this)[0].title);
					}
				}

				$(this).removeClass('active');
				$(this).parent('div').removeClass('active');

			}).blur();

			if($('#blognewsletterInput').length > 0) {
				var $infoTextTemp = $('#searchInput').add('#blognewsletterInput');

				$infoTextTemp.unbind('focus', 'blur').bind('focus', function() {
					//on focus remove info text
					if($(this)[0].title) {
						if($(this).val() === $(this)[0].title) {
							$(this).val('');
						}
					}

					$(this).addClass('active');
					$(this).parent('div').addClass('active');

				}).bind('blur', function() {
					//in blur show info text if input field is empty
					if($(this)[0].title) {
						if($(this).val() === '') {
							$(this).val($(this)[0].title);
						}
					}

					$(this).removeClass('active');
					$(this).parent('div').removeClass('active');

				}).blur();
			}
		},
		/**
		 * browser specific settings
		 */
		setBrowserSpecs : function() {

			if($.browser.msie && $('#outerWrapper').length !== 0) {

				/*
				 if ($('#outerWrapper').width() < 1004) {
				 $('#outerWrapper').css({
				 overflowX: 'auto'
				 });
				 }
				 else {
				 $('#outerWrapper').css({
				 overflowX: 'hidden'
				 });
				 }
				 */
				if($('#header').length !== 0) {
					$('#header').css({
						width : '100%'
					});
				}

			}

			if($.browser.opera) {

				$('#header').css({
					left : '-8px'
				});

				$('#outerWrapper').css({
					/*position: 'fixed',*/
					width : '100%',
					top : '0px',
					left : '0px'
				});

			}

		},
		/**
		 * cookie handling setter
		 * @param {Object} name
		 * @param {Object} value
		 */
		setCookie : function(name, value) {

			var arguments = HugoBoss.utils.setCookie.arguments;
			var aLenght = 0;

			if(arguments) {
				aLenght = arguments.length;
			}

			var cookie = name + '=' + escape(value);

			if(aLenght > 2) {
				var expireDate = HugoBoss.utils.setExpireDate(arguments[2]);
				cookie += '; expires=' + expireDate.toGMTString();
			}
			if(aLenght > 3) {
				cookie += '; path=' + arguments[3];
			}
			if(aLenght > 4) {
				cookie += '; domain=' + arguments[4];
			}
			if(aLenght > 5) {
				cookie += '; secure=' + arguments[5];
			}

			document.cookie = cookie;

		},
		/**
		 * cookie handling getter
		 * @param {Object} name
		 * @ return {String}
		 */
		getCookie : function(name) {

			var arguments = name + '=';
			var aLength = arguments.length;
			var cLength = document.cookie.length;

			var i = 0;

			while(i < cLength) {

				var j = i + aLength;

				if(document.cookie.substring(i, j) === arguments) {

					var endstr = document.cookie.indexOf(";", j);

					if(endstr == -1) {
						endstr = document.cookie.length;
					}

					return unescape(document.cookie.substring(j, endstr));

				}
				i = document.cookie.indexOf("", i) + 1;

				if(i == 0) {

					break;

				}

			}

			return null;

		},
		/**
		 * return cookie expiration date in correct format
		 * @param {Object} days
		 * @return {Object} expireDate
		 */
		setExpireDate : function(days) {

			var expireDate = new Date();
			var livetime = expireDate.getTime() + (days * 24 * 60 * 60 * 1000);

			expireDate.setTime(livetime);

			return expireDate;

		},
		/**
		 * check sound cookie value and load according sound button
		 */
		initSoundButton : function() {

			if(!HugoBoss.utils.getCookie('sound')) {

				HugoBoss.utils.setCookie('sound', 'true', 2, '/');
				HugoBoss.utils.setSoundButton('on');

			} else if(HugoBoss.utils.getCookie('sound') === 'true') {

				HugoBoss.utils.setSoundButton('on');

			} else {

				HugoBoss.utils.setSoundButton('off');

			}

			$('#soundOff').add('#soundOn').css({
				visibility : 'visible'
			});

		},
		/**
		 * sound button click event
		 */
		soundButtonClick : function() {

			if(HugoBoss.utils.getCookie('sound') === 'true') {

				HugoBoss.utils.setCookie('sound', 'false', 2, '/');
				HugoBoss.utils.setSoundButton('off');

			} else {

				HugoBoss.utils.setCookie('sound', 'true', 2, '/');
				HugoBoss.utils.setSoundButton('on');

			}

		},
		/**
		 * change talk video
		 * @param {String} headline
		 * @param {String} path
		 */
		changeVideo : function(headline, path) {

			$('div.flash').children('object').each(function() {

				/**
				 * call inside flash
				 */
				try {
					this.change(headline, path);
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {

				}

			});
		},
		/**
		 * pause talk video
		 */
		pauseVideo : function() {

			$('div.flash').children('object').each(function() {

				/**
				 * call inside flash
				 */
				try {
					this.deactivate();
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {

				}

			});
		},
		/**
		 * play talk video
		 */
		playVideo : function() {

			$('div.flash').children('object').each(function() {

				/**
				 * call inside flash
				 */
				try {
					this.activate();
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {

				}

			});
		},
		/**
		 * show sound button state
		 * @param {Object} state
		 */
		setSoundButton : function(state) {

			switch (state) {
				case 'on':

					$('#soundOff').css({
						display : 'none'
					});
					$('#soundOn').css({
						display : 'block'
					});

					break;
				case 'off':

					$('#soundOff').css({
						display : 'block'
					});
					$('#soundOn').css({
						display : 'none'
					});

					break;
			}

			$('div.flash').children('object').each(function() {

				/**
				 * call inside flash
				 */
				try {
					this.soundClickEvent(state);
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {

				}

			});
		},
		/**
		 * set shopping cart content according to cookie information for store
		 */
		initShoppingCart : function() {

			if(!HugoBoss.utils.getCookie('basketinfo')) {

				$('#headerNavCart').remove();

			} else {

				var cartString = unescape(HugoBoss.utils.getCookie('basketinfo'));
				var cartObject = eval('(' + cartString + ')');

				if(cartObject.items === 0) {

					$('#headerNavCart').remove();

				} else {

					if( typeof (shopCart) == 'undefined') {

						var articleNaming = 'Articles'
						if(cartObject.items === 1) {
							articleNaming = 'Article'
						}

						var content = '<div id="headerNavCart">';
						content += '<a href="' + cartObject.url + '" target="_self">';
						content += '<span>Shopping bag</span>';
						content += '<br/>';
						content += cartObject.items + ' ' + articleNaming + ', ' + cartObject.subtotal;
						content += '</a>';
						content += '</div>';

						$(content).insertAfter('#headerNavLogo');

					} else {

						var articleNaming = shopCart.articlenames
						if(cartObject.items === 1) {
							articleNaming = shopCart.articlename
						}

						var content = '<div id="headerNavCart">';
						content += '<a href="' + cartObject.url + '" target="_self">';
						content += '<span>' + shopCart.bag + '</span>';
						content += '<br/>';
						content += cartObject.items + ' ' + articleNaming + ', ' + cartObject.subtotal;
						content += '</a>';
						content += '</div>';

						$(content).insertAfter('#headerNavLogo');

					}
				}
			}

		},
		/**
		 * debug helper for console calls or alerts if console not available
		 */
		debug : function() {

			var location = window.location + '';

			if(location.indexOf('preview') !== -1) {

				var debugMode = true;
				var debugModeAlert = false;

				if(debugMode) {

					var debugString = '';
					var i = HugoBoss.utils.debug.arguments.length;

					do {
						i--;
						debugString += i + 1 + '. ' + HugoBoss.utils.debug.arguments[i] + '\n';
					} while (i > 0);

					if($.browser.mozilla) {

						try {
							console.log(debugString);
						} catch (e) {

						}
					} else if(debugModeAlert) {
						window.alert(debugString);
					}
				}

			}

		},
		/**
		 * change location
		 */
		changeLocation : function() {

			window.location = HugoBoss.utils.newLocation;

		},
		/**
		 * removes noscript areas
		 */
		clearNoScript : function() {

			$('div.noscript').remove();
			$('noscript').remove();

		},
		/**
		 * show error screens for browser or flash version
		 * @param {Object} reason
		 */
		showErrorSceen : function(reason) {

			$('#headerNavSub').find('span.preview').add('#leftNav').add('#leftNavHeader').add('#rightContent').add('#onlineStoreTeaser').add('#lifestyleTeaser').add('#socialLinks').add('abdeckerFooter').remove();

			if($('#changeCountry').length !== 0) {

				var content = '<div id="headerNav">';
				content += '<div id="headerNavLogo">';
				content += '<a href="/">';
				content += '<img src="/style/img/_shared.headerNav.logo.gif" alt="HUGO BOSS" title="HUGO BOSS" />';
				content += '</a>';
				content += '</div>';
				content += '</div>';

				$('#content').html(content);

			}

			$('body').css({
				background : '#ffffff'
			}).removeClass('js');

			$('#content').css({
				minHeight : '545px',
				height : '545px',
				background : '#ffffff'
			});

			$('#backgroundImg').add('#innerContent').remove();

			$('#headerNav').css({
				background : 'url(/style/img/error.headerNav.bg.gif)'
			});

			var errorHTML = '<div id="warning">';

			switch (reason) {
				case 'flash':
					errorHTML += errorContent.flash.message + '<br />';
					errorHTML += '<a href="' + errorContent.flash.url + '">' + errorContent.flash.link + '</a>';
					break;
				case 'browser':
					errorHTML += errorContent.browser.message + '<br />';
					errorHTML += '<a href="' + errorContent.browser.url1 + '">' + errorContent.browser.link1 + '</a>';
					errorHTML += '<a href="' + errorContent.browser.url2 + '">' + errorContent.browser.link2 + '</a>';
					break;
			}
			errorHTML += '</div>';
			errorHTML += '<div id="errorImage"></div>';

			$('#headerNav').append(errorHTML);

		},
		/**
		 * sets html layer, which is already in the dom to display block. target must be id of the layer.
		 * @param {Object} target
		 */
		showLayer : function(target) {

			$('#' + target).css({
				display : 'block'
			});

			if($('#' + target).find('div.layerBg').length !== 0) {

				$('#' + target).find('div.layerBg').css({
					opacity : 0.4
				});

			}

			setTimeout(function() {

				$('body').bind('click', function() {

					$('#' + target).css({
						display : 'none'
					});

					$('a.close').unbind('click');
					$('body').unbind('click');

				});

				$('a.close').bind('click', function() {

					$('#' + target).css({
						display : 'none'
					});

					$('body').unbind('click');
					$('a.close').unbind('click');

					return false;

				});

				$('div.layer').bind('click', function() {

					return false;

				});
			}, 100);
		},
		hugoNavigation : function(param) {
			if(param && param != "") {
				//alert(param);
				document.location.href = param;
			}

		},
		/**
		 * scrolling of the glossary
		 */
		glossar : {

			init : function() {
				$('#glossar_up').css('display', 'block');
				$('#glossar_down').css('display', 'block');
				$('ul.glossarySub').css('height', '100%');

			},
			/**
			 * direction: scroll down
			 */
			down : function() {

				var effectLength = 7000;

				var divHeight = $('#glossary_content').height();
				var scrollHeight = divHeight - 254;

				var alt_posY = $('#glossary_content').css('top');

				var posY = alt_posY.indexOf("p");

				var start = posY + 1;

				var end = start + 1;

				var now_posY = alt_posY.substring(0, posY);

				var negativHeight = scrollHeight - (scrollHeight * 2);

				//alert('negativ: ' + negativHeight);

				if(now_posY > negativHeight) {

					var nextPos = negativHeight;

					var px_toGo = Math.abs(now_posY);
					px_toGo = scrollHeight - px_toGo;
					effectLength = (8000 / scrollHeight) * px_toGo;

					$('#glossary_content').animate({
						top : nextPos + 'px'
					}, effectLength);

				}
			},
			/**
			 * direction: scroll up
			 */
			up : function() {

				var effectLength = 7000;

				var divHeight = $('#glossary_content').height();
				var scrollHeight = divHeight - 254;

				var alt_posY = $('#glossary_content').css('top');

				var posY = alt_posY.indexOf("p");

				var start = posY + 1;

				var end = start + 1;

				var now_posY = alt_posY.substring(0, posY);

				//alert('now: ' + now_posY);

				if(now_posY < 0) {

					var px_toGo = Math.abs(now_posY);
					effectLength = (8000 / scrollHeight) * px_toGo;

					$('#glossary_content').animate({
						top : '0px'
					}, effectLength);

				}
			}
		}

	},

	/**
	 * event handlers
	 */
	events : {

		/**
		 * initialize
		 */
		init : function() {

			/**
			 * resize event
			 */
			$(window).resize(function() {

				HugoBoss.utils.setBrowserSpecs();
				HugoBoss.flash.getOffsetX();
				HugoBoss.events.getMousePosition();
				HugoBoss.flash.updateSize();

			});
			/**
			 * general click event
			 */
			$('a').live('click', function() {

				HugoBoss.utils.newLocation = $(this).attr('href');

			});
			/**
			 * video links click events
			 */
			$('a.videoLink').live('click', function() {

				var videoAliasTemp = $(this).attr('hash');
				var videoAlias = videoAliasTemp.substring(1);

				HugoBoss.flash.showVideoLayer(videoAlias);

				return false;

			});
			/**
			 * newsletter submit in footer
			 */
			$('#newsletterSubmit').live('click', function() {

				if($('#newsletterInput').attr('title') === $('#newsletterInput').attr('value')) {

					$('#newsletterInput').attr('value', '');

				}

				$('#newsletterForm').submit();

			});
			/**
			 * newsletter submit in blog
			 */
			if($('#blogNewsletter').length > 0) {
				$('#blognewsletterSubmit').live('click', function() {

					if($('#blognewsletterInput').attr('title') === $('#blognewsletterInput').attr('value')) {

						$('#blognewsletterInput').attr('value', '');

					}

					$('#blognewsletterForm').submit();

				});
			}
			/**
			 * search submit in header
			 */
			$('#searchSubmit').live('click', function() {

				if($('#searchInput').attr('title') === $('#searchInput').attr('value')) {

					$('#searchInput').attr('value', '');

				}

				$('#searchForm').submit();

			});
			/**
			 * search submit in blog
			 */
			$('#searchsubmit').live('click', function() {

				var searchphrase = $('#s').attr('value');

				if($('#s').attr('title') === $('#s').attr('value')) {

					$('#s').attr('value', '');

				}

				HugoBoss.flash.analytics('blogSearch', 'link');

				$('#searchForm').submit();

			});
			/**
			 * sound control
			 */
			$('#footerSound').children('a').bind('click', function() {

				HugoBoss.utils.soundButtonClick();
				return false;

			});
			/**
			 * webtrack events online store teaser on collection.php
			 */
			$('#onlineStoreTeaser').find('a').bind('click', function() {

				var imagePath = $(this).css('backgroundImage');
				var image = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('.'));

				HugoBoss.flash.analytics('extLink.' + image, 'link');

			});
			/**
			 * webtrack events lifestyle teaser on collection.php
			 */
			$('#lifestyleTeaser').find('a').bind('click', function() {

				var imagePath = $(this).css('backgroundImage');
				var image = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('.'));

				HugoBoss.flash.analytics('tc.' + image, 'link');

			});
			/**
			 * webtrack events store on root/index.php
			 */
			$('#chooseStore').bind('click', function() {

				HugoBoss.flash.analytics('extLink.flippageStore', 'link');

			});
			/**
			 * webtrack events footer country
			 */
			$('#country_box').bind('click', function() {

				HugoBoss.flash.analytics('footerCountry', 'link');

			});
			/**
			 * webtrack events footer links
			 */
			$('#links_box').find('a').bind('click', function() {

				var linktarget = $(this).attr('href');

				var footersuche = linktarget.indexOf("store");
				if(footersuche == -1) {
					HugoBoss.flash.analytics('extLink.footerGroup', 'link');
				} else {
					HugoBoss.flash.analytics('extLink.footerStore', 'link');
				}
			});
			/**
			 * webtrack events social bookmarks on hugoBLog
			 */
			$('#followhugo').find('a').bind('click', function() {

				var socialId = $(this).attr(id);

				switch (socialId) {
					case 'social_twitter':
						socialId = 'TWITTER';
						break;
					case 'social_facebook':
						socialId = 'FACEBOOK';
						break;
					case 'social_youtube':
						socialId = 'YOUTUBE';
						break;
					case 'social_rss':
						socialId = 'RSS_FEED';
						break;
				}

				HugoBoss.flash.analytics('extLink.blogSocial_' + socialId, 'link');

			});
			/**
			 * webtrack events brand on root/index.php
			 */
			$('#chooseBrand').bind('click', function() {

				HugoBoss.flash.analytics('tc.flippageBrand', 'link');

			});
			/**
			 * webtrack events brand on root/index.php
			 */
			$('#footer_mv_categories').find('a').bind('click', function() {
				var inhalt = $(this).text();
				HugoBoss.flash.analytics('tc.hugoblog.MVarticleTeaser', 'link');

			});
			/**
			 * webtrack events link on hugotracks.php
			 */
			$('#tracksContent').find('a').bind('click', function() {

				var imagePath = $(this).css('backgroundImage');
				var image = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('.'));

				HugoBoss.flash.analytics('tc.' + image, 'link');
				/*console.log('image: ' + image);
				 return false;*/
			});
			/**
			 * webtrack events product teaser on blog sidebar
			 */
			$('.teaser_box').find('a').bind('click', function() {

				var imagePath = $(this).children('div').children('img:last').attr('src');
				var image = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('.'));

				HugoBoss.flash.analytics('extLink.' + image, 'link');

			});
			/**
			 * webtrack events social media links on collection.php and in the lifestyle section
			 */
			$('#socialLinks').add('div.leftNavIcons').add('#socialLayer').find('a').bind('click', function() {

				var className = $(this).attr('class');
				var id;
				switch (className) {
					case 'iPhoneApp':
						id = 'IPHONE_APP';
						break;
					case 'youTube':
						id = 'YOUTUBE';
						break;
					case 'facebook':
						id = 'FB_FANPAGE';
						break;
					case 'twitter':
						id = 'TWITTER';
						break;
				}

				if($(this).parent().attr('id') === 'socialLayer') {

					var linkTarget = $(this).attr('href');
					if(linkTarget.indexOf('facebook') !== -1) {
						id = 'hugo_fashionShow2011_facebook';
					} else if(linkTarget.indexOf('twitter') !== -1) {
						id = 'hugo_fashionShow2011_twitter ';
					}

				}

				HugoBoss.flash.analytics('extLink.' + id, 'link');

			});
			/**
			 * webtrack events outgoing links in header and footer navigation
			 */
			$('#headerNavMain').add('#footer_space2').find('a').bind('click', function() {

				var className = $(this).attr('class');
				var id;

				if(className == 'footerLink career') {
					className = 'career'
				}

				if(className == "company" || className == "online_store" || className == "career") {
					switch (className) {
						case 'company':
							id = 'company';
							break;
						case 'online_store':
							id = 'online_store';
							break;
						case 'career':
							id = 'career';
							break;
					}

					HugoBoss.flash.analyticsCG('extLink.' + id, 'link');
				}
			});
			/**
			 * footer nav glossary control
			 */
			$('#glossar_down').mouseover(function() {

				HugoBoss.utils.glossar.down();

				$('#glossar_down').css('background-image', 'url("/css/images/glossar_down_off.jpg")');

			});
			/**
			 * footer nav glossary control
			 */
			$('#glossar_down').mouseout(function() {

				$('#glossary_content').stop();

				$('#glossar_down').css('background-image', 'url("/css/images/glossar_down_on.jpg")');

			});
			/**
			 * footer nav glossary control
			 */
			$('#glossar_up').mouseover(function() {

				HugoBoss.utils.glossar.up();

				$('#glossar_up').css('background-image', 'url("/css/images/glossar_up_off.jpg")');

			});
			/**
			 * footer nav glossary control
			 */
			$('#glossar_up').mouseout(function() {

				$('#glossary_content').stop();

				$('#glossar_up').css('background-image', 'url("/css/images/glossar_up_on.jpg")');

			});
			/**
			 * @type {Boolean} mouse is over the preview layer
			 */
			HugoBoss.events.mouseOverPreview = false;

			/**
			 * @type {Boolean} mouse is over the link in the header navigation
			 */
			HugoBoss.events.mouseOverLink = false;

			/**
			 * header navigation hover preview layer event. keeps layer visible and handles mouseout events
			 */
			$('#headerNavSub span.preview').hover(function() {

				var target = $(this);

				HugoBoss.events.mouseOverPreview = true;
				if(HugoBoss.events.timeout) {
					window.clearTimeout(HugoBoss.events.timeout);
				}
				HugoBoss.events.fadeOutHeaderNav(target);

			}, function() {

				var target = $(this);
				var parent = $(this).parent().children('a');

				parent.hover(function() {

					var target = $(this);

					parent.unbind('mouseenter');

					HugoBoss.events.mouseOverLink = true;
					if(HugoBoss.events.timeout) {
						window.clearTimeout(HugoBoss.events.timeout);
					}
					HugoBoss.events.fadeOutHeaderNav(target);

				}, function() {

					parent.unbind('mouseleave');

					HugoBoss.events.mouseOverLink = false;
					if(HugoBoss.events.timeout) {
						window.clearTimeout(HugoBoss.events.timeout);
					}
					HugoBoss.events.fadeOutHeaderNav(target);

				});
				if(!HugoBoss.events.timeout) {
					HugoBoss.events.timeout = null;
				}

				if(HugoBoss.events.timeout) {
					window.clearTimeout(HugoBoss.events.timeout);
				}
				HugoBoss.events.timeout2 = window.setTimeout(function() {

					HugoBoss.events.mouseOverPreview = false;
					if(HugoBoss.events.timeout) {
						window.clearTimeout(HugoBoss.events.timeout);
					}
					HugoBoss.events.fadeOutHeaderNav(target);
				}, 40);
			});
			/**
			 * header navigation link hover event. shows preview layer
			 */
			$('#headerNavSub a').not('.active').not('.previewLink').hoverIntent(function() {

				var parent = $(this);
				var target = $(this).parent().children('span.preview');

				HugoBoss.events.mouseOverLink = true;
				if(HugoBoss.events.timeout) {
					window.clearTimeout(HugoBoss.events.timeout);
				}
				HugoBoss.events.fadeOutHeaderNav(target);

				$('span.preview').css({
					display : 'none'
				});

				target.css({
					display : 'block'
				});

				target.stop().animate({
					opacity : 1
				}, {
					duration : 300,
					complete : function() {

						parent.addClass('mouseOver');

					}
				});

			}, function() {

				var target = $(this).parent().children('span.preview');

				HugoBoss.events.mouseOverLink = false;
				if(HugoBoss.events.timeout) {
					window.clearTimeout(HugoBoss.events.timeout);
				}
				HugoBoss.events.fadeOutHeaderNav(target);

			});

			HugoBoss.events.getMousePosition();

			/**
			 * footer nav change country control
			 */
			$('#changeCountries').onmouseover = function() {
				$('#arrow_country').style.right = "16px";
				$('#country_box_open').style.display = "block";
			}
			/**
			 * footer nav change country control
			 */
			$('#changeCountries').onmouseout = function() {
				$('#country_box_open').style.display = "none";
			}
			/**
			 * footer nav change country control
			 */
			$('#changeCountries').hoverIntent(function() {

				$('#arrow_country').css({
					right : '16px'
				});
				$('#country_box_open').css({
					display : 'block'
				});

			}, function() {

				$('#arrow_country').css({
					right : '0px'
				});
				$('#country_box_open').css({
					display : 'none'
				});

			});
			/**
			 * Change Hugo Html Navigation
			 */
			$('#naviwoman').change(function() {
				var str = $(this).val();
				HugoBoss.utils.hugoNavigation(str);
			});
			$('#navimen').change(function() {
				var str = $(this).val();
				HugoBoss.utils.hugoNavigation(str);
			});
		},
		/**
		 * header nav preview layer fade out
		 * @param {Object} ref
		 */
		fadeOutHeaderNav : function(ref) {

			if(!HugoBoss.events.timeout) {
				HugoBoss.events.timeout = null;
			}

			if(HugoBoss.events.timeout) {
				window.clearTimeout(HugoBoss.events.timeout);
			}

			if(!HugoBoss.events.mouseOverLink) {

				var timer = 0;

				if(!HugoBoss.events.mouseOverPreview) {
					timer = 0;
				} else {
					timer = 2000;
				}

				HugoBoss.events.timeout = window.setTimeout(function() {

					var parent = ref.parent().children('a');
					var target = ref;

					if(parent.hasClass('mouseOver')) {

						parent.removeClass('mouseOver');

						target.stop().animate({
							opacity : 0
						}, {
							duration : 150,
							complete : function() {

								target.css({
									display : 'none'
								});

							}
						});

					} else {

						target.stop().animate({
							opacity : 0
						}, {
							duration : 50,
							complete : function() {

								target.css({
									display : 'none'
								});

							}
						});

					}

				}, timer);
			}

		},
		/**
		 * calculates mouse position and hands it to flash
		 */
		getMousePosition : function() {
			
			//catch scroll event to enable highlighting in flash
			$(window).bind('scroll', function() {
				HugoBoss.events.calMousePosition();
			});
			
			//ie7 version here scrolls the outer wrapper
			$('#outerWrapper').bind('scroll', function() {
				HugoBoss.events.calMousePosition();
			});
			
			//catch mouse position to enable highlighting in flash (while/after scrolling)
			$('#outerWrapper').bind('mousemove', function(e) {
				HugoBoss.events.mouseX = e.pageX;
				HugoBoss.events.mouseY = e.pageY;
			});
		},
		calMousePosition : function(){
			
				if(HugoBoss.events.mouseX === undefined) {
					HugoBoss.events.mouseX = 0;
				}
				if(HugoBoss.events.mouseY === undefined) {
					HugoBoss.events.mouseY = 0;
				}

				var offsetModuleX = window.pageXOffset;
				//$('#moduleFlashSwf').offset().left;
				if(offsetModuleY === undefined) {
					offsetModuleY = $('html').offset().left;
				}
				var mouseX = HugoBoss.events.mouseX;
				var offsetModuleY = window.pageYOffset;
				//$('#moduleFlashSwf').offset().top * -1;
				if(offsetModuleY === undefined) {
					offsetModuleY = $('html').offset().top;
				}
				if(HugoBoss.utils.browserAndVersion() === 'ie7') {
					offsetModuleY = $('#content').offset().top * -1;
				}
				
				if(offsetModuleY < 0) {
					offsetModuleY = 0;
				}
				var mouseY = offsetModuleY + HugoBoss.events.mouseY;

				$('div.flash').find('object').each(function() {
					try {
						//function inside flash
						this.scrollOffset(offsetModuleY, offsetModuleX);
						this.scrollContent(mouseX, mouseY);
					} catch (e) {
						//could not connect to flash movie (maybe not loaded jet)
						//return false;
					}

				});
				if(HugoBoss.startpage) {

					var offsetContentY = $('#content').offset().top;
					HugoBoss.startpage.utils.fadeFooter(offsetContentY);

				}
				
		},
		getTwitterLinksTracking : function() {
			/**
			 * webtrack events twitter links on hugoblog
			 */
			$('div.tweet ul.tweet_list').find('a').bind('click', function() {
				alert('extLink');
				HugoBoss.flash.analytics('extLink.hugoBlog.twitterLink', 'link');

			});
		}
	},

	/**
	 * flash communitcation and control
	 */
	flash : {

		/**
		 * initialize
		 */
		init : function() {

			HugoBoss.flash.scrollToTop();
			HugoBoss.flash.prepareFlashContent();

		},
		/**
		 * @type {String} flash player version needed
		 */
		version : '10.0.0',

		/**
		 * prepare html and flash content
		 */
		prepareFlashContent : function() {

			/**
			 * background (scroll) module
			 */
			if(flashContent.background && $('div.backgroundScroll').length !== 0) {

				var id = 'backgroundScrollFlash';

				$('div.backgroundScroll').addClass('flash').append('<div id="' + id + '"></div>');

				var swfObjectData = {
					source : flashContent.background.source,
					id : id,
					width : '100%',
					height : '100%',
					center : true,
					flashvars : flashContent.background.flashvars,
					params : flashContent.background.params
				};

				HugoBoss.flash.initSwfObject(swfObjectData);
			}

			/**
			 * background (fixed) module
			 */
			if(flashContent.background && $('div.backgroundFixed').length !== 0) {

				var id = 'backgroundFixedFlash';

				$('div.backgroundFixed').addClass('flash').append('<div id="' + id + '"></div>');

				var swfObjectData = {
					source : flashContent.background.source,
					id : id,
					width : '100%',
					height : '100%',
					center : true,
					flashvars : flashContent.background.flashvars,
					params : flashContent.background.params
				};

				HugoBoss.flash.initSwfObject(swfObjectData);
			}

			/**
			 * module (main content) module
			 */
			if(flashContent.module && $('div.module').length !== 0) {

				var id = 'moduleFlash';

				$('div.module').addClass('flash').append('<div id="' + id + '"></div>');

				var width;
				if(!flashContent.module.width) {
					var width = '100%';
				} else {
					var width = flashContent.module.width;
				}

				var height;
				if(!flashContent.module.height) {
					var height = '100%';
				} else {
					var height = flashContent.module.height;
				}

				var center;
				if(!flashContent.module.center) {
					var center = false;
				} else {
					var center = true;
				}

				if(!flashContent.module.flashvars) {
					flashContent.module.flashvars = {};
				}

				if(flashContent.module.flashvars.stageHeight == undefined) {
					flashContent.module.flashvars.stageHeight = $(window).height();
				}
				if(flashContent.module.flashvars.stageWidth == undefined) {
					flashContent.module.flashvars.stageWidth = $('#content').width();
				}

				var swfObjectData = {
					source : flashContent.module.source,
					id : id,
					width : width,
					height : height,
					center : center,
					flashvars : flashContent.module.flashvars,
					params : flashContent.module.params
				};

				HugoBoss.flash.initSwfObject(swfObjectData);

			}

			/**
			 * teaser module
			 */
			if(flashContent.teaser && $('div.teaser').length !== 0) {

				var id = 'teaserFlash';

				$('div.teaser').addClass('flash').append('<div id="' + id + '"></div>');

				var width;
				if(!flashContent.teaser.width) {
					var width = '100%';
				} else {
					var width = flashContent.teaser.width;
				}

				/*
				 * 1906px H�he in teaser.php hinterlegen und hier abfragen ob h�he gesetzt, wenn nicht dann 295px
				 * */
				var height;
				if(!flashContent.teaser.height) {
					var height = '295px';
				} else {
					var height = flashContent.teaser.height;
				}

				if(!flashContent.teaser.flashvars) {
					flashContent.teaser.flashvars = {};
				}

				flashContent.teaser.flashvars.stageHeight = $('body').height();
				flashContent.teaser.flashvars.stageWidth = $('#content').width();

				var swfObjectData = {
					source : flashContent.teaser.source,
					id : id,
					width : width,
					height : height,
					center : true,
					flashvars : flashContent.teaser.flashvars,
					params : flashContent.teaser.params
				};

				HugoBoss.flash.initSwfObject(swfObjectData);

			}

			/**
			 * additional content (special content which does not fit anywhere else)
			 */
			if(flashContent.additionalContent && $('div.additionalContent').length !== 0) {

				for(var i = 0; i < flashContent.additionalContent.length; i++) {

					var id = 'additionalContent' + i;

					$('div.additionalContent:eq(' + i + ')').addClass('flash').append('<div id="' + id + '"></div>');

					var width;
					if(!flashContent.additionalContent[i].width) {
						var width = '100%';
					} else {
						var width = flashContent.additionalContent[i].width;
					}

					var height;
					if(!flashContent.additionalContent[i].height) {
						var height = '100%';
					} else {
						var height = flashContent.additionalContent[i].height;
					}

					if(!flashContent.additionalContent[i].flashvars) {
						flashContent.additionalContent[i].flashvars = {};
					}

					flashContent.additionalContent[i].flashvars.stageHeight = height;
					flashContent.additionalContent[i].flashvars.stageWidth = width;

					var swfObjectData = {
						source : flashContent.additionalContent[i].source,
						id : id,
						width : width,
						height : height,
						center : false,
						flashvars : flashContent.additionalContent[i].flashvars,
						params : flashContent.additionalContent[i].params
					};

					HugoBoss.flash.initSwfObject(swfObjectData);

				}

			}

		},
		/**
		 * initialize swf object
		 * @param {Object} data predefined data depending on module type and special on page settings
		 */
		initSwfObject : function(data) {

			if(!data.source) {
				/**
				 * @type {String} data.source source file (swf)
				 */
				data.source = '';
			}

			if(!data.id) {
				/**
				 * @type {String} data.id id of html container to be replaced by flash
				 */
				data.id = '';
			}

			if(!data.width) {
				data.width = '100%';
			}

			if(!data.height) {
				data.height = '100%';
			} else {
				if($.os.mac && $.browser.mozilla) {
					var height = data.height + ' ';
					if(height.indexOf('%') === -1) {
						data.height = parseInt(height) + 1;
					}
					var width = data.width + ' ';
					if(width.indexOf('%') === -1) {
						data.width = parseInt(width) + 1;
					}
				}
			}

			if(!data.version) {
				data.version = HugoBoss.flash.version;
			}

			if(!data.expressInstall) {
				data.expressInstall = null;
			}

			if(!data.flashvars) {
				data.flashvars = {};
			}

			if(!data.flashvars.moduleCSS) {
				data.flashvars.moduleCSS = flashContent.moduleCSS;
			}
			if(!data.flashvars.moduleXML) {
				data.flashvars.moduleXML = flashContent.moduleXML;
			}
			if(!data.flashvars.layoutXML) {
				data.flashvars.layoutXML = flashContent.layoutXML;
			}
			data.flashvars.lcKEY = flashContent.lcKEY;

			if(HugoBoss.utils.getCookie('sound') === 'true') {
				data.flashvars.soundState = 'on';
			} else {
				data.flashvars.soundState = 'off';
			}

			if(!data.params) {
				data.params = {
					allowScriptAccess : 'always',
					menu : false
				};
			} else {
				if(!data.params.allowScriptAccess) {
					data.params.allowScriptAccess = 'always';
				}
				if(!data.params.menu) {
					data.params.menu = false;
				}
			}

			/**
			 * @type {String} href window location
			 */
			var href = window.location.href;

			/**
			 * @type {String} data.params.wmode due to performance issues standard wmode is set to opaque
			 */
			data.params.wmode = 'opaque';
			/**
			 * special cases where wmode transparent is needed
			 */
			if(href.indexOf('/boss_selection') !== -1 || href.indexOf('/hugo_fashionShow2011') !== -1 || href.indexOf('/boss_selection') !== -1 || href.indexOf('/boss_selection') !== -1 || href.indexOf('/bossSelection/') !== -1 || href.indexOf('/emag/mcLaren/') !== -1 || href.indexOf('/emag/sportsSponsorship/') !== -1 || (data.id === 'teaserFlash' && (href.indexOf('/boss_black.php') !== -1 || href.indexOf('/boss_orange') !== -1 || href.indexOf('/boss_green') !== -1))) {
				data.params.wmode = 'transparent';
			}

			if(!data.attributes) {
				data.attributes = {};
				/**
				 * @type {String} data.attributes.id id of the object tag in the dom after adding
				 */
				data.attributes.id = data.id + 'Swf';
				var flashbox = data.id + 'Swfbox';
			} else if(!data.attributes.id) {
				data.attributes.id = data.id + 'Swf';
				var flashbox = data.id + 'Swfbox';
			}

			if(!data.callback) {
				/**
				 * callback to set some css styles
				 */
				data.callback = function() {

					/**
					 * special case for ie9 and collection.php. will be expanded for other pages
					 */
					if(jQuery.browser.msie && jQuery.browser.version == '9.0') {

						if(href.indexOf('/collection.php') !== -1 || href.indexOf('/boss_selection') !== -1 || href.indexOf('/boss_selection') !== -1 || href.indexOf('/bossSelection/') !== -1) {
							$('#' + data.attributes.id).wrap('<div id="' + flashbox + '"></div>');
							var width = data.width + ' ';
							if(data.center && width.indexOf('%') === -1) {

								var marginLeft = Math.ceil(width / 2);
								$('#' + flashbox).css({
									left : '50%',
									marginLeft : '-' + marginLeft + 'px',
									position : 'absolute',
									height : data.height
								});
							} else {
								$('#' + flashbox).css({
									height : '100%'
								});
							}
						}
					} else {

						if(href.indexOf('/collection.php') !== -1) {
							$('#' + data.attributes.id).wrap('<div id="' + data.attributes.id + 'box"></div>');
							var width = data.width + ' ';
							if(data.center && width.indexOf('%') === -1) {

								var marginLeft = Math.ceil(width / 2);
								$('#' + data.attributes.id + 'box').css({
									left : '50%',
									marginLeft : '-' + marginLeft + 'px',
									position : 'absolute',
									height : '100%'
								});
							}
						}
					}
				};
			}

			/**
			 * build swf object
			 */
			swfobject.embedSWF(data.source, data.id, data.width, data.height, data.version, data.expressInstall, data.flashvars, data.params, data.attributes, data.callback);

			if($.os.mac && $.browser.mozilla) {
				swfobject.createCSS('#' + data.attributes.id, 'margin-top:-1px; margin-left:-1px;', null, true);

			}

			var height = data.height + ' ';
			if(height.indexOf('%') !== -1) {

				/*
				 HugoBoss.flash.setHeight();
				 if ($('#footer .teaser').length !== 0) {
				 $('#footer .teaser').css({
				 visibility: 'visible'
				 });

				 }

				 if ($('#footer').length !== 0) {
				 $('#footer').css({
				 visibility: 'visible'
				 });
				 $('.js #footerSound').css({
				 display: 'block'
				 });

				 }

				 */
			}

			/**
			 * mac mousewheel is only used for main flash object (module)
			 */
			if(data.id === 'moduleFlash') {

				HugoBoss.flash.initSwfMacMousewheel('moduleFlashSwf');

			}

			/**
			 * fallback for all pages but collection.php. will be changed due to an ie9 display bug
			 */
			if(href.indexOf('/collection.php') === -1) {
				var width = data.width + ' ';
				if(data.center && width.indexOf('%') === -1) {

					var marginLeft = Math.ceil(width / 2);
					swfobject.createCSS('#' + data.attributes.id, 'left:50%; margin-left:-' + marginLeft + 'px; position:absolute;', null, true);
				}
			}

		},
		/**
		 * mostly called from flash
		 * sroll to top of the page
		 * @param {Object} duration
		 */
		scrollToTop : function(duration) {

			if(!duration || duration == 'undefined') {
				duration = 0;
			}
			if($.browser.chrome) {
				//alert('Chrome');
				$("html,body").animate({
					scrollTop : 0
				}, "slow");
				//$('#outerWrapper').scrollTo(0, duration);
			} else {
				$('body').scrollTo(0, duration);
			}

		},
		/**
		 * called from flash
		 * scroll to a specific position
		 * @param {Object} position
		 * @param {Object} duration
		 */
		scrollToPosition : function(position, duration) {

			if(!position || position == 'undefined') {
				position = 0;
			}

			if(!duration || duration == 'undefined') {
				duration = 0;
			}

			//change scroll $('#outerWrapper')
			$('body').scrollTo(position, duration);

		},
		/**
		 * set flash 100% height
		 */
		setHeight : function() {

			if($.browser.chrome || $.browser.safari) {

				var height = $('#content').height();

				swfobject.createCSS('#moduleFlashSwf', 'height:' + height + 'px;', null, true);
				swfobject.createCSS('#backgroundScrollFlashSwf', 'height:' + height + 'px;', null, true);

			}

		},
		/**
		 * init swf mac mousewheel
		 * @param {Object} target
		 */
		initSwfMacMousewheel : function(target) {
			/**
			 * call inside flash
			 */
			try {
				swfmacmousewheel.registerObject(target);

			}
			/**
			 * could not connect to flash movie (maybe not loaded jet)
			 */
			catch (e) {
			}

		},
		/**
		 * called from flash
		 * hide background if not needed
		 * @param {Boolean} fixed
		 */
		setBackground : function(fixed) {

			if(!fixed) {
				$('div.backgroundFixed').children('object').css({
					display : 'none'
				});
			} else {
				$('div.backgroundScroll').children('object').css({
					display : 'none'
				});
			}

		},
		/**
		 * called from flash
		 * hide Teaser
		 */
		hideTeaser : function() {

			$('#footer').css({
				height : '50px',
				marginTop : '-125px'
			}).children('div.teaser').css({
				display : 'none'
			});

		},
		/**
		 * called from flash
		 * set to height other than 100%
		 * only usesd for special case boss selection
		 * @param {Object} target
		 * @param {Object} height
		 */
		setFlashHeight : function(target, height) {

			swfobject.createCSS('#' + target + 'FlashSwf', 'height:' + height + 'px;', null, true);

			var moduleHeight;
			var teaserHeight;
			var footerHeight;

			switch (target) {
				case 'teaser':

					var additionalContentHeight = 0;
					if(!flashContent.additionalContent) {
						additionalContentHeight = 0;
					} else {
						additionalContentHeight = flashContent.additionalContent[0].height;

						$('div.additionalContent').css({
							height : additionalContentHeight + 'px'
						});

					}
					moduleHeight = $('div.module').height();
					teaserHeight = height;
					footerHeight = teaserHeight + additionalContentHeight + 125;

					$('div.teaser').css({
						height : height + 'px'
					});

					$('#footerNavInner').css({
						marginTop : '50px'
					});

					$('#footer').css({
						height : footerHeight + 'px',
						marginTop : '-' + footerHeight + 'px'
					});

					/*

					 if ($('#footer .teaser').length !== 0) {

					 $('#footer .teaser').css({
					 visibility: 'visible'
					 });

					 }

					 */

					break;
				case 'module':

					var additionalContentHeight = $('div.additionalContent').height();
					moduleHeight = height;
					teaserHeight = $('div.teaser').height();
					footerHeight = teaserHeight + additionalContentHeight + 100;

					$('div.module').css({
						height : height + 'px'
					});

					break;
			}

			$('div.flash').find('object').each(function() {
				/**
				 * call inside flash
				 */
				try {
					this.setModuleHeight(moduleHeight);
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {
				}

			});
			var contentHeight = moduleHeight + footerHeight;

			HugoBoss.flash.positionTeaser(contentHeight);

		},
		/**
		 * call from flash
		 * change teaser position for pv
		 * @param {Object} posY
		 */

		/*
		 var href = window.location.href;
		 if (href.indexOf('/collection.php')) {
		 $('#footer').css({
		 visibility: 'visible'
		 });
		 $('.js #footerSound').css({
		 display: 'block'
		 });
		 }
		 */

		positionTeaser : function(posY) {

			$('#content').css({
				minHeight : posY + 85 + 'px'
			});

			if($('#innerContent').length !== 0) {

				$('#innerContent').css({
					height : posY + 'px'
				});

			}

			HugoBoss.flash.setHeight();
			if($('#footer .teaser').length !== 0) {
				$('#footer .teaser').css({
					visibility : 'visible'
				});

			}

			if($('#footer').length !== 0) {
				$('#footer').css({
					visibility : 'visible'
				});
				$('.js #footerSound').css({
					display : 'block'
				});

			}

		},
		/**
		 * updates size of flash movie (after resize)
		 */
		updateSize : function() {

			var height = $(window).height();
			var width = $('#content').width();

			$('div.flash').children('object').each(function() {
				/**
				 * call inside flash
				 */
				try {
					this.setStageHeight(height);
					this.setStageWidth(width);
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {
				}

			});
		},
		/**
		 * call from flash
		 * used in hb tv to control videos
		 * @param {Object} id
		 */
		hbTvPlayVideo : function(id) {

			$('div.backgroundScroll').find('object').each(function() {
				/**
				 * call inside flash
				 */
				try {
					this.playVideo(id);
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {
				}

			});
		},
		/**
		 * overlay player
		 * @param {Object} videoAlias
		 */
		showVideoLayer : function(videoAlias) {

			HugoBoss.flash.scrollToTop(200);

			setTimeout(function() {

				if($('#videoLayer').length === 0) {

					var videoLayer = '<div id="videoLayerBg"></div>';
					videoLayer += '<div id="videoLayer" class="flash"><a href="#close" class="close">' + textContent.close + '</a><div id="videoLayerFlash"></div></div>';

					$('#outerWrapper').append(videoLayer);

					$('#videoLayerBg').css({
						opacity : 0
					}).animate({
						opacity : 0.9
					}, {
						duration : 400,
						complete : function() {

							var swfObjectData = {
								source : '/assets/mainLoader.swf',
								id : 'videoLayerFlash',
								width : '765',
								height : '432',
								center : true,
								flashvars : {
									stageWidth : '765',
									stageHeight : '432',
									moduleCSS : '/style/style.emag.hbTV.css',
									moduleXML : path + 'emag/data/overlayPlayer.xml',
									layoutXML : '',
									videoAlias : videoAlias
								},
								params : {
									wmode : 'opaque',
									bgColor : '#000000',
									allowFullscreen : true
								},
								attributes : {
									id : 'videoLayerFlashSwf'
								}
							};

							HugoBoss.flash.initSwfObject(swfObjectData);

							$('#videoLayer').css({
								display : 'block'
							});

							$('#videoLayerBg').add('#videoLayer a.close').bind('click', function() {

								if($.os.mac) {
									$('#videoLayer').add('#videoLayerBg').css({
										display : 'none'
									});
								} else {
									$('#videoLayer').add('#videoLayerBg').remove();
								}

								return false;

							});

							$('#videoLayer').bind('click', function() {

								return false;

							});
						}
					});

				} else {

					$('#videoLayerBg').css({
						display : 'block',
						opacity : 0
					}).animate({
						opacity : 0.9
					}, {
						duration : 400,
						complete : function() {

							var swfObjectData = {
								source : '/assets/mainLoader.swf',
								id : 'videoLayerFlashSwf',
								width : '765',
								height : '432',
								center : true,
								flashvars : {
									stageWidth : '765',
									stageHeight : '432',
									moduleCSS : '/style/style.emag.hbTV.css',
									moduleXML : path + 'emag/data/overlayPlayer.xml',
									layoutXML : '',
									videoAlias : videoAlias
								},
								params : {
									wmode : 'opaque',
									bgColor : '#000000',
									allowFullscreen : true
								},
								attributes : {
									id : 'videoLayerFlashSwf'
								}
							};

							HugoBoss.flash.initSwfObject(swfObjectData);

							$('#videoLayer').css({
								display : 'block'
							});

						}
					});

				}

			}, 250);
		},
		/**
		 * called from flash
		 * workaround for storelocator/safari bug (google logo was not in view)
		 * sets content to 100%
		 */
		setTo100Percent : function() {

			/*
			 if ($('#content').length !== 0) {

			 $('#content').css({
			 // minHeight: '100%'
			 });

			 swfobject.createCSS('#moduleFlashSwf', 'height: 100%;', null, true);

			 }

			 HugoBoss.flash.updateSize();
			 */
		},
		/**
		 * mostly called form flash
		 * normal analytics call
		 * @param {Object} klickname
		 * @param {Object} clicktype
		 */
		analytics : function(klickname, clicktype) {

			var target = webtrekk.contentId + '.' + klickname;

			wt_sendinfo(target, clicktype);

		},
		/**
		 * special analytics call to avoid duplicate content in tracking
		 * @param {Object} klickname
		 * @param {Object} clicktype
		 */
		analyticsCG : function(klickname, clicktype) {

			var target = webtrekk.contentGroup[1] + '.' + webtrekk.contentGroup[2] + '.' + klickname;
			wt_sendinfo(target, clicktype);

		},
		/**
		 * called from flah
		 * google analytics call
		 * only used for newsletter at
		 * @param {Object} klickname
		 */
		analyticsGoogle : function(klickname) {

			pageTracker._trackPageview(klickname);

		},
		/**
		 * called from flas
		 * media tracking, used for hbtv
		 * @param {Object} media_id
		 * @param {Object} player_action
		 * @param {Object} clip_position
		 * @param {Object} clip_length
		 * @param {Object} media_group
		 */
		analyticsMedia : function(media_id, player_action, clip_position, clip_length, media_group) {
			//console.log(clip_position + " - " + clip_length);
			wt_sendinfo_media(media_id, player_action, clip_position, clip_length, media_group);

		},
		/**
		 * called from flas 
		 * media tracking, used for fashion show fw 2012
		 * @param {Object} media_id
		 * @param {Object} player_action
		 * @param {Object} clip_position
		 * @param {Object} clip_length
		 * @param {Object} media_group
		 */
		analyticsMediaFashionShow2012 : function(media_id, player_action, clip_position, clip_length, media_group) {

			webtrekk.contentId = webtrekk.contentGroup[1] + '.' + webtrekk.contentGroup[2] + ".collections.hugo.blog.fashionShow2012-january.livestream";
			// content id
			// content group(s)
			webtrekk.contentGroup[3] = "collections";
			webtrekk.contentGroup[4] = "hugo";
			webtrekk.contentGroup[5] = "blog";
			webtrekk.contentGroup[6] = "fashionShow2012-january";
			webtrekk.contentGroup[7] = "livestream";

			// click tracking
			webtrekk.linkTrack = "link";
			webtrekk.linkTrackParams = "";
			webtrekk.linkTrackAttribute = "";

			//console.log(media_id, player_action, clip_position, clip_length, media_group);

			wt_sendinfo_media(media_id, player_action, clip_position, clip_length, media_group);

		},
		/**
		 * called from flash
		 * only used for hugo tracks, returns height of the menu on the lefthand side
		 * @return {Number} height
		 */
		getTracksMenuHeight : function() {

			var height = $('#leftNav').height();
			// + 155
			return height;

		},
		/**
		 * called from flash
		 * calculates distance from flash object to left border of html page
		 * used to get correct mouse position in selection
		 */
		getOffsetX : function() {

			var offsetX;

			if($('#teaserFlashSwf').length !== 0) {
				offsetX = $('#teaserFlashSwf').offset().left;

			} else if($('#moduleFlashSwf').length !== 0) {
				offsetX = $('#moduleFlashSwf').offset().left;

			}

			if(offsetX !== 'undefined') {

				$('div.flash').find('object').each(function() {
					/**
					 * call inside flash
					 */
					try {
						this.setOffsetX(offsetX);
					}
					/**
					 * could not connect to flash movie (maybe not loaded jet)
					 */
					catch (e) {
					}

				});
			}

		},
		/**
		 * called from flash
		 * used to open a layer in flash, used for communication between flash objects
		 */
		openFlashLayer : function() {

			$('div.flash').children('object').each(function() {
				/**
				 * call inside flash
				 */
				try {
					this.openLayer();
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {
				}

			});
		},
		/**
		 * force fade in if flash callback 'loaded' takes more than 8 seconds
		 * @deprecated
		 */
		fadeInTimeout : function() {

			clearTimeout(HugoBoss.flash.timeout);

			HugoBoss.flash.timeout = window.setTimeout(function() {

				HugoBoss.flash.fadeIn();

			}, 8000);
		},
		/**
		 * force page change if flash callback 'fadedOut' takes more than 4 seconds
		 * @deprecated
		 */
		fadeOutTimeout : function() {

			clearTimeout(HugoBoss.flash.timeout);

			HugoBoss.flash.timeout = window.setTimeout(function() {

				HugoBoss.utils.changeLocation();

			}, 4000);
		},
		/**
		 * external interface callback from flash if movie is ready (added to stage)
		 * @deprecated
		 */
		ready : function() {

			if(!HugoBoss.flash.readyCounter) {
				HugoBoss.flash.readyCounter = 1;
			} else {
				HugoBoss.flash.readyCounter += 1;
			}

			HugoBoss.flash.fadeInTimeout();

		},
		/**
		 * external interface callback from flash if movie content is loaded and ready to fade in
		 * @deprecated
		 */
		loaded : function() {

			if(!HugoBoss.flash.loadedCounter) {
				HugoBoss.flash.loadedCounter = 1;
			} else {
				HugoBoss.flash.loadedCounter += 1;
			}

			if(HugoBoss.flash.readyCounter === HugoBoss.flash.loadedCounter) {

				HugoBoss.flash.fadeIn();

			}
		},
		/**
		 * fade in flash content
		 * @deprecated
		 */
		fadeIn : function() {

			clearTimeout(HugoBoss.flash.timeout);

			$('div.flash').children('object').each(function() {
				/**
				 * call inside flash
				 */
				try {
					this.fadeIn();
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {
				}

			});
		},
		/**
		 * fade out flash content
		 * @deprecated
		 */
		fadeOut : function() {

			HugoBoss.flash.fadeOutTimeout();

			$('div.flash').children('object').each(function() {
				/**
				 * call inside flash
				 */
				try {
					this.fadeOut();
				}
				/**
				 * could not connect to flash movie (maybe not loaded jet)
				 */
				catch (e) {
				}

			});
		},
		/**
		 * external interface callback from flash if movie content is faded out
		 * @deprecated
		 */
		fadedOut : function() {

			if(!HugoBoss.flash.fadedOutCounter) {
				HugoBoss.flash.fadedOutCounter = 1;
			} else {
				HugoBoss.flash.fadedOutCounter += 1;
			}

			if(HugoBoss.flash.fadedOutCounter === HugoBoss.flash.loadedCounter) {

				clearTimeout(HugoBoss.flash.fadeOutTimeout);
				HugoBoss.utils.changeLocation();

			}

		}
	}

};

/**
 * dom ready event to initialize all
 */
$(document).ready(function() {

	HugoBoss.init();

	if($('#hugo_html_navi_top').length !== 0) {
		HugoBoss.utils.hugoNavigation();
	}

});

