var isDOM = document.getElementById ? true : false;
var isIE4 = document.all ? true : false;
var isNS4 = document.layers ? true : false;

function getRef(name)
{
  if (isDOM) return document.getElementById(name);
  if (isIE4) return document.all[name];
  if (isNS4) return document.layers[name];
}
function getStyRef(ref) { return ((isNS4 || ref == null) ? ref : ref.style); }
function getSty(id) { return getStyRef(getRef(id)); };

function hyperlink(url) { window.location=url; }

pics = new Array();
var pocet = 0;
function preload(obrName) {
  pics[pocet] = new Array(1);
  pics[pocet][0] = new Image();
  pics[pocet][0].src = obrName;
  pocet++;
}

function check_pass()
{
	if(getRef('heslo1').value != getRef('heslo2').value)
	{
		alert('Hesla se neshodují!');
		return false;
	}
	else
		return true;
}

function galwin(cesta, x, y)
{
	var WindowName;
	var l = Math.floor( (screen.availWidth-10 - x) / 2 );
	var t = Math.floor( (screen.availHeight-20 - y) / 2 );
	WindowName = window.open('','_blank','toolbar=0,location=0,scrollbars=0,width='+x+',height='+y+',resizable=0,left='+l+',top='+t);
	if (WindowName)
	{
  	WindowName.document.open();
  	WindowName.document.write('<html><head><title>OutdoorInfo.cz</title></head>');
  	WindowName.document.write('<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><a href="javascript:window.close();" title="klikni pro uzavreni okna."><img src="'+cesta+'" border="0"></a>');
  	WindowName.document.write('</body></html>');
  	WindowName.document.close();
  }
}
function slov(url)
{
  var x = 650;
  var y = 550;

  var href = (typeof(url) == 'string') ? url : url.href;
 	var l = Math.floor( (screen.availWidth-10 - x) / 2 );
	var t = Math.floor( (screen.availHeight-20 - y) / 2 );
	return !window.open(href,'_blank',"toolbar=0,location=0,scrollbars=1,width="+x+",height="+y+",resizable=0,left="+l+",top="+t);
}

function targetBlank(url)
{
  var width = 800;
  var height = 600;
  var left = Math.floor( (window.screen.availWidth - 10 - width) / 2);
  var top = Math.floor( (window.screen.availHeight - 20 - height) / 2);
  var href = (typeof(url) == 'string') ? url : url.href;

	if (href != "")
	{
    var winParms = "screenX=" + left + ",screenY=" + top + ",top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
		return !window.open(href,'_blank', 'menubar=yes,toolbar=yes,location=yes,directories=no,fullscreen=no,titlebar=yes,hotkeys=yes,alwayslowered=no,status=yes,scrollbars=yes,resizable=yes,dependent=no,channelmode=NO,alwaysraised=yes,zlock=yes,'+winParms);
	}
}

function sw(id)
{
  menuItem = getSty(id);
  if (menuItem.display == 'none' || menuItem.display == '')
    menuItem.display = 'block';
  else
    menuItem.display = 'none';
  zobr = '';
  return false;
}

var zobr;
function sw1(target)
{
	if (zobr != target)
	{ //jinak se jen skryje
	  if (zobr) getSty(zobr).display="none";
	  zobr = target;
	  getSty(target).display="block";
	}
  return false;
}

var count_srovnani = 0;
function addVyrobek(checkBox)
{
  if (!checkBox.checked) count_srovnani--;

  if (count_srovnani >= 3)
  {
    alert('Srovnat lze pouze 3 výroby!');
    return false;
  }

  if (checkBox.checked) count_srovnani++;
  return true;
}

function printPage()
{
  window.print();
  return false;
}

function sendLink(odkaz)
{
 if (odkaz == '') odkaz = window.location.href;
 odkaz_string = new String(odkaz);

 odkaz_string = odkaz_string.replace('&', '%26');
 document.location = "mailto:?subject=Odkaz%20na%20Outdoorinfo.cz&body=Odkaz%20na%20server%20Outdoorinfo.cz%20:%0D%0A"+odkaz_string+"%0D%0AOutdoorinfo.cz";
 return false;
}

function mapaOver(jmeno, cislo)
{
  var krajNazev = getRef('krajNazev');
  if (krajNazev)
    krajNazev.innerHTML = jmeno;

  var mapaCRSK = getRef('mapaCRSK');
  if (mapaCRSK)
    mapaCRSK.src = '/img/prodejny/CRSKmapa' + cislo + '.png';
}

function mapaOut()
{
  getRef('krajNazev').innerHTML = '&nbsp;';
  getRef('mapaCRSK').src = '/img/prodejny/CRSKmapa.png';
}

function preloadMapa()
{
  preload('/img/prodejny/CRSKmapa.png');
  for (i = 0; i<23; ++i )
  {
    preload('/img/prodejny/CRSKmapa' + i + '.png');
  }
}

var slideShow = true;
var timeToShow = 7;
function uvodTema(obrazek, url, nazev)
{
  temaUvod1 = getRef('flash');
  temaUvod1.href = url;
  temaUvod1Style = getStyRef(temaUvod1);
  temaUvod1Style.backgroundImage = 'url(' + obrazek + ')';
//  temaUvod1.innerHTML = nazev + ' ///';
}

var iCountPicture = 0;
function startSlideShow()
{
  if (slideShow) {
    iCountPicture++;
    if (iCountPicture == inputPicture.length) iCountPicture = 0

    uvodTema('/img/tema_uvod/' + inputPicture[iCountPicture], inputUrl[iCountPicture], inputNazev[iCountPicture]);
  }
  setTimeout(startSlideShow, timeToShow * 1000);
}

window.onload =  function() {
  if (getRef('flash') != null && typeof(inputPicture) != 'undefined') {
    startSlideShow();
  }
}