
var BASE_HREF = BASE_HREF || '../';

$(document).ready(function(){

    function left(obj){
        var img = obj;
        var time = (img.width()-el.width()) + parseInt(img.css('left'));
        img.animate({
            'left': '-'+ (img.width()-el.width()) +'px'
        }, time*70, 'linear', function(){setTimeout(function(){right(img)}, 2000)});
    }

    function right(obj){
        var img = obj;
        var time = (img.width()-el.width());
        img.animate({
            'left': '0px'
        }, time*70, 'linear', function(){setTimeout(function(){left(img)}, 2000)});
    }

    function preload(e){
        var img = $(e.target)
        $('#header').prepend(el);
        img.css({
            'position': 'relative',
            'top': '0px',
            'left': -(img.width() - el.width()) / 2 + 'px'
        });
        left(img);
    }

    var el = $('<div class="panorama"></div').css({'overflow':'hidden', 'position': 'absolute', 'top': '0', 'left': '1px', 'z-index':'1', 'width':'958px'});
        el.append('<img src="'+BASE_HREF+'img/motives/panorama.jpg" alt="">');
    $('img', el).bind('load', preload);


	if($.fn.cycle) $('.partners-box div').cycle({
		speed:  1000,
		timeout: 6000,
		pause: 1
	});

	$.fn.kfBox && $('.lightbox, .related-images a').kfBox();


});

