var DOM = (document.getElementById && !document.all);
var IE = (document.all);
var NN = (document.layers);

var mX, mY;

if(NN) document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
document.onmousemove = mPos;

function oFind(n,d) {if(!d) d=document;if(IE) return d.all[n];if(DOM) return d.getElementById(n);if(NN) return findLayer(n,document)}
function findLayer(name, doc) {var i, layer;for (i = 0; i < doc.layers.length; i++) {layer = doc.layers[i];if (layer.name == name) return layer;if (layer.document.layers.length > 0) {layer = findLayer(name, layer.document); if (layer != null) return layer;}}return null;}
function oContentHeight(o) {if(NN) return o.document.height; else if(IE) return o.scrollHeight; else if(DOM) {var th = o.style.height; o.style.height = "auto";var h = o.offsetHeight;o.style.height = th;return h;}}
function oContentWidth(o) {if(NN) return o.document.width; else if(IE) return o.scrollWidth; else if(DOM){var tw = o.style.width; o.style.width = "auto";var w = o.offsetWidth;o.style.width = tw;return w;}}
function mPos(e) {mX = evtX(e); mY = evtY(e);}
function writeTo(o, t) {if(NN) {o.document.open();o.document.write(t);o.document.close()} else {o.innerHTML = t}}
function scLeft() {if(NN) return window.pageXOffset; else return document.body.scrollLeft;}
function scTop() {if(NN) return window.pageYOffset; else return document.body.scrollTop;}
function evtX(e) {if(NN||DOM) return e.pageX; else return window.event.clientX+scLeft();}
function evtY(e) {if(NN||DOM) return e.pageY; else return window.event.clientY+scTop();}
function oLeft(o) {if(NN) return o.left; else if(IE) return o.style.pixelLeft; else return parseInt(o.style.left)}
function oTop(o) {if(NN) return o.top; else if(IE) return o.style.pixelTop; else return parseInt(o.style.top)}
function oWidth(o) {if(NN) return o.clip.width; else if(IE) return o.clientWidth; else return parseInt(o.style.width)}
function oHeight(o){if(NN) return o.clip.height; else if(IE) return o.clientHeight; else return parseInt(o.style.height)}
function oShow(o) {if(NN) o.visibility = "show"; else o.style.visibility = "visible";}
function oHide(o) {if(NN) o.visibility = "hide"; else o.style.visibility = "hidden";}

function oShowDisp(o,t) {if(NN) o.display = t; else o.style.display = t;}
function oHideDisp(o) {if(NN) o.display = "none"; else o.style.display = "none";}

function isVisible(o) {return (NN) ? (o.visibility == "hide") : (o.style.visibility == "hidden")}
function wWidth() {if(NN||DOM) return window.innerWidth-16; else return document.body.clientWidth;}
function wHeight(){if(NN||DOM) return window.innerHeight-16; else return document.body.clientHeight;}
function shiftX(o,x) {if(NN) o.left = x; else o.style.left = x}
function shiftY(o,y) {if(NN) o.top = y; else if(IE) o.style.top = y; else o.style.top = (y + 'px')}
function shiftTo(o,x,y){if(NN) o.moveTo(x,y); else {o.style.left = x; o.style.top = y}}
function sWidth(o,w) {if(NN) o.document.width = w; else o.style.width = w;}
function sHeight(o,h){if(NN) o.document.height = h; else o.style.height = h;}
function sAlpha(o,x) {if(NN||DOM) return; else eval(o.id + '.filters.alpha.opacity = ' + x)}
function showLayers () {for (var i = 0; i < arguments.length; i++) oShow (oFind (arguments[i]));}
function openpopup(src) {window.open(src,'galeria','width=10,height=10,scrollbars=0,toolbar=0,location=0,resizable=1,status=0');}
function openPopup(src, title) {window.open(src,title,'left=' + screen.availWidth/2 + ', top=' + screen.availHeight/2+ ', width=1,height=1,scrollbars=0,toolbar=0,location=0,resizable=0,status=0');}
function openPopup_Pos(src, title) {window.open(src,title,'left=30, top=100, width=1,height=1,scrollbars=1,toolbar=0,location=0,resizable=0,status=0');}
function openPopup_Res(src, title) {window.open(src,title,'left=' + screen.availWidth/2 + ', top=' + screen.availHeight/2+ ', width=1,height=1,scrollbars=0,toolbar=0,location=0,resizable=1,status=0');}
function openPopup_Scr(src, title) {window.open(src,title,'left=' + screen.availWidth/2 + ', top=' + screen.availHeight/2+ ', width=1,height=1,scrollbars=1,toolbar=0,location=0,resizable=0,status=0');}
function openPopup_Res_Scr(src, title) {window.open(src,title,'left=' + screen.availWidth/2 + ', top=' + screen.availHeight/2+ ', width=1,height=1,scrollbars=1,toolbar=0,location=0,resizable=1,status=0');}
function openPopup_Dbg(src, title) {window.open(src,title, 'left=' + screen.availWidth/2 + ', top=' + screen.availHeight/2+ ', width=1,height=1,scrollbars=1,toolbar=0,location=0,resizable=1,status=1');}
function openpopup2(src) {window.open(src,'galeria','width=10,height=10,scrollbars=1,toolbar=0,location=0,resizable=0,status=0');}
function swap_img_p (name, id) {var img = oFind(id); img.src = name; }

var reNazwisko = /^([a-zA-Z']+[ \-]{0,1})+[a-zA-Z']+$/gi
var reTelefon = /^\(0 \d{2}\) \d{3} \d{2} \d{2}$/
var reTelKom = /^\d{3} \d{3} \d{3}$/
var reEmail = /\b(^(\S+@)([a-zA-Z0-9\-]+\.)+(com|net|edu|mil|gov|org|int|([a-zA-Z]{2}))$)\b/i
var reKeywords = /^([a-zA-Z\ ]+,)*[a-zA-Z\ ]+$/i
var reUrl = /^([a-zA-Z0-9\-]+\.)+(com|net|edu|mil|gov|org|int|([a-zA-Z]{2}))$/i

function isToShort (s) {return (s.length < 3);}
function isTelefon(s) {return reTelefon.test(s) || reTelKom.test(s);}
function isNazwisko(s) {return reNazwisko.test(s);}
function isEmail(s) {return reEmail.test(s);}
function isUrl(s) {return reUrl.test(s);}
function isKeywords(s) {return reKeywords.test(s);}

function center_window() {
  var browserWidth, browserHeight;

  if (document.layers){ 
    browserWidth = window.outerWidth; 
    browserHeight = window.outerHeight; 

  } else if (document.all) { 
    browserWidth = document.body.clientWidth; 
    browserHeight = document.body.clientHeight; 

  } 
  
  window.moveTo(((screen.availWidth-browserWidth)/2), ((screen.availHeight-browserHeight)/2)); 
     
}


function doSearch() { oFind ('searchForm').submit(); }