// JavaScript Document
// Author: www.flipcom.cz

var STEP = 18;
var DELAY = 10;

var interval;
var pageWidth;
var pageHeight;
var imgInCenter;
var bannerLeft;

var bannerWidth;
var bannerObj;

function init() {
  bannerObj = document.getElementById("slideBanner");
  bannerWidth = parseInt(bannerObj.style.width);
  
  if (typeof(window.innerWidth) == 'number') { // Non-IE browser
    pageWidth = window.innerWidth;
    pageHeight = window.innerHeight;
  } else if( document.documentElement && (document.documentElement.clientWidth || 
      document.documentElement.clientHeight )) { // IE 6+
    pageWidth = document.documentElement.clientWidth;
    pageHeight = document.documentElement.clientHeight;
  }
  
  imgInCenter = Math.round((pageWidth / 2) - (bannerWidth / 2));
  imgInCenter -= 40;
  
  bannerLeft = -bannerWidth;
  bannerObj.style.left = bannerLeft + "px";
     
  bannerObj.style.top = 137 + "px";
  bannerObj.style.display = "inline";
}

function move(step) {
  bannerLeft += step;
  bannerObj.style.left = bannerLeft + "px"; 
}

function show() {
  if (bannerLeft >= imgInCenter) {
    stop(); 
  }
  move(STEP);  
}

function hide() {
  if (bannerLeft < -bannerWidth) {
    bannerObj.style.display = "none";
    stop();
  }
  move(-STEP);
}

function start() {
  init();
  interval = setInterval('show()', DELAY);
}

function kill() {
  interval = setInterval('hide()', DELAY);
}

function stop() {
  clearInterval(interval);
}

window.onresize = function() {
  init();
}    
          
