﻿// JavaScript Document

function openWindow(url,szer,wys,tytul){
		var nowe;
		if(nowe){
			nowe.close();
		}
		nowe = window.open('','nowe',' width='+szer+',height='+wys+',left=200, top=0, menubar=no, toolbar=no, status=no, resizable=1,scrollbars=yes');
		nowe.document.open();
    	nowe.document.write("<HEAD><title>"+tytul+"</title><META HTTP-EQUIV=\"imagetoolbar\" CONTENT=\"no\"></head><BODY leftmargin=1 topmargin=1 bgcolor=\"#c2c2c2\"><IMG src="+url+"></body>");
    	nowe.document.close();
    	nowe.focus();
	}


function openWindowJS(url)
{
		var nowe;
		if(nowe){
			nowe.close();
		}
		nowe = window.open(url,'nowe',' width=400, height=200, left=400, top=0, menubar=no, toolbar=no, status=no, resizable=1,scrollbars=yes');
    	nowe.focus();
}

// pokazywanie formularza do dodawania komentarzy do zdjecia
function displayKomentarz()
{
	if(document.getElementById('komentarz').style.display == 'none')
	{
		document.getElementById('komentarz').style.display = "block";
	}
	else
	{
		document.getElementById('komentarz').style.display = "none";
	}
}

function checkKomentarz(frm)
{
  	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid


	if(frm.user.value == "")
	{
		alert("Proszę wpisać Imię / Pseudo.");
		frm.user.focus();
		return false;
	}

  	if(!reg1.test(frm.email.value) && reg2.test(frm.email.value)) 
	{
		frm.email.focus();
  	}
	else
	{
    	alert("Proszę wpisać poprawny adres e-mail."); // this is optional
		frm.email.focus();
		return false;
	}

	if(frm.tresc.value == ""){
		alert("Proszę wpisać treść komentarza.");
		frm.tresc.focus();
		return false;
	}

	return true;
}
