var IE, FF, O;
if(window.navigator.userAgent.indexOf('MSIE') != -1) var IE = true;
else if(window.navigator.userAgent.indexOf('Gecko') != -1) var FF = true;
else if(window.navigator.userAgent.indexOf('Opera') != -1) var O = true;

//Zmiana obrazków w menu głównym
function na_preload_img()
{ 
  var img_list = na_preload_img.arguments;
  if (document.preloadlist == null) 
    document.preloadlist = new Array();
  var top = document.preloadlist.length;
  for (var i=0; i < img_list.length; i++) {
    document.preloadlist[top+i] = new Image;
    document.preloadlist[top+i].src = img_list[i+1];
  } 
}

function na_change_img_src(name, nsdoc, rpath, preload)
{ 
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img) {
    img.altsrc = img.src;
    img.src    = rpath;
  } 
}

function na_restore_img_src(name, nsdoc)
{
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img && img.altsrc) {
    img.src    = img.altsrc;
    img.altsrc = null;
  } 
}

/*
Tested with:
	Win IE 5.0/5.1/6.0
	Mozilla 1.5
	Opera 7.21 (3218)
*/
function Add2Favorite(title) {
	currentLocation = location.href;
	if ( title == '' )
		title = currentLocation;

	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4) && !(navigator.userAgent.search('Opera') >=0 ))
	 {
		window.external.AddFavorite(currentLocation, title);
	} else {
		var msg = "Dodaj stronę do ulubionych!\n";
		
		if(navigator.appName == "Netscape") {
			msg += "Wci¶nij CTRL+D";
		}
		alert(msg);
	}
	return false;
}

// Zmiana koloru przycisków przy formularzu kontaktu
function cssActive( buttonname)
{
  document.getElementsByName(buttonname)[0].style.backgroundColor = "#F66014";
}

function cssInactive( buttonname)
{
  document.getElementsByName(buttonname)[0].style.backgroundColor = "#989B9E";
}

//Otwieranie okna planu dojazdu
var win = null;
function NewWindow(mypage,myname,w,h,scroll)
{
LeftPosition = 20
TopPosition = 20
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no'
win = window.open(mypage,myname,settings)
}

//Otwieranie okna dodatków (poleć znajomemu, newsletter ...)
function ME_openOKsrodek(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function writeCookie(name, data, noDays){
  var cookieStr = name + "="+ data
  if (writeCookie.arguments.length > 2){
    cookieStr += "; expires=" + getCookieExpireDate(noDays)
    }
  document.cookie = cookieStr
}

function readCookie(cookieName){
   var searchName = cookieName + "="
   var cookies = document.cookie
   var start = cookies.indexOf(cookieName)
   if (start == -1){ // cookie not found
     return ""
     }
   start += searchName.length //start of the cookie data
   var end = cookies.indexOf(";", start)
   if (end == -1){
     end = cookies.length
     }
   return cookies.substring(start, end)
}

function blocking(nr, cookie, vis_state)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? vis_state : 'none';
		if (cookie != '')
			writeCookie(nr, current);
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? vis_state : 'none';
		if (cookie != '')
			writeCookie(nr, current);
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		display = (document.getElementById(nr).style.display == 'none') ? vis_state : 'none';
		if (cookie != '')
			writeCookie(nr, display);
		document.getElementById(nr).style.display = display;
	}
}


