function wstawtag(form,tag) {
var selekcja = document.selection.createRange().text;
if(selekcja=="")
form.itresc.focus();
document.selection.createRange().text = '<' + tag + '>' + selekcja + '</' + tag + '>';
form.itresc.focus();
}
function wyrownaj(form,wyrownanie) {
var selekcja = document.selection.createRange().text;
if(selekcja=="")
form.itresc.focus();
document.selection.createRange().text = '<DIV ALIGN="' + wyrownanie + '">' + selekcja +
'</DIV>';
form.itresc.focus();
}
function nowalinia(form) {
var selekcja = document.selection.createRange().text;
if(selekcja=="")
form.itresc.focus();
document.selection.createRange().text = selekcja + '<BR>';
form.itresc.focus();
}
function wstawrysunek(form) {
mojrysunek = prompt('Wprowadz adres rysunku:',"http://");
var selekcja = document.selection.createRange().text;
if(selekcja=="")
form.itresc.focus();
document.selection.createRange().text = selekcja + '<IMG SRC="' + mojrysunek + '" border="0">';
form.itresc.focus();
}
function wstawlink(form) {
mojadres = prompt('Wprowadz adres linku:',"http://");
mojlink= prompt('Wprowadz nazwe linku:',"Nazwa");
var selekcja = document.selection.createRange().text;
if(selekcja=="")
form.itresc.focus();
document.selection.createRange().text = selekcja + '<A HREF="' + mojadres + '">' + mojlink + '</a>';
form.itresc.focus();
}

function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
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 niepoprawny (sprawdź @ oraz .)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Nazwa użytkownika zawiera niedozwolone znaki.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Nazwa domeny zawiera niedozwolone znaki.");
return false;
   }
}

if (user.match(userPat)==null) {

alert("Nazwa użytkownika jest niepoprawna.");
return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Adres IP jest niepoprawny!");
return false;
   }
}
return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("Domena jest niepoprawna.");
return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Adres musi się kończyć jedną z podstawowych domen lub dwiema literami - nazwą kraju.");
return false;
}

if (len<2) {
alert("Adres nie zawiera nazwy hosta!");
return false;
}
return true;
}

noweOkienko = null;

function ShowItem(src){
if(noweOkienko){noweOkienko.close();}
if(noweOkienko==null || noweOkienko.closed){
 settings=
 "left=30,"
 +"top=30,"
 +"toolbar=no,"
 +"location=no,"
 +"directories=no,"
 +"status=no,"
 +"menubar=no,"
 +"scrollbars=yes,"
 +"width=110"
 +"height=130"
 +"resizable=yes"
 noweOkienko = window.open("",'galeria',settings);
}
noweOkienko.document.open();
noweOkienko.document.clear();
noweOkienko.document.write(
"<html>\n"
+"<head>\n"
+"<title>Bogdan Bojko</title>\n"
+"</head>\n"
+"<script>\n"
+"function resize() {\n"
+"window.resizeTo(document.images[0].width+50, document.images[0].height+100);}\n"
+"</script>\n"
+"<body topmargin=0 leftmargin=0 onLoad=resize(); onclick=window.close(); bgcolor=#FFFFFF>\n"
+"<img src=" + src + " border=0>\n"
+"</body>\n"
+"</html>"
);
noweOkienko.document.close();
noweOkienko.focus();
}

function Pisz(co)
{
 var d=document;
 if(d.layers)with(d.layers["zegar"].document){
 write(co);close();return}
 if(d.getElementById){d.getElementById("zegar").innerHTML=co;return}
 if(d.all)d.all["zegar"].innerHTML=co;
}

function Zegar()
{
 var T,G,M,S,s;
 T=new Date();
 G=T.getHours();
 M=T.getMinutes();
 S=T.getSeconds();
 
 s=(G<10?"0":" ")+G;
 s+=(M<10?":0":":")+M;
 s+=(S<10?":0":":")+S;
 Pisz(s);
}

function go_href(link)
{
 location.href=link;
}

function actual_date()
{
 var dayNames = new Array("Niedziela","Poniedziałek","Wtorek","Środa","Czwartek","Piątek","Sobota");
 var monthNames = new Array("stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia");
 var now = new Date();
 document.write(dayNames[now.getDay()] + ", " + now.getDate() + " " + monthNames[now.getMonth()] + " " + now.getYear());
}


function openwindow(src, w, h)
{
 ustawienia= "left=100," +"top=100," +"width=" + w + "," +"height=" + h + "," +"toolbar=no," +"location=no," +"directories=no," +"status=no," +"menubar=no," +"scrollbars=yes," +"resizable=no";
 NewWindow = window.open(src,'tk',ustawienia);
 NewWindow.focus();
}

function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
        if (theAction == 'out') {
            newColor = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '')
                     ? thePointerColor
                     : theDefaultColor;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function
