function mywrite(flash)
{
//	alert(flash);
	document.write(flash)
}


function $(name)
{
	obj =  document.getElementById(name);
	return obj;
}

function ShowHide(id)
{
//	alert
	if ($(id).style.display == "none")
		$(id).style.display = "block"
	else
		$(id).style.display = "none";
}


var last;
function SetOne(name)
{
	last = name;
}

function ShowOne(name)
{
	$(last).style.display = "none";
	$(name).style.display = "block";
	$("bt_"+last).style.fontWeight = "normal";
	$("bt_"+name).style.fontWeight = "bold";
	last = name;
}




function CheckEMail(address) {
	return address != "" 	&& address.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/);	
}

function myMail(f)
{
	if (!CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}

	return true;
}


function checkKontakt(f)
{
	if (!f.nazwisko.value)
	{
		alert("Prosze podać imię i nazwisko...");
		f.nazwisko.focus();
		return false;
	}

	
	if (!f.email.value && !f.telefon.value)
	{
		alert("Prosze podać adres e-mail lub telefon kontaktowy...");
		f.email.focus();
		return false;
	}
	
	if (f.email.value && !CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}
	
/*
	if (!f.temat.value)
	{
		alert("Prosze podać temat wiadomości...");
		f.temat.focus();
		return false;
	}
*/

	if (!f.tresc.value)
	{
		alert("Prosze podać treść wiadomości...");
		f.tresc.focus();
		return false;
	}

	return true;
}


function Ankieta(obj)
{
	if ($('ankieta_wybor').value!=0)
	{
		$(obj).submit();
	}
	
}



function powieksz(el, fname, s, w)
{
	wys = w + 5;
	szer = s + 25;

	  if(window.screen){
		aw=screen.availWidth;
		ah=screen.availHeight;
	  }else{
		aw=640;
		ah=450;
	  }

	  if (szer>810) szer = 810;
	  if (wys>610) wys = 610;

	str = "foto.php?dir="+escape(el)+"&ph="+escape(fname);
	var win = window.open(str,"zoom","width="+szer+", height="+wys+", left="+(aw-szer)/2+", top="+ (ah-wys)/2+", titlebar=no, status=no, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=yes, fullscreen=no");
	win.focus();

}


var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers

var selected;

function initMenu(str, sel)
{
	if (navigator.appVersion.indexOf("MSIE")>0)
	{
		str = str.split(",");
		for (var i in str)
		{			
			obj = $("submenu"+str[i]);
			if (obj) obj.style.left = obj.offsetLeft + "px";	
		}
	}

	selected = "submenu"+sel;
	if (sel)
	{
		selected = "submenu"+sel;
		showmenu("",selected);
	}
}


z = 1000;
function showmenu(e,object)
{
	
	if (!document.all&&!document.getElementById&&!document.layers) 
		return;

	if (window.menuobj) 
		hidemenu(object);

	clearhidemenu();
	
	menuobj=$(object);
	if (menuobj)
	{
		menuobj.className = "submenu_on";
//		if (object == selected ) menuobj.className = "submenu_on submenu_sel";
	}

return false
}

function hidemenu(object)
{
	if (window.menuobj)
	{
//		menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
		menuobj.className = "submenu";
	}
	
	if (!object)
	{
//		delayhide=setTimeout('showmenu("",selected);',500)
		showmenu("",selected);
	}
}

function dynamichide(e)
{
	delayhidemenu();
}

function delayhidemenu()
{
	if (ie4||ns6||ns4)
		delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu()
{
	if (window.delayhide)
		clearTimeout(delayhide)
}


function sel_change(object)
{
	clearhidemenu();

	if (object.className=='zmien_on')
		object.className='zmien_off';
	else
		object.className='zmien_on';
}

if (ie4||ns6)
	document.onClick=hidemenu();
	

var act_odp;
function odp(id)
{
	if ($("odp_"+act_odp))
	{
		$("odp_"+act_odp).style.display = "none";
	}

	if ($("odp_"+id))
	{
		$("odp_"+id).style.display = "block";
		act_odp = id;
	}
	return;
}

var last=-3;
var z=0;
function Region(numer)
{
//	alert(numer);
	if (last>-2 && last!=numer)
	{
		opacity("region_"+last, 100, 0, 1000);
	}
	
	
	if (last!=numer)
	{
		changeOpac(0, "region_"+numer)
		$("region_"+numer).style.display = "block";
		$("region_"+numer).style.zIndex = z++;		
		opacity("region_"+numer, 30, 100, 1000);
		last=numer;
	}
}




//////////////////////////// obsluga kalendarza
function updateDiv(divId, content) {
	var http = false;
	
	if(navigator.appName == "Microsoft Internet Explorer") {
	  http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	  http = new XMLHttpRequest();
	}

	http.abort();
  	http.open("GET", content, true);
  	http.onreadystatechange=function() {
//	alert(http.readyState);
    if(http.readyState == 4) {
      $(divId).innerHTML = http.responseText;
    }
  }
  http.send(null);
}



function changeMonth(y,m)
{
	updateDiv("kalendarz", "ajax/kalendarz.ajax.php?head=1&cyear="+y+"&cmonth="+m+"&cday=0");
}


function changeDay(y,m,d)
{
	updateDiv("kalendarz", "ajax/kalendarz.ajax.php?head=1&cyear="+y+"&cmonth="+m+"&cday="+d);
	updateDiv("zdarzenia", "ajax/wydarzenia.ajax.php?head=1&cyear="+y+"&cmonth="+m+"&cday="+d);
}






var mn = new Array;


function flex_showmenu(object)
{

	var start  = $("start_"+object);
	var poz  = $("poz_"+object);
	var menuobj = $("menu_"+object);
	
	if (start) start.className=start.className +' sel_start';
	if (poz) poz.className='sel';
	if (menuobj) menuobj.style.display = "block";

return false
}

function flex_hidemenu(object)
{

	var start  = $("start_"+object);
	var poz  = $("poz_"+object);
	var menuobj = $("menu_"+object);


	if (start) start.className = start.className.replace(' sel_start', '');
	if (poz) poz.className='';
	if (menuobj) menuobj.style.display = "none";

}


function CenterBg()
{
	
	 // wielkosc okna przegladarki
	  if ( document.documentElement.clientWidth )
	  {
	  	myWidth = document.documentElement.clientWidth;
	  }
	  else if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		alert(1);
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		alert(2);
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		alert(3);
	  }
	  
	  $("bg").style.width = myWidth + "px";
	  $("bg_crop").style.width = myWidth + "px";
	 
	 
//	  var divWidth = parseInt(($("bg_img").offsetWidth), 10); 

		divWidth = 1400;
	
		if (myWidth>1000)  $("bg_crop").style.marginLeft = ((myWidth - divWidth) / 2 ) + "px";
	  
	  $("bg").style.display ="block";
}

