// JavaScript Document ąę

var main = {
	rootPath: '/',
	mainUrl: null,
	languageCode: 'pl',
	currentUrl: null,
	breadCrumbTrail: null,
	
	isFlash: false,
	isSifr: false,
	isCufon: true,

	//dla nawigacji(initNav) - czy przeladowac content
	reloadPageContentWithAjaxWhenClickedOnNav: false,
	
	//do topnav, stos z elementami do ukrycia
	topNavHoverStack: new Array(),
	
	//do wykrywania wersji flash parametry
	flashRequiredMajorVersion: 8,
	flashRequiredMinorVersion: 0,
	
	init: function(){
		this.initMainUrl();
		this.initCurrentUrl();
		this.initLanguageCode();
		this.initSelected();
		this.initNav('sideNav');
		this.initTopNavSfHover();	
		this.initTopNavFlash();
		this.initTopNav();
		this.initBreadCrumbTrail();
		this.initMisc();
		
		//app
		this.initFastNavCloud();
		this.initLanguageNav();
	},
	
	initMainUrl: function(){
		var regexp = new RegExp('http://.*?/');
		var mainUrl = regexp.exec(document.location.href);		
		this.mainUrl = new String(mainUrl);
	},	
	initCurrentUrl: function(){
		this.currentUrl = '/' + document.location.href.substring(this.mainUrl);	
	},
	initLanguageCode: function(){
		if($('#containerWrapper').length){
			var str = $('#containerWrapper').attr('class');
			var classes = str.split(' ');	
			this.languageCode = classes[0];		
		}		
	},
	initSelected: function(){
		//if(typeof(breadCrumbTrail)!="undefined"){
		if(this.breadCrumbTrail){
			for(var i = this.breadCrumbTrail.length - 1; i >= 0; i--){			
				//nie dodawaj dla ostatniej, bo ostatnia to glowna wiec podswietli na calej stronie
				if(this.breadCrumbTrail.length > 1 && i == 0){
					break; 
				}
	
				$("a[href='" + this.breadCrumbTrail[i] + "']").addClass('selected');	
			}
		}	
	},
	initNav: function(id) {	
		id = '#' + id;
		if(!$(id).length){
			return false;
		}
		
		//dodaj do li klase ktora pozwoli dodac np. strzalke jesli element jest rozwijany
		$(id + ' ul').parent().children('a').addClass('parentHasChildren').parent().addClass('hasChildren');
			
		$(id + ' ul').hide();	
		
		//zaznaczanie wedle adresu
		var mainUrl = this.getMainUrl();
		var cnt = mainUrl.length;
		var currentUrl = '/' + document.location.href.substring(cnt);	
	
		if(currentUrl != '/'){
			$("a[href='"+currentUrl+"']").addClass('selected');
		} 
	
		$(id + ' a.selected').parents("ul").show();
		
		//dodaje selected tez dla rodzicow
		var li = $(id + ' a.selected').parents("li");
		li.addClass('selected');
		li.children('a').addClass('selected');
		
		$(id + ' li:last').addClass('veryLastChild');
		$(id + ' li:first').addClass('veryFirstChild');
		
		$(id + ' li:last-child').addClass('lastChild');	
		$(id + ' li:first-child').addClass('firstChild');		
	
		$(id + ' li a').click(
			function() {	
				$(id + ' a.selected').removeClass('selected');
				var li = $(this).parents("li");
				li.addClass('selected');
				li.children('a').addClass('selected');
				
				var checkElement = $(this).next();
				//var parent = this.parentNode.parentNode.id;			
				var parent = $(this).parent().parent();
				
				if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {		
					if(main.reloadPageContentWithAjaxWhenClickedOnNav){
						var href = $(this).attr('href');
						if(href){
							$.get(href, {ajax:1}, function(data){
								if(data){				
									$('#mainColumn .page').replaceWith(data);	
								}
							});
						}
					}
					if(parent){
						//$('#' + parent + ' ul:visible').slideUp('normal');
						parent.find('ul:visible').slideUp('normal');
					}
					checkElement.slideDown('normal');
					return false;
				}
			}
		);	
	},	
	initTopNavFlash: function(){
		
		if(this.isFlashEnabled() && this.isFlashRightVersion()) { 
			$('#topNav > li').css('background-image', 'none');
			$('#flashTopNavContainer').flashembed({
					src: main.getRootPath() + 'default/flash/topNav.swf',
					width: '980',
					height: '38',
					quality: 'high',
					align: 'left',
					scale: 'default',
					wmode: 'transparent',
					id: 'flashTopNav',
					bgcolor: 'none',
					name: 'flashTopNav',
					salign: 'LT'
				}, {
					currentUrl: main.getCurrentUrl(), 
					mainUrl: main.getMainUrl()
				}
			);				
		}		
		
	},
	initTopNavSfHover: function(){
		var self = this;

		$('#topNav li').hover(function () {	
			var parents = $(this).parents('li');
			parents.push($(this));				
			
			//sprawdzamy czy elementow nie ma na liscie do zamkniecia, jesli sa to je usuwamy
			//ze wzgledu na opoznione howanie
			for(var i=0; i<self.topNavHoverStack.length; i++){
				parents.each(function(){	
					if(self.topNavHoverStack[i] == $(this).attr('id')){
						self.topNavHoverStack[i] = null;
					}
				});
			}
			$(this).addClass("sfhover");	  
			
			var id = $(this).attr('id');		
			var nbr = id.substr(2);
			if(self.isFlash){
				document.flashTopNav.SetVariable('btnOnWichIsMouseOver', nbr);
			}
	
		}, function () {
			var id = $(this).attr('id');
			self.topNavHoverStack.push(id);		
			
			//opoznienie, zeby zdarzyc 
			setTimeout(function(){								  						  
				for(var i=0; i<self.topNavHoverStack.length; i++){
					if(self.topNavHoverStack[i] == id){					
						$('#' + id).removeClass("sfhover");
						self.topNavHoverStack.splice(i, 1);	
						break;
					}
				}
			}, 50);		
			
	
			var nbr = id.substr(2);
			if(self.isFlash){
				document.flashTopNav.SetVariable('btnOnWichIsMouseOut', nbr);
			}
		});
		
		$('#topNav > *').click(function(){
			window.location.href = $(this).children('a').attr('href');											  
		});	
	},
	initTopNav: function(){
		//topNav
		if($('#topNav').length){
			$('#topNav li:last-child').addClass('lastChild');
			$('#topNav li:first-child').addClass('firstChild');	
			$('#topNav ul').parent().children('a').addClass('parentHasChildren').parent().addClass('hasChildren');
			
			//add hidden at begining prevents little move when swap to flash is made
			if(this.isFlash && this.hasRightVersion){
				$('#topNav > li > a').each(function(){
					$(this).addClass('hidden');
				});
			}
			
			//$('#topNav ul').wrap('<div class="wrapper" />');	
			
			if($('#categoriesTopNavContainer').length){
				var clone = $('#categoriesTopNavContainer').clone();
				$('#categoriesTopNavContainer').remove();
				clone.appendTo('#tn111, #tn122, #tn128, #tn134, #tn141, #tn147, #tn153').show();
			}
		}	
	},	
	initBreadCrumbTrail: function(){
		if($('#breadCrumbTrail').length){
			$('#breadCrumbTrail li:last-child').addClass('lastChild');
			$('#breadCrumbTrail li:first-child').addClass('firstChild');			
		}
	},
	
	initMisc: function(){		
		$('#bottomNav li:last-child').addClass('lastChild');			
		
		this.initNav('productsCategoriesNav');
	},
	
	//app
	initFastNavCloud: function(){
		$('#fastNavContainer ul.authNav li.register a, #footer ul.authNav li.register a').hover(
			function(){
				$(this).parent().children('em').show();	
			},
			function(){
				$(this).parent().children('em').hide();				
			}
		);
	},
	initLanguageNav: function(){
		var langNav = $('#languageBottomNav');
		langNav.hide();
		if(langNav.length){
			$('#footer .langs a.selected').toggle(
				function(){
					langNav.show('normal');
				},
				function(){
					langNav.hide('normal');
				}
			);																			 
		}
	},
	
	//getters
	getMainUrl: function(){
		return this.mainUrl;	
	},
	getCurrentUrl: function(){
		return this.currentUrl;	
	},
	getLanguageCode: function(){
		return this.languageCode;	
	},
	getRootPath: function(){
		return this.rootPath;	
	},
	getFlashRequiredMajorVersion: function(){
		return this.flashRequiredMajorVersion;	
	},
	getFlashRequiredMinorVersion: function(){
		return this.flashRequiredMinorVersion;	
	},	
	
	
	//setters
	setBreadCrumbTrail: function(breadCrumbTrail){
		this.breadCrumbTrail = breadCrumbTrail;
	},
	
	
	//misc
	isFlashRightVersion: function(){
		var version = flashembed.getVersion();
		if(version[0] > this.flashRequiredMajorVersion){				
			return true;	
		} else if(version[0] == this.flashRequiredMajorVersion){
			if(version[1] > this.flashRequiredMinorVersion){
				return true;	
			}
		}
		//return DetectFlashVer(this.flashRequiredMajorVersion, this.flashRequiredMinorVersion, this.flashRequiredRevision);				
		
		return false;
	},		
	isFlashEnabled: function(){
		return this.isFlash;
	},
	translate: function(keyword, languageCode){
		return dictionary.translate(keyword, languageCode);
	},
	verticalAlign: function(elem){
		var top = Math.floor(($(elem).parent().height() - elem.height)/2);
		elem.style.top = top+'px';
	},
	addToBookmarks: function() {
		title = $('title').text(); 
		url = location.href;
			
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url, "");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title); }
		else if(window.opera && window.print) { // Opera Hotlist
	
		}
	},
	isEMailAddr: function(elem) {
		var str = elem.value;
		var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		if (!str.match(re)) {
			alert(this.translate('wrong_email_address'));
			popup.show(this.translate('wrong_email_address'), 'warning');
			return false;
		} else {
			return true;
		}
	},
	setSameHeightForBoxes: function(container){	
		$(document).ready(function(){
			var minHeight = 0;
			$(container + ' .box .content').each(function(){
				if(minHeight < $(this).height()){
					minHeight = $(this).height();
				}
			});
		
			if(minHeight > 0){
				$(container + ' .box .content').css('height', minHeight + 'px');
			}
		});
	}	
	
}
 

