var xmlhttp;

function GetXmlHttpObject()
{
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    return new XMLHttpRequest();
  }
  if (window.ActiveXObject) {
    // code for IE6, IE5
    return new ActiveXObject("Microsoft.XMLHTTP");
  }
  return null;
}

function SimpleAjaxTask(url)
{
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; }
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

//  InnerHtmlAjaxTask
function InnerHtmlAjaxTask(html_id, url)
{
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; }
  
  xmlhttp.onreadystatechange= function(){InnerHtmlCallback(html_id);};
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}
function InnerHtmlCallback(html_id)
{
  if (xmlhttp.readyState==4) {
  
    var newdiv = document.createElement("div");
    newdiv.innerHTML = xmlhttp.responseText;
    var container = document.getElementById(html_id);
    if ( container.hasChildNodes() ) {
      while ( container.childNodes.length >= 1 )
      {
        container.removeChild( container.firstChild );       
      } 
    }   
    container.appendChild(newdiv);
  }
}

// Ajax Tasks
function bannerClick(id) {
  SimpleAjaxTask("ajax_operation.php?id="+id+"&op=banner_click");
}

function VoteYes(id) {
  var url="/ajax_operation.php";
  url=url+"?id="+id+"&vote=yes&op=polling";  
  InnerHtmlAjaxTask("polling", url);
}
function VoteNo(id) {
  var url="/ajax_operation.php";
  url=url+"?id="+id+"&vote=no&op=polling";  
  InnerHtmlAjaxTask("polling", url);
}
function VoteNo(id) {
  var url="/ajax_operation.php";
  url=url+"?id="+id+"&vote=no&op=polling";  
  InnerHtmlAjaxTask("polling", url);
}

function SwitchRideBrand(id) {
  var url="/ajax_xmloperation.php";        
  url=url+"?id="+id+"&op=ride_models";  

  var txt,xx,x,i;
  if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
  else
  {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {         
      var newOptValue, newOptText;
      var modelCombo=document.getElementById('model_combo');
      modelCombo.length = 0;
                                       
      x=xmlhttp.responseXML.documentElement.getElementsByTagName("model");
      for (i=0;i<x.length;i++) {   
        xx=x[i].getElementsByTagName("id");
        {
          try { newOptValue=xx[0].firstChild.nodeValue; }
          catch (er) { newOptValue=''; }
        }
        xx=x[i].getElementsByTagName("name");
        {
          try { newOptText=xx[0].firstChild.nodeValue; }
          catch (er) { newOptText=''; }
        }
         
        var newOpt = modelCombo.appendChild(document.createElement('option'));
        newOpt.text = newOptText;
        newOpt.value = newOptValue;
      }
    }
  }
  xmlhttp.open("GET",url,true);
  xmlhttp.send();
}

function changeContent(gdzie, w, h, path){
  var div = document.getElementById(gdzie);
  div.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+' id="flvplayer"  align="middle"><param name="movie" value="flvplayer.swf?link='+path+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="0" /><param name="allowScriptAccess" value="*" /><param name="salign" value="rb" /><embed src="flvplayer.swf?link='+path+'" width="'+w+'" height="'+h+'" quality="high" align="middle" allowScriptAccess="*" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="0" wmode="transparent" name="flvplayer"></embed></object>';
}

function changeContent2(id, gdzie, w, h, path) { 
  var div = document.getElementById(gdzie);
      div.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+' id="flvplayer"  align="middle"><param name="movie" value="flvplayer.swf?link='+path+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="0" /><param name="allowScriptAccess" value="*" /><param name="salign" value="rb" /><embed src="flvplayer.swf?link='+path+'" width="'+w+'" height="'+h+'" quality="high" align="middle" allowScriptAccess="*" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="0" wmode="transparent" name="flvplayer"></embed></object>';
  var url="/ajax_operation.php";
  url=url+"?id="+id+"&op=movie_description";  
  InnerHtmlAjaxTask("description", url);
}
function pokaz_film_zoom(co){
	document.getElementById('film_back').style.display='block';
	document.getElementById('film_zoom').style.display='block';
	document.getElementById('film_close').style.display='block';
	changeContent('film_zoom','800','600',co);
}
function ukryj_film_zoom(){
	
	document.getElementById('film_back').style.display='none';
	document.getElementById('film_zoom').style.display='none';
	document.getElementById('film_close').style.display='none';
}

