function showhide(objectid) {
		
	var obj=document.getElementById("objectid");
	var status_now=obj.style.display;
		
	if (status_now=="block") {
		status_now='none'; 
	}
	else {
		status_now='block'; 
	}
		
	obj.style.display=status_now;
}


function changeimg(oclicked,text){
 oclicked.src=text;
}
function TAZ()
{
 win = window.open(	"finishing_vzory.php?show=0","CobraTuning","width=600, height=650, toolbar=no, scrollbars=no")
}
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
function showHideContent(co,position,where)
{
	var dots = new Array(); 
	dots[0] = new Image(10,10);
	dots[0].src = "images/buttons/plus.gif";
	dots[1] = new Image(10,10);
	dots[1].src = "images/buttons/minus.gif";
	var oContent = document.all.item(co);
 	if (!oContent) return;
 	if (oContent.style.display == "" || oContent.style.display == "block")
 	{
		oContent.style.display = "none";
		eval("document." + where + ".style.visibility='visible'");
		eval("document." + position + ".src=dots[0].src");
	}
	else
	{
		oContent.style.display = "block";
		eval("document." + where + ".style.visibility='hidden'");
		eval("document." + position + ".src=dots[1].src");
	}
	var myCookie = oContent.id;
	var myName = oContent.style.display;
	//writeCookie(myCookie, myName, 24);	
}
function writeLayer(div) {
	//var Visibility = readCookie(div);
	//alert(Visibility);
	//var Visibility = "hidden";	
	if(div != "")
	{
	var Visibility = "none";
	var Layer = "<DIV id='"+div+"' style='display:"+Visibility+"'>";
	}
	return Layer;
}
function goToURL(dest, sirka, vyska, meno){
var left = (screen.width/2) - sirka/2;
var top = (screen.height/2) - vyska/2;
var fileStr="img.php?obrazok="+dest;
var styleStr="width="+sirka+",height="+vyska+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left="+left+",top="+top;
var nameStr=meno;
window.open(fileStr, nameStr, styleStr);
}
function opencenteredwin(URL, sirka, vyska, meno){
var left = (screen.width/2) - sirka/2;
var top = (screen.height/2) - vyska/2;
var styleStr="width="+sirka+",height="+vyska+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left="+left+",top="+top;
var nameStr=meno;
fwin=window.open(URL, nameStr, styleStr);
fwin.focus();
}
function detail()
{
	url="img.php?obrazok=images/prototypes/diplom.jpg";
	window.open(url,"Nove","height=595,width=820,top=0,left=0");
}

function popup_news()
{
	url="popup.php";
	window.open(url,"popup","height=240,width=320,top=100,left=100,resizeable=no,toolbar=no,status=no,menubar=0,scrollbars=0");
}

function popup_eshop()
{
	url="popup_zrkadla.html";
	window.open(url,"Nove3","height=250,width=250,top=50,left=50");
}

function verify()
{
   prihlasit.submit();
}

function send_form()
{
   send.submit();
}

function forward()
{
	window.location.href = "news.php"; 
}

function okno_wall(path, name, img, sirka, vyska)
{
	path_full=path + name + img;
	url="img.php?obrazok="+path_full;
	window.open(url,"Nove","width="+sirka+" height="+vyska+" top=0,left=0");
	
}

function showmenu(elmnt)
{
document.all(elmnt).style.visibility="visible"
}
function hidemenu(elmnt)
{
document.all(elmnt).style.visibility="hidden"
}

function gettip(txt)
{
document.getElementById('tip').innerHTML=txt
}

function reset()
{
document.getElementById('tip').innerHTML=""
}

function startInterval()
{
    interval = window.setInterval("tTimer()",3000);
}

function tTimer()
{
	objShow('obrazok',false);
}

function objShow (obj,on) 
{
return objSetStyle(obj,'visibility',(on) ? 'visible':'hidden');
}

function objSetStyle (obj,prop,val) 
{
	var o = objGet(obj);
	if (o && o.style) {
		eval ('o.style.'+prop+'="'+val+'"');
		return true;
		}
	else return false;
}
	
function objGet(x) 
{
	if (typeof x != 'string') return x;
	else if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);  
	else return null;
}

function show_km()
{
var mil = document.distin_mile.mile_km.value
var dist = (mil * 1.61)
document.distin_mile.km.value = dist
}

function show_mile()
{
var km = document.distin_km.km_mile.value
var dist = (km * 0.6211)
document.distin_km.mil.value = dist

}

function show_ps()
{
var kw = document.distin_ps.kw1.value
var dist = Math.ceil(kw*1.359622-0.5)
document.distin_ps.ps1.value = dist
}

function show_kw()
{
var ps = document.distin_kw.ps2.value
var dist = Math.ceil(ps*0.735499-0.5)
document.distin_kw.kw2.value = dist
}

function getImageName(name)
{
		
		var fulldata=unescape(window.location.search);
		var startOfImageName=fulldata.indexOf(name);
		
	if(startOfImageName != -1)
	{
		var endOfImageName = fulldata.indexOf("&",startOfImageName+6);
		var imageName = fulldata.substring(startOfImageName+6,endOfImageName);
	}
	else
		imageName= "missing";
		return imageName;
}

var ConvertMe = new Array(0.0680460, 760, 1.333224/1000, 1e+03, 1e+02, 1e-03, 1e-03, 1e-03, 0.1450376264514975*1e+06);

	// Double the array; makes this easier.
	var ArrayLength = ConvertMe.length;
	for(count = 0;  count <= ArrayLength; count++)
		ConvertMe[count + ArrayLength] = ConvertMe[count];

