/* CORE AJAX  */
function vytvorXMLHttpRequest2(handler) {
  //var xmlHttp=null
  if (window.XMLHttpRequest) {
    xmlHttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (error) {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}
/*  //END CORE AJAX */

function prepocitej_cenu_vstupenky(pocet) {

  var vysledna_cena = document.getElementById('vysledna_cena');
  //inicializace dat
  vysledna_cena.value = 0;
  
  for (i = 1; i <= pocet; i++) {
    var cena = parseFloat(document.getElementById('cena_vstupenky_kultura_'+i).value);
    var pocet_vstupenek = parseInt(document.getElementById('pocet_'+i).value);
    var vysledek = document.getElementById('vysledna_cena_vstupenek_'+i);
    
    vysledek.value = cena * pocet_vstupenek;
    vysledna_cena.value = parseFloat(vysledna_cena.value) + parseFloat(vysledek.value);
  }
  
  return true;
}

/**** vyzdoba ****/

function zobraz_variantu_vyzdoby(varianta) {
  var xmlHttp = vytvorXMLHttpRequest2();

  xmlHttp.onreadystatechange = function () {
    vrat_variantu_vyzdoby();
  };
  //xmlHttp.open('GET','/aridareal.cz/exec/ajax-vrat-clanek-vyletu.php?clanek='+clanek,true);
  //xmlHttp.open('GET','/aridareal.cz/trunk/exec/ajax-vrat-clanek-vyletu.php?clanek='+clanek,true);
  xmlHttp.open('GET','/exec/ajax-vrat-variantu-vyzdoby.php?typ='+varianta,true);
  xmlHttp.send(null);
}

function vrat_variantu_vyzdoby() {
  if (xmlHttp.readyState == 4) {
    if (xmlHttp.status == 200) {
    
      //var cf = 0;
      if (document.body) {
        y = document.body.scrollTop;
        //cf = -1;
      } else if (self.pageYOffset) {
    		y = self.pageYOffset;
    		//cf = 1;
    	} else if (document.documentElement && document.documentElement.scrollTop) {
    		y = document.documentElement.scrollTop;
    		//cf = 2;
    	} else if (document.body) {
    		y = document.body.scrollTop;
    		//cf = 3;
    	}
    	
    	//alert(cf);
    
    
      var add_text = '<a href="" onclick="return zavri_okno_clanku();" class="a_article_window_close">zavøít</a>';
      var start_article = '<div class="article_text">';
      var end_article = '</div>';
      //location.href= 'mailto:' + xmlHttp.responseText;
      //document.write('mailto:' + xmlHttp.responseText);
      document.getElementById('article_window').innerHTML = add_text + start_article + xmlHttp.responseText + end_article;
      document.getElementById('article_window').style.top = (y + 80) + 'px';
      document.getElementById('article_window').style.display = 'block';
      
      document.getElementById('flash_banner_preprava_osob').style.visibility = 'hidden';
    } else {
      alert('UNCRIPTED ERROR 0x458');
    }
  }
}


/**** clankyk k vyletu ****/

function zobraz_clanek_vyletu(clanek) {
  var xmlHttp = vytvorXMLHttpRequest2();

  xmlHttp.onreadystatechange = function () {
    vrat_clanek_vyletu();
  };
  //xmlHttp.open('GET','/aridareal.cz/exec/ajax-vrat-clanek-vyletu.php?clanek='+clanek,true);
  //xmlHttp.open('GET','/aridareal.cz/trunk/exec/ajax-vrat-clanek-vyletu.php?clanek='+clanek,true);
  xmlHttp.open('GET','/exec/ajax-vrat-clanek-vyletu.php?clanek='+clanek,true);
  xmlHttp.send(null);
}

function vrat_clanek_vyletu() {
  if (xmlHttp.readyState == 4) {
    if (xmlHttp.status == 200) {
    
      //var cf = 0;
      if (document.body) {
        y = document.body.scrollTop;
        //cf = -1;
      } else if (self.pageYOffset) {
    		y = self.pageYOffset;
    		//cf = 1;
    	} else if (document.documentElement && document.documentElement.scrollTop) {
    		y = document.documentElement.scrollTop;
    		//cf = 2;
    	} else if (document.body) {
    		y = document.body.scrollTop;
    		//cf = 3;
    	}
    	
    	//alert(cf);
    
    
      var add_text = '<a href="" onclick="return zavri_okno_clanku();" class="a_article_window_close">zavøít</a>';
      var start_article = '<div class="article_text">';
      var end_article = '</div>';
      //location.href= 'mailto:' + xmlHttp.responseText;
      //document.write('mailto:' + xmlHttp.responseText);
      document.getElementById('article_window').innerHTML = add_text + start_article + xmlHttp.responseText + end_article;
      document.getElementById('article_window').style.top = (y + 80) + 'px';
      document.getElementById('article_window').style.display = 'block';
      
      document.getElementById('flash_banner_preprava_osob').style.visibility = 'hidden';
    } else {
      alert('UNCRIPTED ERROR 0x458');
    }
  }
}

/**** pronajem limuzin s ridicem ****/

function zobraz_clanek_limuziny(clanek) {
  var xmlHttp = vytvorXMLHttpRequest2();

  xmlHttp.onreadystatechange = function () {
    vrat_clanek_limuziny();
  };
  //xmlHttp.open('GET','/aridareal.cz/exec/ajax-vrat-ponajem-limuzin.php?clanek='+clanek,true);
  //xmlHttp.open('GET','/aridareal.cz/trunk/exec/ajax-vrat-ponajem-limuzin.php?clanek='+clanek,true);
  xmlHttp.open('GET','/exec/ajax-vrat-ponajem-limuzin.php?clanek='+clanek,true);
  xmlHttp.send(null);
}

function vrat_clanek_limuziny() {
  if (xmlHttp.readyState == 4) {
    if (xmlHttp.status == 200) {

      //var cf = 0;
      if (document.body) {
        y = document.body.scrollTop;
        //cf = -1;
      } else if (self.pageYOffset) {
    		y = self.pageYOffset;
    		//cf = 1;
    	} else if (document.documentElement && document.documentElement.scrollTop) {
    		y = document.documentElement.scrollTop;
    		//cf = 2;
    	} else if (document.body) {
    		y = document.body.scrollTop;
    		//cf = 3;
    	}

    	//alert(cf);


      var add_text = '<a href="" onclick="return zavri_okno_clanku();" class="a_article_window_close">zavøít</a>';
      var start_article = '<div class="article_text">';
      var end_article = '</div>';
      //location.href= 'mailto:' + xmlHttp.responseText;
      //document.write('mailto:' + xmlHttp.responseText);
      document.getElementById('article_window').innerHTML = add_text + start_article + xmlHttp.responseText + end_article;
      document.getElementById('article_window').style.top = (y + 80) + 'px';
      document.getElementById('article_window').style.display = 'block';
      
      document.getElementById('flash_banner_preprava_osob').style.visibility = 'hidden';

    } else {
      alert('UNCRIPTED ERROR 0x458');
    }
  }
}

/*** clanek recenze ***/
function zobraz_clanek_recenze(clanek, barva) {
  var xmlHttp = vytvorXMLHttpRequest2();

  xmlHttp.onreadystatechange = function () {
    vrat_clanek_recenze(barva);
  };
  xmlHttp.open('GET','/exec/ajax-vrat-recenze.php?clanek='+clanek,true);
  //xmlHttp.open('GET','/aridareal.cz/trunk/exec/ajax-vrat-ponajem-limuzin.php?clanek='+clanek,true);
  //xmlHttp.open('GET','/exec/ajax-vrat-ponajem-limuzin.php?clanek='+clanek,true);
  xmlHttp.send(null);
}

function vrat_clanek_recenze(barva) {
  if (xmlHttp.readyState == 4) {
    if (xmlHttp.status == 200) {

      //var cf = 0;
      if (document.body) {
        y = document.body.scrollTop;
        //cf = -1;
      } else if (self.pageYOffset) {
    		y = self.pageYOffset;
    		//cf = 1;
    	} else if (document.documentElement && document.documentElement.scrollTop) {
    		y = document.documentElement.scrollTop;
    		//cf = 2;
    	} else if (document.body) {
    		y = document.body.scrollTop;
    		//cf = 3;
    	}

    	//alert(cf);


      var add_text = '<a href="" onclick="return zavri_okno_recenze();" class="a_article_window_close">zavøít</a>';
      var start_article = '<div class="article_text_recenze">';
      var end_article = '</div>';

      //document.getElementById('article_window_recenze').style.background = '#54aaad';
      document.getElementById('article_window_recenze').className = barva + '_window';
      //location.href= 'mailto:' + xmlHttp.responseText;
      //document.write('mailto:' + xmlHttp.responseText);
      document.getElementById('article_window_recenze').innerHTML = add_text + start_article + xmlHttp.responseText + end_article;
      document.getElementById('article_window_recenze').style.top = (y + 40) + 'px';
      document.getElementById('article_window_recenze').style.display = 'block';

      //document.getElementById('flash_banner_preprava_osob').style.visibility = 'hidden';

    } else {
      alert('UNCRIPTED ERROR 0x458');
    }
  }
}
/**** other ****/

/**** other ****/


function zavri_okno_clanku() {
  document.getElementById('article_window').style.display = 'none';
  document.getElementById('article_window').innerHTML = '';
  document.getElementById('flash_banner_preprava_osob').style.visibility = '';
  return false;
}

function zavri_okno_recenze() {
  document.getElementById('article_window_recenze').style.display = 'none';
  document.getElementById('article_window_recenze').innerHTML = '';
  return false;
}

