function opensmallwindow2(size_w, size_h, url, scroll) {
	new_size_w = Number(size_w)+10;
	new_size_h = Number(size_h)+25;
	popup_left = Math.round((screen.availWidth-new_size_w)/2);
	popup_top = Math.round((screen.availHeight-new_size_h)/2);
	msg=open(url,"POPUP","scrollbars="+scroll+",toolbar=no,directories=no,width="+size_w+",height="+size_h+",menubar=no, top="+popup_top+", left="+popup_left+"");
	msg.document.close();
	msg.focus();
};

function opensmallwindow(w, h) {
	if (window.smallwindow) {smallwindow.close();}
	smallwindow = window.open('', 'smallwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=no')
	smallwindow.focus();
}

function openimgwindow(w, h) {
	if (window.imgwindow) {imgwindow.close();}
	imgwindow = window.open('', 'imgwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=no')
	imgwindow.focus();
}

function openhelpwindow(w, h) {
	if (window.helpwindow) {helpwindow.close();}
	helpwindow = window.open('', 'helpwindow', 'width='+w+', height='+h+', toolbar=no, scrollbars=yes')
	helpwindow.focus();
}

function se(a,b) {
	window.location.href = 'mailto:'+a+'@'+b+'.pl';
}

function simpvalidateform() {
 for(var i=0; i<fields.length; i++) {
  if (document.f.elements[fields[i]].value == '' || document.f.elements[fields[i]].value == 0) {
   alert(fields_info[i]);
   document.f.elements[fields[i]].focus();
   return false;
  }
 }
 if (!validatecode(document.f.elements['code'].value)) {
  return false;
 }
 if (!validateemail(document.f.elements['email'].value)) {
  return false;
 }
 return true;
}

function validateform() {
 for(var i=0; i<fields.length; i++) {
  if (document.f.elements[fields[i]].value == '' || document.f.elements[fields[i]].value == 0) {
   alert(fields_info[i]);
   document.f.elements[fields[i]].focus();
   return false;
  }
 }
 if(!validateemail(document.f.elements['email'].value))
 	return false;
else
 return true;
}

function validatecode(code) {
	if (code.length != 6) {
		alert('Nieprawidowy format Kodu pocztowego.');
		document.f.elements['code'].focus();
		return false;
	}
	code = code.toString().replace(/\-/g,'');
	if (code.length != 5) {
		alert('Nieprawidowy format Kodu pocztowego.');
		document.f.elements['code'].focus();
		return false;
	}
	if (isNaN(code)) {
		alert('Kod pocztowy musi by liczb.');
		document.f.elements['code'].focus();
		return false;
	}
	return true;
}

function validatenip(nip) {
	if (nip.length != 13) {
		alert('Nieprawidowy format numeru NIP.');
		document.f.elements['nip'].focus();
		return false;
	}
	nip = nip.toString().replace(/\-/g,'');
	if (nip.length != 10) {
		alert('Nieprawidowy format numeru NIP.');
		document.f.elements['nip'].focus();
		return false;
	}
	if (isNaN(nip)) {
		alert('Numer NIP musi by liczb.');
		document.f.elements['nip'].focus();
		return false;
	}
	return true;
}
/*
function validateemail(t) {
  maska = /^[0-9a-z_.-]+@([0-9a-z-]+.)+[a-z]{2,4}$/;
  if (maska.test(t)==false) { 
    alert("Podaj poprawny adres e-mail");
    document.f.elements['email'].focus();
    return false;
  }
  return true;
}
*/
function validatepass(t) {
  if (document.f.elements['pass'].value != document.f.elements['pass2'].value) { 
    alert('Pola "Haso" i "Powtrz haso" musz by rwne');
    document.f.elements['pass2'].focus();
    return false;
  }
  return true;
}

function p(x) {
   return x.toString().replace(/\,/,'.');
}

function checkext(name) {
  var ext = document.f.elements[name].value;
  if (ext.length > 0) {
  	ext = ext.substring(ext.length-3,ext.length);
  	ext = ext.toLowerCase();
  	if(ext != 'jpg') {
      alert('W tym polu akceptowane s wycznie pliki JPG.');
	  document.f.elements[name].focus();
	  document.f.elements[name].select();
      return false;
    } else {
      return true;
    }
  }
  return true;
}

function checkextgif(name) {
  var ext = document.f.elements[name].value;
  if (ext.length > 0) {
  	ext = ext.substring(ext.length-3,ext.length);
  	ext = ext.toLowerCase();
  	if(ext != 'gif') {
      alert('W tym polu akceptowane s wycznie pliki GIF.');
	  document.f.elements[name].focus();
	  document.f.elements[name].select();
      return false;
    } else {
      return true;
    }
  }
  return true;
}

var NS = (navigator.appName == "Netscape");
IE4 = (document.all) ? true : false; 
NS4 = (document.layers) ?  true : false;
NS6a = document.getElementById;
if(NS6a && NS) {NS6=true} else {NS6=false}
if ((IE4) || (NS4) || (NS6)) {dhtml=1;}

function pokaz(ident) {
	mainwidth=770;
	menuLeftPosition = new Array();
	menuLeftPosition['m1'] = 148;
	menuLeftPosition['m2'] = 0;
	menuLeftPosition['m3'] = 273;
	menuLeftPosition['m3a'] = 310;
	menuLeftPosition['m4'] = 398;
//	if(document.layers) {
	if(NS4) {
		document.layers[ident].visibility = "show";
//	} else if (document.getElementById(ident)) {
	} else if (NS6) {
		if (window.innerWidth){
        	if (document.body.offsetWidth){
            	if (window.innerWidth!=document.body.offsetWidth) {
                	LeftPosition = (document.body.offsetWidth - mainwidth)/2 + menuLeftPosition[ident];
				} else {
               		LeftPosition = (innerWidth - mainwidth)/2 + menuLeftPosition[ident];
				}
           	} else {
               	LeftPosition = (innerWidth - mainwidth)/2 + menuLeftPosition[ident];
			}
    	}
		document.getElementById(ident).style.left = LeftPosition;
		document.getElementById(ident).style.visibility = "visible";
//	} else if(document.all) {
	} else if(IE4) {
		LeftPosition = (document.body.offsetWidth - mainwidth)/2 + menuLeftPosition[ident]-10;
		document.all[ident].style.left = LeftPosition;
		document.all[ident].style.visibility = "visible";
	}
}

function schowaj(ident) {
//	if(document.layers) {
	if(NS4) {
    	document.layers[ident].visibility = "hide";
//    } else if (document.getElementById(ident)) {
    } else if (NS6) {
    	document.getElementById(ident).style.visibility = "hidden";
//	} else if(document.all) {
	} else if(IE4) {
	    document.all[ident].style.visibility = "hidden";
	}
}
