function produkt(id){
	document.form1['dz'].value = 'product';
	document.form1['id'].value = id;
	document.form1.submit();
}

function checkEmail(email){
	fd_v = document.form1.elements['email'].value;
	if(fd_v.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("Podaj prawidłowy adres email");
		document.form1.elements['email'].focus();
		return false;
	}else{
		document.form1.action = 'subskrypcja.php';
		document.form1.method = 'post';
		document.form1.submit();		
	}
}

var miasto_last = 'szczecin';
function sklep(miasto){
	document.getElementById('miasto_'+miasto_last).style.display = 'none';
	document.getElementById('miasto_'+miasto).style.display = 'block';
	document.getElementsByName('miasto_select').selectIndex = miasto;
	setSelectAfterReload(miasto);
	miasto_last = miasto;
}

function sklep1(miasto){
	document.getElementById('miasto_'+miasto_last).style.display = 'none';
	document.getElementById('miasto_'+miasto).style.display = 'block';
	document.getElementsByName('miasto_select').selectIndex = miasto;
	setSelectAfterReload(miasto);
	miasto_last = miasto;
	setMap(miasto);
}

function setMap(miasto){
	var t = '';
	var IE = navigator.appName.indexOf("Microsoft") != -1;
	t = IE ? window.document.mapa : window.document['mapa'];
	t.SetVariable("danySklep",miasto);
	t.TGotoFrame("/",2);
}


function setSelectAfterReload(miasto){
	var signed = 0;
	for (i=0; i < document.form1.miasto_select.options.length; i++){
		if (document.form1.miasto_select[i].value == miasto)
			signed = i;
	}
	document.form1.miasto_select.selectedIndex = signed;
}

function gazetka_strona(id){
	if (document.getElementById('gazetka_strona_'+id))
	document.getElementById('gazetka_strona_'+id).className = 'tekst_gazetka';
}

//--- Aufruf JAVA-Client ---
function openJAVAClient()
{
	browserTitle = escape("Fotoservice");
path = "http://app.photoprintit.de/ops/oc.jsp?keyaccid=5076&currency=PLN&LOCALE_LANGUAGE=pl&LOCALE_COUNTRY=PL&browser_title=" + browserTitle;
javaClientWindow = open( path, "OPS_JAVA_Client", "width=640,height=524,screenX=0,screenY=0" );
}
//--- Aufruf HTML-Client ---
function openHTMLClient()
{
	browserTitle = escape("Fotoservice");
path = "http://app.photoprintit.de/hclient/frame_index.jsp?keyacc_id=5076&currency=PLN&LOCALE_LANGUAGE=pl&LOCALE_COUNTRY=PL&browser_title=" + browserTitle;
htmlClientWindow = open( path, "OPS_HTML_Client", "width=540,height=436,screenX=0,screenY=0" );
}

		//--- Aufruf Fun-Client ---
function openFunClient()
{
	browserTitle = escape("Fotoservice");
path = "http://app.photoprintit.de/hclient/frame_index.jsp?keyacc_id=5077&currency=PLN&LOCALE_LANGUAGE=pl&LOCALE_COUNTRY=PL&browser_title=" + browserTitle;
htmlClientWindow = open( path, "OPS_HTML_Client", "width=540,height=436,screenX=0,screenY=0" );
}

function check(){
var argv=check.arguments;	var argc=argv.length;	
var form = document.form1;			var i=1;				var err=0;
// Sprawdzenie wymaganej ilosci argumentow 
if(argc%2 != 1){
	alert('Błąd w skrypcie: Brak wymaganej liczby parametrów!\nPrawdopodobnie brak typu dla jednego z pól.');
	return false;
}
while(i<argc){
	fd_n=argv[i];	fd_wt=argv[i+1];	 fd=form.elements[fd_n];
	// pobierz wartosc w zaleznosci od typu elementu formularza
	switch(fd=form.elements[fd_n].type){
		case 'text'	:
		case 'hidden':
		case 'password':
		case 'textarea':
		case 'file'	:
		case 'radio':
					fd_v=form.elements[fd_n].value;
					break;
		case 'select-one':
		case 'select-multiple':
					fd_v=form.elements[fd_n].options[form.elements[fd_n].selectedIndex].value;
					break;
		case 'select':
					fd_v=form.elements[fd_n].options[form.elements[fd_n].selectedIndex].value;
					break;			
		case 'checkbox':
					fd_v=form.elements[fd_n].checked;
					break;
		default		:
					fd_v=false;
	}
	if(fd_v.length==0){
		err=1;
	}else{
		// sprawdz wartosc, czy jest ona zgodna z wymaganym typem
		switch(fd_wt){
			case 'int'	:
						if(isNaN(parseInt(fd_v)))  err=2;
						break;
			case 'float':
						if(isNaN(parseFloat(fd_v)))  err=2;
						break;
			case 'text'	:
						if(fd_v.length==0)  err=2;
						break;
			case 'select'	:
						if(fd_v.length==0)  err=2;
						break;			
			case 'checkbox'	:
						if(!fd_v)  err=2;
						break;
			case 'email':
						if(fd_v.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/)==-1)  err=2;
						break;
			case 'kod':
						if(fd_v.search(/^[0-9]{2}-[0-9]{3}$/)==-1)  err=2;
						break;
			case 'telefon':
						if(fd_v.search(/[0-9]+/)==-1)  err=2;
						break;			
			default		:
						alert('Błąd w skrypie:\nnieznany typ pola '+fd_n+'!');
						return false;
		}
	}
	// pokaz rodzaj bledu
	switch(err){
		case 1	:
				alert('Brak wartości w polu '+fd_n+'!');
				return false;
				break;
		case 2	:
				alert('Wartość:\n \"'+fd_v+'\"\n w polu '+fd_n+' jest nieprawidłowa!');
				return false;
				break;					
	}
	i=i+2;
}
return true;
}


function wyslij(){
	if (check('this','imie','text','email_kontakt','email','temat','text','Tekst','text')){
		document.form1.submit();
	}
}

function okno(url, width, height) {
var Win = window.open(url,"okno",'width=' + width + ',height=' + height
	+ ',resizable=0,scrollbars=no,menubar=no,left=5,top=5');
}

function okno2(url, width, height) {
var Win = window.open(url,"okno",'width=' + width + ',height=' + height
	+ ',resizable=0,scrollbars=yes,menubar=no,left=0,top=0');
}
