

//viditelnost = 0;
//okno = window.open('','oknos');

var ie = null;

function Is() {
 var agent = navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.minor = parseFloat(navigator.appVersion);
 this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
 this.ns5 = (this.ns && (this.major > 4));
 this.ie = (agent.indexOf("msie") != -1);
 this.ie4 = (this.ie && (this.major >= 4));
 this.ie6 = (navigator.appVersion.indexOf("MSIE 6.") != -1);
 this.op3 = (agent.indexOf("opera") != -1);
 this.pc  = (agent.indexOf("win") != -1);

 if (this.ie6)
	{
	 return true;
	}
else if(this.ie4)
	{
	 return 2;
	}
else
	{
	 return false;
	}
}

ie = Is();

function init()
{
	if(!ie)
	 {
		document.getElementById('inpolep').style.overflow = "auto";
	 }
	else
	 {
	delka = document.getElementById('inpolep').scrollHeight;
	misto = document.getElementById('inpolep').scrollTop;
	policko = document.getElementById('inpolep').offsetHeight;
	if(delka > policko)
		{
		 if(misto > 0)
		 	{
			 document.getElementById('nahoru').style.visibility = "visible";
			}
		else
		 	{
			 document.getElementById('nahoru').style.visibility = "hidden";
			}
		 if(misto < (delka-policko))
		 	{
			 document.getElementById('dolu').style.visibility = "visible";
			}
		else
		 	{
			 document.getElementById('dolu').style.visibility = "hidden";
			}
		}
	 }
//	alert(vyska+" "+vyska2);
}

function kontrola(odkaz)
{
if(odkaz == "http://" || odkaz.length <8)
	{
		alert("patně zadaný odkaz!");
		return false;
	}
	else return true;
}

function obrazek(co,cim)
{
	document.getElementById(co).src = cim;
}

function barva(barvap,objekt,text)
{
	document.getElementById('prod'+objekt).style.backgroundColor = barvap;
	if(barvap != "") document.getElementById('prod'+objekt).style.backgroundImage = "url('obrazy/line.gif')";
	else document.getElementById('prod'+objekt).style.backgroundImage = "";
	document.getElementById('produ'+objekt).style.backgroundColor = barvap;
	document.getElementById('produk'+objekt).style.color = text;
}

runId = null;
velkroku = 16;
rychlost = 20;
function scroll(smer)
{

	delka = document.getElementById('inpolep').scrollHeight;
	misto = document.getElementById('inpolep').scrollTop;
	policko = document.getElementById('inpolep').offsetHeight;
//	 text.innerHTML="misto: "+misto+"<br> runId: "+runId+"<br> smer: "+smer+" * "+delka+" - "+policko;
	if(smer == 0)
		{
//		 if(runId)
    			clearTimeout(runId);
		 runId = 0;
//		 alert(misto+" < "+(delka-300));
		}
	else if(smer == 1)
		{
		 misto -= velkroku;
		 if(misto < 0)
		 	{
			 misto = 0;
//			 document.all['nahoru'].src = "obrazy/nahoru.gif";
			 document.getElementById('nahoru').style.visibility = "hidden";
			 smer = 3;
			}
		}
	else if(smer == 2)
		{
		 misto += velkroku;
		 if(misto > (delka-policko))
		 	{
			 misto = delka-policko;
//			 document.all['dolu'].src = "obrazy/dolu.gif";
			 document.getElementById('dolu').style.visibility = "hidden";
			 smer = 3;
			}
		}
	if(smer == 1 || smer == 2 || smer == 3)
		{
		 nahorus = document.getElementById('nahoru').style.visibility;
		 dolus = document.getElementById('dolu').style.visibility;
//alert(nahorus);
		 if(misto > 0 && nahorus == "hidden") document.getElementById('nahoru').style.visibility = "visible";
		 if(misto < (delka-policko) && dolus == "hidden") document.getElementById('dolu').style.visibility = "visible";
		 document.getElementById('inpolep').scrollTop = misto;
		 smer1 = smer;
		 if(smer != 3) runId = setTimeout('scroll('+smer1+')', rychlost);
		 else smer = 0;
		}
}



	 var tlac1 = null;
	 var tlac2 = null;
	 var tlac3 = null;
	 var tlac4 = null;
