//globalna wartosc buttonA
var buttAnr=1;

// -------- onLoad ---------------------//
//ukrycie zawartosci przed zaladowaniem - po zaladowaniu wyswietlenie
function onLoad(){
	
	//wylaczenie alertu javascript -testpage
	//document.getElementById("testpage").innerHTML="";
	
	//przywrocenia clasy body
	//document.body.className="body";
	
	//rozpoznanie przegladarki
	initDHTMLAPI();
	
	//alert("onLoad");
	createAlert();
	
	//preloading images
	if(typeof(arrImgBef)=="object"){
		preloadImages(arrImgBef);
	}
	
	document.getElementById("wrapper").style.display="block";
	
	//preloading images
	if(typeof(arrImgAft)=="object"){
		preloadImages(arrImgAft);
	}
	
			
	//zaloadowanie podstawowych images
	//alert
	preloadImages(new Array('images/themes/new_modern/alertLeft.png','images/themes/new_modern/alertRight.png','images/themes/new_modern/alertCenter.png'));

	//document.getElementById("structure").onmousemove=fun1;
}

//--------------- alert -------------//
function createAlert(){
//czy jest element alertDiv
	//alert("alertDiv");
 	if(!document.getElementById("alertDiv")){
 		//utworzenie elementu
 		var alertDiv = document.createElement("div"); 
		alertDiv.setAttribute("id","alertDiv"); 
		document.getElementById("inside").appendChild(alertDiv);
	}
	
	var alertDiv=document.getElementById("alertDiv");

	//przypisanie styli
	alertDiv.style.visibility="hidden";
	//alertDiv.style.display="block";
	alertDiv.style.position="absolute";
	alertDiv.style.width="300px";
	alertDiv.style.height="140px";
	alertDiv.style.zIndex="100";

	
	//alert(left);
	
	var wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0"><tr><td width="9px"><div id="alertTableLeft"></div></td><td><table cellspacing="0" cellpadding="0" id="alertTableInside"><tr><td valign="middle" height="87px"></td></tr><tr><td valign="middle" align="center" height="35px"><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertOK" onclick="alertRet(\'OK\')">OK</div></td></tr><tr><td height="18px">&nbsp;</td></tr></table></td><td  width="9px"><div id="alertTableRight"></div></td></tr></table>';
	alertDiv.innerHTML=wpis;

}
/**
* wyswietla alert
* @param kom komunikat
* @param type typ okna 0 - OK, 1 - Tak, Nie, Anuluj
* @param inst instrukcja wywolana po kliknieciu
* @param data argument instrukcji
*/
function alertWin(kom,type,inst,data){
 	
	var wpis;
	//OK
	if(type==0||type==null){
		//wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0"><tr><td width="9px"><div id="alertTableLeft"></div></td><td><table cellspacing="0" cellpadding="0" id="alertTableInside"><tr><td valign="middle" height="87px">'+kom+'</td></tr><tr><td valign="middle" align="center" height="35px"><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertOK" onclick="alertRet(\'OK\','+data+')">OK</div></td></tr><tr><td height="18px">&nbsp;</td></tr></table></td><td  width="9px"><div id="alertTableRight"></div></td></tr><table>';
		wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0" id="alertTableInside"><tr><td width="25px" rowspan="2"><div class="alertTableLeft"></div></td><td valign="middle" height="95px">'+kom+'</td><td  width="25px" rowspan="2"><div class="alertTableRight"></div></td></tr>';	
		wpis+='<tr valign="top" align="center"><td height="45px"><div id="alertOK"></div></td>';
		wpis+='</tr></table>';
	//Tak, Nie, Anuluj
	}else if(type==1){
		//wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0"><tr><td width="9px"><div id="alertTableLeft"></div></td><td><table cellspacing="0" cellpadding="0" id="alertTableInside"><tr><td valign="middle" colspan="3" height="87px">'+kom+'</td></tr><tr align="center" height="35px"><td><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertYES" onclick="'+inst+'(\'YES\','+data+')">Tak</div></td><td><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertNO" onclick="'+inst+'(\'NO\','+data+')">Nie</div></td><td><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertCANCEL" onclick="'+inst+'(\'CANCEL\','+data+')">Anuluj</div></td></tr><tr height="18px"><td></td><td></td><td></td></tr></table></td><td  width="9px"><div id="alertTableRight"></div></td></tr><table>';
		//wy='Jeśli chcesz przejść do edycji wybranej ankiety wybierz: ';
		/*wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0" id="tabtest"><tr><td width="25px"><div id="alertTableLeft">AA&nbsp;</div></td><td><table cellspacing="0" cellpadding="0" id="alertTableInside"><tr><td valign="middle" colspan="3" height="82px">'+wy+wy+kom+'</td></tr>';	
		wpis+='<tr align="center"><td><div id="alertYES"></div></td><td><div id="alertNO"></div></td><td><div id="alertCANCEL"></div></td>';
		wpis+='</tr></table></td><td  width="25px"><div id="alertTableRight">BB&nbsp;</div></td></tr><table>';
		*/
		wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0" id="alertTableInside"><tr><td width="25px" rowspan="2"><div class="alertTableLeft"></div></td><td valign="middle" height="95px">'+kom+'</td><td  width="25px" rowspan="2"><div class="alertTableRight"></div></td></tr>';	
		wpis+='<tr valign="top"><td height="40px"><div id="alertYES"></div><div id="alertNO"></div><div id="alertCANCEL"></div></td>';
		wpis+='</tr></table>';
		
		
		
		//wywolanie ladowania buttonow
		//wpis+='<script type="text/javascript"> buttonA("alertYES","Tak","'+inst+'(\'YES\','+data+')",100);  buttonA("alertNO","Nie","'+inst+'(\'YES\','+data+')",100); buttonA("alertCANCEL","Anuluj","'+inst+'(\'CANCEL\','+data+')",100);';
	}
	
	
	
	
	var alertDiv=document.getElementById("alertDiv");
	//alertDiv.style.visibility="hidden";
	alertDiv.style.width="300px";
	alertDiv.innerHTML=wpis;

	//wywolanie ladowania buttonow
	//OK
	if(type==0||type==null){
		inst="alertRet";
		buttonA("alertOK","OK",(inst+'(\'OK\','+data+')'),80);
	//Tak, Nie, Anuluj
	}else if(type==1){
		buttonA("alertYES","Tak",(inst+'(\'YES\','+data+')'),80);
		buttonA("alertNO","Nie",(inst+'(\'NO\','+data+')'),80);
		buttonA("alertCANCEL","Anuluj",(inst+'(\'CANCEL\','+data+')'),80);
	}
	
	
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	
	
	    //pozycja okna 
   if(!window.innerHeight){
   		frameHeight=frameHeight>document.body.scrollHeight?document.body.scrollHeight:frameHeight;

   		var scrollTop;
   		if (document.documentElement && document.documentElement.scrollTop){
   			scrollTop=document.documentElement.scrollTop;
   		}else{
	   		scrollTop=document.body.scrollTop;
   		}
   		
   		//alert(frameHeight+","+document.body.offsetTop+","+document.body.offsetHeight+","+scrollTop);
		alertDiv.style.top = (parseInt(frameHeight / 2) - (140 / 2) + scrollTop) + 'px';
		//alertDiv.style.left = (parseInt(frameWidth / 2) - (300 / 2) + document.body.offsetLeft) + 'px';
		alertDiv.style.left = (parseInt(frameWidth / 2) - (300 / 2) ) + 'px';
    }else{
		//MOZ
		frameHeight=frameHeight>document.getElementById("wrapper").offsetHeight?document.getElementById("wrapper").offsetHeight:frameHeight;
		alertDiv.style.top = (window.pageYOffset+(frameHeight / 2) - (140 / 2)) + 'px';
		alertDiv.style.left = (window.pageXOffset+(window.innerWidth / 2) - (300 / 2)) + 'px';
    }
	
	//alert(document.body.scrollHeight+","+window.innerHeight+","+document.getElementById("wrapper").offsetHeight);
	
	//jesli istnieje DIV : selectDiv
	if(document.getElementById("selectDiv")){
		selectResize(parseInt(alertDiv.style.left),parseInt(alertDiv.style.top),parseInt(alertDiv.style.width),parseInt(alertDiv.style.height));
	}
	//wyswietlenie elementow
	//alertIframe.style.top=170;
	
	//alertIframe.style.display="block";
	//alertDiv.style.display="block";
	
	//document.getElementById("sel").style.display="none";
	
	//var selStyle=document.getElementById("div1").style;
	//alert(arrPos[0]+","+arrPos[1]+","+arrPos[2]+","+arrPos[3]);

	//selStyle.width="100px";
	//selStyle.overflow="hidden";

	
	//alert(window.innerHeight+","+window.pageYOffset);
	
	//wyswietlenie alertu	
	alertDiv.style.visibility="visible";
	
}
//---------------------------------------------
//----- zmniejszanie pol select -------
function selectResize(left,top,width,height){
	//alert(left+","+top+","+width+","+height);
	//pobranie wartosci elementu select
	//var sel=document.getElementsByTagName("select")[0];
	var sel=document.getElementById("selectDiv");
	var arrSel=findPos(sel);
	//alert(left+","+top+","+width+","+height+"\n"+arrSel[0]+","+arrSel[1]+","+arrSel[2]+","+arrSel[3]);
	if((arrSel[0]+arrSel[2]>left)&&(arrSel[1]+arrSel[3]>top)&&(arrSel[1]<top+height)){
		//alert("poczlo");
		sel.style.overflow="hidden";
		sel.style.width=left-arrSel[0]+"px";
	}
}
//---------------------------------------------------
//---------- wyznaczanie pozycji obiektu---------
function findPos(obj) {
	var curleft = curtop = 0;
	var curwidth = curheight = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		
		curwidth = obj.offsetWidth;
		curheight = obj.offsetHeight;
		
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop,curwidth,curheight];
}
//--------------------------
// ---------------- alert skok --------------//
function alertSkok(kom,inst,nrAns,arrPyt){
	
	//alert(nrAns+","+arrPyt);
/* 
 	//czy jest element alertDiv
 	if(!document.getElementById("alertDiv")){
 		//utworzenie elementu
 		var alertDiv = document.createElement("div"); 
		alertDiv.setAttribute("id","alertDiv"); 
		document.body.appendChild(alertDiv);
	}
	
	var alertDiv=document.getElementById("alertDiv");

	//przypisanie styli
	alertDiv.style.position="absolute";
	alertDiv.style.width="450px";
	alertDiv.style.height="140px";
	alertDiv.style.zIndex="100";
	//alertDiv.style.display="block";
	*/
		
	//alert(left);
	
	/* var wpis;
	wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0"><tr><td width="9px"><div id="alertTableLeft"></div></td><td><table cellspacing="0" cellpadding="0" id="alertTableInside"><tr><td valign="middle" colspan="3" height="60px">'+kom+'</td></tr>';
	wpis+='<tr align="top" height="35px"><td colspan="3">';
	//utworzenie pola Select
	wpis+='<form name="formSkok"><select name="selNrPyt" onchange="" style="width:400px;font-weight:normal;font-size:11px;">';
	for(licz=1;licz<arrPyt.length;licz++){
		wpis+='<option value="'+licz+'"><b>'+licz+'.</b>'+arrPyt[licz]+'</option>';
	}
	wpis+='</select></form></td></tr>';
	wpis+='<tr align="center" height="35px"><td><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertYES" onclick="'+inst+'(\'OK\',document.formSkok.selNrPyt.selectedIndex,'+nrAns+')">OK</div></td><td><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertDEL" onclick="'+inst+'(\'DEL\',document.formSkok.selNrPyt.selectedIndex,'+nrAns+')">Brak przejścia</div></td><td><div class="buttonUp" onmouseover="this.className=\'buttonOver\';" onmousedown="this.className=\'buttonDown\';" onmouseout="this.className=\'buttonUp\';" id="alertCANCEL" onclick="'+inst+'(\'CANCEL\',document.formSkok.selNrPyt.selectedIndex,'+nrAns+')">Anuluj</div></td></tr><tr height="10px"><td></td><td></td><td></td></tr></table></td><td  width="9px"><div id="alertTableRight"></div></td></tr><table>';
*/


	var wpis;

	wpis='<table width="100%" height="100%" cellspacing="0" cellpadding="0" id="alertTableInside">';
	wpis+='<tr><td width="25px" rowspan="3"><div class="alertTableLeft"></div></td><td valign="middle" height="60px">'+kom+'</td><td  width="25px" rowspan="3"><div class="alertTableRight"></div></td></tr>';	
	//utworzenie pola Select
	wpis+='<tr><td><form name="formSkok"><select name="nrPyt" onchange="" style="width:400px;font-weight:normal;font-size:11px;">';
	for(licz=1;licz<arrPyt.length;licz++){
		wpis+='<option value="'+licz+'"><b>'+licz+'.</b>'+arrPyt[licz]+'</option>';
	}
	//for(licz=1;licz<arrPyt.length;licz++){
		//wpis+='<option value="'+licz+'"><b>'+licz+'.</b>'+arrPyt[licz]+'</option>';
//	}
	wpis+='</select></form></td></tr>';
	wpis+='<tr valign="top"><td height="40px"><div id="alertYES"></div><div id="alertNO"></div><div id="alertCANCEL"></div></td></tr>';
	wpis+='</table>';

	
	var alertDiv=document.getElementById("alertDiv");
	//alertDiv.style.visibility="hidden";
	alertDiv.style.width="450px";
	/* alertDiv.style.height="140px";*/
	alertDiv.innerHTML=wpis;

	//wywolanie ladowania buttonow

	buttonA("alertYES","OK",(inst+'(\'OK\',document.formSkok.nrPyt.selectedIndex,'+nrAns+')'),80);
	buttonA("alertNO","Usuń",(inst+'(\'DELETE\',document.formSkok.nrPyt.selectedIndex,'+nrAns+')'),80);
	buttonA("alertCANCEL","Anuluj",(inst+'(\'CANCEL\')'),80);

	
	
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	
	    //pozycja okna 
	    //dla IE
   if(!window.innerHeight){
   		frameHeight=frameHeight>document.body.scrollHeight?document.body.scrollHeight:frameHeight;
		 var scrollTop;
   		if (document.documentElement && document.documentElement.scrollTop){
   			scrollTop=document.documentElement.scrollTop;
   		}else{
	   		scrollTop=document.body.scrollTop;
   		}
   		
   		//alert(frameHeight+","+document.body.offsetTop+","+document.body.offsetHeight+","+scrollTop);
		alertDiv.style.top = (parseInt(frameHeight / 2) - (140 / 2) + scrollTop) + 'px';
		//alertDiv.style.left = (parseInt(frameWidth / 2) - (450 / 2) + document.body.offsetLeft) + 'px';
		alertDiv.style.left = (parseInt(frameWidth / 2) - (450 / 2)) + 'px';
    }else{
		//MOZ
		frameHeight=frameHeight>document.getElementById("wrapper").offsetHeight?document.getElementById("wrapper").offsetHeight:frameHeight;
		alertDiv.style.top = (window.pageYOffset+(frameHeight / 2) - (140 / 2)) + 'px';
		alertDiv.style.left = (window.pageXOffset+(window.innerWidth / 2) - (450 / 2)) + 'px';
	}
	
	//alert(document.body.scrollHeight+","+window.innerHeight+","+document.getElementById("wrapper").offsetHeight);
	
	//jesli istnieje DIV : selectDiv
	if(document.getElementById("selectDiv")){
		selectResize(parseInt(alertDiv.style.left),parseInt(alertDiv.style.top),parseInt(alertDiv.style.width),parseInt(alertDiv.style.height));
	}
	
	//wyswietlenie alertu	
	alertDiv.style.visibility="visible";


	/* alertDiv.innerHTML=wpis;
	
	    //pozycja okna 
   if(!window.innerHeight){	//dla IE
		alertDiv.style.top = (parseInt(document.body.clientHeight / 2) - (140 / 2) + document.body.scrollTop) + 'px';
		alertDiv.style.left = (parseInt(document.body.clientWidth / 2) - (450 / 2) + document.body.scrollLeft) + 'px';
    }else{
		//MOZ
		alertDiv.style.top = (window.pageYOffset+(window.innerHeight / 2) - (140 / 2)) + 'px';
		alertDiv.style.left = (window.pageXOffset+(window.innerWidth / 2) - (450 / 2)) + 'px';
    }
	
	//jesli istnieje DIV : selectDiv
	if(document.getElementById("selectDiv")){
		selectResize(parseInt(alertDiv.style.left),parseInt(alertDiv.style.top),parseInt(alertDiv.style.width),parseInt(alertDiv.style.height));
	}
	alertDiv.style.visibility="visible";*/
}
//---- alertOK
function alertRet(arg){
	
	if(arg=="OK"||arg=="CANCEL"){
		//document.getElementById("alertDiv").style.display="none";
		document.getElementById("alertDiv").style.visibility="hidden";
		if(document.getElementById("selectDiv")){
			document.getElementById("selectDiv").style.overflow="visible";
		}
	}
}
//----------- escape ----------//
//dodaje przed znakami: " ' \
// symbol: \
function escape(we){
	
	var wy="";
	var strLen=we.length;
	for(licz=0;licz<strLen;licz++){
		if(we.charAt(licz)=="\""||we.charAt(licz)=="'"||we.charAt(licz)=="\\"){
			wy+="\\"+we.charAt(licz);
		}else{
			wy+=we.charAt(licz);
		}
	}
	return wy;
}

