// JavaScript Document

function AddFavorite(linkObj,addUrl,addTitle) {
  
  if (document.all && !window.opera) {
    window.external.AddFavorite(addUrl,addTitle);
    return false;
  }
  else if (window.opera && window.print) {
    linkObj.title = addTitle;
    return true;
  }
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) {
    if (window.confirm('Přidat oblíbenou stránku jako nový panel?'))
    {
      window.sidebar.addPanel(addTitle,addUrl,'');
      return false;
    }
  }
  window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
  return false;
}

function img_change( img , typ ) {
  
  var img;
  var typ;
  
  var detail_img = img.replace( typ , typ + '/detail/');

  document.getElementById('detail-hlavni').src= img;
  document.getElementById('detail-hlavni-href').href= detail_img;
  
}

function OpenWindow(file,xwidth,yheight,title,name){
  
  var yheight;
  var winl = (screen.width - xwidth) / 2;
  var wint = (screen.height - yheight) / 2;
  
  if(yheight > 650) {
    var a = window.open(file,name,"left="+winl+",top="+wint+",width="+xwidth+",height=650,scrollbars=yes,resizable=yes");
  }
  else {
    var a = window.open(file,name,"left="+winl+",top="+wint+",width="+xwidth+",height="+yheight);  
  }

  if (parseInt(navigator.appVersion) >= 4) { a.window.focus(); }
}


function posli_odkaz( server , url ) {
  
  var url;
  var server;
  OpenWindow(server+'modules/posli-odkaz.php?url='+url,400,350,'Pošli odkaz','odkaz');

}


function mapa( obrazek , udalost , server , typ ) {

  var obrazek;
  var udalost; 
  var vychozi;
  var typ;
  
  if(obrazek && udalost == 1) {
    document.getElementById('cr').src = server+"tmpl/images/mapa/"+typ+"/"+obrazek+".jpg";
  }
  else if(obrazek && udalost == 0){
    vychozi = document.getElementById('vychozi').value;
    document.getElementById('cr').src = server+"tmpl/images/mapa/"+typ+"/"+vychozi+".jpg";
  }
  
}


function preload_mapa( server , typ ) {
    
    var server;
    var typ;
    
    preload_kraj = new Image();

    kraj_url = new Array();
    kraj_url[0] = server+"tmpl/images/mapa/"+typ+"/praha.jpg";
    kraj_url[1] = server+"tmpl/images/mapa/"+typ+"/stredocesky.jpg";
    kraj_url[2] = server+"tmpl/images/mapa/"+typ+"/liberecky.jpg";
    kraj_url[3] = server+"tmpl/images/mapa/"+typ+"/ustecky.jpg";
    kraj_url[4] = server+"tmpl/images/mapa/"+typ+"/karlovarsky.jpg";
    kraj_url[5] = server+"tmpl/images/mapa/"+typ+"/kralovehradecky.jpg";
    kraj_url[6] = server+"tmpl/images/mapa/"+typ+"/pardubicky.jpg";
    kraj_url[7] = server+"tmpl/images/mapa/"+typ+"/olomoucky.jpg";
    kraj_url[8] = server+"tmpl/images/mapa/"+typ+"/plzensky.jpg";
    kraj_url[9] = server+"tmpl/images/mapa/"+typ+"/jihocesky.jpg";
    kraj_url[10] = server+"tmpl/images/mapa/"+typ+"/vysocina.jpg";
    kraj_url[11] = server+"tmpl/images/mapa/"+typ+"/moravskoslezsky.jpg";
    kraj_url[12] = server+"tmpl/images/mapa/"+typ+"/jihomoravsky.jpg";
    kraj_url[13] = server+"tmpl/images/mapa/"+typ+"/zlinsky.jpg";

    var i = 0;
    for(i=0; i<=13; i++)  {
      preload_kraj.src = kraj_url[i];
    }  
  
}

function financovani ( idp , server , cena ) {
  
  var idp;
  var server;
  var cena;
  
  OpenWindow(server+'modules/financovani.php?idp='+idp+'&cena='+cena,400,500,'Kalkulačka','kalkulacka');
  
}


function showFoto(id) {

  el = document.getElementById(id);
	
  if (el.style.display == 'none') {
		
    el.style.display = '';
		el = document.getElementById(id);
		
		tl1 = document.getElementById('zobrazit-foto');
		tl1.style.display = 'none';
		
		tl2 = document.getElementById('skryt-foto');
		tl2.style.display = '';		
	
  } else {
		
    el.style.display = 'none';
		el = document.getElementById(id);

		tl1 = document.getElementById('zobrazit-foto');
		tl1.style.display = '';

		tl2 = document.getElementById('skryt-foto');
		tl2.style.display = 'none';	

  }

}

/* by ascaria */
function vycentruj(co,sirka,vyska)
  {
  co2 = co
  myWidth = 0;
  myHeight = 0;
  if(typeof(window.innerWidth)=='number')
    {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    }
  else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    }
  else if(document.body && (document.body.clientWidth || document.body.clientHeight))
    {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    }
  //horni_okraj = Math.floor((myHeight-vyska)/2);
  horni_okraj = 77;
  levy_okraj = Math.floor((myWidth-sirka)/2);
  document.getElementById(co).style.margin = horni_okraj+'px 0px 0px '+levy_okraj+'px';
  }

function zobraz_akcni_nabidku()
  {
  document.getElementById('o_banner').style.display='block';
  }

function interstitial(soubor)
  {
  if(soubor==""){return false;}
  if(window.ActiveXObject)
    {
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
  else
    {
    httpRequest = new XMLHttpRequest();
    }
    httpRequest.open("GET", '/require/interstitial.php?soubor='+soubor, true);
    httpRequest.onreadystatechange= function () {processRequest(); } ;
    httpRequest.send(null);
  }

function processRequest()
  {
  if(httpRequest.readyState == 4)
    {
    if(httpRequest.status == 200)
      {
      document.getElementById("o_banner").innerHTML = httpRequest.responseText;
      zobraz_akcni_nabidku();
      }
    else
      {
      alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
      }
    }
  }



