function setcolor(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;

    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        }
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
}


function wybierzurl(s) { 
   var kliknij = s.options[s.selectedIndex].value;   window.top.location.href = kliknij; 
} 

function $(id) {
	return document.getElementById(id);
}

function Dodaj(co) {
	var obj = document.getElementById(co); 
	obj.style.display = "block"; 
}   

function Usun(co) {
	var obj = document.getElementById(co); 
	obj.style.display = "none"; 
}   

function sprawdzdane() {
	if($("do0").value == '' || $("do1").value == '' || $("do2").value == '' || $("do3").value == '' || $("do4").value == ''){
		alert('WYPELNIJ POLA OZNACZONE GWIAZDKA!!!');
		if($("do0").value == '') { 
			$("do0").style.border='1px solid red';
			$("do0").style.backgroundColor='#dddddd';
		}
		else {
			$("do0").style.border='1px solid #989898';
			$("do0").style.backgroundColor='#ffffff';
		}
		if($("do1").value == '') {
			$("do1").style.border='1px solid red';
			$("do1").style.backgroundColor='#dddddd';
		}
		else {
			$("do1").style.border='1px solid #989898';
			$("do1").style.backgroundColor='#ffffff';
		}
		if($("do2").value == '') {
			$("do2").style.border='1px solid red';
			$("do2").style.backgroundColor='#dddddd';
		}
		else {
			$("do2").style.border='1px solid #989898';
			$("do2").style.backgroundColor='#ffffff';
		}
		if($("do3").value == '') {
			$("do3").style.border='1px solid red';
			$("do3").style.backgroundColor='#dddddd';
		}
		else {
			$("do3").style.border='1px solid #989898';
			$("do3").style.backgroundColor='#ffffff';
		}
		if($("do4").value == '') {
			$("do4").style.border='1px solid red';
			$("do4").style.backgroundColor='#dddddd';
		}
		else {
			$("do4").style.border='1px solid #989898';
			$("do4").style.backgroundColor='#ffffff';
		}
	}
	else  {
		$("zgloszenie").submit();
	}
}

function wo_kalendarz(co,ref)
{
switch(co)
{
case "do":
lista = window.open("kalendarz.php?ref="+ref+"&co=do&data="+d.datado.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=yes,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
}
}

function kalendarz(co,ref)
{
switch(co)
{
case "_dnia":
lista = window.open("kalendarz.php?ref="+ref+"&co=do&data="+d.z_dnia.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=yes,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "do":
lista = window.open("kalendarz.php?ref="+ref+"&co=do&data="+d.datado.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=yes,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "od":
lista = window.open("kalendarz.php?ref="+ref+"&co=od&data="+d.dataod.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=no,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "akt":
lista = window.open("kalendarz.php?ref="+ref+"&co=akt&data="+d.dataakt.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=no,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "_wyk":
lista = window.open("kalendarz.php?ref="+ref+"&co="+co+"&data="+d.data_wyk.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=no,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "_umi":
lista = window.open("kalendarz.php?ref="+ref+"&co="+co+"&data="+d.data_umi.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=no,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "_do":
lista = window.open("kalendarz.php?ref="+ref+"&co="+co+"&data="+d.data_do.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=yes,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "_od":
lista = window.open("kalendarz.php?ref="+ref+"&co="+co+"&data="+d.data_od.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=no,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "_do_s":
lista = window.open("kalendarz.php?ref="+ref+"&co="+co+"&data="+d.data_do_s.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=yes,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
case "_od_s":
lista = window.open("kalendarz.php?ref="+ref+"&co="+co+"&data="+d.data_od_s.value,"Kalendarz","toolbar=no,location=no,directories=no,statusbar=no,menubar=no,resizable=no,scrollbars=no,width=280,height=230");
break;
}
}

function kalendarz_flex(nazwa_inputa)
{
	eval("data=d."+nazwa_inputa+".value");
	lista = window.open("kalendarz.php?ref=UNIWERSAL&co="+nazwa_inputa+
			"&data="+data,"Kalendarz", "toolbar=no,location=no"+
			",directories=no,statusbar=no,menubar=no,resizable=no"+
			",scrollbars=no,width=280,height=230");

}

extArray = new Array(".jpg", ".gif", ".jpeg",".png", ".bmp");
function LimitAttach(form, file) {
    allowSubmit = false;
    if (!file) return;
    while (file.indexOf("\\") != -1)
        file = file.slice(file.indexOf("\\") + 1);
    ext = file.slice(file.indexOf(".")).toLowerCase();
    for (var i = 0; i < extArray.length; i++) {
        if (extArray[i] == ext) { allowSubmit = true; break; }
    }
    if (allowSubmit) return true;
    else 
        alert("Nieprawidlowy format pliku, dozwolone formaty:  "
        + (extArray.join("  ")) + "\nWybierz inny plik. ");
    return false;
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Nieprwidlowy E-mail")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Nieprwidlowy E-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Nieprwidlowy E-mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Nieprwidlowy E-mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Nieprwidlowy E-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Nieprwidlowy E-mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Nieprwidlowy E-mail")
            return false
		 }

 		 return true					
	}