//---------------------------------------
//---------------------------------------
// Global variables
var isCSS, isW3C, isIE4, isNN4, isIE6CSS,isMOZILLA,isFIREFOX; 
// Initialize upon load to let all browsers establish content objects 
function initDHTMLAPI( ) { 
    if (document.images) { 
        isCSS = (document.body && document.body.style) ? true : false; 
        isW3C = (isCSS && document.getElementById) ? true : false; 
        isIE4 = (isCSS && document.all) ? true : false; 
        isNN4 = (document.layers) ? true : false; 
        isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ?true : false; 
		isOPERA = (window.opera)?true:false;
    } 
   // alert(navigator.appName + "," + navigator.appVersion+","+navigator.userAgent);
    
    var info=navigator.userAgent.toLowerCase();
    if(info.indexOf("gecko")!=-1){
    	  if(info.indexOf("firefox")==-1){
    	  	isMOZILLA=true;
    	  	isFIREFOX=false;
    	  }else{
    	  	isMOZILLA=false;
    	  	isFIREFOX=true;
    	  }
	}
    
    //alert(info+","+isMOZILLA+","+isFIREFOX);
   //alert(isCSS+","+isW3C+","+isIE4+","+isNN4+","+isIE6CSS+","+isOPERA);
} 
//---------------------------------------
// Center a positionable element whose name is passed as  // a parameter in the current window/frame, and show it 
function centerOnWindow(elemID) { 
    // 'obj' is the positionable object 
    var obj = getRawObject(elemID); 
    // window scroll factors 
    var scrollX = 0, scrollY = 0; 
    if (document.body && typeof document.body.scrollTop != "undefined") { 
        scrollX += document.body.scrollLeft; 
        scrollY += document.body.scrollTop; 
        if (document.body.parentNode && typeof document.body.parentNode.scrollTop != "undefined") { 
            scrollX += document.body.parentNode.scrollLeft; 
            scrollY += document.body.parentNode.scrollTop; 
        } 
    } else if (typeof window.pageXOffset != "undefined") { 
        scrollX += window.pageXOffset; 
        scrollY += window.pageYOffset; 
    } 
    var x = Math.round((getInsideWindowWidth( )/2) -  
        (getObjectWidth(obj)/2)) + scrollX; 
    var y = Math.round((getInsideWindowHeight( )/2) -  
        (getObjectHeight(obj)/2)) + scrollY; 
    shiftTo(obj, x, y); 
    show(obj); 
}
//------------------------------------------
// Convert object name string or object reference // into a valid element object reference 
function getRawObject(obj) { 
    var theObj; 
    if (typeof obj == "string") { 
        if (isW3C) { 
            theObj = document.getElementById(obj); 
        } else if (isIE4) { 
            theObj = document.all(obj); 
        } else if (isNN4) { 
            theObj = seekLayer(document, obj); 
        } 
    } else { 
        // pass through object reference 
        theObj = obj; 
    } 
    return theObj; 
}
//---------------------------------
//---------------------------------------------------------------
//--------------- alert -------------//


