function foto(name, w, h)
{
 window.open("show_img.php?"+name, "foto","tollbar=no,menubar=no,location=no,personalbar=no,scrollbars=no,status=no,resizable=no,width="+w+",height="+h+", top="+((screen.height/2)-(h/2))+",left="+((screen.width/2)-(w/2)));
} // foto()

function pokaz_pola_uploadu()
{
  var ile_zdjec = parseInt(document.forms[0].pictures_count.value);
  var pola = document.getElementById('pola');
  var zwrot = '';

  for( i = 0; i < ile_zdjec; i++ )
    zwrot = zwrot + '<label>Zdjęcie nr. '+parseInt(i+1)+'</label>&nbsp;<input type="file" size="50" style="width: 330px; margin: 3px 0px 3px 0px" name="pictures[]" class="textField" value="" /><br />';

  pola.innerHTML = zwrot;
} // pokaz_pola_uploadu()

function pokaz_pola_uploadu_2()
{
  var ile_zdjec = parseInt(document.forms[0].pictures_count.value);
  var pola = document.getElementById('pola');
  var zwrot = '';

  for( i = 0; i < ile_zdjec; i++ ) {
    zwrot = zwrot + 'Opis nr. '+ parseInt(i+1) + '<input type="text" name="descs[]" style="width: 100px" class="textField" value="" /> ';
    zwrot = zwrot + 'Zdjęcie nr. '+parseInt(i+1)+'&nbsp;<input type="file" size="10" style="margin: 3px 0px 3px 0px" name="pictures[]" class="textField" value="" /><br />';
  }
  pola.innerHTML = zwrot;
} // pokaz_pola_uploadu()




function addFav()
{
if( document.all && navigator.userAgent.indexOf('Opera')==-1 )
 window.external.AddFavorite(location.href, document.title);
else if( window.sidebar )
 window.sidebar.addPanel(document.title, location.href, "");
else
 alert('Naci¶nij Ctrl+D aby dodać stronę do ulubionych');
} // dodaj_do_ulubionych()


function popup(url,tytul){
with(open('','','width=500,height=500').document){open();write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl"><head><title>');
write(''+tytul+'</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /></head><body style="margin:0;padding:0" onclick="self.close()"><img src="'+url+'" style="display:block" onload="resizeTo(this.width,this.height+60)"></body></html>');close()}
}

function popup2(nazwa, w, h)
{
 var pos_y = (screen.height/2)-(h/2);
 var pos_x = (screen.width/2)-(w/2);
 if( pos_y < 0 ) pos_y = 0;
 if( pos_x < 0 ) pos_x = 0;
 window.open("include/popup2.php?" + nazwa, "","tollbar=no,menubar=no,location=no,personalbar=no,scrollbars=yes,status=no,resizable=no,width="+ w +",height="+ h +", top="+ pos_y +",left="+ pos_x);
} 
 
function showOrHideElement(id)
{
	var element;
	elemet = document.getElementById(id);
	elemet.style.display = (elemet.style.display == 'none')? 'block':'none';
}

function changeElement(id1,id2)
{
	var element1;
	var element2;
	element1 = document.getElementById(id1);
	element2 = document.getElementById(id2);
	
	if(element1.style.display=='none')
	{
		element1.style.display='inline';
		element2.style.display='none';
	}
	else
	{
		element2.style.display='inline';
		element1.style.display='none';
	}
}

function showViz(id1,ids)
{
	document.getElementById(id1).style.display='block';
	
	for(var i in ids)
	{
		
		document.getElementById(ids[i]).style.display='none';
	}
}

function changePicture(pictures,pictureID)
{
	var element1;
	var element2;
	element1 = document.getElementById("Picture_"+pictureID);
	element2 = document.getElementById("PictureZoom_"+pictureID);
	
	for(var pic in pictures)
	{
		if(pictures[pic] != pictureID)
		{
			document.getElementById("Picture_"+pictures[pic]).style.display='none';
			document.getElementById("PictureZoom_"+pictures[pic]).style.display='none';
		}
		//alert("Picture_"+pictures[pic]);
	}
	
	element1.style.display='block';
	element2.style.display='block';
	return true;
}


function showFields(quntityField,id,txt,tableName,fileType)
{
  if(parseInt(quntityField)>20)
		alert('Za duża liczba. Max to 20.');
  else
  {
	  if(typeof(fileType) == 'unidentified')
		fileType= 'text'; 
	  var quantity = parseInt(quntityField);
	  var outputElement = document.getElementById(id);
	  var output = '';

	  for( i = 0; i < quantity; i++ )
	    output += '<label>'+txt+' <span style="color:#ff9900">nr. '+parseInt(i+1)+'</span></label><br/><input type="'+fileType+'" size="25" style="width: 150px; margin: 3px 0px 3px 0px" name="'+tableName+'[]" class="textField" value="" /><br />';


		outputElement.innerHTML = output;
 }
  return false;
}




function addField(quntityField,id,txt,tableName)
{
 var quantity = document.getElementById(quntityField);
  if(quantity.value > 0)
	quantity.value ++ ;
  else
	quantity.value=1;

  var outputElement = document.getElementById(id);
  var output = '';

 
    output += '<label>'+txt+' <span style="color:#ff9900">nr. '+parseInt(quantity.value)+'</span></label>&nbsp;<input type="text" size="50" style="width: 330px; margin: 3px 0px 3px 0px" name="'+tableName+'[]" class="textField" value="" /><br />';


	outputElement.innerHTML += output;
  
  return false;
}


function showFields2(quantity,idIn,idOut,max)
{
 
 if(quantity>max)
	return alert('Podana liczba jest za duża.Max to '+max);

  var outputElement = document.getElementById(idOut);
  var output = '';
  var inputElement = document.getElementById(idIn).innerHTML;
  
  for(i=0; i<quantity; i++)
  {
	output += inputElement;
  }
  outputElement.innerHTML = output;
  return false;
}


function addField2(quantity,idIn,idOut,max)
{
 if(quantity.value>max)
	return alert('Podana liczba jest za duża.Max to '+max);
  if(quantity.value > 0)
	quantity.value ++ ;
  else
	quantity.value=1;

	
  document.getElementById(idOut).innerHTML += document.getElementById(idIn).innerHTML ;

  return false;
}

function isVat(value)
{
	if(isNaN(parseInt(value)))
		return alert('Stawka Vat powinna być liczbą');
	else if(parseInt(value)<0 || parseInt(value)>22)
		return alert('Stawka Vat powinna być między 0-22');
	else 	
		return true;
}


function CheckAll()
{
var col = document.getElementsByTagName("input");
for (var i=0;i<col.length;i++)
col[i].checked= true;
return true;
}
function UnCheckAll()
{
var col = document.getElementsByTagName("input");
for (var i=0;i<col.length;i++)
col[i].checked= false;
return true;
}

function PopPrintPrev(page,title, w, h)
{
 window.open(page, title,"tollbar=no,menubar=no,location=no,personalbar=no,scrollbars=no,status=no,resizable=no,width="+w+",height="+h+", top="+((screen.height/2)-(h/2))+",left="+((screen.width/2)-(w/2)));
} // foto()