//popup
var popup = {
	container: null,
	method: 'prepend',
	
	init: function(container, method){
		//popup
		if($('#popup').length){
			$('#popup').delay(5000).hide('slow');
		}
		
		this.setContainer(container);
		if(method){
			this.setMethod(method);
		}
	},
	
	setContainer: function(container){
		if(container){			
			if(container instanceof jQuery){
				this.container = container;
			} else {
				this.container = $(container);	
			}
		}	
	},
	
	setMethod: function(method){
		this.method = method;
	},
	
	show: function(message, type, isAppend){
		var popup = $('#popup ul');
		var className = type;

		if(!popup.length){			
			if(this.method == 'prepend'){
				this.container.prepend('<div id="popup"><ul></ul><div>');
			} else if(this.method == 'append'){
				this.container.append('<div id="popup"><ul></ul><div>');
			} else if(this.method == 'after'){
				this.container.after('<div id="popup"><ul></ul><div>');
			} else {
				alert(message);	
			}
			popup = $('#popup ul');
		} 
		
		if($('#popup').is(':hidden')){
			$('#popup').show('slow');
		}
		$('#popup').delay(8000).hide('slow');		

		var html = '<li class="' + className + '">' + message + '</li>';
		if(isAppend){
			popup.append(html);	
		} else {
			popup.html(html)
			popup.removeClass();
			popup.addClass(className);
		}		
	}
}

