

$(document).ready(function() {
	if ($.browser.msie) {
		$('#menuLeft > li > a img').click(function() {
			document.location.href = $(this).parents().filter('a').attr('href');
		});
	}
		
	$('select').selectbox();
	
	$('.containerBlogWide h4 a').parent().next().hide();
	$('.containerBlogWide h4 a').click(function() {
		anchor = $(this);
		anchor.toggleClass('up');
		anchor.parent().next().slideToggle('fast');
		
		return false;
	});
	
	$(document.location.hash).click();
	
	
	if ($('#produktyRozwiazaniaWrap').length > 0) {
		$('#produkty, #produktyOpis, #rozwiazania, #rozwiazaniaOpis').css('height', '679px');
		$('#produktyRozwiazania').css('height', '704px');
		$('#produktyOpisBox, #rozwiazaniaOpisBox').css('height', '658px');
	
		$('#rozwiazania .rozwiazaniaMenu a').click(function() {	
			$this = $(this);
			if ($this.hasClass('unfold')) {
				$('#produkty li a').removeClass('this').removeClass('unfold');;
				$('#rozwiazania .rozwiazaniaMenu a').removeClass('this').removeClass('unfold');
				$('#produkty').animate( { width: "458px" }, 400 );
				$('#rozwiazania').animate( { width: "457px" }, 400 );
			}
			else {
				$('#produkty li a').removeClass('this').removeClass('unfold');;
				$('#rozwiazania .rozwiazaniaMenu a').removeClass('this').removeClass('unfold');
				
				$this.addClass('this').addClass('unfold');
				
				mids = $this.attr('rel').split(',');
				for (i in mids) {
					$('.mid_'+mids[i]).addClass('this');	
				}
				
				$('#rozwiazaniaOpis').animate( { opacity: 1, width: "440px" }, 400 );
				$('#produktyMenu').animate( { width: "0", opacity: 0.4 }, 300, '', function() { $(this).hide() } );
				$('#rozwiazania').animate( { width: "226px" }, 400 );
				if ($('#produkty').css('width') != '250px') {
					$('#produkty').animate( { width: "250px" }, 400 );
				}
				$('#produktyOpis').animate( { width: "0", opacity: 1 }, 300, '', function() { $(this).hide() } );
				
				$('#rozwiazaniaOpisBox').addClass('loading');
				$('#rozwiazaniaOpisBox div').html('');
				$('#rozwiazaniaOpisBox').load(document.location.href.split('#')[0] + '?solId='+this.href.split('/').pop(), {}, function() {
					$('#rozwiazaniaOpisBox').removeClass('loading');
				});
			}
			return false;
		});
		
		$('#menuLeft a').not('.submenu').click(function() {
			$this = $(this);
			if ($this.hasClass('unfold')) {
				/*$('#produkty li a').removeClass('this').removeClass('unfold');;
				$('#rozwiazania .rozwiazaniaMenu a').removeClass('this').removeClass('unfold');
				$('#produkty').animate( { width: "458px" }, 400 );
				$('#produktyOpis').animate( { width: "0", opacity: 1 }, 400, '', function() { $(this).hide() } );
				$('#rozwiazania').animate( { width: "457px" }, 400 );*/
			}
			else {
				$('#produktyMenu .produktyMenu a').removeClass('this');
				$('#menuLeft a').removeClass('this').removeClass('unfold');
				$('#rozwiazania .rozwiazaniaMenu a').removeClass('this');
				$(this).addClass('this').addClass('unfold');
				
				$('#rozwiazania').animate( { width: "226px" }, 400 );
				if ($('#produkty').css('width') != '250px') {
					$('#produkty').animate( { width: "250px" }, 400 );
				}
				$('#produktyOpis').animate( { width: "615px", opacity: 1}, 400 );
				$('#rozwiazaniaOpis').animate( { width: "0", opacity: 1 }, 300, '', function() { $(this).hide() } );
				$('#produktyMenu').animate( { width: "0", opacity: 1 }, 300, '', function() { $(this).hide() } );
				
				$('#produktyOpisBox').addClass('loading');
				$('#produktyOpisBox div').html('');
				
				id = $(this).attr('id').split('_')[1];
				$('#produktyOpisBox').load(document.location.href.split('#')[0] + '?prodId='+id, {}, function() {
					$('#produktyOpisBox').removeClass('loading');
				});
			}
			return false;
		});
		
		$('#menuLeft a.submenu').click(function() {
			$this = $(this);
			if ($this.hasClass('unfold')) {
				$('#produkty li a').removeClass('this').removeClass('unfold');;
				$('#rozwiazania .rozwiazaniaMenu a').removeClass('this').removeClass('unfold');
				$('#produktyMenu a').removeClass('this').removeClass('unfold');
				$('#produkty').animate( { width: "458px" }, 400 );
				$('#produktyOpis').animate( { width: "0", opacity: 1 }, 400, '', function() { $(this).hide() } );
				$('#produktyMenu').animate( { width: "0", opacity: 1 }, 400, '', function() { $(this).hide() } );
				$('#rozwiazania').animate( { width: "457px" }, 400 );
				
			}
			else {
				$('#rozwiazania .rozwiazaniaMenu a').removeClass('this');
				$('#menuLeft a').removeClass('this').removeClass('unfold');
				$this.addClass('this').addClass('unfold');
				
				$('.produktyMenu').hide();
				rel = $(this).attr('rel');
				$('#'+rel).show();
				$('#'+rel + ' a:first').click();
				
				$('#produktyOpis').animate( { width: "470px", opacity: 1 }, 400 );
				$('#rozwiazania').animate( { width: "226px" }, 400 );
				if ($('#produkty').css('width') != '250px') {
					$('#produkty').animate( { width: "250px" }, 400 );
				}
				$('#produktyMenu').animate( { opacity: 1, width: "150px"}, 400);
			}
			return false;
		});
		
		$('#produktyMenu .produktyMenu a').click(function() {
			$('#produktyMenu .produktyMenu a').removeClass('this');
			$('#rozwiazania .rozwiazaniaMenu a').removeClass('this');
			$(this).addClass('this').addClass('unfold');
			
			$('#produktyOpisBox').addClass('loading');
			$('#produktyOpisBox div').html('');
			id = $(this).attr('id').split('_')[1];
			$('#produktyOpisBox').load(document.location.href.split('#')[0] + '?prodId='+id, {}, function() {
				$('#produktyOpisBox').removeClass('loading');
			});
			
			return false;
		});
		
		$('#menuBottom a').click(function() {
			doLink('#'+$(this).attr('href').split('#')[1]);
		});
		
		
		
		doLink = function(hash) {
			if (hash.match(/^#prod/)) {
				id = hash.split('/')[1];
				anchor = $('.mid_'+id);
				if (anchor.hasClass('submenu')) {
					anchor.click();
					submenu = anchor.attr('rel');
					$('#'+submenu+' a:first').click();
				}
				else {
					anchor.click();
				}
			}
			if (hash.match(/^#subprod/)) {
				id = hash.split('/')[1];
				anchor = $('.mid_'+id);
				if (anchor.hasClass('submenu')) {
					anchor.click();
					submenu = anchor.attr('rel');
					$('#'+submenu+' a:first').click();
				}
				else {
					anchor.click();
				}
			}
			if (hash.match(/^#sol/)) {
				id = hash.split('/')[1];
				$("a[href=#sol/"+id+"]").click();
			}	
		}	
		
		doLink(document.location.hash);
	}
});

$(document).ready(function() {
	$('#produkty .MenuEcommerce a:first').click();
});


//stanusch technologies wirtualny doradca
$(document).ready(function() {
	$('#WirtualnyDoradca').click(function(){
			adres='http://wenus.stanuschtechnologies.pl/players/beyond/';
			window.open(adres, 'wdplayer', 'top=0,left=0,menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=700, 		height=300');}
	);
});