//	 var tlac5 = null;
//	 var tlac6 = null;
	 tlac1 = new SetTlac('tlac1','gallery.gif');
	 tlac2 = new SetTlac('tlac2','slovnik.gif');
	 tlac3 = new SetTlac('tlac3','odkaz.gif');
	 tlac4 = new SetTlac('tlac4','omne.gif');
//	 tlac5 = new SetTlac('tlac5','gallery.gif');
//	 tlac6 = new SetTlac('tlac6','gallery.gif');



function SetTlac(id,soubor)
{
 this.obrazek = "images/"+soubor;
 this.stupen = 0;
 this.id = id;
 this.interval = 10;
 this.runId = 0;
 this.krok1 = 40;
 this.krok2 = 20;
 this.smer = 1;
}

function startTlac(smer)
{

 if (this.runId)
    clearTimeout(this.runId);
 this.runId = null;
 this.smer = smer;
 ie = Is();
 if(ie == 2)
	{
	if(this.smer == 1)
		{
		 document.getElementById(this.id).src = this.obrazek;
		}
	else
		{
		 document.getElementById(this.id).src = "images/mezera.gif";
		}
	}
 else if(ie == true)
	{
	 if (!this.runId)
		{
		document.getElementById(this.id).src = this.obrazek;
		if(this.smer == 1)
			{
			 this.stupen += this.krok1;
			}
		else
			{
			 this.stupen -= this.krok2;
			}

		if(this.stupen >= 150)
			{
			 this.stupen = 150;
			 this.smer = 0;
			}
		else if(this.stupen <= 0)
			{
			 this.stupen = 0;
			 this.smer = 0;
			}
		else if(this.stupen < 150 && this.stupen > 0)
			{
			 this.runId = setTimeout(this.id + '.runId=0;'+this.id + '.start('+this.smer+')', this.interval);
			}
		 document.getElementById(this.id).style.filter = "alpha(opacity="+this.stupen+", finishopacity="+(this.stupen-50)+", style=1, startX=0, startY=0, finishX=100, finishY=10)";

		}
	}
}

SetTlac.prototype.start = startTlac;


/*
fadeColor = "#604100";
stepIn = 13;
stepOut = 20;
autoFade = true;  
sloppyClass = true;
macCompat = false;
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

document.onmouseover = domouseover;
document.onmouseout = domouseout;

fadeColor = dehexize(fadeColor.toLowerCase());

var fadeId = new Array();

function dehexize(Color){
	var colorArr = new makearray(3);
	for (i=1; i<7; i++){
		for (j=0; j<16; j++){
			if (Color.charAt(i) == hexa[j]){
				if (i%2 !=0)
					colorArr[Math.floor((i-1)/2)]=eval(j)*16;
				else
					colorArr[Math.floor((i-1)/2)]+=eval(j);
			}
		}
	}
	return colorArr;
}

function domouseover() {
	if(document.all){
		var srcElement = event.srcElement;
		if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
				if (!srcElement.startColor) {
					srcElement.startColor = (srcElement.style.color)? srcElement.style.color: srcElement.currentStyle.color;
					srcElement.startColor = dehexize(srcElement.startColor.toLowerCase());
				}
				var link = (macCompat? srcElement.name: srcElement.uniqueID);
				if (link) fade(srcElement.startColor,fadeColor,link,stepIn);				
//				else if (macCompat) alert("Error: Mac Compatility mode enabled, but link has no name.");
		}
	}
}

function domouseout() {
	if (document.all){
		var srcElement = event.srcElement;
		if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
			var link = (macCompat? srcElement.name: srcElement.uniqueID);
			if (link) fade(fadeColor,srcElement.startColor,link,stepOut);
		}
	}
}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(s,e,element,step) {
	var sr = s[0]; var sg = s[1]; var sb = s[2];
	var er = e[0]; var eg = e[1]; var eb = e[2];
	
	if (fadeId[0] != null && fade[0] != element && eval(fadeId[0])) {
		var orig = eval(fadeId[0]);
		setColor(orig.startColor[0],orig.startColor[1],orig.startColor[2],orig);
		var i = 1;
		while(i < fadeId.length) {
			clearTimeout(fadeId[i]);
			i++;
		}
	}
		
	for(var i = 0; i <= step; i++) {
		fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
			step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
			")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
	}
	fadeId[0] = element;
}
*/
