function printOrder(_url)
{/*   version 1.4.0.00 */
   printWindow = window.open(_url,
                       "printWindow","toolbar=0, location=0, status=1, resizable=1, menubar=1, "+
                       "scrollbars=1, width=750, height=540");
   printWindow.focus();
}

var i=1; // minimalni broj slika flasheva (koji su u divovima)
var timer = null;
var iBullet; // broj slike po redu
var bBullet; // broj prethodne slike
var moving = true; // da li se animacija zavrsila
var auto = true;

$(document).ready(function() {

        // Dodavanje dugmica - levo - desno -  pozicija slika
        // (U koliko ima vise od 2 banera)

        //alert($('#addons_home').children().length);

        if ($('#addons_home').children().length>2){
            $('#img_falsh_content').append('<div class="left_button" onclick="move(\'left\', \'\');"></div>');
            $('#img_falsh_content').append('<div class="right_button" onclick="move(\'right\', \'\');"></div>');
            $('#img_falsh_content').append('<div class="bullet_holder"></div>');

            for ( i ; i <= $('#addons_home').children().length ; ++i ){
                if ( i == 1 ) $('.bullet_holder').append('<div id="bullet_' + i + '" class="bullet active" onclick="move(\'none\', ' + i +');"></div>');
                else $('.bullet_holder').append('<div id="bullet_' + i + '" class="bullet" onclick="move(\'none\', ' + i +');"></div>');
            }
            --i;
        }

		iBullet = 1;

        $('.bullet_holder').width( i*20 + 'px');
		$('#addons_home').width( i*888 + 'px');

        // Pokretanje animacije sa timeoutom od 8 sec, ukoliko postoji
        // vise od jednog banera

		if ($('#addons_home').children().length>1) timer = setTimeout('auto_move()', 8000);
       
});

function auto_move(){
	if (moving && auto){
		auto = false;
		move('right');
	}
}

function move(direction, id){

	if (moving){
		//alert('pokrenut move' + direction + ' ' + id);
		moving = false;
		auto = false;
		if (direction == 'none'){
				if (iBullet < id) {
					var x = id - iBullet; //razlika izmedju pozicija
					var position = x*888;
					$('#addons_home').animate({
						left: '-=' + position
						}, 750, 'swing',function() {
							//postavi dugme da svetli plavo
							bBullet = iBullet;
							iBullet = id;
							$('#bullet_' +  iBullet).css('background','url(\'UI/Images/Content/blue.png\') no-repeat');
							$('#bullet_' +  bBullet).css('background','url(\'UI/Images/Content/red.png\') no-repeat');	
							moving = true;
							auto = true;
							if (timer) clearTimeout(timer);
							timer = setTimeout('auto_move()', 8000);
					});
				}
				if (iBullet > id) {
					var x = iBullet - id; //razlika izmedju pozicija
					var position = x*888;
					$('#addons_home').animate({
						left: '+=' + position
						}, 750, 'swing',function() {
							//postavi dugme da svetli plavo
							bBullet = iBullet;
							iBullet = id;
							$('#bullet_' +  iBullet).css('background','url(\'UI/Images/Content/blue.png\') no-repeat');
							$('#bullet_' +  bBullet).css('background','url(\'UI/Images/Content/red.png\') no-repeat');
							moving = true;
							auto = true;
							if (timer) clearTimeout(timer);
							timer = setTimeout('auto_move()', 8000);
					});
				}			
		}
		
		if (direction == 'right'){	
			//alert ($('#addons_home').position().left + ' ' + -$('#addons_home').width()+888);
			if ($('#addons_home').position().left == -($('#addons_home').width())+888) {
				iBullet = 1;
				$('#addons_home').animate({
					left: '+=' + ($('#addons_home').width()-888)
					}, 500, 'swing',function() {
						//postavi dugme da svetli plavo
						$('#bullet_' +  iBullet).css('background','url(\'UI/Images/Content/blue.png\') no-repeat');
						bBullet = i;
						$('#bullet_' +  bBullet).css('background','url(\'UI/Images/Content/red.png\') no-repeat');
						moving = true;
						auto = true;
						if (timer) clearTimeout(timer);
						timer = setTimeout('auto_move()', 8000);					
				});
				
			}
			else {
				iBullet++; 
				$('#addons_home').animate({
					left: '-=888'
					}, 1000,  'swing',function() {
					//postavi dugme da svetli plavo u zavisnosti od pozicije
					$('#bullet_' +  iBullet).css('background','url(\'UI/Images/Content/blue.png\') no-repeat');
					bBullet = iBullet - 1;
					$('#bullet_' +  bBullet).css('background','url(\'UI/Images/Content/red.png\') no-repeat');
					moving = true;
					auto = true;
					if (timer) clearTimeout(timer);
					timer = setTimeout('auto_move()', 8000);
				});
			}
			
		}
		
		if (direction == 'left'){
			if ($('#addons_home').position().left == 0) {
				iBullet = i;
				$('#addons_home').animate({
					left: '-='+($('#addons_home').width()-888)
					}, 500,  'swing',function() {
					//postavi dugme da svetli plavo
					$('#bullet_' +  iBullet).css('background','url(\'UI/Images/Content/blue.png\') no-repeat');
					bBullet = 1;
					$('#bullet_' +  bBullet).css('background','url(\'UI/Images/Content/red.png\') no-repeat');
					moving = true;
					auto = true;
					if (timer) clearTimeout(timer);
					timer = setTimeout('auto_move()', 8000);
				});
			}
			else {
				iBullet--; 
				$('#addons_home').animate({
					left: '+=888'
					}, 1000, 'swing',function() {
					//postavi dugme da svetli plavo u zavisnosti od pozicije
					$('#bullet_' +  iBullet).css('background','url(\'UI/Images/Content/blue.png\') no-repeat');
					bBullet = iBullet + 1;
					$('#bullet_' +  bBullet).css('background','url(\'UI/Images/Content/red.png\') no-repeat');
					moving = true;
					auto = true;
					if (timer) clearTimeout(timer);
					timer = setTimeout('auto_move()', 8000);
				});
			}		
		}
	}
}

