function mywrite(flash)
{
	document.write(flash)
}


function $(name)
{
	obj =  document.getElementById(name);
	return obj;
}

function CheckEMail(str){
	try{
		//var objRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var objRegExp = /^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9_\.-]+\.[a-zA-Z]+$/;
		var objRegExp2 = /@{2,}/;
		var objRegExp3 = /\.{2,}/;
		return ( objRegExp.test(str) && ! objRegExp2.test(str) && ! objRegExp3.test(str) );
	} catch(e) {  }
};

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 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 && !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 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 && !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 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();

}

function drukuj(tresc){
		tresc = escape(tresc);
		window.open('print.php?to_print='+tresc,'','resizable=yes,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,left=0,top=0')
};

function checkForm(f)
{
    
	if (!f.k_firma.value)
	{
		alert("Prosze podać nazwę firmy");
		f.k_firma.focus();
		return false;
	}
	/*
	if (!f.k_upr.value)
	{
		alert("Prosze podać numer uprawnień");
		f.k_upr.focus();
		return false;
	}
    var patt1=new RegExp("^[0-9]{4}$");
	if (! patt1.test(f.k_upr.value ) )
	{
		alert("Prosze podać poprawny numer uprawnień\n\nformat: 4 cyfry");
		f.k_upr.focus();
		return false;
	}
	*/
	if (!f.k_ulica.value)
	{
		alert("Prosze podać ulicę");
		f.k_ulica.focus();
		return false;
	}
	if (!f.k_adres.value)
	{
		alert("Prosze podać i numer domu i/lub numer lokalu");
		f.k_adres.focus();
		return false;
	}
	if (!f.k_kod.value)
	{
		alert("Prosze podać kod pocztowy miejscowości");
		f.k_kod.focus();
		return false;
	}
    var patt1=new RegExp("^[0-9]{2}-[0-9]{3}$");
	if (! patt1.test(f.k_kod.value ) )
	{
		alert("Prosze podać poprawny kod pocztowy\n\nformat: XX-XXX");
		f.k_kod.focus();
		return false;
	}
    
	if (!f.k_miasto.value)
	{
		alert("Prosze podać nazwę miejscowości");
		f.k_miasto.focus();
		return false;
	}
	
	if ( ! f.k_mail.value || !CheckEMail(f.k_mail.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.k_mail.focus();
		return false;
	}
    
    var patt1=new RegExp("^[(]0[0-9]{2}[)][0-9]{3}-[0-9]{2}-[0-9]{2}$");
   	if ( ! patt1.test(f.k_tel.value ) )
	{
		alert("Prosze podać poprawnie telefon stacjonary\n\nformat: (0xx)xxx-xx-xx");
		f.k_tel.focus();
		return false;
	}

    var patt1=new RegExp("^[0-9]{3}-[0-9]{3}-[0-9]{3}$");    
	if ( f.k_gsm.value && ! patt1.test(f.k_gsm.value ) )
	{
		alert("Prosze podać poprawnie telefon komórkowy\n\nformat: xxx-xxx-xxx ");
		f.k_gsm.focus();
		return false;
	}	

	if ( ! f.k_zgoda.checked )
	{
		alert("Prosze wyrazić zgodę na przetwarzanie doanych osobowych ");
		return false;
	}	

	f.submit();
	//return true;
};



