window.addEvent('domready', function(){	
		$$('.shop_error, .shop_warning, .shop_debug, .shop_critical, .shop_tip').addEvent('click', function(e){this.setStyle('left','-3000px')});
		setTimeout("$$('.shop_error, .shop_warning, .shop_debug, .shop_critical, .shop_tip').setStyle('left','-3000px')", 5000);

		$$('a.productTitle').each(function(item,index){
				item.setText( truncate(item.getText(), 33, true));
				//				alert('a');//				this.set('text','aaa');
			});
		if( !$chk($$('stranavirtuemart2')) ){
			window.scrollTo( 0,200 );
		}
			});



/* skroler za brendove */
window.addEvent('domready', function() {
		
	// project matrix and lightbox
	var widthproj = 120;				// total widht of every proejct item (incl. margin and borders)
	var scrollnumproj = 7;				// how many projects to scroll at once
	var scrolldiv1 = $('matrix1');		// id of the first element to scroll
	var lightboxop = 0.75;				// lightbox opacity
	
	// effects
	var slide1 = new Fx.Styles(scrolldiv1, {duration:600, wait:false, transition:Fx.Transitions.Back.easeOut});
	
	// actions to perform on page load
	slide1.start({
		'margin-left': 0
	});
	$('btn-next').setOpacity(0.5);
	$('btn-prev').setOpacity(0.5);
	
	// matrix buttons events
	$('btn-next').addEvent('click', function(event) {
// 			alert( scrolldiv1.getStyle('margin-left').toInt() );
// 			alert( (widthproj*numproj)-(widthproj*scrollnumproj));
		if(scrolldiv1.getStyle('margin-left').toInt() > 0-((widthproj*numproj)-(widthproj*scrollnumproj))) {
			var offset = scrolldiv1.getStyle('margin-left').toInt()-(widthproj*3/*scrollnumproj*/);
			slide1.start({
				'margin-left': offset
					});
		};
	});
	$('btn-next').addEvent('mouseover', function(event) {
		var fx = new Fx.Styles(this, {duration:600, wait:false, transition:Fx.Transitions.Quad.easeIn}).start({ 'opacity': 1 });
	});
	$('btn-next').addEvent('mouseout', function(event) {
		var fx = new Fx.Styles(this, {duration:600, wait:false, transition:Fx.Transitions.Quad.easeIn}).start({ 'opacity': 0.5 });
	});
	
	$('btn-prev').addEvent('click', function(event) {
		if(scrolldiv1.getStyle('margin-left').toInt() < 0) {
			var offset = scrolldiv1.getStyle('margin-left').toInt()+(widthproj*3/*scrollnumproj*/);
			slide1.start({
				'margin-left': offset
			});
		};
	});	
	$('btn-prev').addEvent('mouseover', function(event) {
		var fx = new Fx.Styles(this, {duration:600, wait:false, transition:Fx.Transitions.Quad.easeIn}).start({ 'opacity': 1 });
	});
	$('btn-prev').addEvent('mouseout', function(event) {
		var fx = new Fx.Styles(this, {duration:600, wait:false, transition:Fx.Transitions.Quad.easeIn}).start({ 'opacity': 0.5 });
	});

});


function truncate(el, max, atChar, trail){
    var s = el;//el.trim();
    if(s.length<1) return '';
    if(!$defined(max)) var max = 100;
      else max = max.toInt();
    if(!$defined(atChar)) var atChar=' '; // break at space
      else if(atChar == null) var atChar=false;
    if(!$defined(trail)) var trail = '...';

    if(s.length > max) {
        var i=0;
		s=s.slice(0,max);
        if(atChar){
            if((i = s.lastIndexOf(atChar)) != -1){
                s = s.substring(0, i);
            }else{
                s = s.substring(0, max);
            }
        }

        s += trail;
    }

    return s;
}


