
window.offscreenBuffering=true
//"pano0", "{file=1.jpg}{title=something}{interpolators_mode=3}{image_id=333}{pan=0}{panmin=-150}{panmax=150}{tilt=0}{tiltmin=-30}{tiltmax=30}{fov=65}{fovmin=30}{fovmax=90}"
  //<param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />
  //EnableJavaSript="true" in the movie's EMBE
  function PanoLauncher(){
  this._flasReqPar={classid:'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',codebase:'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'}
	    //gen start
	    this.vmpBaseURI="http://www.amu.pl/vpm";
	  //this.panoramaSet=[''];
	  this.lang='pl';
	  this.pageEncoding='';
	  this.detect=false;
	  this.layOverName="layOver"
	  this.layAllName="elAll"
	  //gen end
			this._rP=null;
			this.user='';
			this.humanId='';
	 
	  this.showOverLayer=function(){//alert('showOverLayer')

		    var rb=document.getElementsByTagName('body');
		    //alert(rb.length);
		    this.rOver.style.display='block';//alert('th1')
		    //this.setOpacity(this.rOver,1);
		     try{
		 var rbw=rb[0].clientWidth
		 var rbh=rb[0].offsetHeight
		
		 if(typeof(rbw)!="string"){
		 rbw+="px"
		 }
		 if(typeof(rbh)!="string"){
		 rbh+="px"
		 }
		  this.rOver.style.width=rbw
		    this.rOver.style.height=rbh
		   	
		      }catch(e){
		     
		      }
		    //alert(this.rAll.style.display)
		    if(this.br.engine.microsoft){
		    this.rAll.style.display='none';
		    
}else if(this.br.engine.gecko){
this.rAll.style.visibility='hidden';
}
		    };
	  this.hideOverLayer=function(){//alert('hideOverLayer')
 this.rOver.style.display='none';
			    if(!this.br.engine.gecko){
			    this.rOver.innerHTML=' ';
			    }
		    if(this.br.engine.microsoft){
		   this.rAll.style.display='block';
		    }else if(this.br.engine.gecko){
this.rAll.style.visibility='visible';
}
if(typeof(onHideOverLayer)=="function"){
onHideOverLayer()
}
		    };
	  this._opLoop=function(v){
	  
			  /* Zanik  
		    this.setOpacity(this.rOver,v);
		    v-=0.2;
		    if(v>=0){
			    setTimeout('panoLauncher._opLoop('+v+')',20)
			    }else{
			    this.rOver.style.display='none';
			    this.rOver.innerHTML=' ';
			    }
			    */
		    };
	  this.launch=function(panoramaId,versionType,versionSize,mode,skinId){
	  if(typeof(onLaunch)=="function"){
		onLaunch()
		}
	  var re=/'/g
		this.launchMode=mode.replace(re,"")
		var params={};
					
		params.panoramaId=panoramaId
		this.humanId=panoramaId;
		params.lang=this.lang
		params.detect=this.detect
		params.versionType=versionType.replace(re,"")
		params.versionSize=versionSize.replace(re,"")
		params.pageEncoding=this.pageEncoding
		try{
		params.skinId=skinId.replace(re,"")
		}catch(e){}
		params.host=this.host
		params.port=this.port
		params.path=this.path
		
/*		
var str=""
//"http://"+location.host+":"+location.port+"/vpm/proxy.php?"
if(typeof(_vpmRunningHost)=="string"){
str+=_vpmRunningHost
}
str+="/modules/VPM/proxy.php?"
for(var i in params){
str+=i+"="+params[i]+"&"
}
//alert(str)
//var str="/js/test_resp.xml"
*/
//document.write(str);return
var oDoc=Sarissa.getDomDocument();
oDoc.async =false;
//var str2=this.vmpBaseURI+"/test/test_resp.xml"
///oDoc.load(str)
//alert(serialize(oDoc))
//alert(oDoc)

//if(oDoc.parseError!=0){
//alert(Sarissa.getParseErrorText(oDoc))
//return
//}

/*
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", str, false);
xmlhttp.send(null);
alert(Sarissa.serialize(xmlhttp.responseXML));
*/
		   this._setContent(oDoc);


		    };
						this._setFVar=function(k,v){
							this._rP.SetVariable('/config:'+k,String(v))
							//alert(this._rP.GetVariable('/config:'+k))
						};
	  
						//was id,v,size
	  this._setContent=function(x){//alert(x.documentElement.getAttribute('versionType'))
				var v='flash';//x.documentElement.getAttribute('versionType');
				var size='l';//this.versionSize=x.documentElement.getAttribute('versionSize');
				this.user='kpz';//x.documentElement.getAttribute('user');
				//this.humanId=x.documentElement.getAttribute('humanId');
				//this.title=x.documentElement.getAttribute('title');
		    var str='';
		    switch(v){
				    case "java":
				    this.showOverLayer();
				    
								//alert(this._getJava({size:size}))
			    str+=this._decorateCenter(this._getJava({size:size}),this._getCloseButton());
				    this.rOver.innerHTML=str
				      break;
				    case "qt":
				    var posParams={};
				    for(var i=0;i<x.documentElement.childNodes.length;i++){
				    if(x.documentElement.childNodes[i].getAttribute('type')=="start"){
				    posParams={pan:x.documentElement.childNodes[i].getAttribute('pan'),tilt:x.documentElement.childNodes[i].getAttribute('tilt'),fov:x.documentElement.childNodes[i].getAttribute('fov')}
				    }
				    }
				    switch(size){
						    case "l":
						    case "h":
						    this.showOverLayer();
						    
					      str+=this._decorateCenter(this._getQt({size:size,position:posParams}),this._getCloseButton());
						    this.rOver.innerHTML=str;
						    
						      break;
						    case "b":
					    str+=this._getQt({size:size,position:posParams});
						    this._showExternal(str)
						    break;
						    case "dl":
						    location=this.vmpBaseURI+'panoramas/'+this.user+'/'+this.humanId+'_dl.mov'
						      break;
					    };

				    break;
				    case "flash":
				    switch(size){
						    case "l":
						    
						    this.showOverLayer();
						    
						    //break;
						    str+=this._decorateCenter(this._getFlash(),this._getCloseButton());//alert(this._getFlash());
						    this.rOver.innerHTML=str;
						    break;
						    case "dl":
						    location=this.vmpBaseURI+'panoramas/'+this.user+'/'+this.humanId+"_"+this.lang+'.exe'
						      break;

					    };

				    break;
			    };

		    };
	  this._showExternal=function(content,useQt){
		    var cw=window.open('about:blank','ebw','top=0,left=0,scrollbars=0,toolbar=0,status=0,location=0,menubar=0,resizable=0');//channelmode=1,fullscreen=1,
		    cw.focus();
		    //var d=[5,25] Przy wychodzeniu poza
		    var d=[0,0]
		      cw.moveTo(d[0],d[1])
		      //screen.width+d[0]+5,screen.height+d[1]+5 Przy wychodzeniu
		      cw.resizeTo(screen.availWidth,screen.availHeight);//(screen.availWidth,screen.availHeight)
		    cw.document.open();
		    cw.document.clear();
		    cw.document.write('<html><head><title>www.panoramy.amu.pl</title></head><body style="margin:0;background-color:#000000;">');
		    cw.document.write('<div style="text-align:center">');
		    cw.document.write(content);
		    cw.document.write('</div>');
		   
		    cw.document.write('</body></html>');
		    };
	  this._getCloseButton=function(){
		    var str='';
		    str+='<a href="#" onclick="panoLauncher.hideOverLayer();return false;">';
		    str+='<img src="'+this.vmpBaseURI+'www/img/close_'+this.lang+'.gif" alt="" style="border:0px;float:right;margin:5px 0px 0px 0px">';
		    str+='</a>'
		      return str;
		    };
	  this._getJava=function(p){
    var sizes={l:[471,304],h:[471,304],b:['100%','100%']}
      var req={id:'vpmApplet',name:'vpmApplet',codebase:this.vmpBaseURI+'www/',archive: this.vmpBaseURI+'www/'+'Browser_471.jar',code:'pl.amu.panobrowser1_1a.Browser.class',mayscript:'true'};//,codebase:'http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab'

		        req.width=sizes[p.size][0];
		    req.height=sizes[p.size][1];
						//TODO pano0 - temporary
    var par={pano0:'{file='+this.user+'/'+this.humanId+'_'+this.versionSize+'.jpg}{title='+this.title+'}{interpolators_mode=3}{image_id='+'}',uid:'',lang:this.lang,load:'0',windowMode:'layer',path:this.path}//pano0,
		      return this._getAppletTag(req,par);
		    };
	  this._getAppletTag=function(attr,pConf){
		    var str='<applet';
		    str+=' id="'+attr.id+'"';
		    str+=' name="'+attr.name+'"';
		    str+=' width="'+attr.width+'"';
		    str+=' height="'+attr.height+'"';
		    str+=' archive="'+attr.archive+'"';
		    str+=' codebase="'+attr.codebase+'"';
		    str+=' code="'+attr.code+'"';
		    str+=' mayscript="'+attr.mayscript+'">';
		    for(var el in pConf){
			    str+='<param name="'+el+'" value="'+pConf[el]+'"/>';
			    }
		    str+='</applet>';//alert(str)
		    return str;
		    };
	  this._getQt=function(p){
    var sizes={l:[640 , 480],b:['100%','100%']}//l:[320,240],
      var obAttr={classid:'clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b',codebase:'http://www.apple.com/qtactivex/qtplugin.cab',id:'panoTtMovie1'}
		        if(p.size=='b'){       
			        sizes.b[0]=0
			          sizes.b[1]=Math.round(screen.availHeight-30);
			        sizes.b[0]=Math.round((sizes.b[1])/(3/4))//4/6
			        //Opcja
			        sizes.b[0]=sizes.b[1]='100%'
			          }
		          obAttr.width=sizes[p.size][0];
		    obAttr.height=sizes[p.size][1];
						//na xp err
						var ac=navigator.userAgent.toLowerCase().indexOf('windows nt 5.1;')!=-1?'?ac='+Math.random()*100:''
    var par={src:this.vmpBaseURI+'panoramas/'+this.user+'/'+this.humanId+'_'+p.size+'.mov'+ac,controller:'true',scale:'tofit',correction:'full',bgcolor:'#000000',kioskmode:"true"}//aspect
      par=this._addPar(par,p.positions)
      var embAttr={width:obAttr.width,height:obAttr.height,controller:par.controller,href:par.src,src:par.src,bgcolor:par.bgcolor,border:'0',scale:par.scale,correction:par.correction,pluginspage:'http://www.apple.com/quicktime/download/indext.html',name:obAttr.id,enablejavascript:"true",kioskmode:"true"}
		embAttr=this._addPar(embAttr,p.positions)
		//alert(this._getObjectTag(req,par,emb))
		        return this._getObjectTag(obAttr,par,embAttr);
		    };
	  this._getFlash=function(p){
		    var obAttr=this._flasReqPar;
		    obAttr.id="pano_flashmovie_1";
		      obAttr.width=750;
		    obAttr.height=375;
    var par={movie:this.vmpBaseURI+'www/pano_simple_thin.swf?isweb=true&imgFile='+this.vmpBaseURI+'panoramas/'+this.user+'/'+this.humanId+'_flash.jpg',bgcolor:'#000000',quality:'high', menu:'false',scale:"exactfit"}
      var embAttr={src:par.movie,quality:par.quality,	menu:par.menu,bgcolor:par.bgcolor,	width:obAttr.width,height:obAttr.height,type:"application/x-shockwave-flash",pluginspage:"http://www.macromedia.com/go/getflashplayer",scale:par.scale,swliveconnect:"true",name:obAttr.id}
		        return this._getObjectTag(obAttr,par,embAttr);
		    };
	  this._getObjectTag=function(obAttr,par,embAttr){
		    var str='<object';
		    for(var el in obAttr){
			    str+=' '+el+'="'+obAttr[el]+'"';
			    }
		    /*str+=' id="'+obAttr.id+'"';
		    
		    str+=' classid="'+obAttr.classid+'"';
		    str+=' width="'+obAttr.width+'"';
		    str+=' height="'+obAttr.height+'"';
		   // str+=' enablejavascript="true"';
		    str+=' codebase="'+obAttr.codebase+'">';*/
		    str+='>';
		    for(var el in par){
			    str+='<param name="'+el+'" value="'+par[el]+'"/>';
			    }
		    str+='<embed';
		    for(var el in embAttr){
			    str+=this._addAttr(el,embAttr[el]);
			    }
		    str+='></embed>';
		    str+='</object>';
		   // alert(str)
		    return str;
		    };
	  this._addAttr=function(k,v){
		    return ' '+k+'="'+v+'"'
		      }
	      /**
	      *dowolny układ
	      */
	      this._getHTML=function(){

		        };
	  this._decorateCenter=function(c,cl){
				var str='<table   align="center">'
				if(typeof(cl)=='string'){
				str+='<tr><td></td><td style="text-align:right;padding-top:80px" valign="bottom">'+cl+'</td><td></td></tr>'
				}
				str+='<tr><td></td><td valign="top" height="1" style="width:1px;height:1px" align="center">'+c+'</td><td></td></tr>'
				str+='</table>' 
				return str
		      };
	  this.setOpacity=function(el,op){
		    if(typeof(el.style.opacity)!='undefined'){
			    el.style.opacity=op;
			    }else if(typeof(el.style.MozOpacity)!='undefined'){
			    el.style.MozOpacity=op
			      }else if(typeof(el.style.filter)!='undefined'){
			      var v=Math.round(op*100);
			      el.style.filter="alpha(opacity="+v+")"
			        }
		        };

						
						this.start=function(){
						   this.rOver=document.getElementById(this.layOverName);
	    //alert(this.layOverName)
	  this.rAll=document.getElementById(this.layAllName);
						this.vmpBaseURI="http://"+this.host+":"+this.port+this.path
						this.br=new VpmAnyBrowser();
							
						};
						this._addPar=function(inP,params){
						for(var p in params){
						inP[p]=params[p]
						}
						return inP;
						}
	  };
			clearPreloadScreen=function(){
			};
			panoLanuncher_hideOverLayer=function(){
				panoLanuncher.hideOverLayer()
			};

panoLauncher=new PanoLauncher();
