function setvisibility(id, parent)
{
    if(document.getElementById(id).style.display!='none')
    {
	document.getElementById(id).style.display='none';
	parent.style.backgroundImage='url(imgs/plus.gif)';
    }
    else
    {
	document.getElementById(id).style.display='block';
	parent.style.backgroundImage='url(imgs/minus.gif)';
    }
}

function changeMainPicture(picture, where)
{
    document.getElementById(where).src=picture;
}

function changeMainPictureURL(url, where)
{
    document.getElementById(where).parentNode.href=url;
}

function changeGalleryPicture(picture, where, id, isIntro)
{
    document.getElementById(where).src=picture;
    for(var i = 0; i < ids.length; i++) {
	document.getElementById("intro_"+ids[i]).style.display = "none";
    }
    if(isIntro) {
	document.getElementById("bIcenter").style.width = "645px";
	document.getElementById("bI").style.backgroundImage = "url('imgs/bimage-right.gif')";
	document.getElementById("bIinfo").style.display = "block";
	document.getElementById("intro_"+id).style.display = "block";
    }
    else {
	document.getElementById("bIinfo").style.display = "none";
	document.getElementById("bI").style.backgroundImage = "none";
	document.getElementById("bIcenter").style.width = "878px";
    }
    hideImageText(currentid);
    currentid = id;
}

function showImageText(id) {
    document.getElementById('bI').style.display="none";
    document.getElementById('text_' + id).style.display="block";
}

function hideImageText(id) {
    document.getElementById('text_' + id).style.display="none";
    document.getElementById('bI').style.display="block";
}

function randomPictures()
{
    var nr=images.length;
    var random=Math.round(Math.random()*(nr-1));
    document.getElementById('bigImage').src=images[random];
    setTimeout("randomPictures()", 5000);
}

function enableBox(chkbx, bx) {
    if (document.getElementById(chkbx).checked){
	document.getElementById(bx).disabled=true;
    }else{
	document.getElementById(bx).disabled=false;
    }
}


INVNAME	=	'Podaj imię';
INVLASTNAME	=	'Podaj nazwisko';
INVCITY	=	'Podaj miasto';
INVLOGIN	=	'Podaj NIK';
INVPASSWORD	=	'Podaj hasło';
INVEMAIL	=	'Podaj email';
INVEMAILFORMAT	=	'Popraw adres email';
INVADRESS	=	'Podaj adres';
INVREPEATPASSWORD	=	'Powtórz hasło';
DIFFRENTPASSWORD	=	'Hasła nie są ze sobą zgodne';
INVAGE	= 	'Podaj wiek (liczba całkowita)'
INVCITY	= 	'Podaj miasto'
INVSEX	= 	'Wybierz płeć'
ERRALERT = "Wypełnij / popraw pola";
INVZGODA = " Musisz zaakceptować regulamin";
INQUIRY	=	'Nie podałeś odpowiedzi na jedno z pytań';

	
function validatePlayerRegisterForm(formObj, errors){
	var blad='';
		validMail=/^[a-zA-Z0-9._-]+\@([a-zA-Z0-9_-]+\.){1,}[\w]{1,5}$/;
		validNum=/^[0-9]+$/;
		
	with (formObj)
	{							
			if (name.value == '')
					blad+='\n- '+ INVNAME;
			if (surname.value == '')
					blad+='\n- '+INVLASTNAME;
			if (login.value == '')
					blad+='\n- '+ INVLOGIN;
			if (a_street.value == '')
					blad+='\n- '+INVADRESS;
			if (email.value == '')
					blad+='\n- '+INVEMAIL;
			if (email.value != '' && email.value.search(validMail) == -1)
					blad+='\n- '+ INVEMAILFORMAT;
			if (password.value == '')
					blad+='\n- '+ INVPASSWORD;
			if (password_submit.value == '')
					blad+='\n- '+ INVREPEATPASSWORD;
			if (password.value !== password_submit.value)
					blad+='\n- '+ DIFFRENTPASSWORD;
			if (a_city.value == '')
					blad+='\n- '+ INVCITY;
			if (age.value == '' || age.value.search(validNum) == -1)
					blad+='\n- '+ INVAGE;
			if (!(sex[0].checked) && !(sex[1].checked))
					blad+='\n- '+ INVSEX;
			
			if (!zgoda.checked)
					blad+='\n- '+ INVZGODA;
			if(errors!='')
			    blad+='\n' + errors;
			if (blad!='')
		{
			alert(ERRALERT+'\n'+blad);
			return false;
		}
	else
		{
		return true;
		}
	}
}

function setBoxes(chkbx, id, id2)
{
    if (document.getElementById(chkbx).checked)
    {
	document.getElementById(id).style.display='block';
    }
    else
    {
	document.getElementById(id).style.display='none';
    }
    if (document.getElementById(chkbx).checked)
    {
	document.getElementById(id2).style.display='block';
    }
    else
    {
	document.getElementById(id2).style.display='none';
    }
}

function changeSection(nr, count)
{
    for(var i=1; i<=count; i++)
    {
	if(i==nr)
	{
	    document.getElementById('sekcja_'+i).style.display='block';
	    document.getElementById('page_nr'+i).style.color='#e89a32';
	    document.getElementById('page_nr'+i).style.fontWeight='bold';
	}
	else
	{
	    document.getElementById('sekcja_'+i).style.display='none';
	    document.getElementById('page_nr'+i).style.color='#452e0f';
	    document.getElementById('page_nr'+i).style.fontWeight='normal';
	}
    }
}

function send()
{
	if (document.getElementById('faqQuestion').value=='')
	{
		alert ('Proszę wpisać treść pytania.');
		return false;
	}
	else
	{
		alert ('Dziękujemy - Twoje pytanie zostało wysłane. Odpowiemy w przeciągu 3 dni roboczych.');
	}
	return true;
}
