//==========================================================================
// helpCont
//==========================================================================

var helpCont=new Object();



	//tablica oznaczajaca czy otwarta zakladka; 0 - zamknieta, 1 - otwarta
	helpCont.arrFold=new Array();
	
	//zawartosc tekstowa zakladek
	helpCont.arrVal=new Array();
	
	//zawartosc tekstowa zakladek
	helpCont.lineHeight=14;
	
	/** 
	* @var boolean czy pomoc kontekstowa wlaczona
	*/
	helpCont.on;
	
	/** 
	* @var object AjaxObj obiekt Ajax
	*/
	helpCont.AjaxObj;
	
	//naglowek help
	helpCont.helpTop="<h2 style='margin-left:0px;'>Pomoc kontekstowa</h2><h4>&nbsp;</h4>";

 //=========================================================
 	//wlaczenie pomocy kontekstowej
 	helpCont.check=function(){

		//alert(getCookie("helpCont.on"));
		if(getCookie("helpCont.on")=="true"){
			this.open(this.go);
		}
	};
 //=========================================================
	//pobranie danych z readHelp
	helpCont.income=function(){
	
		//alert(this.AjaxObj[0]);
		
		//wartosc przesuniecia od lewej strony
		//var marginLeft=182;
		var marginLeft=170;
		//max liczba linii w ostatniej zakladce
		var maxLineDown=3;
		//wlasciwosci przycisku
		var butWidth=25;
		var butHeight=15;
			
		//alert("income");
		
		var html="";
		// wysokosci
		var marg=0;
		var arrHeight=new Array();
		var prevObj=0;
		
		var len=0;
		for(val in this.AjaxObj[1]){
			marg=(this.AjaxObj[1][val]-prevObj)*this.lineHeight;
			prevObj=this.AjaxObj[1][val];
			arrHeight.push(marg);
			len++;
		}
		len--;
		
		arrHeight.push(2*this.lineHeight);
		
	
		//var marginLeft=parseInt(document.getElementById('insideRight').style.width) - butWidth;
	
	
		
		//wysokosc paska oddzielajacego
		var breakHeight=6;
		//calkowita wyskosc od gory
		var top=0;
		
		if(parseInt(document.getElementById('insideRight').style.marginTop)>0) top=parseInt(document.getElementById('insideRight').style.marginTop);
		
		//var foldWidth=parseInt(document.getElementById('insideRight').style.width);
		
		var foldWidth=195;
	
		//arrId
		var i=0;
		
		//inicjacja
	
		//piewszy blok od gory
		if(arrHeight[i]>=0){
			if(arrHeight[i]>0) html+='<div style="height:'+arrHeight[i]+'px;width:'+foldWidth+'px;">';
			html+='</div><div style="margin:2px 0 2px 0;width:'+foldWidth+'px;padding:0;height:1px;font-size:2px;background-color:#ddd;"></div>'+"\n";
			top+=arrHeight[i]+breakHeight;
		}
	
		//styl wyswietlania
		var display="";
		var pos=(isOPERA||isMOZILLA||isFIREFOX)?'position:absolute;':'';
		var padR=(isOPERA)?'0':'3px';
		
		//alert(isMOZILLA+","+pos);		
		
		for(val in this.AjaxObj[0]){
			//arrHeight[i];
			//this.arrVal[i]=val;
			
			//jesli zakladka ma byc otwarta
			if(this.arrFold[i]==1){
				//display="display:table;";	
				display="display:inline;";	
				
				//alert(i);
				
				html+='<div id="fold'+i+'" style="top:'+arrHeight[i]+'px;height:'+arrHeight[i+1]+'px;width:'+foldWidth+'px;'+display+'background-image:url(images/global/helpContBack.png);background-repeat:repeat-y;"><span class="helpContVal">'+val+'</span>: ';
				html+=this.AjaxObj[0][val]+'</div>'+"\n";
		    	
		    		 
		    	//przycisk zamkniecia zakladki
				if(this.AjaxObj[2][val]==1){
					top+=arrHeight[i+1]+breakHeight;
					display="display:block;";	
					//html+='<div style="position:absolute;top:'+(top-butHeight)+'px;height:'+butHeight+'px;width:'+butWidth+'px;margin:-'+(butHeight)+'px 0 0 '+marginLeft+'px;'+display+'z-index:2;background-color:#eee;">&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:helpCont.closeFold('+i+');">&lt;&lt;</a></div>'+"\n";
					html+='<div style="'+pos+'height:'+butHeight+'px;width:'+(butWidth-10)+'px;margin:-'+(butHeight)+'px 0 0 '+(marginLeft+10)+'px;'+display+'z-index:2;background-color:#fafafa;">&nbsp;<a href="javascript:helpCont.closeFold('+i+');" style="text-decoration:underline;">&lt;&lt;</a></div>'+"\n";
				}
				   
		    	//pasek odzielajacy
		    	html+='<div style="margin:2px 0 2px 0;width:'+foldWidth+'px;padding:0;height:1px;font-size:1px;background-color:#ddd;z-index:1;"></div>'+"\n";
				
					
			}else{
				//alert(i+","+len)
				//jesli wszystkie zakladki oprocz ostatniej
				if(i<len){
					display="overflow:hidden;";
					html+='<div id="fold'+i+'" style="top:'+arrHeight[i]+'px;height:'+arrHeight[i+1]+'px;width:'+foldWidth+'px;'+display+'background-image:url(images/global/helpContBack.png);background-repeat:repeat-y;"><span class="helpContVal">'+val+'</span>: ';
				//jesli ostatnia zakladka
				}else{
					display="overflow:visible;";
					html+='<div id="fold'+i+'" style="top:'+arrHeight[i]+'px;width:'+foldWidth+'px;'+display+'background-image:url(images/global/helpContBack.png);background-repeat:repeat-y;"><span class="helpContVal">'+val+'</span>: ';
				}
				

				html+=this.AjaxObj[0][val]+'</div>'+"\n";
		    		    
		    	
				
				//przycisk otwarcia zakladki
				if(this.AjaxObj[2][val]==1){
					top+=arrHeight[i+1]+breakHeight;
					//html+='<div style="position:absolute;top:'+(top-butHeight)+'px;height:'+butHeight+'px;width:'+butWidth+'px;margin:-'+(butHeight)+'px 0 0 '+marginLeft+'px;'+display+'z-index:2;background-color:#eee;"> ... <a href="javascript:helpCont.openFold('+i+');">&gt;&gt;</a></div>'+"\n";
					
					html+='<div style="'+pos+'height:'+butHeight+'px;width:'+butWidth+'px;margin:-'+(butHeight)+'px 0 0 '+marginLeft+'px;'+display+'z-index:2;background-color:#fafafa;"> ... <a href="javascript:helpCont.openFold('+i+');" style="text-decoration:underline;">&gt;&gt;</a></div>'+"\n";
				}
				
				//pasek odzielajacy
		    	html+='<div style="margin:2px 0 2px 0;width:'+foldWidth+'px;padding:0;height:1px;font-size:1px;background-color:#ddd;z-index:1;"></div>'+"\n";
				
			}
	
	   		i++;
		}
	
	   
	    //alert(this.helpTop+html);
	    document.getElementById('insideRight').innerHTML=this.helpTop+html;
	
	    //var arrSel=findPos(document.getElementById('fold2'));
	   // alert(arrSel[0]+","+arrSel[1]+","+arrSel[2]+","+arrSel[3])
	};
 //=========================================================
	/**
	*otwarcie zakladek
	*@param number nr - zakladka do otwarcia
	*/
	helpCont.openFold=function(nr){
		
		this.arrFold[nr]=1;

		this.income();
	};
 //=========================================================
	/**
	*zamkniecie zakladek
	*@param number nr - zakladka do zamkniecia
	*/
	helpCont.closeFold=function(nr){
	
		this.arrFold[nr]=0;
		
		this.income();
	
	};
 //=========================================================
 	/**
 	* otwarcie pomocy glownej
 	*/
 	helpCont.openHelp=function(h1,h2){
 
 		//menuH2 Pomoc - ma byc wlaczone
 		for(i=0;i<menuAH2.menu.length;i++){
			if(menuAH2.menu[i]=="Pomoc"){
				menuAH2.arrOn[(i+1)]=1;
				break;
			}
		}
		
		//document.getElementById("menuH2Butt"+(++i)).className='buttonAH2Down';
		document.getElementById("menuH2Butt"+(++i)).style.backgroundImage='url(images/global/menuH2Down.png)';
		document.getElementById("menuH2Butt"+i).style.color='#fff';
		
		//wywolanie helpInside
		//jesli zamkniete
		if(helpInside.actualHistory==0){
			helpInside.open();
			helpInside.event[0]="this.clickFoldH1("+h1+",0,0)";
			helpInside.event[1]="this.clickFoldH2("+h1+","+h2+",1)";
		}else{
			helpInside.clickFoldH2(h1,h2,1);
	//		helpInside.event[1]="this.clickFoldH2("+h1+","+h2+",1)";
		}
		
		//helpInside.openH1[h1]=0;
		//helpInside.clickFoldH1(h1);
		
		//helpInside.clickFoldH2(h1,h2,1);
		//helpInside.history[helpInside.actualHistory++]={h1:0,h2:0};
		//helpInside.event="this.clickFoldH2("+h1+","+h2+",1)";
		
	};		
 //=========================================================		
	/**
	* otwarcie pomocy kontekstowej
	* 
	*/
	helpCont.open=function(arg){
	
		//alert("open");
		document.body.style.width="990px";
	    document.getElementById('insideRight').className="insideRight";
		
		 //menuH2 Pomoc kontekstowa - ma byc wlaczone
 		for(i=0;i<menuAH2.menu.length;i++){
			if(menuAH2.menu[i]=="Pomoc kontekstowa"){
				menuAH2.arrOn[(i+1)]=1;
				break;
			}
		}
		
		//document.getElementById("menuH2Butt"+(++i)).className='buttonAH2Down';
		document.getElementById("menuH2Butt"+(++i)).style.backgroundImage='url(images/global/menuH2Down.png)';
		document.getElementById("menuH2Butt"+i).style.color='#fff';
		
		this.on=true;
		//zapis do cookie
    	setCookie("helpCont.on", "true");  
    	
	   //	alert("goajax");
	   //wywolanie procedur ajax
  		remote.readHelpCont(arg);
	
	};
 //=========================================================
	/**
	* zamkniecie pomocy kontekstowej
	* 
	*/
	helpCont.close=function(){
	
		//alert("close");
	
		document.body.style.width="780px";
		document.getElementById('insideRight').innerHTML="";
	  	document.getElementById('insideRight').className="hide";
	   
		
	   	this.on=false;
		//zapis do cookie
    	setCookie("helpCont.on", "false");
    	
	   //wywolanie procedur ajax
	 //  remote.readHelp('ank');
	
	};
 //=========================================================