//dictionary
var dictionary = {	
	pl: {
		wrong_email_address: 'Sprawdź poprawność adresu email!',
		image: 'Obraz',
		of: 'z',
		please_login_to_ask_about_product: 'Aby zadać pytanie musisz być zalogowany!'
	},
	en: {
		wrong_email_address: 'Check your email address!',
		image: 'Image',
		of: 'of',
		please_login_to_ask_about_product: 'To ask a question you must be logged in!'		
	},
	sk: {
		wrong_email_address: 'Skontrolujte svoj e-mail!',
		image: 'Obraz',
		of: 'z',
		please_login_to_ask_about_product: 'Na niečo opýtať, musíte byť prihlásený!'		
	},	
	ru: {
		wrong_email_address: 'Проверьте ваш адрес электронной почты!',
		image: 'изображение',
		of: 'из',
		please_login_to_ask_about_product: 'Чтобы задать вопрос необходимо войти в систему!'			
	},
	ch: {
		wrong_email_address: 'Check your email address!',
		image: 'Image',
		of: 'of',
		please_login_to_ask_about_product: '要問一個問題，你必須先登錄！'		
	},
	lt: {
		wrong_email_address: 'Patikrinkite savo elektroninio pašto adresą!',
		image: 'Vazidas',
		of: 'iš',
		please_login_to_ask_about_product: 'Norėdami užduoti klausimą, turite būti prisijungęs!'		
	},
	cz: {
		wrong_email_address: 'Zkontrolujte svůj e-mail!',
		image: 'Obraz',
		of: 'z',
		please_login_to_ask_about_product: 'Na něco zeptat, musíte být přihlášeni!'		
	},	
	
	translate: function(keyword, languageCode){
		if(!languageCode){
			languageCode = main.getLanguageCode();
		}

		if(this[languageCode][keyword]){
			return this[languageCode][keyword];	
		} else {
			return keyword;	
		}
	}
}

