//*********************************************************************
function ulubione(obj)
{
	title = document.title;
	url = document.location;
	if (window.sidebar)
	{
		window.sidebar.addPanel(title, url, "");
		return true;
	}
	else if (window.external)
	{
		window.external.AddFavorite(url, title);
		return true;
	}
	else if (window.opera && window.print)
	{
		/**
		 * Opera wymaga ustawienia parametru REL dla linku
		 * Firefox także wspiera takie rozwiązanie, jednak w typ wypadku
		 * spowodowało by to wywołanie 2 okienek dodania - jednego pustego
		 * dlatego ustawiamy parametr poprzez JavaScript
		 */
		obj.rel = 'sidebar';
		return true;
	}
	return false;
}
//*********************************************************************
function drukuj()
{
	var oldLink = document.location;
	if (!oldLink.toString().match('drukuj'))
	{
		var newLink = document.location+"-drukuj";
   		document.location = newLink;
	}
	else 
		window.print();
}
//*********************************************************************
//duze zdjecie w nowym okienku
function zdjecie_mod(file)
{
	var left, top, x, y;
	x = 400;
	y = 340;
	left = Math.round((screen.width - x) / 2);
	top = Math.round((screen.height - y) / 2);
	window.open('zdjecie.php?z='+file,'','width='+x+', height='+y+', top='+top+', left='+left+', resizable=no, scrollbars=no, menubar=no, status=no').focus();	
}
/***********************************************************************************************************/
//funckje zwijajace i rozwijajace rejestr zmina w pliku dokument.tpl
function pokaz()
{
	document.getElementById("pokaz_ukryj_cont").style.display = "block";
	document.getElementById("pokaz_ukryj_link").innerHTML = "[ - ]";
	document.getElementById("pokaz_ukryj_link").href = "javascript:ukryj();";
}

function ukryj()
{
	document.getElementById("pokaz_ukryj_cont").style.display = "none";
	document.getElementById("pokaz_ukryj_link").innerHTML = "[ + ]";
	document.getElementById("pokaz_ukryj_link").href = "javascript:pokaz();";
}
/***********************************************************************************************************/
//funckaj sprawdza formularz w rejestracji nowego uzytkownika
//walidacja formularza dodawania ogloszenia (-1 bo submita:))
function check_registrationform()
{
	var form = document.forms['registrationform'];
	var puste = false;
	var innehasla = false;
	var zlymeil = false;
	
	for (i = 1; i < form.elements.length-2; i++)
	{
   		if( form.elements[i].value == '' )
			puste = true;
  	}
		
	reg = /^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/;
	if( !form.elements['email'].value.match(reg) )
	{
		alert('Musisz podać poprawny adres e-mail !');
		return false;
	}
	
	if( puste )
	{
		alert('Musisz wypełnić wszystkie pola formularza !');
		return false;
	}
	
   	return true;	
}
/***********************************************************************************************************/
//***********************************************************************************************************
//zawartosc poliku file w wyskakujacym na srodku okienku o zadanej wysokości i szerokosci
function popup(file, x, y)
{
	var left, top;
	left = Math.round((screen.width - x) / 2);
	top = Math.round((screen.height - y) / 2);
	window.open(''+file+'','','width='+x+', height='+y+', top='+top+', left='+left+', resizable=yes, scrollbars=yes, menubar=no, status=no').focus();
}
//***********************************************************************************************************
//zawartosc poliku file w wyskakujacym na srodku okienku o zadanej wysokości i szerokosci
function popup1(file, x, y)
{
	var left, top;
	left = Math.round((screen.width - x) / 2);
	top = Math.round((screen.height - y) / 2);
	window.open(''+file+'','','width='+x+', height='+y+', top='+top+', left='+left+', resizable=yes, scrollbars=no, menubar=no, status=no').focus();	
}
//***********************************************************************************************************
function test_formularz_kontaktowy()
{
	var form = document.forms['formularz_kontaktowya'];
	var puste = false;
	
	for (i = 0; i < form.elements.length; i++)
	{
   		if( form.elements[i].value == '' )
			puste = true;
  	}
	if( puste )
	{
		alert('Musisz wypełnić wszystkie pola w formularzu !');
		return false;
	}
	
	
	reg = /^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/;
	if( !form.elements['email'].value.match(reg) )
	{
		alert('Musisz podać poprawny adres e-mail !');
		return false;
	}
	
   	return true;
}
//*********************************************************************
//***********************************************************************************************************
function test_newsletter_form()
{
	var form = document.forms['newsletter_form'];	
	reg = /^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/;
	if( !form.elements['email'].value.match(reg) )
	{
		alert('Musisz podać poprawny adres e-mail !');
		return false;
	}
   return true;
}
//*********************************************************************
//duze zdjecie w nowym okienku
function zdjecie(file, x, y)
{
	var left, top;//, x, y;
	//x = 800;
	//y = 600;
	left = Math.round((screen.width - x) / 2);
	top = Math.round((screen.height - y) / 2);
	window.open('zdjecie.php?z='+file,'','width='+x+', height='+y+', top='+top+', left='+left+', resizable=no, scrollbars=no, menubar=no, status=no').focus();	
}
//**************************************************************************************************
//menu rozwijane
var display_timer_id = new Array();
function display(id, wartosc)
{
  clearTimeout(display_timer_id[id]);
  if (document.getElementById)
		display_timer_id[id] = setTimeout('document.getElementById("' + id + '").style.display = "' + wartosc + '"', 1);
  else if (document.all)
		display_timer_id[id] = setTimeout('document.all["' + id + '"].style.display = "' + wartosc + '"', 1);
}
//**************************************************************************************************
//podmienienie obrazkow w menu
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//********************************************************************************************
//********************************************************************************************
function potwierdz()
{
	komunikat = "Are you sure?"
	if (confirm(komunikat))
		return true;
	else
		return false;
}
//********************************************************************************************
function zamknij_okno()
{
	window.opener.location.href = window.opener.location.href;
	window.close();
}