function chkChar(evt)
{
	var charCode=evt.which; // For Netscape
	if (isNaN(charCode)) {charCode = evt.keyCode;} // For IE
		if (charCode==13 | charCode==3) {return calculator();}
	else {return true;}
}

function calculator()

{
	
	// Make sure the input is a number; if not, prompt user
	if (isNaN(document.pressure.oldpressure.value)) {
		document.pressure.newpressure.value = "Type numbers, not letters!";
		if (document.pressure.oldpressure.value.search(/,/i) != -1)
			{document.pressure.newpressure.value = "Omit commas in input.";}
		if (document.pressure.oldpressure.value.search(/x/i) != -1)
			{document.pressure.newpressure.value = "Enter 'e' instead of 'x10'.";}
	return false;}

	// Ralph is the container used to hold our answer.  Initialize with input value.
	var Ralph = document.pressure.oldpressure.value;

// Set start and end of conversion chain
	var StartHere = document.pressure.oldunit.selectedIndex;
	var EndHere = document.pressure.newunit.selectedIndex;
	
	if (StartHere > EndHere) {  // This is why we doubled the array.  Conversion works left to right.
		EndHere = EndHere + ArrayLength;}  

	// This runs through every calc between the starting unit and ending unit, but only if needed.
	if (StartHere !=  EndHere) {
		for(count = StartHere; count < EndHere; count++) 
		Ralph = Ralph*ConvertMe[count]; }

	// Cut decimal places to 7; this even cleans up big mantissas!
		var RalphClone = Ralph + "";    // Makes it copy of Ralph as a string to find e

		if (RalphClone.search(/e/i) == -1) {Ralph = Math.round(Ralph*1e7)/1e7;}
		else {
			var CutHere = RalphClone.split("e");
			CutHere[0] = Math.round(CutHere[0]*1e7)/1e7;
			Ralph = CutHere[0] + "e" + CutHere[1];
		}
	// Commas are fun, but a pain!  Why didn't they set a Number Format property in Javascript?
		RalphClone = Ralph + "";  // Make him a string again		
	
		CutHere = RalphClone.split(".");
		if (typeof CutHere[1] == "undefined") {CutHere[1] = "";}  // in case answer is integer.
			else {CutHere[1] = "." + CutHere[1];}

		var duh = 0;   // placeholder for comma loop; increments once for each comma inserted.
		var ThisLong = CutHere[0].length + Math.floor(CutHere[0].length/3); 
		var CommaStart = CutHere[0].length % 3;   // Starting position for comma
		if (CommaStart == 0) {CommaStart=3;}  // Keeps us from making numbers like ",123"
		Ralph = "";   
	
		if (CutHere[0].search(/e/i) == -1)   // exponents here would mess up the commas, so skip.
		{
		for(count = 0; count < ThisLong; count++) { 
			if (count == CommaStart + duh * 4) {
				if (count < ThisLong - 1) {Ralph = Ralph + ",";}
				duh = duh + 1;}
			else {
				Ralph = Ralph + CutHere[0].substring(count-duh, count+1-duh);}
			}
		}  else
			Ralph = CutHere[0];
		Ralph = Ralph + "" + CutHere[1];  // Slap the decimals back on.
	// Just to be picky, add a leading zero if first character is a decimal.
		if (Ralph.substring(0,1) == ".") {Ralph = "0" + Ralph};
		
	// Write result to the output field.
		document.pressure.newpressure.value = Ralph;
	return false;
}

function tyre_fnc(form)
  {
  var povodny=(form.rozmer1.value*25.4/2) + (form.et1.value*1);
  var novy=(form.rozmer2.value*25.4/2) + (form.et2.value*1);
  var temp1=(form.rozmer1.value*25.4) - (povodny);
  var temp2=(form.rozmer2.value*25.4) - (novy);
  var vysledok=temp2-temp1;
  document.all.v.innerHTML='<b>Výsledok:</b><br>Nové koleso vystúpi / vpadne von / dnu o <b> '+Math.round(vysledok)+' mm</b>.';
  }




function spoctikola(form){

  var r1=form.D1.value*form.D2.value/100+(form.D3.value*12.6);
  var r2=form.D4.value*form.D5.value/100+(form.D6.value*12.6);
  
 
    
  if (r1>r2) {
     var vyska="zníži";
     var tacho="vyššie";
     }
  else {
     var vyska="zvýši";
     var tacho="nižšie";
     }
  
  dif=Math.round(Math.abs(r1-r2));
  
  proc=Math.round(Math.abs((r1/r2-1)*100));
    
  if (proc <5) var tolerance="je";
  else var tolerance="nie je";

  var prevodtext='tak isto o <b>'+proc+'% '+tacho+'</b>.';

  if (1!=1) {
     var preproc=((form.D8.value/1)-1)*100+((r1/r2-1)*100);
     if (preproc>0) var prevod="väčšie";
     else var prevod="menšie"
     var preproc=Math.round(Math.abs(preproc));
     
     prevodtext='a prevodovky o <b>'+preproc+'% '+prevod+'</b>.';
     }


  document.all.script.innerHTML='<b>Výsledky:</b><br>Polomer starého kolesa je <b>'+Math.round(r1)+' mm</b>, polomer nového kolesa je <b>'+Math.round(r2)+' mm</b>.<br>\
  Podvozok sa <b>'+vyska+' o '+dif+' mm</b>.<br>\
  Tachometer bude ukazovať o <b>'+proc+'% '+tacho+' rýchlosť</b>, čo '+tolerance+' v povolenej 5% tolerancii.<br>\
  Sila prenášaná na vozovku bude pri zmene kolies '+prevodtext;
  }
  
  
