rotating_images = new Array();

//Duplicate these lines here to add new images to the rotation.

var active_image_delay = 3; //in seconds

var active_image_index = 0;

function rotateImages() {

  //Ensure routine runs only if my_images exists on the page.
  if (!document.getElementById('my_images') || rotating_images.length < 1) return;
  var new_image_code = '';

  new_image = document.createElement('IMG');
  new_image.src = rotating_images[active_image_index].image;
  new_image.border = "0";

  new_link = document.createElement('A');
  new_link.href = rotating_images[active_image_index].url;

  new_link.appendChild(new_image);


  if (document.getElementById('my_images').hasChildNodes() ) {
    while (document.getElementById('my_images').childNodes.length >= 1 ) {
      document.getElementById('my_images').removeChild(document.getElementById('my_images').firstChild );
    }
  }

  document.getElementById('my_images').appendChild(new_link);

  active_image_index = (active_image_index+1)%rotating_images.length;

  setTimeout('rotateImages();',active_image_delay*1000);
}
function RotatingImage (image_url, url) {
  this.image = image_url;
  this.url = url;
}

function generate_price(id_language) {
var oMiesto = document.getElementById('miesto');
var oVaha = document.getElementById('vaha');
var oPrice_content = document.getElementById('generate_price_content');
var price;
var price_city;

var city = cennik[oMiesto.options[oMiesto.selectedIndex].value].split("|");

//if ( oVaha.value == 1 ) {
//price = (oMiesto.options[oMiesto.selectedIndex].value*1) * (oVaha.value*1);
//  price_city = city[2];
//} else 
if ( oVaha.value <= 80 ) {
  price_city = city[3];
} else if (  oVaha.value > 80 && oVaha.value <= 160 ) {
  price_city = city[4];
} else if ( oVaha.value > 160 ) {
  price_city = city[5];
}
price = ((price_city*1) * (oVaha.value*1))*100;
price = Math.round(price)/100;
var txt;
if ( price < 25 ) {price = 25}
if (id_language==2) {
    txt = '<font size="2" color="#004785">Cena prepravn&eacute;ho do mesta <font size="3" color="#e26719"><strong>'+oMiesto.options[oMiesto.selectedIndex].innerHTML+'</strong></font> pri hmotnosti <font size="3" color="#e26719"><strong>'+ oVaha.value +'kg</strong></font><br />';
    txt = txt + 'je</font> <font size="4"><font size="3" color="#e26719"><strong>&pound; '+ price +'</strong></font>.</font><font size="2"> ';
    txt = txt + '<br />';
    txt = txt + '<font color="#004785">Cena za jeden kilogram z/do mesta '+oMiesto.options[oMiesto.selectedIndex].innerHTML+' je &pound; '+ price_city +'.</font>';
} else {
    txt = '<font size="2" color="#004785">Cena prepravn&eacute;ho do mesta <font size="3" color="#e26719"><strong>'+oMiesto.options[oMiesto.selectedIndex].innerHTML+'</strong></font> pri hmotnosti <font size="3" color="#e26719"><strong>'+ oVaha.value +'kg</strong></font><br />';
    txt = txt + 'je</font> <font size="4"><font size="3" color="#e26719"><strong>&pound; '+ price +'</strong></font>.</font><font size="2"> ';
    txt = txt + '<br />';
    txt = txt + '<font color="#004785">Cena za jeden kilogram z/do mesta '+oMiesto.options[oMiesto.selectedIndex].innerHTML+' je &pound; '+ price_city +'.</font>';
} 
oPrice_content.innerHTML = txt;

}

function generate_combo () {
  var oMiesto = document.getElementById('miesto_td');
	var option = '<option>vyberte si miesto</option>';
  for (i in cennik) {
  		value = cennik[i].split("|");
      option += '<option value="'+value[0]+'">'+value[1]+'</option>';
  }
  oMiesto.innerHTML = '<select name="miesto" id="miesto">' + option + '</select>'; 
}