// JavaScript Document
function getEl(id)
{
	return document.getElementById(id);	
}

function fontChange( inc ) { 
	var tags = new Array('div','td','h6','h5','h4', 'p','span');
	var font_size = new Array( '12px','14px','16px' );
	var line_height = new Array( '16px','18px','22px' );

	if (!getEl) return;
	var d = document,cEl = null,sz,i,j,cTags;
	
	sz = inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 2 ) sz = 2;
	starfontChangez = sz;
	setCookie(inc);
	if ( ( cEl = d.getElementById( 'text' ) ) ) 
	{
		cEl.style.fontSize=cEl.style.fontSize;
		cEl.style.fontSize   = font_size[ sz ];
		cEl.style.lineHeight   = line_height[ sz ];
		for ( i = 0 ; i < tags.length ; i++ ) {
			cTags = cEl.getElementsByTagName( tags[ i ] );
			for ( j = 0 ; j < cTags.length ; j++ ){ 
				cTags[ j ].style.fontSize = font_size[ sz ]; 
				cTags[ j ].style.lineHeight = line_height[ sz ]; 
			}
		}
	}
	return false;
}

function setCookie(size)
{
    document.cookie='font='+size+'; path=/';
}

function getCookie(cookie)
{
    var fs = cookie.indexOf("font");
	if (fs != -1) {
        return (cookie.substr(fs+5, 1));
    }
    return -1;
}


function initFont()
{
	var fs = getCookie(document.cookie);
	if (fs != -1) 
	{
		fontChange(fs);
	}	
}

function chGal(layeron, titleon, layeroff, titleoff, sel)
{
		getEl(layeron).style.display="block";
		getEl(layeroff).style.display="none";
		getEl(titleon).className="act";
		getEl(titleoff).className="";
		if (getEl('select_type'))
			getEl('select_type').value=sel;
}




function menuHide()
{
	getEl('m_igrzyska').style.display="none";	
	getEl('mm_igrzyska').className="";	
	getEl('m_olimpijczycy').style.display="none";	
	getEl('mm_olimpijczycy').className="";	
	getEl('m_pkol').style.display="none";	
	getEl('mm_pkol').className="";	
	getEl('m_edukacja').style.display="none";	
	getEl('mm_edukacja').className="";	
}

function menuShow(n)
{
	state=getEl(n).style.display;
	if (state=="block")
	{
		//getEl('m'+n).className="";
		getEl('sub_menu').style.display="none";
		menuHide();
	}
	else
	{
		getEl('sub_menu').style.display="block";
		menuHide();
		getEl(n).style.display="block";	
		getEl('m'+n).className="act";
	}
	return false;
	
}

document.banners=new Array();

function chBan(id)
{
		for(i=1; i<10; i++)
		{
			if (getEl("b"+i))
				  getEl("b"+i).className="";
		}
		
		if (document.banners[id])
		{
			if (getEl(id))
				getEl(id).className="act";
	
			if (getEl("banner_img"))
				getEl("banner_img").innerHTML='<img src="'+document.banners[id]['img']+'" alt="" />';
			//getEl("banner_img").innerHTML=img;
			if (getEl("banner_info"))
			{
				if (document.banners[id]['newsid'])
					getEl("banner_info").innerHTML='<a href="pages/news/'+document.banners[id]['id']+'/'+document.banners[id]['newsid']+'">'+document.banners[id]['info']+'</a>';
				else
					getEl("banner_info").innerHTML='<a href="pages/news/'+document.banners[id]['id']+'">'+document.banners[id]['info']+'</a>';
				
			}
		}
}

function loadBan(titleon, img, info, id, newsid)
{
	document.banners[titleon]=new Array();
	document.banners[titleon]['info']=info;	
	document.banners[titleon]['id']=id;	
	document.banners[titleon]['img']=img;
	document.banners[titleon]['newsid']=newsid;	
	count_all++;
}

var count = 0;
var count_all = 0;

function rotBan()
{
	count++;
	if (count>count_all)
		count=1;
	chBan('b'+count);
	setTimeout(rotBan,10000); 
}

function rotStart()
{
	setTimeout(rotBan,10000); 	
}

function photoSelect(g)
{
	var d=document.getElementById("photoSelect").value;
	location.href="/pl/pages/gallery/"+g+"/"+d+"#view";
}
