var sciezka = "http://www.napco.pl/";
var katGrafika = sciezka+"grafika/";

var historia = 1;

function showHistZ()
{
	if( historia == -1 )
	{
		//ukryj
		document.getElementById("idhistoriaZ").style.display = 'none';
		historia = 1;
	}
	else
	{
		//pokaz
		document.getElementById("idhistoriaZ").style.display = 'block';
		historia = -1;
	}
}


function getMouseXYmoje(e){

	if( startProgress == true ){
		pasek = e.clientX+document.getElementById("progres_pasek").offsetLeft -480;
		
		procent = Math.ceil((pasek - 20)/2) ;
		
		if(procent <= 0){ procent = 0; }
		if(procent >=100){ procent =100; }
		
		document.getElementById("idproc").value = procent;
		
		progres(procent);
	}
	

} 

function zmien(obj,act,c)
{
	if( act == 1)
	{
		obj.className='posZOnMouse';
	}
	else
	{
		obj.className=c;
	}
}
function showPos(id_Z)
{
	window.open("index.php?mod=zadania&act=newZ&id_Z="+id_Z,'_self');
}

function info(act,e,lewa,szerokosc)
{
	getMouseXY(e);

	if( act == 1)
	{
		document.getElementById("idtooltip").style.display = 'block';
		document.getElementById("idtooltip").style.left = ''+lewa+'px';
		document.getElementById("idtooltip").style.top = ''+(tempY+30)+'px';
		if( typeof(szerokosc) != "undefined")
		{
			document.getElementById("idtooltip").style.width = ''+szerokosc+'px';
		}
	}
	else
	{
		document.getElementById("idtooltip").style.display = 'none';
		document.getElementById("idtooltip").innerHTML = '';
	}
}
function infotxt(txt)
{
	document.getElementById("idtooltip").innerHTML = txt;
}

var IE = document.all?true:false; 
if (!IE) document.captureEvents(Event.MOUSEMOVE) 
document.onmousemove = getMouseXY; 
var tempX = 0; 
var tempY = 0; 


function getMouseXY(e) { 
if (IE) { // grab the x-y pos.s if browser is IE 
tempX = event.clientX + document.body.scrollLeft; 
tempY = event.clientY + document.body.scrollTop; 
} 
else { // grab the x-y pos.s if browser is NS 
tempX = e.pageX; 
tempY = e.pageY; 
} 
if (tempX < 0){tempX = 0;} 
if (tempY < 0){tempY = 0;} 


return true; 
}

//-----------------------------tooltip glowny-----------------------------------//
function tooltip(act,e,txt)
{
	getMouseXY(e);

	if( act == 1)
	{
		document.getElementById("idtooltipG").style.display = 'block';
		document.getElementById("idtooltipG").style.left = ''+(tempX+15)+'px';
		document.getElementById("idtooltipG").style.top = ''+(tempY+20)+'px';
	}
	else
	{
		document.getElementById("idtooltipG").style.display = 'none';
	}
}
function tooltiptxt(txt)
{
	document.getElementById("idtooltipG").innerHTML = txt;
}

//-----------------doklejanie pozycji dla formularza----------------------------------------------------------------------------------------------------

if (!Array.prototype.forEach)
{
  Array.prototype.forEach = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        fun.call(thisp, this[i], i, this);
    }
  };
}
		
//------------------------------------------ocena---------------------------------------------------------------------
function showStar(star,ident)
{

		for (var i = 1; i < 6 ; i++)
	    {
	    	if( i <= star )
	    	{
	    		document.getElementById("star"+i+"_"+ident).src = katGrafika+'starOn.png'; 
	    	}
	    	else
	    	{
				document.getElementById("star"+i+"_"+ident).src = katGrafika+'starOff.png';
	    	}	
	    }
}

function showStar2(ident)
{
		var starFinish = document.getElementById("hiddenStar_"+ident).value;
		
		for (var i = 1; i < 6 ; i++)
	    {
	    	if( i <= starFinish )
	    	{
	    		document.getElementById("star"+i+"_"+ident).src = katGrafika+'starOn.png';  		
	    	}
	    	else
	    	{
				document.getElementById("star"+i+"_"+ident).src = katGrafika+'starOff.png';
	    	}	
	    }
}

function showStar3(star,ident)
{
	document.getElementById("hiddenStar_"+ident).value = star;
}

