var start = document.cookie.indexOf(cookieName);
if (start == -1){
  var cookieName = 'roStat';
  document.cookie = cookieName+'='+screen.colorDepth+"|"+screen.width+'; path=/';
}

function changeClass (elem) {
  if (elem.className != 'elemh') {
    elem.className="elemv";
  } else {
    elem.className="elemh";
  }
}

function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
	map.setCenter(new GLatLng(50.084849, 19.903107), 15);
	map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new GScaleControl());
	var marker = new GMarker(new GLatLng(50.083849, 19.901900)); // obiekt szpilki
	map.addOverlay(marker); // postawienie szpilki na mapie
	var info =  "<b>ROBOBAT Polska Sp. z o.o.</b><br>ul. Radzikowskiego 47A<br>31-315 Krak&#243w";
 	GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(info);});
 	map.addOverlay(marker);

 }}

function changepane (paneno,time) {
 
  for(var i = 0; i < 1; i++) {
    tab = document.getElementById('tab'+(i+1)); 
    pane = document.getElementById('pane'+(i+1)); 
    if (i+1 == paneno) {
      tab.className = 'tabact';
      pane.className = 'elemv';
    } else {
      tab.className = 'tab';
      pane.className = 'elemh';
    }
  }
  
}

var histold = 1;

function histshow(nr) {
  nr = parseFloat(nr);

  if (histold != nr) {
    tab_new = document.getElementById('histtab_'+nr);
    pan_new = document.getElementById('hist_'+nr);
    
    tab_new.className = 'histyearact';
    pan_new.className = 'histvisible';

    tab_old = document.getElementById('histtab_'+histold);
    pan_old = document.getElementById('hist_'+histold);
  
    tab_old.className = 'histyear';
    pan_old.className = 'histhidden';
  }
  histold = nr;
}

function putFlash( path, width, height) {
  document.write( "<object width=\""+ width +"\" height=\""+ height +"\" data=\""+ path +"\" type=\"application/x-shockwave-flash\">");
  document.write( "<param value=\""+ path +"\" name=\"movie\" />");
  document.write( "<param value=\"high\" name=\"quality\" />");
  document.write( "<param value=\"transparent\" name=\"wmode\" /></object>");
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

sfHover2 = function() {
	var sfEls = document.getElementById("nav_header").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover2);

function OpenVideo ( sPath, dx, dy, lang) {
  if(sPath.substring(0, 3)=="all") {
    if(sPath.split("_")[1]!="rcad") {
      var prod = sPath.split("_")[1];
    } else if(sPath.split("_")[1]=="rcad") {
      var prod = sPath.split("_")[1]+"_"+sPath.split("_")[2];
    }
    var name = sPath.split("/")[1];
    var sPath = prod+"/"+name;
  }
  var frm = document;
  var str = new String(document.URL);
  try {
    parent.window.external.ShellExecute('bin/CamPlay.exe', "/MX /M /T /S ../film_avi/"+lang+"/"+sPath+'.avi');
  } catch(er) {
    var oImgView = open("http://www.robotoffice.com/film_str/"+lang+"/0"+lang+"_player_swf.htm?"+sPath+','+dx +','+dy, '', 'Left = 0, Top = 0, Width = ' + dx + ', Height = ' + dy + ', ScrollBars = no, status=no, Toolbar = no, titlebar = no, resizable = no;');
    oImgView.focus();
  }
  return false;
}

function shDesc (elem) {
  var expanded = document.getElementById(elem); 
  if (expanded.className != 'sho_desc') {
    expanded.className="sho_desc";
  } else {
    expanded.className="hid_desc";
  }
}

function showDesc (elem) {
  var expanded = document.getElementById(elem); 
  expanded.className="sho_desc";
}

function hideDesc (elem) {
  var expanded = document.getElementById(elem); 
  expanded.className="hid_desc";
}

function updatestate(countryid) {
  var url = '/n/xml/regions/'+countryid;
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
      http_request.overrideMimeType('text/xml');
    }
  } else if (window.ActiveXObject) { // IE
    try {
      http_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
    }
  }
  if (!http_request) {
    alert('Giving up :( Cannot create an XMLHTTP instance');
    return false;
  }
  http_request.onreadystatechange = alertContents;
  http_request.open('GET', url, true);
  http_request.send(null);
}
function alertContents() {
  if (http_request.readyState == 4) {
    if (http_request.status == 200) {
      var xmldoc = http_request.responseXML;
      var root_node = xmldoc.getElementsByTagName('regions')[0];
      var opt = document.FormRegisterFreware.f_state.options;
      var sel = document.FormRegisterFreware.f_state;
      var selstate = document.FormRegisterFreware.f_stateid_h.value;

      var tmpArayVal = new Array(2);
      var tmpArayTxt = new Array(2);
      var l = opt.length;
      if (l > 0) {
        tmpArayVal[0] = opt[0].value;
        tmpArayTxt[0] = opt[0].text;

        tmpArayVal[1] = opt[l-1].value;
        tmpArayTxt[1] = opt[l-1].text;
        
      }

      opt.length=0;
      //opt.length++;
      opt[0]= new Option(tmpArayTxt[0],tmpArayVal[0]);
      for(var i = 0; i < root_node.childNodes.length; i++) {
        //opt.length++;
        opt[i+1]= new Option(root_node.childNodes[i].firstChild.nodeValue,root_node.childNodes[i].attributes[0].nodeValue);
        if (selstate == root_node.childNodes[i].attributes[0].nodeValue) opt[i+1].selected = true;
      }
      //opt.length++;
      opt[i+1]= new Option(tmpArayTxt[1],tmpArayVal[1]);
      document.FormRegisterFreware.f_stateoth.disabled = true;
      document.FormRegisterFreware.f_stateoth.value = '';
    } else {
      alert('There was a problem with the request.');
    }
  }
}
function othstate() {
  var opt = document.FormRegisterFreware.f_state.options;
  if (opt[document.FormRegisterFreware.f_state.selectedIndex].value == "00") {
    document.FormRegisterFreware.f_stateoth.disabled = false;
    document.FormRegisterFreware.f_stateoth.focus();
  } else {
    document.FormRegisterFreware.f_stateoth.disabled = true;
    document.FormRegisterFreware.f_stateoth.value = '';
  }
}

