image1a = new Image();image1a.src = "/gfx/menu/menu1a.gif";
image1n = new Image();image1n.src = "/gfx/menu/menu1.gif";
image2a = new Image();image2a.src = "/gfx/menu/menu2a.gif";
image2n = new Image();image2n.src = "/gfx/menu/menu2.gif";
image3a = new Image();image3a.src = "/gfx/menu/menu3a.gif";
image3n = new Image();image3n.src = "/gfx/menu/menu3.gif";
image4a = new Image();image4a.src = "/gfx/menu/menu4a.gif";
image4n = new Image();image4n.src = "/gfx/menu/menu4.gif";
image5a = new Image();image5a.src = "gfx/menu/menu5a.gif";
image5n = new Image();image5n.src = "gfx/menu/menu5.gif";

function showmenu()
{
	document.getElementById('submenu').style.display="block";
	document.getElementById('zdjecie1').src=image1a.src;
}
function hidemenu()
{
	document.getElementById('submenu').style.display="none";
	document.getElementById('zdjecie1').src=image1n.src;
	
}
function zamknij()
{
	closeTimer = window.setTimeout(hidemenu, 300);
}
function anulujzamykanie()
{
	if(window.closeTimer)
	{
		window.clearTimeout(closeTimer);
		closeTimer = null;
	}
}

var tempnaw=0;
var strona=0;

function pokaz(id)
{
	document.getElementById(id).style.color="#425d6f";
	document.getElementById(id).style.cursor="pointer";
	if(document.getElementById(id).getAttribute('orygjs'))
	 document.getElementById(id).setAttribute('onclick',document.getElementById(id).getAttribute('orygjs'));
}

function ukryj(id)
{
	document.getElementById(id).style.color="#98abc9";
	document.getElementById(id).style.cursor="default";
	if(!(document.getElementById(id).getAttribute('orygjs')))
	 document.getElementById(id).setAttribute('orygjs',document.getElementById(id).getAttribute('onclick'));
	document.getElementById(id).setAttribute('onclick','');
}

function pokaz2(id)
{
	document.getElementById(id).style.display="block";
}

function ukryj2(id)
{
	document.getElementById(id).style.display="none";
}

function changenaw(numer)
{
	aktualne=[];
	aktualne=wszystkie[numer];
	zmienzdjecia(0);
	document.getElementById('naw'+(tempnaw+1)).className="";
	document.getElementById('naw'+(numer+1)).className="active";
	tempnaw=numer;
}

function zmienzdjecie(nr_ramki,nr_zdjecia,gdzie)
{
	newHTML = '<div class="zoom"><img src="gfx/zoom.gif" onmousedown="showtrail(\'gfx/'+gdzie+'/';
	newHTML += nr_zdjecia + 'd.jpg\',400,300);canceltrail();"';
	newHTML += 'ondragstart="closetrail();" /></div>';
	newHTML += '<div class="fix"></div>';
	newHTML += '<div class="zdjecie_ramka" onmousedown="showtrail(\'gfx/'+gdzie+'/';
	newHTML += nr_zdjecia + 'd.jpg\',400,300);canceltrail();"">';
	newHTML += '<img class="zdjecie" src="gfx/'+gdzie+'/' + nr_zdjecia + 'm.jpg" />';
	newHTML += '</div>';
	newHTML += '<div class="opis" onmousedown="showtrail(\'gfx/'+gdzie+'/';
	newHTML += nr_zdjecia + 'd.jpg\',400,300);canceltrail();">';
	newHTML += opisy[nr_zdjecia-1];
	newHTML += '</div>';
	document.getElementById("ramka" + nr_ramki).innerHTML=newHTML;
}

function zmienzdjecia(o_ile)
{
	var na_strone = 15;
	var gdzie_temp='';
	if(o_ile==0)strona=0;
	else strona+=o_ile;
	if(strona<0)strona=0;
	if(strona > (aktualne.length-1)/na_strone)strona = Math.floor((aktualne.length-1)/na_strone);
	if(realizacje==1)gdzie_temp = 'realizacje';
	else gdzie_temp = 'galeria';
	for(var petla=0;petla<na_strone;petla++)
	{
		if(strona*na_strone+petla < aktualne.length)
		{
			zmienzdjecie((petla+1),aktualne[strona*na_strone+petla],gdzie_temp);
			pokaz2('ramka'+(petla+1));
		}
		else ukryj2('ramka'+(petla+1));
		
		if((petla+1) % na_strone == 0)break;
	}
	
	var inner = "prezentowane zdjęcia: " + (strona*na_strone+1) + "-" + (((strona+1)*na_strone) < aktualne.length ? ((strona+1)*na_strone) : aktualne.length) + " z "+aktualne.length;
	document.getElementById("numer").innerHTML = inner;
	//document.getElementById("numer2").innerHTML = inner;
	
	if(strona==0){
    ukryj('poprzednie');
    ukryj('poprzednie2');
  }
	else{
    pokaz('poprzednie');
    pokaz('poprzednie2');
  }
	
	if(aktualne.length - (strona+1)*na_strone > 0){
    pokaz('nastepne');
    pokaz('nastepne2');
  }
	else {
    ukryj('nastepne');
    ukryj('nastepne2');
  }
	
	if(!(aktualne.length - (strona+1)*na_strone > 0) && strona==0){
    ukryj('kreska1');
    ukryj('kreska2');    
  }
	else{
    pokaz('kreska1');
    pokaz('kreska2');
  }
	
}

function zapytaj()
{
    if (document.forms['zapytanie'].pytanie_tresc.value.length==0) {
        alert('Nie podano treści pytania');
        return;
    }
//    if (document.forms['zapytanie'].kontakt_email.value.length==0) {
//        alert('Nie podano adresu e-mail');
//       return;
//    }
//    if (document.forms['zapytanie'].kontakt_miasto.value.length==0) {
//        alert('Nie podano miasta');
//        return;
//    }
    document.forms['zapytanie'].submit();
}
function zapytaj_duze()
{
    if (document.forms['zapytanie_duze'].pytanie_tresc.value.length==0) {
        alert('Nie podano treści pytania');
        return;
    }
    if (document.forms['zapytanie_duze'].kontakt_email.value.length==0) {
        alert('Nie podano adresu e-mail');
        return;
    }
    if(!checkEmail(document.forms['zapytanie_duze'].kontakt_email)){
    	alert('Podany adres email jest niepoprawny');
    	document.forms['zapytanie_duze'].kontakt_email.focus();
    	return;
    }
    if (document.forms['zapytanie_duze'].kontakt_miasto.value.length==0) {
        alert('Nie podano miasta');
        return;
    }
    document.forms['zapytanie_duze'].submit();
}
function checkEmail(element){
	var filter  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(element.value); 
}

function textarea_limit(obj, maxlen){
if (obj.getAttribute && obj.value.length>maxlen)
obj.value=obj.value.substring(0,maxlen);
}

