
var timeout=1500;
var tactive=0;
var twhat="";
var timerID = null
var swhat="";

DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
Konqueror = (navigator.userAgent.indexOf("Konqueror") > -1) ? 1 : 0;
Konqueror21 = (navigator.userAgent.indexOf("Konqueror 2.1") > -1 || navigator.userAgent.indexOf("Konqueror/2.1") > -1) ? 1 : 0;
Konqueror22 = (navigator.userAgent.indexOf("Konqueror 2.2") > -1 || navigator.userAgent.indexOf("Konqueror/2.2") > -1) ? 1 : 0;
Konqueror2 = Konqueror21 || Konqueror22;
Opera5 = (navigator.userAgent.indexOf("Opera 5") > -1 || navigator.userAgent.indexOf("Opera/5") > -1) ? 1 : 0;
Opera6 = (navigator.userAgent.indexOf("Opera 6") > -1 || navigator.userAgent.indexOf("Opera/6") > -1) ? 1 : 0;
Opera = Opera5 || Opera6;
IE = (document.all) ? 1 : 0;
IE4 = IE && !DOM;

function getoffsetleft(layer) {
	var value = 0;
	if (DOM) {
		object = document.getElementById(layer);
		value = object.offsetLeft;
//alert (object.tagName + " --- " + object.offsetLeft);
		while (object.tagName != "BODY" && object.offsetParent) {
			object = object.offsetParent;
//alert (object.tagName + " --- " + object.offsetLeft);
			value += object.offsetLeft;
		}
	} else if (NS4) {
		value = document.layers[layer].pageX;
	} else {	// IE4 IS SIMPLY A BASTARD !!!
		if (document.all["IE4" + layer]) {
			layer = "IE4" + layer;
		}
		object = document.all[layer];
		value = object.offsetLeft;
		while (object.tagName != "BODY") {
			object = object.offsetParent;
			value += object.offsetLeft;
		}
	}
	return (value);
} 

function getoffsettop(layer) {
	var value = 0;
	if (DOM) {
		object = document.getElementById(layer);
		value = object.offsetTop;
		while (object.tagName != "BODY" && object.offsetParent) {
			object = object.offsetParent;
			value += object.offsetTop;
		}
	} else if (NS4) {
		value = document.layers[layer].pageY;
	} else {	// IE4 IS SIMPLY A BASTARD !!!
		if (document.all["IE4" + layer]) {
			layer = "IE4" + layer;
		}
		object = document.all[layer];
		value = object.offsetTop;
		while (object.tagName != "BODY") {
			object = object.offsetParent;
			value += object.offsetTop;
		}
	}
	return (value);
} 

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(URL,windows,features) { 
window.open(URL, windows, features);
};

function MM_showHideLayers() { 
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function BW_centerLayers() { //v4.1.1
	if (document.layers || document.all || document.getElementById){
		var winWidth, winHeight, i, horz, vert, width, height, offsetX, offsetY, negX, negY, group, x, y, args;
		args = BW_centerLayers.arguments;
		
		onresize = BW_reload;

				
		winWidth = (document.all)?document.body.clientWidth:window.innerWidth;
		winHeight = (document.all)?document.body.clientHeight:window.innerHeight;
				
		for (i=0; i<(args.length-9); i+=10) {
			horz    = args[i+1];
			vert    = args[i+2];
			width   = parseInt(args[i+3]);
			height  = parseInt(args[i+4]);
			offsetX = parseInt(args[i+5]);
			offsetY = parseInt(args[i+6]);
			negX    = args[i+7];
			negY    = args[i+8];
		
			x = ((winWidth - width)/2) + offsetX;
			y = ((winHeight - height)/2) + offsetY;
						
			x = (negX=='false' && (x < 0))?0:x;
			y = (negY=='false' && (y < 0))?0:y;
				
			layerObj = (document.getElementById)?document.getElementById(args[i]):MM_findObj(args[i]);
			
			if (layerObj!=null) {
				layerObj = (layerObj.style)?layerObj.style:layerObj;
				layerObj.left = (horz=="true")?x:layerObj.left;
				layerObj.top = (vert=="true")?y:layerObj.top;
			}
		}
	}
}

function BW_reload() {location.reload();}


function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' musí obsahovat e-mailovou adresu.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' musí obsahovat číslo.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' musí obsahovat číslo mezi '+min+' a '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' je nutno uvést.\n'; }
  } if (errors) alert('Ve formuláři byly nalezeny následující chyby:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function Hide() {
	MM_showHideLayers(twhat,'','hide');
	clearTimeout(timerID);
	tactive=0;
	twhat="";
};

function Show(what) {
	MM_showHideLayers(what,'','show');
};

function StopTimeout(what) {
	what="div"+what;
	if (what!=twhat) {
		Hide();
	};
	clearTimeout(timerID);
	tactive=0;
	twhat="";
};

function StartTimeout(what) {
	what="div"+what;
	if (tactive==1 && twhat!=what) {
		Hide();
	};
	tactive=1;
	if (twhat!=what) {
		twhat=what;
	};
	timerID=setTimeout("Hide()",timeout);
};