//wyslij do flash elementy menu
var topNavContainer = {	
	sendToFlash: function(){
		var rows = new Array();
		//dla ie, bo ie nie widzi klasy selected
	
		var selectedUrl = '';
		if(typeof(breadCrumbTrail) !== 'undefined' && breadCrumbTrail.length){
			if(breadCrumbTrail.length > 1){
				selectedUrl = breadCrumbTrail[1];
			} else {
				selectedUrl = breadCrumbTrail[0];
			}
			
			if(selectedUrl.search('http') == -1){
				selectedUrl = '/' + selectedUrl + '.html';			
			}	
		}
			
		$('#topNav > *').each(function(i){											 
			var row = new Object();
			var a = $(this).children('a');
			row.url = a.attr('href');
			row.name = a.text();
			row.id = $(this).attr('id').substr(2);
			
			if(a.hasClass('selected') || row.url == selectedUrl){
				row.selected = true;
			} else {
				row.selected = false;
			}
			
			if($(this).children('ul').length){
				row.hasChildren = true;	
			} else {
				row.hasChildren = false;	
			}
			rows[i] = row;
		});
	
		return rows;
	},
	
	//dopasuj elementy menu w html do tych we flash, zeby dropdown sie dobrze wyswietlalo
	adjustWidth: function(nbr, width){
		var a = $('#tn'+nbr+' :first');	
		a.addClass('hidden');
		a.css('width', width + 'px');
	}	
}

