//radova.js



var ie
var counter=0
var caption=""
var tempImg
var loadDone=false
var engl=false
var menuFound=false

document.onclick=tap


ie=document.all?1:0
if (location.search.length > 0 || window.location.href.indexOf("_e.") > 0) engl=true

// -- check whether location of this page is included in a menu, if so highlight it
var x=document.getElementById("masterdiv").getElementsByTagName("A")
	for (var i=0; i<x.length; i++){
		//alert(x[i].href)
		if (location.href.indexOf(x[i])==0){

			x[i].className="menulink"	// highlight by assigning class "menulink"
			menuFound = true
			if (x[i].parentNode.id) x[i].parentNode.style.display = "block";
		}
	}

//if (location.href != "http://radova.cz/") alert("extended address")



// special care about "previous exhibitions"
if (menuFound == false) {
	if (location.href=="http://radova.cz/" || location.href=="http://www.radova.cz/") {
		document.getElementById("home").className="menulink";
		document.getElementById("home").style.cursor="pointer";
	}
	else{
	document.getElementById("prevexh").className="menulink";
	document.getElementById("prevexh").style.cursor="pointer";
	document.getElementById("prevexh_e").className="menulink";
	document.getElementById("prevexh_e").style.cursor="pointer";
	}
}







// -- highlight current language texts
var hideLang
if (engl)
	hideLang="cz";
else
	hideLang="en";


// -- enable current language menu only
if (engl)
	document.getElementById("czmenu").innerHTML="";
else
	document.getElementById("enmenu").innerHTML="";





if (document.getElementsByTagName) {
  var a, aList = document.getElementById("content").getElementsByTagName("*");
    for (var i = 0; i < aList.length; i++) {
      a = aList[i];
      if (a.className==hideLang) {
        //  a.className="disabl" 
        a.style.display="none" 
      }
    }
}


/*	not used now
// -- if used locally (without SSI support) add a simple menu
if (!document.getElementById("masterdiv").getElementsByTagName("span")[0]){
	if (engl) document.getElementById("masterdiv").innerHTML = "<iframe src='menu_e.htm' id='mainmenu' allowTransparency='true' scrolling='yes' frameborder='0'></iframe>";
	else
	document.getElementById("masterdiv").innerHTML = "<iframe src='menu.htm' id='mainmenu' allowTransparency='true' scrolling='yes' frameborder='0'></iframe>";
	}
*/


// -- add method onMouse.. to class "nolink"
if (document.getElementsByTagName) {
  var a, aList = document.getElementById("masterdiv").getElementsByTagName("span");
    for (var i = 0; i < aList.length; i++) {
      a = aList[i];
      if (a.className=="nolink") {
        a.onmouseover = function(){this.style.color="#C30000";this.style.backgroundColor="#FFFFFF";}
        a.onmouseout = function(){this.style.color="gray";this.style.backgroundColor="transparent";} 
      }
    }
}


//	not used anymore, folloving line insead of it:
document.getElementById("warning").innerHTML = "" //Scripts and browser O.K.
/*
// -- change Warning mess if scripting is allowed
if (document.getElementById("warning")){ 
	//ie=document.all?1:0
	if (!ie) {
		if (engl){		
			document.getElementById("warning").innerHTML = "Not tested with this browser.<br>Sorry if not displayed correctly"
			}
		else {
			document.getElementById("warning").innerHTML = "V tomto prohlížeči nebyly stránky testovány.<BR>Omlouváme se za případné nedostatky ve zobrazení"
			}
		}
	else	
		{document.getElementById("warning").innerHTML = ""} //Scripts and browser O.K.
}
*/

// -- preload  quasi animation
if (document.getElementById){
  document.write('<div id="thumb"><img src="thumb.jpg"></div>')
}

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//************************
function SwitchMenu(obj){
//************************
if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span");

	if(el.style.display != "block"){ //DynamicDrive.com change
		for (var i=0; i<ar.length; i++){
			if (ar[i].className=="submenu")
			        //alert(ar[i].id)
				ar[i].style.display = "none";
			}
			el.style.display = "block";
	}else{
		el.style.display = "none";
	}
}
}

function ShowPic(picName){
  loadDone=false
  counter=0
  caption=format(picName.firstChild.title)
  tempImg = new Image();
  tempImg.src = picName
  tempImg.onload = function(){loadDone=true;}
  setTimeout("ready()",200)
  document.getElementById('BlowUp').innerHTML = "&nbsp;<div id=caption>" + caption + "</div><div id=loading>loading</div>"
  window.location='#BlowUp' //removed 4.7.2011
}

function ready(){
  counter++
  if (ie && tempImg.complete || !ie && loadDone) {
    document.getElementById('loading').style.marginTop=0
    document.getElementById('loading').innerHTML = "<IMG SRC='" + tempImg.src +  "'  onClick='GetBack();' STYLE='cursor:pointer;' ALT='Full size photo' title='Click to get back'></div>"
    window.location='#BlowUp'
  }
  else {
    if (counter<20) {
      setTimeout("ready()", 500);
      document.getElementById('loading').firstChild.appendData('.');
      tap()
    }
    else {
      GetBack()
    }
  }
}

function GetBack(){
  document.getElementById('BlowUp').innerHTML = ""
//  history.back() //4.7.2011 replaced with folloving command because of bad behaviour in MSIE
document.body.scrollTop=0
  tap()
}

function tap(){
  if(document.getElementById('thumb')){
    document.getElementById('thumb').style.paddingTop=document.body.scrollTop + document.body.clientHeight//-63
    document.getElementById('thumb').style.visibility="visible"
    setTimeout("tapend()", 200)
  }
}

function tapend(){
  document.getElementById('thumb').style.visibility="hidden"
}

function shift(target){
  location.replace(target.href);
  //window.scrollBy(0,-90); 
  document.body.scrollTop=document.body.scrollTop-90	// the same as window.scrollBy
}


function format(text){
  var b = text
  var temp = new Array();
  temp = b.split('/');

  b=(hideLang=="cz"?"<div class='disabl'>":"<div>") + temp[0] + "</div>"
  if (temp[1]) {
    b+= (hideLang=="en"?"<div class='disabl'>":"<div>") + temp[1] + "</div>"
  }
  if (temp[2]) {
    b+= "<i>" + temp[2] + "</i>"
  }
  return b
}

function CzechVer(){
	var expireDate = new Date();
	expireDate.setDate(365 + expireDate.getDate());
	document.cookie="LANG=cs; path=/; expires="+expireDate.toGMTString() ; 
        location.replace('index.shtml')
}

function EnglVer(){

	var expireDate = new Date();
	expireDate.setDate(365 + expireDate.getDate());
	document.cookie="LANG=en; path=/; expires="+expireDate.toGMTString() ; 
	location.replace('index_e.shtml')
}