function SetRelativePosition(theSource,theTarget,ofsX,ofsY) {
	layerObj2 = (document.getElementById)?document.getElementById(theTarget):MM_findObj(theTarget);
	if (layerObj2!=null) {
		layerObj2 = (layerObj2.style)?layerObj2.style:layerObj2;
		layerObj2.left = getoffsetleft(theSource)+ofsX;
		layerObj2.top = getoffsettop(theSource)+ofsY;
	}
};

// SKRIPTY PRO MENU

var menuActive = 'noName';
var menuDirection = 'bottom';
var menuIniWidth = 0;
var menuIniHeight = 0;
var menuSlideVal = 0;
var menuStep = 5;
var menuTimeStep = 10;

function slideMenu() {
var layer = document.getElementById(menuActive);  //get path to layer depending on browser executing this code
	if(NS4){
		if(layer.clip.left > 0){
		
		if (menuDirection == 'left') {layer.clip.left -= menuStep;};
		if (menuDirection == 'right') {layer.clip.right += menuStep;};
		if (menuDirection == 'top') {layer.clip.top -= menuStep;};
		if (menuDirection == 'bottom') {layer.clip.bottom += menuStep;};
		setTimeout("slideMenu()",menuTimeStep)
		}
	}
	else {
		oldVal = menuSlideVal;
		if (menuDirection == 'left') {
			menuSlideVal -= menuStep;
			if (menuSlideVal < 0) {menuSlideVal = 0;};
			iniClip = "rect(" + 0 + "px " + menuIniWidth + "px " + menuIniHeight + "px " + menuSlideVal + "px)";
			};
		if (menuDirection == 'right') {
			menuSlideVal += menuStep;
			if (menuSlideVal > menuIniWidth) {menuSlideVal = menuIniWidth;};
			iniClip = "rect(" + 0 + "px " + menuSlideVal + "px " + menuIniHeight + "px " + 0 + "px)";
			};
		if (menuDirection == 'top') {
			menuSlideVal -= menuStep;
			if (menuSlideVal < 0) {menuSlideVal = 0;};
			iniClip = "rect(" + menuSlideVal + "px " + menuIniWidth + "px " + menuIniHeight + "px " + 0 + "px)";
			};
		if (menuDirection == 'bottom') {
			menuSlideVal += menuStep;
			if (menuSlideVal > menuIniHeight) {menuSlideVal = menuIniHeight;};
			iniClip = "rect(" + 0 + "px " + menuIniWidth + "px " + menuSlideVal + "px " + 0 + "px)";
			};
		layer.style.clip = iniClip;
		if (oldVal != menuSlideVal) {
			setTimeout("slideMenu()",menuTimeStep)
		};
	};
};

function shMenu(divID) {
	if (NS4) {
		menuIniHeight = parseInt(document[divID].document.height);
		menuIniWidth = parseInt(document[divID].document.height);
	} else {
		menuIniHeight = parseInt(document.all[divID].scrollHeight);
		menuIniWidth = parseInt(document.all[divID].scrollWidth);
	};
	if (menuDirection == 'left') {iniClip = "rect(" + 0 + "px " + menuIniWidth + "px " + menuIniHeight + "px " + menuIniWidth + "px)"; iniVal = menuIniWidth;};
	if (menuDirection == 'right') {iniClip = "rect(" + 0 + "px " + 0 + "px " + menuIniHeight + "px " + 0 + "px)"; iniVal = 0;};
	if (menuDirection == 'top') {iniClip = "rect(" + menuIniHeight + "px " + menuIniWidth + "px " + menuIniHeight + "px " + 0 + "px)"; iniVal = menuIniHeight;};
	if (menuDirection == 'bottom') {iniClip = "rect(" + 0 + "px " + menuIniWidth + "px " + 0 + "px " + 0 + "px)"; iniVal = 0;};
	document.getElementById(divID).style.clip = iniClip;
	MM_showHideLayers(divID,'','show');
	menuSlideVal = iniVal;
	menuActive = divID;
	slideMenu();
	return (true);
};

function StartMenuBoth(what,y) {
	if (MM_findObj('div' + what) != null) {
		SetRelativePosition('sub' + what, 'div' + what,0,y);
		what='div' + what;
		if (twhat != what) {
			MM_showHideLayers(twhat,'','hide');
		};
		twhat=what;
		MM_showHideLayers(what,'','show');
	//	shMenu(what);
		clearTimeout(timerID);
		tactive=0;
	};
};

function StartMenu(what) {
  StartMenuBoth(what,-42);
};

function StartMenuTall(what) {
  StartMenuBoth(what,-110);
};

function changeCphoto(photo) {
  var photoContainer = document.getElementById('catBig');
  photoContainer.src = photo;
};

function divShow(divName) {
	document.getElementById(divName).style.display = 'block';
}

function divHide(divName) {
	document.getElementById(divName).style.display = 'none';
}