//myAccountShortBox - obsluga inputa password
var myAccountShortBox = {
	init: function(){
		if($('#myAccountShortBox').length){
			$('#myAccountShortPasswordInput').click(this.myAccountShortBoxFocus);
			$('#myAccountShortPasswordInput').focus(this.myAccountShortBoxFocus);
		}
	},
	myAccountShortBoxFocus: function(){			
		$(this).remove();
		$('#myAccountShortBox .passwordContainer').prepend(' <input id="myAccountShortPasswordInput" class="input" name="password" type="password" />');
		
		$('#myAccountShortPasswordInput').blur(self.myAccountShortBoxBlur);
		//set kursor to this new field
		$('#myAccountShortPasswordInput').focus();		
	},	
	myAccountShortBoxBlur: function(){
		if($(this).val() == ''){
			$(this).remove();
			$('#myAccountShortBox .passwordContainer').prepend(' <input id="myAccountShortPasswordInput" class="input" name="password" type="text" value="Hasło" />');
			
			$('#myAccountShortPasswordInput').click(self.myAccountShortBoxFocus);	
			$('#myAccountShortPasswordInput').focus(self.myAccountShortBoxFocus);	
		}	
	}
}

var appNewsBox = {
	
	init: function(){		
		if(!$('.appNewsBox').length){
			return false;
		}
		
		$('.appNewsBox .newestBtn').click(function(){
			if(!$(this).hasClass('current')){
				$(this).addClass('current');
				$('.appNewsBox .archiveBtn').removeClass('current');
				
				$('.appNewsBox .tab_1').hide();				
				$('.appNewsBox .tab_0').show();				
			}
			
			return false;
		});
		
		$('.appNewsBox .archiveBtn').click(function(){																
			if(!$(this).hasClass('current')){
				$(this).addClass('current');
				$('.appNewsBox .newestBtn').removeClass('current');
				
				$('.appNewsBox .tab_0').hide();				
				$('.appNewsBox .tab_1').show();
			}
			
			return false;
		});		
	}
	
}

var appProductsLatestBox = {
	
	currentNumber: 0,
	lastNumber: null,
	timeout: 5000,
	intervalId: null,
	
	init: function(){
		if(!$('.appProductsLatestBox').length){
			return false;	
		}
		
		var self = this;

		this.lastNumber = $('.appProductsLatestBox .tab').length - 1;
		
		$('.appProductsLatestBox .prev').click(function(){
			self.showPrev();
			
			self.stopSlideShow();
			
			return false;
		});
		
		$('.appProductsLatestBox .next').click(function(){
			self.showNext();
			
			self.stopSlideShow();
			
			return false;
		});		
		
		$('.appProductsLatestBox .number').click(function(){
			var nbr = new Number($(this).text()) - 1; 																		  
			self.show(nbr);				
			
			self.stopSlideShow();
			
			return false;
		});
		

		$('.appProductsLatestBox .product img').one('load', function(){
			var element = $(this);
			var parent = $(this).parents('.product');
			var parentHeight = parent.height();
			var elementHeight = element.height();
			var parentWidth = parent.width();
			var elementWidth = parent.width();
			
			while(elementHeight > parentHeight - 10){
				elementWidth = elementWidth - 10;
				
				element.css('width', elementWidth + 'px');
				elementHeight = element.height();
			}
			
			var top = Math.floor((parentHeight - elementHeight)/2);

			element.css('margin-top', top + 'px');
		}).each(function(){
			if(this.complete || (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6))
			$(this).trigger("load");
		});
		
		//start slideshow
		if(this.lastNumber > 1){
			this.startSlideShow();
		}

	},
	
	show: function(nbr){		
		$('.appProductsLatestBox .tab').fadeOut('slow');
		$('.appProductsLatestBox .tab' + nbr).fadeIn('slow');
		$('.appProductsLatestBox .number').removeClass('current');
		$('.appProductsLatestBox .number' + nbr).addClass('current');
		this.currentNumber = nbr;
	},
	
	showNext: function(){
		if(this.currentNumber < this.lastNumber){																		
			this.show(this.currentNumber + 1);						
		} else {
			this.show(0);						
		}
	},
	
	showPrev: function(){
		if(this.currentNumber > 0){																		
			this.show(this.currentNumber - 1);						
		} else {
			this.show(this.lastNumber);						
		}		
	},
	
	startSlideShow: function(){
		var self = this;
		this.intervalId = setInterval(function(){
			self.showNext();									
		}, this.timeout);
	},
	
	stopSlideShow: function(){
		clearInterval(this.intervalId);
	}
	
}

