var lastImg = null;

function imgSwap(ev,imgName) {
if (imgName != 0) {
	lastImg = ev.src;
	ev.src = imgName;
	}	
	else
	{
	ev.src = lastImg;
	}
}
function checkFields(newForm) {
	if (newForm.title.value == '') {
		alert('Brak tytułu');
		return ;
	} else if (newForm.body.value == '') {
		alert('Brak treści');
		return ;
	}
	newForm.submit();
}


function fullsize(pI,title,desc) {
        if(document.all){picId = "/_uTils/site/gallery.html?" + pI + "&title=" + encodeURIComponent(escape(title)) + "&desc=" + encodeURIComponent(escape(desc));}
        else{picId = "/_uTils/site/gallery.html?" + pI + "&title=" + escape(title) + "&desc=" + escape(desc);}
//picId = encodeURI(picId);
        Win = window.open(picId,'DispalyWindow','width=300, height=300, resizable=yes, scrollbars=auto menubar=no, location=no');
        return;
}
function isN(v,f,n) {
	if(v.length>0)if((v!=~~v)||(v<=0)){alert('Wymagana jest liczba całkowita dodatnia.');o=eval('document.'+f+"."+n);o.value="";}
}
function deleteRecord(str)
{
    if(confirm("Czy na pewno usunąć wpis?"))
	      location.href = str;
}
function openWindow(url,top,left,width,height) {
	var p = "";
	if (top>-1) p=",top="+top;
	if (left>-1) p=p+",left="+left;
	if (width>-1) p=p+",width="+width;
	if (height>-1) p=p+",height="+height;
	window.open(url,'','toolbar=0,location=0,directories=0,status=0,menubar=0.scrollbars=1,resizable=0'+p);
	//  return false;
}

function checkDocumentType () {
	if (document.forms.formularz) {
		a = document.getElementsByTagName('h3');
		fn = a[0].firstChild.nodeValue;
		switch ( fn ) {
			case 'Wniosek o sporządzenie zaświadczenia o zadłużeniu i obsłudze kredytu':
			case 'Wniosek o sporządzenie zaświadczenia o zapłaconych odstekach':
			case 'Wniosek o sporządzenie zaświadczenia o zapłaconych odsetkach':
			case 'Wniosek o zmianę harmonogramu spłat':
			case 'Wniosek o wysłanie harmonogramu':
				document.forms.formularz.btnSend.style.display = "inline";
				break;
			default:
				break;
		}
	}
}

function newForm(form){
	a = document.getElementsByTagName('h3');
	a = a[0].firstChild.nodeValue;
	pole = a + "\n\n\n";
	for(i=6; i<form.length; i++){
		if (form.elements[i].type!='button')
			if(form.elements[i].type!='checkbox'){
				pole=pole + form.elements[i].name +': '+ form.elements[i].value + "\n\n";
			}
			else{
				if (form.elements[i].checked==true)
					pole=pole+form.elements[i].name+': opcja wybrana '+"\n";
			}
		if (form.elements[i].type!='button'){
			form.elements[i].name='';
			form.elements[i].value='';
		}
	}
	form.elements[5].name='message_';
	form.elements[5].value=pole;
	form.submit();
}

function setCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
function getCookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return "";
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length;
 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function showPopUpOrNot(){
		openWindow("/_iMg/site/baner.html", 100,100,775,545);
}
