var Win="";
function displayWindow(url, width, height, left, top)
{
	if (Win.closed == false) {Win.close()}
   Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ', left=' + left +', top=' + top +',resizable=0,scrollbars=auto, menubar=no' );
   Win.focus();
}

var Wn="";
function dispWindow(url, title, width, height, left, top, scrollbars)
{
	if (Wn.closed == false) {Wn.close()}
	if (scrollbars=="")
	{
		scrollbars="auto";
	}
   Wn = window.open(url,title,'width=' + width + ',height=' + height + ', left=' + left +', top=' + top +',resizable=0,scrollbars=' + scrollbars + ', menubar=no' );
   Wn.focus();
}

function wstaw(a,z)
{
	docSel=document.selection.createRange().text;
	if (docSel) {
		// Add tags around selection
		document.selection.createRange().text = a + docSel + z;
//		docSel = '';
		return;
	}
	else
	{
		alert("Nie zaznaczono tekstu");
	}
}

function emailCheck (emailStr)
{
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
 alert("Adres e-mail jest nieprawid�owy (sprawd� @ oraz prefix przed @)")
 return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    alert("Nieprawid�owo podano adres e-mail.")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
   for (var i=1;i<=4;i++) {
     if (IPArray[i]>255) {
         alert("Ten adres IP jest b��dny!")
  return false
     }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
 alert("Nazwa domeny zosta�a b��dnie podana.")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>4) {
   alert("Ko�c�wka domeny musi posiada� dwie, trzy lub cztery litery!")
   return false
}

if (len<2) {
   var errStr="Ten adres jest b��dny! Sprawd� jeszcze raz poprawno�� domeny"
   alert(errStr)
   return false
}

return true;
}

//set colours in tr
function setPointer(theRow, thePointerColor)
{
    if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
        return false;
    }

    var row_cells_cnt = theRow.cells.length;
    for (var c = 0; c < row_cells_cnt; c++) {
        theRow.cells[c].bgColor = thePointerColor;
    }
    return true;
}

window.onerror = null;
 var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS4 = (bName == "Netscape" && bVer >= 4);
 var IE4 = (bName == "Microsoft Internet Explorer"
 && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer"
 && bVer < 4);
 var blink_speed=900;
 var i=0;

if (NS4 || IE4) {
 if (navigator.appName == "Netscape") {
 layerStyleRef="layer.";
 layerRef="document.layers";
 styleSwitch="";
 }else{
 layerStyleRef="layer.style.";
 layerRef="document.all";
 styleSwitch=".style";
 }
}

function Blink(layerName){
 if (NS4 || IE4) {
 if(i%2==0)
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="visible"');
 }
 else
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="hidden"');
 }
 }
 if(i<1)
 {
 i++;
 }
 else
 {
 i--
 }
 setTimeout("Blink('"+layerName+"')",blink_speed);
}


function showLayer(obj) {
  var div = null ;
  if (document.getElementById){
    div = document.getElementById(obj);
  }else if (document.all){
    div = document.all[obj];
  }else if (document.layers){
    div = document.layers[obj];
  }
  
  if (!div) {	}
  else if (div.style){
    if (div.style.display != 'none') {
      div.style.display = 'none';
    }else{
      div.style.display = 'block';
    }
  }else{
    if (div.visibility == 'hidden'){
      div.visibility = 'show';
    }else{
      div.visibility = 'hidden';
    }
  }  
}

