var x = -50;
var current = 1;
var max = 9;
var min = 1;
var stop = 0; 
function moveLeftBy(step) {
	if (current >= min) {
    slideLeft(step);
		current--;
	}
}

function slideLeft(step) {
	if (step > 0) {
  	tempstep = step-5;
  	if (step < 5) {
			if (x < -1) {
				x+=step;
			}
    }
    else {
			if (x < -1) {
				x+=5;
			}
		}
    document.getElementById("rightheader").style.backgroundPosition = x+"px -50px";
    setTimeout('slideLeft('+tempstep+')',1)
  }
 }

function moveRightBy(step) {
	if (current <= max) {
  	slideRight(step);
		current++;
	}
}

function slideRight(step) {
	if (step > 0) {
   tempstep = step-5;
 	if (step < 5) {
	 	if (x > -3700) {
			x-=step;
		}
   }
   else {
	 		if (x > -3700) {
				x-=5;
			}
		}
   document.getElementById("rightheader").style.backgroundPosition = x+"px -50px";
   setTimeout('slideRight('+tempstep+')',1)
 	}
}


var direction = 1;
function playSlideshow() {
  if (current > max) {
			current = max;
			direction = -1;
	}
	
	if (current < min) {
			current = min+1;
			direction = 1;
	}
  
  if (direction == 1) {
     moveRightBy(400);
  }
  if (direction == -1) {
     moveLeftBy(400);
  }
  
	if (stop == 0) {
		setTimeout("playSlideshow()", 7000);
	}
}

function setStop(n) {
	stop = n;
}



function addImagesInElement(eid) {
	var el = document.getelementById(eid);
	var images = el.getElementsByTagName("img");
	for(i=0; i < images.length; i++) {
		var _parent = images[i].parentNode;
		var inner_html = _parent.innerHTML;
		_parent.innerHTML='<a src="'+images[i].src+'" rel="lightbox[slike]">'+inner_html+'</a>';
	}	
}