function ukryj (x)
{
   _txt = document.getElementById(x);
   
   if (_txt.className=="widoczny")
   {
      _txt.className="ukryty";
   } 
   else
   { 
      _txt.className="widoczny";
   } 
}

function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}

function openWindow(url,windowName,width,height) {
  parameters = "width=" + width + ",height=" + height + "toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes";
  window.open(url,windowName,parameters);
}
function okno() {
	window.open('/prezentacje.html','Certyfikat Energetyczny','toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes, width=800,height=600');
}

function pytanie(url,message) {
    var where_to= confirm(message);
    if (where_to== true) {
      window.location = url
    } else {
      return;
    }
}

function pytanie_submit(message) {
    var where_to= confirm(message);
    if (where_to== true) {
      document.admin.submit();
    } else {
      return;
    }
}


function setChkbox(theid){
 //document.getElementsByName(theid).style.backgroundColor = '#00ff00';
 document.getElementById(theid).style.backgroundColor = '#00ff00';
}

function adrive(){
	window.open('http://www.adrive.com','Adrive','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width=10,height=10');
	}

function cena(x)
{
var cena=document.getElementById(x).value;
  if (isNaN(cena)) {
  alert("Wprowadz odpowiednia kwote.");
  }
var okres=document.getElementById("okres").value;
var oplata=document.getElementById("wplata").value;
var rata=(parseFloat(cena)*1.17-(parseInt(cena)*(parseInt(oplata)/100)))/parseInt(okres);
document.getElementById("rata").innerHTML=rata.toFixed(2);
}

function przelicz()
{

  var cena=document.getElementById("cena").value;
  if (isNaN(cena)) {
  alert("Wprowadz odpowiednia kwote.");
  }
  
  var okres=document.getElementById("okres").value;
  var oplata=document.getElementById("wplata").value;
  var rata=(parseFloat(cena)*1.17-(parseInt(cena)*(parseInt(oplata)/100)))/parseInt(okres);
  document.getElementById("rata").innerHTML=rata.toFixed(2);
}
	
	
var timeout         = 1500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
