var W3CDOM = (document.createElement && document.getElementsByTagName);
var nav = new Array();
var as = new Array();
var div = new Array();
var divs = new Array();
var aheights = new Array();
var print = new Array()
window.onload = init;



function init()
{
	       if (!W3CDOM) return;
	        new_window_link();
	        imgPOP();
	        var nav = document.getElementById('menu');
	        var as =  nav.getElementsByTagName('a');
	        
          var spans = nav.getElementsByTagName('span'); 
          for (var x=0;x<spans.length;x++){
          if(spans[x].className == "visible") {
          var aheightsvisible = spans[x].getElementsByTagName('a');   
          var pridej = 0;
          for (var y=0;y<aheightsvisible.length;y++)
	        {
	        if(aheightsvisible[y].firstChild.data.length>33){ 
          pridej = pridej+1;
          }
	        }
           var vyskavisible = (aheightsvisible.length * 2)+ pridej + 1;
           spans[x].style.height = vyskavisible + "em";
           spans[x].style.display = 'block';
           spans[x].style.overflow = 'hidden';
          }
          }
          
	       //var nav = document.getElementById('menu');
	       //var as =  nav.getElementsByTagName('a');
	       for (var i=0;i<as.length;i++)
	       {
	       
	        if(as[i].parentNode.tagName == 'DIV'){
	  	    var span =  as[i].parentNode.getElementsByTagName('span');
	  	    for (var y=0;y<span.length;y++)
	        {
	              
                      
	              
	        as[i].number = i;	
	        as[i].onclick = slideExcept; 	
	        
	  	    }
	  	   }
	       }
	
}
function test(nr,direction){
         
         // alert('jedu test');
          var pridej = 0;
          
          if(nr>=-1){this.number = nr; var x = this.number;}else{var x = this.number;}
          
	        var nav = document.getElementById('menu');
	        var as =  nav.getElementsByTagName('a');
	        as[this.number].onmouseout = mouseGoesOut2; 
          var spans = as[this.number].parentNode.getElementsByTagName('span'); 
          var aheights = spans[0].getElementsByTagName('a');         
          for (var c=0;c<aheights.length;c++)
	        {
	        if(aheights[c].firstChild.data.length>33){ 
          pridej = pridej+1;
          }
	        }


          //if(spans[0].className == "visible") { 
            
          //var vyska = (aheights.length * 2)+ pridej + 1;
          //if(spans[0].style.height == ""){spans[0].style.height = vyska + "em";}
          //spans[0].style.display = 'block';
          //spans[0].style.overflow = 'hidden';
          //}
          
          //else{ 
           
          if(spans[0].style.display == ""){spans[0].style.display = "none";}
          if(spans[0].style.height == ""){spans[0].style.height = 0 + "em";}
        	if((spans[0].style.display == "none")||(direction == 1)){
        	 
          spans[0].style.display = 'block';
          spans[0].style.overflow = 'hidden';
          var vyska = (aheights.length * 2)+ pridej + 1;
              
          if(parseFloat(spans[0].style.height) < vyska){  
          
                        spans[0].style.height = parseFloat(spans[0].style.height) + 1 + "em";
                          
                        nr = this.number;
                        direction = 1;
                        setTimeout("test("+nr+","+direction+")",1);
                        
                        
                        
                        }
                           
          

          } 
          else{
           //alert(this.number);
           if(parseFloat(spans[0].style.height) > 0){
           spans[0].style.height = parseFloat(spans[0].style.height) - 1 + "em";
           nr = this.number;
           direction = 0;
           setTimeout("test("+nr+","+direction+")",1);
           }
           else{
           spans[0].style.display = 'none';
           spans[0].style.height = 0;
           	
           
         
         var nav = document.getElementById('menu');
	       var as =  nav.getElementsByTagName('a');	       
         for (var i=0;i<as.length;i++)
	       {
	       
	       if(as[i].parentNode.tagName == 'DIV'){
 
          as[i].number = i;	
          as[i].onmouseover = mouseGoesOver;
          as[i].onmouseout = mouseGoesOut;
         
         }
         }
           
           
           }
          }
           
         
          //}
          
     return false; 

}

function mouseGoesOver()
{
 
         var nav = document.getElementById('menu');
	       var as =  nav.getElementsByTagName('a');	       
         for (var i=0;i<as.length;i++)
	       {
	       
	       if(as[i].parentNode.tagName == 'DIV'){

         
          as[this.number].style.backgroundColor = 'transparent';
          as[this.number].style.backgroundImage = 'none';
          as[this.number].style.textDecoration = 'none';

          }
          }

}

