var activeId;
menuManagerC=function(){
  this.positionParams=navigationConf.l2Pos
	  this.u=new utils()
	  this.fps=24;
	  this.waitTimer=2000;
	  window.topMenuTimerId=null;
	  window.topMenuClipTimerId=null;
	  this.bSw=true;
	  document.ondblclick=function() { 
	  menuManager.hideContener(); 
	  }
	    this.showSection=function(id){
		      this.resetTimer();
		      if(this.curId!=null)this.hideContener();
		      if(id!=='')this.showContener(id);
								try{document.getElementById('dPanoAll').style.display='none'}catch(e){};
		      };
	  this.hideSection=function(id){
		    this.resetTimer();
		    window.topMenuTimerId=setInterval('menuManager.hideContener()',this.waitTimer);
		    };
	  this.resetTimer=function(){
		    this.bSw=true;
		    clearInterval(window.topMenuTimerId);
		    window.topMenuTimerId=null;
		    clearInterval(window.topMenuClipTimerId);
		    window.topMenuClipTimerId=null;
						
		    };
	  /**
	  *Tu miejsce na animacje 
	  */
	  this.switchSection=function(id){
		    window.event.cancelBubble=true;
		    //alert(this.bSw)
		    if(this.bSw){
			    this.showSection(id);
			    this.bSw= !this.bSw;
			    }else
			    {
			    this.hideContener();
			    };
		    };
	  this.hideContener=function(){
		    this.resetTimer()
		    var id=this.curId;
		    if(id==null)return;
		    this.curId=null;
		    this.findContener(id).style.display='none';
						try{document.getElementById('dPanoAll').style.display='inline'}catch(e){};
		    };
	  this.showContener=function(id){
		    if(typeof(this.mdestPos)=='undefined'){
			    this.mdestPos=parseInt(this.findContener(id).style.left);
			    };
		    this.curId=id;

		    this.setStartPosition();
		    this.findContener(id).style.display='inline';
		    this.clipLoop();
		    window.topMenuClipTimerId=setInterval('menuManager.clipLoop()',this.fps);
		    };
	  this.setStartPosition=function(){
		    this.obRef=this.findContener(this.curId)
		      //this.curContentW=this.u.getDivScrollWidth(this.obRef);
		      this.u.setDivPos(this.obRef,'left',this.positionParams.left);
		    this.u.setDivPos(this.obRef,'top',this.positionParams.top);
		    //this.clipPos=[this.positionParams.height/2-2,this.positionParams.width/2,this.positionParams.height/2,this.positionParams.width/2]
						var d=70;
						this.clipPos=[-1,this.positionParams.width/2+d,50,this.positionParams.width/2-d]
		      };
	  this.clipLoop=function(){
    var steps={x:15,y:10};
		    this.clipPos[1]+=steps.x;
		    this.clipPos[3]-=steps.x;
		    //logDebug(this.clipPos[1]<this.positionParams.width)
		    if(this.clipPos[1]<=this.positionParams.width ){
			    this.u.clipDiv(this.obRef,this.clipPos);
			    return;
			    };
		    //this.clipPos[0]-=steps.y;
		    this.clipPos[2]+=steps.y;
		    if(this.clipPos[2]<=this.positionParams.height){
			    this.u.clipDiv(this.obRef,this.clipPos);
			    return;
			    }
		    this.resetTimer();
		    };
	  this.findContener=function(id){
		    return document.getElementById('dml'+id);
		    };
	  this.getCurId=function(){
		    return this.curId;
		    };
		this.swfCom=function(command, args){
			switch(command){
				case 'go':
				if(args=="menu"){
					//this.showSection(1)
					var el=document.getElementById("dln-"+args)
					location=el.href;
					activeId=args;
				}
				else{
					var el=document.getElementById("dln-"+args)
					location=el.href;
					activeId=args;
				}
				break;
				case 'reset':
					this.hideContener();
					break;
				}
		}
	  };
function startMenuManager(){
	window.menuManager=new menuManagerC()
}
onLoadQueue.appendOnLoad(startMenuManager)
/*
 function menuswf_DoFSCommand(command, args) {
//alert(command)
switch(command){
case 'go':
if(args=="menu"){
	menuManager.showSection(1)
}
else{
	var el=document.getElementById("ln-"+args)
	location=el.href;
}
break;
case 'reset':
	menuManager.hideContener();
	break;
}
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<scr'+'ipt language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub menuswf_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call menuswf_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</scr'+'ipt\>\n');
}*/