// JavaScript Document
function OtevriAkciHyundai()
  {
  window.open('/hyundai/nabidka.html', '', 'width=660,height=480,scrollbars=yes');
  }

function vypln_modely()
  {
  var znacka_vozu = document.forms['ppnv'].znacka_vozu.value;
  var zacatek_modely_selectu = '<select name="model_vozu" onchange="f_segmenty();f_zmen_model();">';
  var konec_modely_selectu = '</select> <span>&nbsp;</span>';
  document.getElementById('div_model_vozu').innerHTML = zacatek_modely_selectu+eval(znacka_vozu)+konec_modely_selectu;
  }

function zmen_obrazek(zdroj)
  {
  document.getElementById('detail_vozu_img').src=zdroj;
  }

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 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 show(id) {
	
  el = document.getElementById(id);
	
  if (el.style.display == 'none') {
		
    el.style.display = '';
		el = document.getElementById(id);
	
  } else {
		
    el.style.display = 'none';
		el = document.getElementById(id);
	
  }
}

var ajax = new Array();
var ajax_segmenty;

function ziskej_segmenty(model,post_segment_vozu)
  {
		ajax_segmenty = new sack();
		ajax_segmenty.requestFile = '/require/ajax-nacti-segmenty.php?model='+model;	// nastavime model
    ajax_segmenty.onCompletion = function() {	// Funkce ktera probehne po ziskani dat 
      zapis_segmenty(post_segment_vozu); 
     }
		ajax_segmenty.runAJAX();		// vykonani
  }
function zapis_segmenty(post_segment_vozu)
  {
  odpoved = ajax_segmenty.response;
  zapis_co = '<option value="vyberte_prosim">vyberte prosím</option>'
            +'<option value="nepreferuji konkrétní segment">nepreferuji konkrétní segment</option>'
            +odpoved+'';

  var zacatek_segmenty_selectu = '<select name="segment_vozu" onchange="zmen_segment();">';
  var konec_segmenty_selectu = '</select> <span>&nbsp;</span>';
  document.getElementById('div_segment_vozu').innerHTML = zacatek_segmenty_selectu+zapis_co+konec_segmenty_selectu;
  document.forms['ppnv'].segment_vozu.value = post_segment_vozu;
  }
function f_segmenty()
  {
  var delitel = document.forms['ppnv'].model_vozu.value.split(" ")[0];
  var model = document.forms['ppnv'].model_vozu.value.split(delitel+" ")[1];
  ziskej_segmenty(model,post_segment_vozu);
  }
function zmen_segment()
  {
  post_segment_vozu = document.forms['ppnv'].segment_vozu.value;
  }
function zmen_model()
  {
  document.forms['ppnv'].model_vozu.value = post_model_vozu;
  }
function f_zmen_model()
  {
  post_model_vozu = document.forms['ppnv'].model_vozu.value;
  }


function ziskejModely(idv) {
  if(idv.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'require/ajax-nacti-modely.php?idv='+idv;	// nastavime idv
		//alert(ajax[index].requestFile);
    ajax[index].onCompletion = function() {	// Funkce ktera probehne po ziskani dat 
      vytvorModely(index,idv) 
     }
		ajax[index].runAJAX();		// vykonani
	}
}

function vytvorModely(index,idv) {
	var obj = document.getElementById('model');
  document.getElementById('model').options.length = 1;	// vynulujeme select modelu
	eval(ajax[index].response);	// vyrizeni 	
}




function zobrazit_reklamu1()
  {
  document.getElementById('top_reklama1').style.display = 'block';
  document.getElementById('top_obal_zavrit1').style.display = 'block';
  }

function skryj_reklamu1()
  {
  document.getElementById('top_reklama1').style.display = 'none';
  document.getElementById('top_obal_zavrit1').style.display = 'none';
  }

