﻿var idselimg=0;var oldheight=0;var newheight=0;

/* funkce pro fsi okno */
	window.onError = doNothing;
	self.focus();
	var brwsnetscape = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? true : false;
	var sleep_r=1000; // in ms
	var r_timer=false;
	var off_x=315;
	var off_y=120;
	var old_fsi_width=0,old_fsi_height=0;
	var fsi_preload=1;
	var old_fsi_preload=1;
	

	function sleep_resize(){
		if (r_timer) clearTimeout(r_timer);
		if(document.getElementById) r_timer=setTimeout('resize_fsi()', sleep_r);
		else reload_site();
	}

	function resize_fsi(fsi_width,fsi_height)
	{
		
    flashik = document.getElementById("fsiwindow").innerHTML.replace(/ViewerWidth=.*ViewerHeight/gi,"ViewerWidth="+fsi_width+"&amp;ViewerHeight");
    flashik = flashik.replace(/ViewerHeight=.*plugins/gi,"ViewerHeight="+fsi_width+"&amp;plugins");
    //alert (flashik);
    flashik = flashik.replace(/ height=["]{0,1}[0-9]{1,3}["]{0,1}/gi," height=\""+fsi_height+"\"");
    flashik = flashik.replace(/ width=["]{0,1}[0-9]{1,3}["]{0,1}/gi," width=\""+fsi_width+"\"");
    //fsi_url="<%=show_url%>&ViewerWidth="+fsi_width+"&ViewerHeight="+fsi_height+"&plugins=navextension,clockprogress,zoommeter,mousemodes&ScenePreload="+fsi_preload+"&InitialMouseMode=2";

    flashik = flashik+" ";

    //alert (flashik);

	 	//akcode = '<EMBED id="flash_obrazku" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash SRC="'+fsi_url+'" width='+fsi_width+' height='+fsi_height+' BGCOLOR=#FFFFFF QUALITY=high MENU=false LOOP=false />';
		
    if ((fsi_width != old_fsi_width && fsi_height != old_fsi_height) || (fsi_preload != old_fsi_preload))
		{
			if (document.getElementById("fsiwindow")){
				fsi_obj="";
        fsi_obj=document.getElementById("fsiwindow");
				if (fsi_obj)
				{
	  			fsi_obj.innerHTML=flashik;
				}
			}
			else if(document.layers)
			{
				if (backmode) {
					return akcode;
				}
			}
		}
		old_fsi_width=fsi_width;
		old_fsi_height=fsi_height;
		old_fsi_preload=fsi_preload;
		return '';
	}

	function reload_site(){
		location.reload();
	}

	function rmode(fsi_size){
		switch (fsi_size){
			case 'small':
				rwidth=(300);
				rheight=(300);
				break;
			case 'medium':
				rwidth=(500);
				rheight=(500);
				break;
			case 'large':
				rwidth=(800);
				rheight=(800);
				break;
		}
		  
		  //alert (rwidth-Math.round(document.getElementById("flash_obrazku").offsetWidth));
      swidth=Math.round(document.getElementById("main").style.width.replace("px",""))+(rwidth-Math.round(document.getElementById("flash_obrazku").offsetWidth))+"px";
      //alert (swidth);
			
      resize_fsi(rwidth,rheight);
			document.getElementById("main").style.width=swidth;
			SizeWinFsi()
		
	}


	function pmode(preload){
	
		switch (preload){
			case 'fast':
				fsi_preload=1;
				document.getElementById("fast").style.color="#FE4D16";
				document.getElementById("slow").style.color="black";
				
				break;
			case 'slow':
				fsi_preload=0;
				document.getElementById("slow").style.color="#FE4D16";
				document.getElementById("fast").style.color="black";
				break;
		}
		
		flashik=document.getElementById("fsiwindow").innerHTML.replace(/ScenePreload=[0-9]{1}/gi,"ScenePreload="+fsi_preload);
    document.getElementById("fsiwindow").innerHTML="";
    document.getElementById("fsiwindow").innerHTML=flashik;
    //alert (flashik);
	}


      	function getPageHeight() {
          var myWidth = 0, myHeight = 0;
          if( typeof( window.innerWidth ) == "number" ) {
            //Non-IE" & vbcrlf &_
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
          } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in "standards compliant mode"
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
          } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible" & vbcrlf &_
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
          }
          //window.alert( "Height = " + myHeight );
          return(myHeight);
        }
        
	function doNothing() {return true}

  function changeFsiImg(sFsiUrl,sLanguage,nid)
    {
    flashik=document.getElementById("fsiwindow").innerHTML;
   // alert(flashik);
    flashik=flashik.replace(/SRC=.*plugins/gi,"SRC="+sFsiUrl+"&amp;plugins");
   // alert(flashik);
    document.getElementById("fsiwindow").innerHTML="";
    document.getElementById("fsiwindow").innerHTML=flashik;
    document.getElementById('addimage'+idselimg).className='grey';
    document.getElementById('addimage'+nid).className='active';
    idselimg=nid;
    }

  function SizeWinFsi() {
      //document.body.onresize="";
      //alert ('ba');
      newheight=(getPageHeight()-70-((document.getElementsByTagName("h2")[0])?document.getElementsByTagName("h2")[0].offsetHeight:0)-document.getElementsByTagName("h1")[0].offsetHeight-((document.getElementById("next_images"))?document.getElementById("next_images").offsetHeight:0));
      //alert (newheight);
      oldheight=document.getElementById("fsiwindow").style.height;
      //alert (oldheight);
      if (newheight!=oldheight) document.getElementById("fsiwindow").style.height=newheight.toString()+"px";
      //document.body.onresize="SizeWin()";
		}
		
	function clearselection()
	 {
   for (i=0;document.getElementById("obr"+i);i++)
       {
       document.getElementById("obr"+i).style.background="#CFCFCF";
       }
   }
     
   function SizeWinImages() { 
          if (oldheight>0) {window.resizeBy(0,document.getElementById("main").offsetHeight+document.getElementById("pic_text").offsetHeight-oldheight);oldheight=document.getElementById("pic_text").offsetHeight+document.getElementById("main").offsetHeight;}
          else {
           window.resizeTo(document.getElementById("main").offsetWidth+100,screen.availHeight);
           
           nWholeHeightBoxes=60+((document.getElementById("navigate"))?document.getElementById("navigate").offsetHeight:0)+document.getElementById("pic_text").offsetHeight+((document.getElementById("next_images"))?115:0)+((document.getElementsByTagName("h2")[0])?20:0)+document.getElementsByTagName("h1")[0].offsetHeight;
          // alert(nWholeHeightBoxes);          
           window.resizeBy(0,document.getElementById("main").offsetHeight+nWholeHeightBoxes-getPageHeight());
            oldheight=document.getElementById("pic_text").offsetHeight+document.getElementById("main").offsetHeight;}
      		}
      		
    
    function SizeWinFsiL() { 
          if (oldheight==0) 
          {
           window.resizeTo(600,screen.availHeight);
           nWholeHeightBoxes=60+((document.getElementById("navigate"))?document.getElementById("navigate").offsetHeight:0)+((document.getElementById("next_images"))?115:0)+((document.getElementsByTagName("h2")[0])?20:0)+document.getElementsByTagName("h1")[0].offsetHeight;        
           window.resizeBy(0,500+nWholeHeightBoxes-getPageHeight());
           oldheight=500; document.getElementById("fsiwindow").style.height='500px';
          // alert(document.getElementById("fsiwindow").style.height);        
      		} SizeWinFsi();    }
      		

      	
  
        