function adjust_popup()
{
	var w, h, fixedW, fixedH, diffW, diffH;
	
	if (document.all) {
		fixedW = document.body.clientWidth;
		fixedH = document.body.clientHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - document.body.clientWidth;
		diffH = fixedH - document.body.clientHeight;
	} else {
		fixedW = window.innerWidth;
		fixedH = window.innerHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - window.innerWidth;
		diffH = fixedH - window.innerHeight;
	}
	w = fixedW + diffW;
	h = fixedH + diffH;
	if (h >= screen.availHeight) w += 16;
	if (w >= screen.availWidth)  h += 16;
	w = Math.min(w,screen.availWidth);
	h = Math.min(h,screen.availHeight);
	window.resizeTo(w,h);
	window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

//Rozwijanie wpisu nowego tematu forum
var e_cache = new Array();
function e(o, c) { if(!e_cache[o] || c) e_cache[o] = document.getElementById(o); return e_cache[o]; }

function a() {
	f_s1 = e('search_adv1');
	f_s2 = e('search_adv2');
	if(
	f_s1.style.display == 'inline') 
	{
		f_s1.style.display = 'none';
		f_s2.style.display = 'none';
		//e('search').style.background='url(/_img/_search-bg-1.png)';
		e('s_f').value='';
		e('s_m').value='';
		//e('s_cat').value='';
		//e('s_f').value='';
		//e('s_o').value='';
		e('s_n').value='';
		e('s_adv_a').innerHTML='<img src=\"/forum/images/dodaj_wpis.jpg\" border=\"0\" width=\"91\" height=\"20\" alt=\" dodaj nowy temat \" title=\" dodaj nowy temat \"/>';
	} else {
		f_s1.style.display = 'inline';
		f_s2.style.display = 'inline';
		//e('search').style.background='url(/_img/_search-bg-2.png)';
		e('s_adv_a').innerHTML='<img src=\"/forum/images/zamknij_wpis.jpg\" border=\"0\" width=\"91\" height=\"20\" alt=\" zamknij okna \" title=\" zamknij okna \"/>';
	}
}

//Rozwijanie wpisu nowego tematu forum2
var e_cache2 = new Array();
function e2(o2, c2) { if(!e_cache2[o2] || c2) e_cache2[o2] = document.getElementById(o2); return e_cache2[o2]; }

function a2() {
	f_s12 = e2('search_adv12');
	f_s22 = e2('search_adv22');
	if(
	f_s12.style.display == 'inline') 
	{
		f_s12.style.display = 'none';
		f_s22.style.display = 'none';
		//e2('search2').style.background='url(/_img/_search-bg-1.png)';
		//e2('s_f2').value='';
		e2('s_m2').value='';
		//e2('s_cat2').value='';
		//e2('s_f2').value='';
		//e2('s_o2').value='';
		e2('s_n2').value='';
		e2('s_adv_a2').innerHTML='<img src=\"/forum/images/dodaj_wpis.jpg\" border=\"0\" width=\"91\" height=\"20\" alt=\" dodaj nowy temat \" title=\" dodaj nowy temat \"/>';
	} else {
		f_s12.style.display = 'inline';
		f_s22.style.display = 'inline';
		//e2('search2').style.background='url(/_img/_search-bg-2.png)';
		e2('s_adv_a2').innerHTML='<img src=\"/forum/images/zamknij_wpis.jpg\" border=\"0\" width=\"91\" height=\"20\" alt=\" zamknij okna \" title=\" zamknij okna \"/>';
	}
}

//Rozwijanie formularza kontaktu
var e_cache3 = new Array();
function e3(o3, c3) { if(!e_cache3[o3] || c3) e_cache3[o3] = document.getElementById(o3); return e_cache3[o3]; }

function a3() {
	f_s13 = e3('search_adv13');
	f_s23 = e3('search_adv23');
	if(
	f_s13.style.display == 'inline') 
	{
		f_s13.style.display = 'none';
		f_s23.style.display = 'none';
		//e3('search3').style.background='url(/_img/_search-bg-1.png)';
		//e3('s_f3').value='';
		e3('s_m3').value='';
		//e3('s_cat3').value='';
		//e3('s_f3').value='';
		//e3('s_o3').value='';
		e3('s_n3').value='';
		e3('s_adv_a3').innerHTML='<img src=\"/images/otworz_form.jpg\" border=\"0\" width=\"62\" height=\"20\" alt=\" otwórz formularz \" title=\" otwórz formularz \"/>';
	} else {
		f_s13.style.display = 'inline';
		f_s23.style.display = 'inline';
		//e3('search3').style.background='url(/_img/_search-bg-2.png)';
		e3('s_adv_a3').innerHTML='<img src=\"/images/zamknij_form.jpg\" border=\"0\" width=\"62\" height=\"20\" alt=\" zamknij formularz \" title=\" zamknij formularz \"/>';
	}
}
