function log_out()
{
	ht = document.getElementsByTagName("html");
	ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm('Czy chcesz się wylogować?'))
	{
		return true;
	}
	else
	{
		ht[0].style.filter = "";
		return false;
	}
}

function win(url) {
	width=750;
	height=600;
	width1=width/2;
	height1=height/2;
	x=screen.availWidth/2-width1;
	y=screen.availHeight/2-height1;
    var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no, menubar=no, left='+x+', top='+y );
	Win.resizeTo(width, height);
	Win.focus();
};


function zamien() { 
  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 zaladuj() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=zaladuj.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 znajdz(n, d) { 
  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=znajdz(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function swap() { 
  var i,j=0,x,a=swap.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=znajdz(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function szukaj(theForm)
{

  if (theForm.nazwa.value == "")
  {
    alert("Podaj nazwę szukanego zdjęcia");
    theForm.nazwa.focus();
    return (false);
  }
 
//if (theForm.katalog.selectedIndex < 0)
//  {
//    alert("Wybierz jedną z opcji");
//    theForm.katalog.focus();
//    return (false);
//  }

//  if (theForm.katalog.selectedIndex == 0)
//  {
//    alert("Wybór pierwszej nazwy nie jest prawidłowy. Proszę wybrać inną kategorię.");
//    theForm.katalog.focus();
//    return (false);
//  }


  return (true);
}

function logout(url){
	var agree=confirm("Czy na pewno chcesz się wylogować ?");
	if (agree)
	document.location=url;
}

function confirmDelete(url){
	var agree=confirm("Czy chcesz usunąć ten produkt ?");
	if (agree)
	document.location=url;
}

function usuwam(url){
	var agree=confirm("Czy chcesz usunąć ten rekord ?");
	if (agree)
	document.location=url;
}

 function confirmUsun(url){
	var agree=confirm("Czy chcesz usunąć wszytskie produkty z koszyka?");
	if (agree)
	document.location=url;
}


function sprawdzPole(pole,komunikat){
  pole=document.getElementById(pole).value;
  if(!pole || pole=='' || pole==undefined)
    return komunikat;
  else
    return '';
}

function logowanie(){
var komunikat='';

komunikat+=sprawdzPole('username',"- Podaj użytkownika\n");
komunikat+=sprawdzPole('haslo',"- Podaj hasło\n");	

  if(komunikat!=''){
    alert("Zaloguj się:\n\n"+komunikat);
    return false;
  }
  else{
    return true;
  }
}

function lostpass(){
var komunikat='';

komunikat+=sprawdzPole('username',"- Podaj użytkownika\n");

  if(komunikat!=''){
    alert("Przypomnienie hasła:\n\n"+komunikat);
    return false;
  }
  else{
    return true;
  }
}

function showDiv(id) {
 if (document.getElementById)
    current=(document.getElementById(id).style.display == 'none') ? 'block' : 'none';
    document.getElementById(id).style.display = current;
}

function ukrywanie(id) {
 if (document.getElementById)
 current=(document.getElementById(id).style.display == 'none') ? 'block' : 'none';
    document.getElementById(id).style.display = current;
}


function kasa(){

var email = document.getElementById('email').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);

var email2 = document.getElementById('email2').value ;
var email2Pat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray2=email2.match(email2Pat);

var komunikat='';

komunikat+=sprawdzPole('imie',"- Podaj Imię\n");
komunikat+=sprawdzPole('nazwisko',"- Podaj Nazwisko\n");

 
 if (email!='' && matchArray==null)
  komunikat+="* podany adres e-mail jest niewłaściwy\n";

 if (email2!='' && matchArray2==null)
  komunikat+="* podany adres e-mail na który mamy wysłać zdjęcia jest niewłaściwy\n";

  if (email=='')
    komunikat+="- Podaj Adres e-mail\n";

  if (email2=='')
    komunikat+="- Podaj Adres e-mail na który mamy wysłać zdjęcia\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }



  else{
    return true;
  }
}

function rejestracja(){
var email = document.getElementById('email').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

komunikat+=sprawdzPole('imie',"- Podaj Imię\n");
komunikat+=sprawdzPole('nazwisko',"- Podaj Nazwisko\n");
  if (email=='')
komunikat+="- Podaj Adres e-mail\n";
komunikat+=sprawdzPole('username',"- Podaj użytkownika\n");
komunikat+=sprawdzPole('haslo',"- Podaj hasło\n");
komunikat+=sprawdzPole('haslo1',"- Podaj ponownie hasło\n");

 if (email!='' && matchArray==null)
  komunikat+="* podany adres e-mail jest niewłaściwy\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

function zmien(){
var email = document.getElementById('email').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

komunikat+=sprawdzPole('imie',"- Podaj Imię\n");
komunikat+=sprawdzPole('nazwisko',"- Podaj Nazwisko\n");
  if (email=='')
komunikat+="- Podaj Adres e-mail\n";
komunikat+=sprawdzPole('haslo',"- Podaj hasło\n");
komunikat+=sprawdzPole('haslo1',"- Podaj ponownie hasło\n");

 if (email!='' && matchArray==null)
  komunikat+="* podany adres e-mail jest niewłaściwy\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

function newsleter(){
var email = document.getElementById('email5').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

 if (email=='')
 komunikat+="- Podaj adres e-mail\n";

 if (email!='' && matchArray==null)
  komunikat+="* podany adres email jest niewłaściwy\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

function kontakt(){
var email = document.getElementById('email1').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

komunikat+=sprawdzPole('imie',"- Podaj imię i nazwisko\n");
  if (email=='')
komunikat+="- Podaj adres e-mail\n";
komunikat+=sprawdzPole('pytanie',"- wpisz twoje pytanie\n");

 if (email!='' && matchArray==null)
  komunikat+="* podany adres email jest niewłaściwy\n";


  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

function usun(){
var email = document.getElementById('email').value ;
var emailPat=/^(.+)@(.+)\.(.+)$/ ;
var matchArray=email.match(emailPat);
var komunikat='';

komunikat+=sprawdzPole('nazwa',"- Podaj Imię/Nazwisko lub Nick\n");
  if (email=='')
komunikat+="- Podaj Adres e-mail\n";

 if (email!='' && matchArray==null)
  komunikat+="* podany adres e-mail jest niewłaściwy\n";

  if(komunikat!=''){
    alert("Wypełnij wymagane pola:\n\n"+komunikat);
    return false;
  }

  else{
    return true;
  }
}