//-----------------------------------------menu-----------------------------------------------------------------------------

function showMenu2( modul, fontStylOn, fontStylOff, bnStylOn, bnStylOff )
{


	for ( var i = 0; i < menu.length; i++ )
	{
		if( menu[i]['modRewrite'] == modul )
		{
			menu[i]['onOff'] = 1;
		}
		else
		{
			menu[i]['onOff'] = 0;
		}
	}
	
	

	for ( var i = 0; i < menu.length; i++ )
	{
		if( menu[i]['onOff'] == 1 )
		{
			document.getElementById("menu2_"+menu[i]['modRewrite']).style.display = 'block';
			document.getElementById("bn_"+menu[i]['modRewrite']).className = bnStylOn;
			document.getElementById("link_"+menu[i]['modRewrite']).className = fontStylOn;
		}
		else
		{
			document.getElementById("menu2_"+menu[i]['modRewrite']).style.display = 'none';
			document.getElementById("bn_"+menu[i]['modRewrite']).className = bnStylOff;
			document.getElementById("link_"+menu[i]['modRewrite']).className = fontStylOff;
		}
	}
}

function showMenu2holdTime( modul, fontStylOn, fontStylOff, bnStylOn, bnStylOff )
{

	if( typeof timerHT != "undefined" )
	{	
		clearTimeout(timerHT);
		delete(timerHT);
	}
	
	if( typeof timerHT == "undefined" ) 
	{
		modul2 = modul;
		fontStylOn2 = fontStylOn;
		fontStylOff2 = fontStylOff;
		bnStylOn2 = bnStylOn;
		bnStylOff2 = bnStylOff;
		
	timerHT = setTimeout("showMenu2(modul2, fontStylOn2, fontStylOff2, bnStylOn2, bnStylOff2 )",300);
	}

}

function timerON(modul, fontStylOn, fontStylOff, bnStylOn, bnStylOff )
{
	/*
	if( typeof timer == "undefined" ) 
	{
		modul1 = modul;
		fontStylOn1 = fontStylOn;
		fontStylOff1 = fontStylOff;
		bnStylOn1 = bnStylOn;
		bnStylOff1 = bnStylOff;
		
		timer = setTimeout("showMenu2(modul1, fontStylOn1, fontStylOff1, bnStylOn1, bnStylOff1 )",1000);
	}
	*/
}

function timerOFF()
{
	if( typeof timer != "undefined" )
	{
		clearTimeout(timer);
		delete(timer);
	}
	
	if( typeof timerHT != "undefined" )
	{	
		clearTimeout(timerHT);
		delete(timerHT);
	}
}

//--------------------------------------------podswietlanie wierszy------------------------------------------------------

function zmien2(obj,act,classOnMouse, classStatic)
{
	if( act == 1)
	{
		obj.className = classOnMouse;
	}
	else
	{
		obj.className = classStatic;
	}
}

//----------------------------------------------------------------------------------------------------------------------
function przepisztxt(obj)
{
	if( document.getElementById("modRewriteArtA").value == "" )
	{
		document.getElementById("modRewriteArtA").value = obj.value;
	}
}

//09.10.2008-----------------------------------------------------------------------------------------------------------------------
function infoWindow(infoNr)
{
	window.open(sciezka+"informacja/informacja.php?temat="+infoNr,'','width=600px, height=400px, menubar=no, toolbar=no, location=no, scrollbars=no, resizable=yes, status=no');
}



function onOff( invert, contentName, idOkno, handle )
{

	var io = document.getElementById( contentName+idOkno ).style.display;
	var ha;
	
	var icoOpen = '<img src="/grafika/skin/arrowOpen.jpg" alt="" style="vertical-align: top" />';
	var icoClose = '<img src="/grafika/skin/arrowClose.jpg" alt="" style="vertical-align: top" />';
	
	if( invert == 1 )
	{
		if( io == "none" )
		{ 
			io = 'block';
			ha = icoClose; 
		}
		else
		{ 
			io = 'none'; 
			ha = icoOpen;
		}
	}
	else
	{
		if( io == "block" )
		{ 
			io = 'none'; 
			ha = icoOpen;
		}
		else
		{ 
			io = 'block';
			ha = icoClose; 
		}
	}
	
	document.getElementById( contentName+idOkno ).style.display = io;
	
	if( handle != 0 )
	{
		document.getElementById(handle+idOkno).innerHTML = ha;
	}
}
