function popup(url,wintitle,features)
{
	window.open(url,wintitle,features);
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',title,args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); title=args[i+1];
    if (val) { if(title) {nm=title+': '}else{nm=val.name}; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' musi zawierać adres e-mail.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' musi zawierać tylko cyfry.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' musi zawierać  tylko cyfrę z zakresu od '+min+' do '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' jest wymagane(y).\n'; }
  }
  if (errors) alert('Wystąpiły następujące błędy:\n'+errors);
  document.MM_returnValue = (errors == '');
  if (!errors) return true;
}
function initMainMenu() {

	var mainItems=document.getElementById('siteMenu').childNodes;

	for(var i=0;i<mainItems.length;++i) {
		var mainItem=mainItems[i];
		if(mainItem.nodeName.toUpperCase()=='LI') {
			for(var j=0;j<mainItem.childNodes.length;++j) {
				if(mainItem.childNodes[j].nodeName.toUpperCase()=='UL') {
					mainItem.subMenu=mainItem.childNodes[j];
					mainItem.onmouseover=function() {
						this.subMenu.style.display='block';
						this.a.style.backgroundImage='none';
						this.s.style.backgroundImage='none';
					}
					mainItem.onmouseout=function() {
						this.subMenu.style.display='none';
						this.a.style.backgroundImage='url(img/corner_right.gif)';
						this.s.style.backgroundImage='url(img/corner_left.gif)';
					}
				} else if(mainItem.childNodes[j].nodeName.toUpperCase()=='A') {
					mainItem.a=mainItem.childNodes[j];
					mainItem.s=mainItem.childNodes[j].firstChild;
				}
			}
		}
	}

}


function resetContactForm(f) {

	f.firstName.value='';
	f.lastName.value='';
	f.message.value='';

	f.receiver.selectedIndex=0;

}

function checkContactForm(f) {

	if(document.getElementById('itemtext[name]').value.length <3){
		alert('Proszę wpisać swoje imię i nazwisko');
		return false;
	}
	if(document.getElementById('itemtext[email]').value.length <3){
		alert('Proszę wpisać swój adres e-mail.');
		return false;
	}
	if(document.getElementById('itemtext[pagetext]').value.length <3){
		alert('Proszę wpisać treść wiadomości.');
		return false;
	}
	if(document.getElementById('itemform[emial]').selectedIndex == 0){
		alert('Proszę wybrać adresata wiadomości.');
		return false;
	}

	return true;

}


function checkNewsletterForm(f) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(f.email.value)) {
		alert('Proszę wpisać poprawny adres email.');
		return false;
	}
	return true;
}

function updateNewsletterForm(f) {
	var Obj = document.getElementById('newsletter_op');
	Obj.value = f;
}