//---------------obsługa buttonow --------------------//
/**
* obsługa buttonA
* @param string id identyfikator pola div
* @param string napis - na przycisku
* @param string oper - operacja która ma zostać wykonana po naciśnięciu
* @param number minWidth - minimalna szerokosc
*/
function buttonA(id,napis,oper,minWidth){

	//alert ("weszlo:"+id);
	
	
	
	//document.styleSheets.buttonAUp.all.width=minWidth+"px";
	var layer="buttAlayer"+buttAnr++;
	//var wpis='<div class="buttonAUp" id="buttAlayer'+buttAnr+'"><div><div><div onclick="'+oper+'" onmouseover="document.getElementById(\''+"buttAlayer"+buttAnr+'\').className=\'buttonAOver\';" onmousedown="document.getElementById(\''+"buttAlayer"+buttAnr+'\').className=\'buttonADown\';" onmouseout="document.getElementById(\''+"buttAlayer"+buttAnr+'\').className=\'buttonAUp\';">'+napis+'</div></div></div></div>';
	//var wpis='<a href="javascript:'+oper+'" id="'+layer+'" class="buttonMenuA"  onmouseover="setTimeout(\'document.getElementById(\\\''+layer+'\\\').style.backgroundImage=\\\'url(images/global/buttonBlueOver.gif)\\\'\',500);" onmousedown="this.style.backgroundImage=\'url(images/global/buttonBlueDown.gif)\';" onmouseout="this.style.backgroundImage=\'url(images/global/buttonBlue.gif)\';">'+napis+'</a>';
	var wpis='<a href="javascript:'+oper+'" id="'+layer+'" class="buttonMenuA"  onmouseover="this.style.backgroundImage=\'url(images/global/buttonBlueOver.gif)\';" onmousedown="this.style.backgroundImage=\'url(images/global/buttonBlueDown.gif)\';" onmouseout="this.style.backgroundImage=\'url(images/global/buttonBlue.gif)\';">'+napis+'</a>';
	
	document.getElementById(id).innerHTML=wpis;
	
	/* var layer="buttAlayer"+buttAnr;
	if(minWidth!=null) document.getElementById(layer).style.width=minWidth+"px";
	
	buttAnr++;
	
	//preloading pozostalych img na buttony - over down
	var img=new Array("images/themes/new_modern/butAoverLeft.png","images/themes/new_modern/butAoverCenter.png","images/themes/new_modern/butAoverRight.png","images/themes/new_modern/butAdownLeft.png","images/themes/new_modern/butAdownCenter.png","images/themes/new_modern/butAdownRight.png");
	var pic=new Array();
	for(i=0;i<img.length;i++){
		
		pic[i]=new Image();
		pic[i].src=img[i];
		//pic[i].onerror = preloadOnError;	
	
	}
	
	//preloading pozostalych img na alert
	var img2=new Array("images/themes/new_modern/alertRight.png","images/themes/new_modern/alertLeft.png");
	var pic2=new Array();
	for(i=0;i<img2.length;i++){
		
		pic2[i]=new Image();
		pic2[i].src=img2[i];
		pic2[i].onerror = preloadOnError;	
	
	}  */
	
}

