function mywrite(flash)
{
	document.write(flash)
}


function $(name)
{
	obj =  document.getElementById(name);
	return obj;
}



function myMail(f)
{
	if (!isEmail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}

	return true;
}


function isEmail(s) {
	return s != "" 	&& s.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/);	
}


function checkProfil(f)
{

	if (!f.login.value)
	{
		alert("Prosze podać login...");
		f.login.focus();
		return false;
	}

	if (f.haslo1.value)
	{
		if (MD5(f.old_haslo.value) != f.old_haslo_md5.value)
		{
			alert("Stare hasło nieprawidłowe...");
			f.old_haslo.focus();
			return false;			
		}
		

		if (f.haslo1.value != f.haslo2.value)
		{
			alert("Hasła nie są zgodne...");
			f.haslo2.value = "";
			f.haslo1.focus();
			return false;						
		}
	}




	if (!f.nazwisko.value)
	{
		alert("Prosze podać imię i nazwisko...");
		f.nazwisko.focus();
		return false;
	}

	if (!f.firma.value)
	{
		alert("Prosze podać nazwę firmy...");
		f.firma.focus();
		return false;
	}

	if (!f.miasto.value)
	{
		alert("Prosze podać nazwę miasta...");
		f.miasto.focus();
		return false;
	}

	
	if (!f.email.value)
	{
		alert("Prosze podać adres e-mail...");
		f.email.focus();
		return false;
	}
	
	if (f.email.value && !isEmail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}

	if (!f.zgoda.checked)
	{
		alert("Prosze wyrazić zgodę na przetwarzanie danych...");
		f.zgoda.focus();
		return false;
	}



	if (f.haslo1.value) f.pass.value = MD5(f.haslo1.value);
	f.old_haslo.value = "";
	f.old_haslo_md5.value = "";

	f.haslo1.value = "";
	f.haslo2.value = "";
	
	return true;
}


function checkKonkurs1(f)
{
	odp = false;
	for (i=1; i<20; i++ )
	{
		if (!$('odp['+i+']'))
		{
			break;
		}
		if ($('odp['+i+']').checked)
		{
			odp = true;
			break;
		}
	}

	if (!odp)
	{
		alert("Proszę wybrać jedną odpowiedź...");
		$("odp[1]").focus();
		return false;
	}

	if (!f.opis.value)
	{
		alert("Proszę odpowiedzieć na pytanie...");
		f.opis.focus();
		return false;
	}

	if (!f.nazwisko.value)
	{
		alert("Proszę podać imię i nazwisko...");
		f.nazwisko.focus();
		return false;
	}

	if (!f.firma.value)
	{
		alert("Proszę podać nazwę firmy...");
		f.firma.focus();
		return false;
	}

	if (!f.stanowisko.value)
	{
		alert("Proszę podać stanowisko...");
		f.stanowisko.focus();
		return false;
	}

	if (!isEmail(f.email.value))
	{
		alert("Proszę podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}
	
	if (!f.telefon.value)
	{
		alert("Proszę podać telefon kontaktowy...");
		f.telefon.focus();
		return false;
	}


	if (!f.zgoda.checked)
	{
		alert("Prosze wyrazić zgodę na przetwarzanie danych...");
		f.zgoda.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 && !isEmail(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 checkPrzedstawiciel(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 && !isEmail(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 checkZapytaj(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 && !isEmail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}
	
	if (!f.tresc.value)
	{
		alert("Prosze podać treść wiadomości...");
		f.tresc.focus();
		return false;
	}

	return true;
}


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

z = 1000;
function showmenu(e,object)
{
	if (!document.all&&!document.getElementById&&!document.layers) 
		return;

	if (window.menuobj) 
		hidemenu();

	clearhidemenu();
	
	menuobj=document.getElementById(object);
	if (menuobj)
	{
		menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj
		menuobj.thestyle.visibility="visible"
		menuobj.thestyle.zIndex=z++;
	}
//	alert(z + " " +menuobj.thestyle.zIndex);
//	pozobj=document.getElementById('poz_'+object);
//	if (pozobj)
//		pozobj.className='menu_hover';

return false
}

function hidemenu()
{
	if (window.menuobj)
	{
		menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
//		pozobj.className='menu';
	}
}

function dynamichide(e)
{
	if (ie4&&!menuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		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 nr=0;
function Woj(numer)
{
	
	if (nr>-2)
	{
		$("woj"+nr).style.display = "none";
	}
	
	if ($("woj"+numer))
	{
		nr = numer;
	}
	else
	{
		nr = -1;
	}

	$("miasto").style.display = "none"
	$("woj"+nr).style.display = "block"
}

function WojA(numer)
{
	
	if (nr>-2)
	{
		$("woj"+nr).style.display = "none";
	}
	
	if ($("woj"+numer))
	{
		nr = numer;
	}
	else
	{
		nr = -1;
	}

//	$("miasto").style.display = "none"
	$("woj"+nr).style.display = "block"
}