popup="";
function okno(arg,s,x,y) {
  if (popup == '[object]') {popup.close()} else {}
  scr_width = screen.availWidth;
  scr_height = screen.availHeight;
  left_align = eval(scr_width/2)-eval(x/2);
  top_align = eval(scr_height/2)-eval(y/2);
  popup=window.open(arg,'szczegoly','toolbar=0,location=0,direction=0,status=0,resize=1,menubar=0,scrollbars='+s+',width='+x+',height='+y+',left='+left_align+',top='+top_align);
}
function valid_mail(co) { return (/^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(co)); }
function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href")&&anchor.getAttribute("rel")=="external") anchor.target="_blank";
  }
}
window.onload = externalLinks;


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/* newsletter label */
function newsletterLabel() {
	if (!document.getElementById) return false;
	if (!document.getElementById("newsletter")) return false;
	var newsletter = document.getElementById("newsletter");
	var label = newsletter.value;
	newsletter.value = label;
	newsletter.onfocus = function() {
		if (this.value == label) {
			this.value = '';
		}
	}
	newsletter.onblur = function() {
		if (this.value == '') {
			this.value = label;
		}
	}
}

/* select offer - rollover */
function showOffer() {
	if (!document.getElementById) return false;
	if (!document.getElementById("select_offer")) return false;
	if (!document.getElementById("nav-offer")) return false;
	var select = document.getElementById("select_offer");
	var nav = document.getElementById("nav-offer");
	select.onmousemove =  function() {
		nav.style.display = "block";
	}
	var lis = nav.getElementsByTagName("li");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover = function() {
			nav.style.display = "block";
		}
	}
	nav.onmouseout =  function() {
		nav.style.display = "none";
	}
}


/* select sites - rollover */
function showSites() {
	if (!document.getElementById) return false;
	if (!document.getElementById("select_sites")) return false;
	if (!document.getElementById("nav-sites")) return false;
	var select = document.getElementById("select_sites");
	var nav = document.getElementById("nav-sites");
	select.onmousemove =  function() {
		nav.style.display = "block";
	}
	var lis = nav.getElementsByTagName("li");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover = function() {
			nav.style.display = "block";
		}
	}
	nav.onmouseout =  function() {
		nav.style.display = "none";
	}
}

addLoadEvent(showOffer);
addLoadEvent(showSites);
addLoadEvent(newsletterLabel);