var appProductsRandBox = {
	
	current: 0,
	last: null,
	intervalId: null,
	timeout: 5000,
	
	init: function(){
		if(!$('.appProductsRandBox').length){
			return false;	
		}
		
		var self = this;

		this.last = $('.appProductsRandBox .product').length - 1;
		
		$('.appProductsRandBox .prev').click(function(){
			self.showPrev();
			
			self.stopSlideShow();
			
			return false;
		});
		
		$('.appProductsRandBox .next').click(function(){
			self.showNext();
			
			self.stopSlideShow();
			
			return false;
		});		
		
		$('.appProductsRandBox .image img').one('load', function(){
			var element = $(this);
			var elementHeight = element.height();
			var elementWidth = element.width();
			var parentHeight = 250;
			
			while(elementHeight > parentHeight){
				elementWidth = elementWidth - 10;
				
				element.css('width', elementWidth + 'px');
				elementHeight = element.height();
			}		
		}).each(function(){
			if(this.complete || (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6))
			$(this).trigger("load");
		});		
		
		//start slideshow
		if(this.last > 1){
			this.startSlideShow();
		}
	},
	
	show: function(nbr){		
		$('.appProductsRandBox .product').fadeOut('slow');
		$('.appProductsRandBox .product' + nbr).fadeIn('slow');
		this.current = nbr;
	},
	
	showNext: function(){
		if(this.current < this.last){																		
			this.show(this.current + 1);						
		} else {
			this.show(0);						
		}
	},
	
	showPrev: function(){
		if(this.currentNumber > 0){																		
			this.show(this.current - 1);						
		} else {
			this.show(this.last);						
		}		
	},
	
	startSlideShow: function(){
		var self = this;
		this.intervalId = setInterval(function(){
			self.showNext();									
		}, this.timeout);
	},
	
	stopSlideShow: function(){
		clearInterval(this.intervalId);
	}	
	
}

//showGoogleMap
var appGoogleMapBox = {	

	show: function(){
		var googleMapAddress = 'http://mapy.google.pl/maps/ms?ie=UTF8&amp;hl='+main.getLanguageCode()+'&amp;msa=0&amp;msid=217610328663514736380.0004930b165c02757ad75&amp;t=h&amp;vpsrc=0&amp;ll=51.071093,16.961904&amp;spn=0.012944,0.027423&amp;z=15&amp;iwloc=0004930b19f2af5a4f4fa&amp;output=embed';	
		
		var containerWrapper = $('#containerWrapper');
		containerWrapper.append('<div id="googleMapBg"><div>');		
		$('body').append('<iframe id="googleMap" width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' + googleMapAddress + '"></iframe>');			
	
		//http://maps.google.pl/maps/ms?msa=0&amp;msid=202865882018032139436.0004a996192e38085afd5&amp;hl='+languageCode+'&amp;ie=UTF8&amp;ll=51.358062,16.66626&amp;spn=1.715143,3.515625&amp;z=8&amp;iwloc=0004a996213d2ccc160c0&amp;output=embed
		var googleMapBg = $('#googleMapBg');
		var googleMap = $('#googleMap');
		
		googleMapBg.css({
			opacity:	0.7,
			height: containerWrapper.height()
		});	
		
		var top = $(document).scrollTop() + Math.round($(window).height()/2) - 240;
		googleMap.css('top', top + 'px');
		
		googleMapBg.click(function(){
			googleMap.remove();
			googleMapBg.remove();
		});
		
	}
	
}

//grupuje tylko
var openStandardOverlay = {
	mask: '#000000',
	effect: 'apple',
	
	onBeforeLoad: function() {	
		// grab wrapper element inside content
		var wrapper = this.getOverlay().find(".overlayContent");
	
		// load the page specified in the trigger
		var url = this.getTrigger().attr("href") + '/is_ajax/1';
		wrapper.load(url);
	}	
}

