function mail(user, domain)
{
	window.location = 'mailto:'+user+'@'+domain;
}

function error(elem, text)
{
	if (errfound) return;
	window.alert(text);
	elem.select();
	elem.focus();
	errfound = true;
}

function Validate()
{
	errfound = false;
	//komentarze
	if (document.getElementById('autorx').value == "")
	{
		error(document.getElementById('autorx'),"Nie uzupełniłeś pola NICK.");
	}
	if (document.getElementById('newsx').value == "")
	{
		error(document.getElementById('newsx'),"Nie uzupełniłeś pola KOMENTARZ.");
	}
	return !errfound;
}

function Validate_gb()
{
	errfound = false;
	//księga gości
	if (document.getElementById('nick').value == "")
	{
		error(document.getElementById('nick'),"Nie uzupełniłeś pola NICK.");
	}
	if (document.getElementById('e_mail').value == "")
	{
		error(document.getElementById('e_mail'),"Nie uzupełniłeś pola E-MAIL.");
	}
	if (document.getElementById('wpis').value == ""){
		error(document.getElementById('wpis'),"Nie uzupełniłeś pola WPIS.");
	}
	return !errfound;
}

function emoticon(text, pole)
{
	if (document.getElementById(pole).createTextRange && document.getElementById(pole).caretPos)
	{
		var caretPos = document.getElementById(pole).caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		document.getElementById(pole).focus();
	}
	else if (document.getElementById(pole).selectionStart != undefined)
	{
		document.getElementById(pole).value = document.getElementById(pole).value.substring(0, document.getElementById(pole).selectionStart) + ' ' + text + ' ' + document.getElementById(pole).value.substring(document.getElementById(pole).selectionStart);
		document.getElementById(pole).focus();
	}
	else
	{
		document.getElementById(pole).value += ' ' + text;
		document.getElementById(pole).focus();
	}
}

function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no' );
}

function GoToForm(form) {
    window.open('plan/index.html'+'?frame='+form, '_self');
}

function GoToTeacher(teacher) {
   window.open('plan/teachers.html'+'?frame='+teacher, '_self');
}

function GoToRoom(room) {
	window.open('plan/rooms.html'+'?frame='+room, '_self');
}

function GoToSummary(summary) {
    if (summary != "-1") {
	window.open(summary, '_self');
    }
}

function selecturl(s) {
	var gourl = s.options[s.selectedIndex].value;	window.top.location.href = gourl;
}