function preloadOnError() {                                           
	alert("błąd ładowania");
}
//----------------------------------------------------------------------
//instrukcja H4
function loadInst(arg){

	 //wywolanie procedur ajax
  	remote.readHelpInst(arg);

}

//------------------------------------------------
//------------------------- menuAH2 -------------------------------------------
var menuAH2=new Object();

menuAH2.arrOn=new Array();

//menuH2.menu array z nazwami elementow Menu

//-------------------------
/**
* obsługa wywolan menuH2 
*/
menuAH2.onclick=function (oper){
	
	//dla przyciskow jednostanowych
	//helpInside.close();
	
	sendData(new Array({name:"oper",value:new Array(oper+"")}));
	
	//var re = /\/.*/g; 
	//var path = location.pathname.replace(re, "")
	
	//oper=oper.toLowerCase();
	//location.href=oper;
	
};
//-------------------------
/**
* obsługa zdarzen menuH2 
* @param string arg up, over ... aktualne zdarzenie
* @param number nrButton nr przycisku
* @param object button referencja do danego obiektu
* @param string instrOpen instrukcja otwarcia
* @param string instrClose instrukcja zamnkiecia lub null w przypadku przyciskow jednostanowych
*/
menuAH2.event=function (arg,nrButton,button,instOpen,instClose){

	//alert(arg);

	//alert(this.arrOn[nrButton]);

	
	//dla przyciskow dwustanowych
	if(instClose!=null){
		switch(arg){
		
			//dla buttonH2
			case "up":
				//jesli wcisniety
				if(this.arrOn[nrButton]==1){
					button.style.backgroundImage='url(images/global/menuH2Down.png)';
					button.style.color='#fff';
				}else{
					button.style.backgroundImage='url(images/global/menuH2Up.png)';
					button.style.color='#74A500';
				}
			break;
			case "over":
				//jesli wcisniety
				if(this.arrOn[nrButton]==1){
					button.style.backgroundImage='url(images/global/menuH2Down.png)';
					button.style.color='#fff';
				}else{
					button.style.backgroundImage='url(images/global/menuH2Over.png)';
					button.style.color='#74A500';					
				}
			break;
			case "down":
			//alert(this.arrOn[nrButton]);
				button.style.backgroundImage='url(images/global/menuH2Click.png)';
				button.style.color='#74A500';				
				//this.arrOn[nrButton]=this.arrOn[nrButton]==1?0:1;
				if(this.arrOn[nrButton]==1){
					this.arrOn[nrButton]=0;
					eval(instClose);
				
				}else{
					this.arrOn[nrButton]=1;
					
					eval(instOpen);
	
				}
			break;
			case "out":
				//jesli jest nie wlaczone po zdarzeniu out powrot do Down, w przeciwnym wypadku powrot do stanu normalnego
				if(this.arrOn[nrButton]==1){
					button.style.backgroundImage='url(images/global/menuH2Down.png)';
					button.style.color='#fff';					
				}else{
					button.style.backgroundImage='url(images/global/menuH2Up.png)';
					button.style.color='#74A500';					
				}
			break;
			
		
		}
	//dla przyciskow jednostanowych
	}else{
		switch(arg){
			//dla buttonH2
			case "up":
				button.style.backgroundImage='url(images/global/menuH2Up.png)';
			break;
			case "over":
				button.style.backgroundImage='url(images/global/menuH2Over.png)';
			break;
			case "down":
				button.style.backgroundImage='url(images/global/menuH2Down.png)';
			break;
			case "out":
				button.style.backgroundImage='url(images/global/menuH2Up.png)';
			break;
		}
		
	}
	

		
};
//------------------------------------------------
//===================================================================================
/**
* przywolanie dymku z foto lub komunikatem
* @param number evn zdarzenie 1 - wlaczenie, 0 - wylaczenie
* @param string name nazwa pliku jpg lub komunikat
* @param number type 0, undefined - zdjecie, 1 - komunikat
*/
var onMapIn=0;
function onMap(evn,name,type){

	//alert(name);
	//wlaczenie
	if(evn==1){

		//jesli nie istnieje to utworz alertMap
		if(!document.getElementById("alertMap")){
	 		//utworzenie elementu
	 		var alertMap = document.createElement("div"); 
			alertMap.setAttribute("id","alertMap"); 
			document.getElementById("inside").appendChild(alertMap);
		}
		
		var alertMap=document.getElementById("alertMap");
	
		//przypisanie styli
		alertMap.style.visibility="hidden";
		//alertMap.style.display="block";
		alertMap.style.position="absolute";
		alertMap.style.width="80px";
		alertMap.style.height="40px";
		alertMap.style.zIndex="100";
		
		//utworzenie etykiety
		var out='<table id="label_table" width="100%" height="100%" cellspacing="0" cellpadding="0">';
		out+='<tr><td><div id="label_lt"><div></td><td id="label_top"></td><td><div id="label_rt"><div></td></tr>';
		//out+='<tr><td id="label_left"></td><td id="label_inside"><img id="labelImg" src="images/help/'+img+'.jpg"></td><td id="label_right"></td></tr>';

		//jesli jest img
		if(type!=1 && name!=null) out+='<tr><td id="label_left"></td><td id="label_inside"><img id="labelImg" src="images/help/'+name+'.jpg" alt=" "></td><td id="label_right"></td></tr>';
		//jesli jest komunikat
		else if(type==1) out+='<tr><td id="label_left"></td><td id="label_inside">'+name+'</td><td id="label_right"></td></tr>';
		else out+='<tr><td id="label_left"></td><td id="label_inside"></td><td id="label_right"></td></tr>';

		out+='<tr><td><div id="label_lb"><div></td><td id="label_bottom"></td><td><div id="label_rb"><div></td></tr>';
		out+='</table>';
		//alert(out);
		alertMap.innerHTML=out;
		//alertMap.style.visibility="visible";
	//wylaczenie
	}else{
		var alertMap=document.getElementById("alertMap");
		//alertMap.innerHTML="dddd";
		alertMap.style.visibility="hidden";
		//alertMap.style.display="none";
	}
}