var pagesNavContainer = {
	//stock popup
	init: function (){
		$('#pagesNavContainer a.printAllPdfBtn').overlay(openStandardOverlay);
	}
}

var appProducts = {
	
	init: function(){
		//stock popup
		$('#appProductsIndex a.stocksLink, #appProductsDetails a.stocksLink, #appProductsIndex a.printPdfBtn').overlay(openStandardOverlay);
		
		if(!$('#appProductsIndex, #appProductsDetails').length){
			return false;
		}	
		
		//hide menu after opening popup
		$('#appProductsIndex a.printPdfBtn').click(function(){
			$(this).parent().parent().hide();																				 
		});
		
		//show menu
		$('#appProductsIndex a.showMenu').click(function(){
			var ul = $(this).parent().children('ul');															 
			if(ul.is(':visible')){				
				ul.hide();
			} else {
				ul.show();
			}
		});
		
		//ask form
		$('#appProductsDetails a.askAboutProductBtn').click(function(){
			var form = $('#appProductsDetails div.askAboutProductContainer form');
			
			if(form.length){
				$(this).hide();																						 			
				form.show('slow');
			} else {
				popup.show(main.translate('please_login_to_ask_about_product'), 'warning', false);	
			}
			return false;
		});
		
		//onclick onblur
		$('#appProductsIndex .product form input.input').click(function(){
			$(this).attr('size', $(this).val());
			$(this).val('');														 
		});
		$('#appProductsIndex .product form input.input').blur(function(){
			if($(this).val() == ''){
				$(this).val($(this).attr('size'));
			}
		});		
		$('#appProductsIndex .product form a').click(function(){
			$(this).parent().submit();
			return false;
		});
	},
	
	
	
	printPdf: function(category_id){
		if(!category_id){
			return false;
		}
		
		
		
		return false;
	}
	
}

var appProductsCategoriesBox = {
	
	init: function(){
		main.initNav('productsCategorieNav');	
	}
	
}

var appProductsCartIndex = {
	
	init: function(){
		if(!$('#appProductsCartIndex').length){
			return false;
		}		
		
		$('#appProductsCartIndex a.update').click(function(){
																						
		});
		
		$('.noMinimalCartPriceBtn').click(function(){																		 
			popup.show($(this).attr('title'), 'error', false);						
			$('html,body').animate({scrollTop: $('#header').offset().top},'slow');
			return false;												   
		});
	}
		
}


$(document).ready(function(){		
	main.init();		
	myAccountShortBox.init();
	popup.init('#breadCrumbTrailContainer', 'after');
	
	appNewsBox.init();
	appProductsLatestBox.init();
	appProductsRandBox.init();
	appProducts.init();
	appProductsCategoriesBox.init();
	pagesNavContainer.init();
	appProductsCartIndex.init();
});

//sifr config
if(main.isSifr){
	
}

//cufon config
$(document).ready(function(){
	if(main.isCufon && (main.getLanguageCode() == 'pl' || main.getLanguageCode() == 'en')){
		Cufon.replace('.cufon, .box .header h3, .page .mainHeader h2, '+
						  '#footer p.copyrights, '+
						  '#topNav > li > a, '+
						  '.commonShortCuts h4, '+
						  '.appProductsRandBox .product .description a.name, '+
						  '.appProductsHeaderBox h2, '+
						  '#appProductsDetails h3.name', {
						  fontFamily: 'kp', 
						  letterSpacing: '-1px'
		});				
		
		Cufon.replace('#fastNavContainer ul.authNav li em, ', {
						  fontFamily: 'kp'
		});				
		
		Cufon.replace('#fastNavContainer ul.authNav li a, #footer ul.authNav li a, .productsContainer a.name', {
							fontFamily: 'kp', 
							letterSpacing: '-1px',
							hover: {
								color: '#08467e'
							}					  
		});	
		
		/*Cufon.replace('#topNav > li > a', {
							fontFamily: 'kp', 
							letterSpacing: '-1px',
							hover: {
								color: '#1ab0d5'
							}					  
		});*/					
		
	}
});
