function confirmLink(theLink, theWarning)
{
    var is_confirmed = confirm(theWarning);
    if (is_confirmed) {
        document.location=theLink;
    }
    return is_confirmed;
} // end of the 'confirmLink()' function


function confirmSubmitForm(theForm, theWarning)
{
    var is_confirmed = confirm(theWarning);
    if (is_confirmed) {
        document.forms[theForm].submit();
    }
//    return is_confirmed;
} // end of the 'confirmLink()' function

function sprawdz_formularz(){
  
 if( document.getElementById('temat').value == '' || document.getElementById('tresc_posta').value == '')
  alert( 'Musisz podać tytul oraz treść' );
 else
  document.forms.wiadomosc.submit() 
}


function str_repeat(i, m) {
for (var o = ''; m-- > 0; o += i);
return o;
}

function sprintf () {
var a, f = arguments[0], fi= '', i = 1, m = [''], o = '', p;
while (f = f.substring (m[0].length)) {
m = /^([^\%]*)(?:(\x25)((\x25)|(?:(\d+)\$)?(\+)?(0|'([^$]))?(-|\^)?(\d+)?(?:\.(\d+))?([bcdefosuxX])))?/.exec(f);
if (a = m[12]) {
if (arguments.length < (i = m[5] || i))
throw("sprintf '" + m[0] + "' : No argument " + i);
a = arguments[i++];
s = (/[def]/.test(m[12]) && m[6] && a > 0) ? '+':'';
switch (m[12]) {
case 'b': a = a.toString(2); break;
case 'c': a = String.fromCharCode(a); break;
case 'd': a = parseInt(a); break;
case 'e': a = m[11] ? a.toExponential(m[11]) : a.toExponential(); break;
case 'f': a = m[11] ? parseFloat(a).toFixed(m[11]) : parseFloat(a); break;
case 'o': a = a.toString(8); break;
case 's': a = ((a = String(a)) && m[11] ? a.substring(0, m[11]) : a); break;
case 'u': a = Math.abs(a); break;
case 'x': a = a.toString(16); break;
case 'X': a = a.toString(16).toUpperCase(); break;
}
if (m[10] && (m[10] > a.length)) {
fir=fil=str_repeat(m[7] ? m[8] || '0' : ' ', m[10]-a.length);
if (m[9] == '^') {
fil = fil.substr(0, fil.length / 2);
fir = fir.substr(fil.length);
} else
m[9] == '-' ? (fil = '') : (fir = '');
a = fil + a + fir;
}
}
o += m[1] + ((m[3] ? m[4] || (s + a) : m[2]) || '');
}
return o;
}
 
function AktywujMenu( id ) {
 var poz = document.getElementById( 'menu_' + id );
 poz.className = 'PozycjaMenuAktywna';
}

function DeaktywujMenu( id ) {
 var poz = document.getElementById( 'menu_' + id );
 poz.className = 'PozycjaMenu';
}

function SprawdzKod(id){
 if (!id) {
 	xajax_SprawdzKod( xajax.getFormValues("dodaj_post") );
 } else {
 	xajax_SprawdzKod( xajax.getFormValues("skomentuj_"+id),id );
 }
}

function SprawdzPost(typ) {
	var wynik = 0;
	var str = '';
	
	if (typ == 'watek' && document.getElementById('tresc').value == '' ) {
		document.getElementById('tytul').style.backgroundColor = 'Red';
		str += "Podaj tytuł nowego wątku\r\n";
		wynik = wynik+1;
	}
	if( document.getElementById('tresc_posta').value == '') {
		document.getElementById('tresc_posta').style.backgroundColor = 'Red';
		str += "Podaj treść wpisu\r\n";
		wynik = wynik+1;
	} else {
  		document.getElementById('tresc_posta').style.backgroundColor = 'White';
	}
 	
 	if (wynik == 0) {
		xajax_SprawdzKod( xajax.getFormValues("dodaj_post") );
 	} else {
 		alert(str);
 	}
}

function SprawdzKomentarz(id) {
	var wynik = 0;
	var str = '';

	if( document.getElementById('dopisujacy_'+id).value == '') {
		document.getElementById('dopisujacy_'+id).style.backgroundColor = 'Red';
		str += "Podaj swój nick\r\n";
		wynik = wynik+1;
	} else {
  		document.getElementById('dopisujacy_'+id).style.backgroundColor = 'White';
	}	
	if( document.getElementById('tresc_'+id).value == '') {
		document.getElementById('tresc_'+id).style.backgroundColor = 'Red';
		str += "Podaj treść wpisu\r\n";
		wynik = wynik+1;
	} else {
  		document.getElementById('tresc_'+id).style.backgroundColor = 'White';
	}
	if (wynik == 0) {
		xajax_SprawdzKod( xajax.getFormValues("skomentuj_"+id),id );
 	} else {
 		alert(str);
 	}
}