/**
* poruszanie dana warstwa
**/
function onMouseMove(evt) {  
	
	e = (evt) ? evt : ((event) ? event : null); 
	//alert(evt);
	var alertMap=document.getElementById("alertMap");
	
	 // turn on IE mouse capture
	 /*if (alertMap.setCapture) { 
		alertMap.setCapture( ); 
	} */
	
   // var targElem = (evt.target) ? evt.target : evt.srcElement ;
      
	//var left=0;
	//var top=0;
	
	/*if (evt.pageX) {  
		left = evt.pageX; 
		top = evt.pageY; 
	}else if (evt.x || evt.y) { 
		var imgLeft= window.event.clientX - window.event.offsetX;
		var imgTop= evt.clientY - evt.offsetY;
		if(imgLeft<0) left-=imgLeft;
   		left += evt.x;
	    top = evt.y;
		//left+= 304; 
		//top+= 240; 
	}else if (evt.clientX) { 
		left = evt.clientX; 
		top = evt.clientY; 
	} */
	

  if( typeof( e.pageX ) == 'number' ) {
    //most browsers
    var xcoord = e.pageX;
    var ycoord = e.pageY;
  } else if( typeof( e.clientX ) == 'number' ) {
    //Internet Explorer and older browsers
    //other browsers provide this, but follow the pageX/Y branch
    var xcoord = e.clientX;
    var ycoord = e.clientY;
    var badOldBrowser = ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) ||
     ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ||
     ( navigator.vendor == 'KDE' );
    if( !badOldBrowser ) {
      if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //IE 4, 5 & 6 (in non-standards compliant mode)
        xcoord += document.body.scrollLeft;
        ycoord += document.body.scrollTop;
      } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE 6 (in standards compliant mode)
        xcoord += document.documentElement.scrollLeft;
        ycoord += document.documentElement.scrollTop;
      }
    }
  }
	//alert(left+","+top);

	//alertMap.innerHTML=xcoord+","+ycoord;
    alertMap.style.position="absolute";       	
	alertMap.style.top=ycoord +15+"px";
	alertMap.style.left=xcoord+10+"px";
	alertMap.style.visibility="visible";
 }


