	function mycarousel_initCallback(carousel)
	{
		carousel.buttonNext.bind('click', function() {carousel.startAuto(0);});
	
		carousel.buttonPrev.bind('click', function() {carousel.startAuto(0);});
	
		carousel.clip.hover(function() {carousel.stopAuto();}, function() {carousel.startAuto();});
	};
	
	jQuery.easing['EaseInOutCirc'] = function(s, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	};
	
	$(function() {
		$('#brands').jcarousel({
			vertical: true,
			auto: 5,
			scroll: 1,
			wrap: 'last',
			easing: 'EaseInOutCirc',
			animation: 1200,
			initCallback: mycarousel_initCallback
			});
	});

$(function(){
	$('a.external_link').attr("target", "_blank");
});

/*sucker fish menu init*/
jQuery(function(){
	jQuery('#topMenu ul').superfish({
		autoArrows:  false,
		animation:   {height:'show'},
		speed:       'fast',
		dropShadows:  false 
	}).find('ul').bgIframe({opacity:0});
});

$(document).ready(function(){
		
	//Remove outline from links
	$("a").click(function(){
		$(this).blur();
	});
	
	//When mouse rolls over
	$("#flyout ul li").hover(function(){
		$(this).find(".flyCont").stop().animate({height:'106px'},{queue:false, duration:600, easing: 'easeOutQuart'})
		$(this).find("a.menuLink").addClass("opened")
		if ($(this).index() == 0){
			$('#loginLink').addClass("shade")
		} else {
			$('#cartLink').addClass("shade")
		}
	}, function(){
		$(this).find(".flyCont").stop().animate({height:'0px'},{queue:false, duration:200, easing: 'easeOutCirc'})
		$(this).find("a.menuLink").removeClass("opened")
		if ($(this).index() == 0){
			$('#loginLink').removeClass("shade")
		} else {
			$('#cartLink').removeClass("shade")
		}
	});
	
});

/*replacing tag <hr> with stylable div*/
$(function(){
	$(".weditor").find("hr").wrap('<div class="fakeHr"></div>')
});
/*add alt text under image in weditor*/
$(function(){
	var imgAlt
	var imgWidth
	$('.weditor img.fleft').wrap('<div class="img-border-left"></div>')
	$('.weditor img.fright').wrap('<div class="img-border-right"></div>')
	
	$('.weditor img.fleft, .weditor img.fright').each(function (i){
		i = i+1;
		$(this).addClass("imgAlts"+i);
		imgAlt = $('.weditor .imgAlts'+i).attr("alt")
		imgWidth = $(this).width() + 8;
		$(this).parent().css('width', imgWidth + "px");
		if ($(this).attr("alt").length > 0){
			$(".weditor .imgAlts"+i).after("<p>" +imgAlt+ "</p>");
		}
	});
});
$(function(){
	bgImageTotal=7;
	randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1;
	imgPath=('/web/reklamnimlsani/images/Main_header'+randomNumber+'.jpg');
	$('#header').css("background",'url("'+imgPath+'")');
});

