var prd_bufor='1';
function getPageScroll()
{

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollLeft;
	}
	
	return yScroll;
}
function getPageSize()
{
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function validacjaTYP(cel,typ)
{
	if($(cel))
	{ 
		var vartosc = $(cel).value;
		
		if(typ=='tekst')
		{
			if(vartosc=='')
			{
				$(cel).style.backgroundColor="#FFD9D9";
				return false;
			}
			else
			{
				$(cel).style.backgroundColor="#ECFFEC";
				return true;
			}	
		}
		if(typ=='email')
		{
			if(vartosc=='')
			{
				$(cel).style.backgroundColor="#FFD9D9";
				return false;
			}
			else
			{
				if(vartosc.indexOf('@')>-1 && vartosc.indexOf('.')>-1)
				{
					$(cel).style.backgroundColor="#ECFFEC";
					return true;		
				}
				else
				{
					$(cel).style.backgroundColor="#FFD9D9";
					return false;
				}
			}	
		}
		if(typ=='liczba')
		{
			if(vartosc=='')
			{
				$(cel).style.backgroundColor="#FFD9D9";
				return false;
			}
			else
			{
				vartosc = parseFloat(vartosc );
				if(isNaN(vartosc))
				{
					$(cel).style.backgroundColor="#FFD9D9";
					return false;	
				}
				else
				{
					$(cel).style.backgroundColor="#ECFFEC";
					return true;	
				}
			}	
		}
	}
}
function prdCHNG(id)
{
	$('prd'+prd_bufor).style.backgroundColor='#0074AD';	
	$('opos'+prd_bufor).style.display='none';
	
	$('prd'+id).style.backgroundColor='#FF0000';	
	$('opos'+id).style.display='';
	prd_bufor=id;
}
function prdDRUKUJ(id)
{window.open('drukujPRD.php?id='+id+'', 'okienko', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no,width=800, height=600');	}
function wyszNastStr(id)
{
	$('szukane_str').value=id;
	$('wyszSTR').submit();
}
function form_zapytV()
{
	var blad= '';
	if(validacjaTYP('fw_imie','tekst')==false)
		{blad+='Pole "Imie i nazwisko" nie zostalo wypelnione \r\n';}
	if(validacjaTYP('fw_email','email')==false)
		{blad+='Pole "Adres e-mail:" nie zostalo wypelnione \r\n';}
	if(validacjaTYP('fw_tresc','tekst')==false)
		{blad+='Pole "Tresc wiadomosc" nie zostalo wypelnione \r\n';}
	
	
	if(blad=='')
		{$('form_zapyt').submit();}
	else
		{alert(blad);}
	
}
function menu(id,status)
{
	if(status==1)
	{
		var okno = getPageSize();
		
		$('menuS_'+id).style.display='';
		
		
		//okno[2]
			
		
	}
	else
	{
		$('menuS_'+id).style.display='none';	
		
	}
	
}