function mouseGoesOut()
{
 

	       if (!W3CDOM) return;
	       var nav = document.getElementById('menu');
	       var as =  nav.getElementsByTagName('a');
	       var x=0;
	       for (var i=0;i<as.length;i++)
	       {
	       
	       if(as[i].parentNode.tagName == 'DIV'){
	  	   if(x==0){
         as[i].style.backgroundColor = '#a2bc37';
         as[i].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_first.gif")';
         as[i].style.textDecoration = 'underline';
         as[i].style.backgroundRepeat = 'no-repeat';
         as[i].style.backgroundPosition = 'left -15px'; 
         }
         if(x==1){
         as[i].style.backgroundColor = '#99b624';
         as[i].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_second.gif")'; 
         as[i].style.textDecoration = 'underline';
         as[i].style.backgroundRepeat = 'no-repeat';
         as[i].style.backgroundPosition = 'left -15px';         
         }
         if(x==2){
         as[i].style.backgroundColor = '#90b011';
         as[i].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_third.gif")';
         as[i].style.textDecoration = 'underline';
         as[i].style.backgroundRepeat = 'no-repeat';
         as[i].style.backgroundPosition = 'left -15px';          
         }
         if(x==3){
         as[i].style.backgroundColor = '#88aa00';
         as[i].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua.gif")';  
         as[i].style.textDecoration = 'underline';
         as[i].style.backgroundRepeat = 'no-repeat';
         as[i].style.backgroundPosition = 'left -15px';        
         }                  
         
	  	   if(x>3){
         as[i].style.backgroundColor = '#88aa00';
         as[i].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua.gif")';
         as[i].style.textDecoration = 'underline';
         as[i].style.backgroundRepeat = 'no-repeat';
         as[i].style.backgroundPosition = 'left -15px';        
	  	   }
	  	   
	  	   x=x+1;
	  	   
	  	   
         
	  	
	       }
         }

 
}

function mouseGoesOut2()
{

 
	       if (!W3CDOM) return;
	       var nav = document.getElementById('menu');
	       var as =  nav.getElementsByTagName('a');

         if(as[this.number].parentNode.parentNode.className == "first"){
         as[this.number].style.backgroundColor = '#a2bc37';
         as[this.number].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_first_active.gif")';
         }
         if(as[this.number].parentNode.parentNode.className == "second"){
         as[this.number].style.backgroundColor = '#99b624';
         as[this.number].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_second_active.gif")';
         }         
         if(as[this.number].parentNode.parentNode.className == "third"){
         as[this.number].style.backgroundColor = '#90b011';
         as[this.number].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_third_active.gif")';
         }         
         if(as[this.number].parentNode.parentNode.className == "fourth"){
         as[this.number].style.backgroundColor = '#88aa00';
         as[this.number].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_active.gif")';
         }       
         if(as[this.number].parentNode.parentNode.className == ""){
         as[this.number].style.backgroundColor = '#88aa00';
         as[this.number].style.backgroundImage = 'url("http://www.rusnuclear.cz/images/menua_active.gif")';
         }       
         
         
           
         as[this.number].style.textDecoration = 'underline';
         as[this.number].style.backgroundRepeat = 'no-repeat';
         as[this.number].style.backgroundPosition = 'left -15px';        


 
}


function slideExcept(nr){
          
           
          
          var x = this.number;
          
	        var nav = document.getElementById('menu');
	        var as =  nav.getElementsByTagName('a');
          for (var i=0;i<(as.length);i++) 
	        {
	    
           if(i == x){
           
          
           
	         }
	         else{
	              if(as[i].parentNode.tagName == 'DIV'){
                
                         
	              var ems = as[i].parentNode.getElementsByTagName('span');
                for (var e=0;e<ems.length;e++)
	              {  
                ems[e].style.display = 'none';
                
                
                }
	              
                
                
                }
                

           
        }
	    }
	     test(this.number);
	         return false; 
}	        
          
          
      
       var path_to_icon 		= 'http://www.rusnuclear.cz/images/icon.gif';
			 var link_alt_text 		= 'Otevřít odkaz v novém okně';
			 var link_title_text 	= 'Otevřít odkaz v novém okně';

			function new_window_link() {
			  
				if (!document.getElementById || !document.createTextNode || !document.domain || !document.getElementById('text')) return;
				
        var text = document.getElementById('text');
        var linx = text.getElementsByTagName('a');
       
				for (var i = 0; i < linx.length; i++) {

					// just for off-site links
					
			    if(linx[i].protocol == 'http:'){
					if (linx[i].href.split('/')[2].replace(/www\./, '') != document.domain.replace(/www\./, '')
						&& !linx[i].getAttribute('target')
						&& !linx[i].parentNode.id.match(/^copy/)) {

						// create new elements
						var nwl = document.createElement('a');
						var nwl_image = document.createElement('img');
						var space = document.createTextNode(' ');

						// setup image attributes
						nwl_image.setAttribute('src', path_to_icon);
						nwl_image.setAttribute('alt', link_alt_text);
						nwl_image.setAttribute('title', link_title_text);

						// set link attributes
						nwl.setAttribute('href', linx[i].getAttribute('href'));
						nwl.setAttribute('target', '_blank');
						nwl.setAttribute('title', link_title_text);
						nwl.className = 'new_window_link';

						// append new elements
						nwl.appendChild(nwl_image);
						linx[i].parentNode.insertBefore(space, linx[i].nextSibling);
						linx[i].parentNode.insertBefore(nwl, linx[i].nextSibling.nextSibling);
					}
				}
			
				}
			}

      function imgPOP(){ 
  
      var linx = document.getElementsByTagName('a');
      for (var i = 0; i < linx.length; i++) {      
      if(linx[i].id){   
      
      linx[i].number = linx[i].id;   
      linx[i].onclick = openWin; 
     
      }
      }
      }
      
      function openWin(){
       
      var splits = new Array();
      var stringfrom = this.number;    
      splits = stringfrom.split('open_');
      var page = splits[1]; 
      page = "/pictures/"+page;     
      window.open(page);
      return false;
      }


