var baskettimeout = null;
$(document).ready(function(){

	$('#center_container p.description').jTruncate({
		length : 300
//		,
//		moreText : ' more',
//		lessText : ' less'
//		,moreAni: 'slow'
//		lessAni : 'slow'
	});

	$('#left_container ul.produkty_panel > li:not(.no-children) > h2 > a').click(function(e){
		e.preventDefault();
		var ul = $(this).parents('li').children('ul');
		ul.show('slow',function(){
			$(this).parents('li').addClass('active');
		});
		$('#left_container ul.produkty_panel ul').not(ul).hide('fast',function(){
			$('#left_container ul.produkty_panel').not(ul).children('li:not(.no-children)').removeClass('active')
		});
	});

	$('#parent_0_13_level1 a').each(function(){
		if($(this).attr('href') != '#'){
			var local = $(this).attr('href').split('/');
			var global = jQuery.url.attr('path').split('/');
			var global2 = global[1].split('.');
			if(global2 == 'pl' || global2 == 'en'){
				local = local[2].split('.');
				global = global[2].split('.');
				if(local[0] == global[0]){
					$(this).parent().addClass('active');
				}
			}else if(global2[0] != 'pl'){
				local = local[1].split('.');
				global = global[1].split('.');
				if(local[0] == global[0]){
					$(this).parent().addClass('active');
				}
			}
		}
	});
	$('ul.produkty_panel a').each(function(){
		if($(this).attr('href') != '#'){
			var local = $(this).attr('href');//.split('/');
			var global = jQuery.url.attr('path');//.split('/');
			if(local == global){
				$(this).parents('li').addClass('active');
			}
		}
	});

	$('td.pics a, td.miniaturka a').not('.smallkup').fancybox({
		padding: 0,
		titlePosition 	: 'over',
		hideOnContentClick: true,
		onStart : function(){$('#cycle').cycle('pause');},
		onClosed : function(){$('#cycle').cycle('resume');}
	});

	$("img.rounded10px.size1").each(function() {
		$(this).wrap(function(){
			return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: 168px; height: 225px;" />';
		});
		$(this).css("opacity","0");
	});

	$("img.rounded10px.size2").each(function() {
		$(this).wrap(function(){
			return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: 690px; height: 200px;" />';
		});
		$(this).css("opacity","0");
	});

	$("img.rounded10px.size3").each(function() {
		$(this).wrap(function(){
			return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: 150px; height: 120px;" />';
		});
		$(this).css("opacity","0");
	});

	$("img.rounded10px.size4").each(function() {
		$(this).wrap(function(){
			return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: 80px; height: 108px;" />';
		});
		$(this).css("opacity","0");
	});

	$('ul li:last-child').addClass('last-child');
	$('p.stronnicowanie a:first-child').each(function(){
		if(isNaN($(this).text())){
			$(this).addClass('prev');
		}
	});
	$('p.stronnicowanie a:last-child').each(function(){
		if(isNaN($(this).text())){
			$(this).addClass('next');
		}
	});

	$('#basket_wrap.full').hover(
		function(){
//			$('#langbox').hide('fast');
			clearTimeout(baskettimeout);
			$(this).stop().animate({
				width:'250px'
			});
		},function(){
//			$('#langbox').show('fast');
			$(this).stop().animate({
				width:'127px'
			});
		});

});
// taken from Lukasz Lach devblog - http://anakin.us
function om(m){
	t='';
	for(i=m.length-1;i>=0;i--)if(m.charAt(i)=='*')t+='@';else t+=m.charAt(i);document.write('<a href="mailto:'+t+'" title="'+t+'">'+t+'</a>');
}
