<!-- //

var from = escape(document.referrer);
var query = location.search;
var colorDepth = window.screen.colorDepth;			
var res = window.screen.width + "," + window.screen.height;
document.write("<img src='/statystyka/zlicz.php?referer=" + from + "&query=" + query + "&kolory=" + colorDepth + "&rozdzielczosc=" + res + "' align='middle' style='display:none'>");

function Rozpoznanie(warstwa)
{
	if(document.all)
	{
		warstwa = document.all(warstwa);
	}
	else if(document.getElementById)
	{
		warstwa = document.getElementById(warstwa);
	}
   else if(document.layers)
	{
		warstwa = document.layers[warstwa];
	}
   return warstwa;
}

function slideSwitch() {
    var $active = jQuery('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = jQuery('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function PowiekszZdjecie(url,lang)
{
	var okno = null;
	if(okno) okno.close();
	var ScrWidth = 640;
	var ScrHeight = 480;
	var width = 1;
	var height = 1;
	if(window.screen)
  	{
   	ScrWidth = window.screen.width; 
		ScrHeight = window.screen.height;
  	}
  	PosX = Math.round((ScrWidth - width) / 2);
  	PosY = Math.round((ScrHeight - height) / 2);
  	width = width;
  	height = height;
  	okno = window.open("/pokaz_zdjecie.php?url="+url+"&lang="+lang, "zdjecie", "menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,copyhistory=no,width=" + width + ",height=" + height + ",left=" + PosX + ",top=" + PosY);
  	okno.focus();	
}

function PokazGalerie(galeria_id,zdjecie_id,lang)
{
	var okno = null;
	if(okno) okno.close();
	var ScrWidth = 640;
	var ScrHeight = 480;
	var width = 1;
	var height = 1;
	if(window.screen)
  	{
   	ScrWidth = window.screen.width; 
		ScrHeight = window.screen.height;
  	}
  	PosX = Math.round((ScrWidth - width) / 2);
  	PosY = Math.round((ScrHeight - height) / 2);
  	width = width;
  	height = height;
  	okno = window.open("/pokaz_galerie.php?galeria_id="+galeria_id+"&zdjecie_id="+zdjecie_id+"&lang="+lang, "zdjecie", "menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,copyhistory=no,width=" + width + ",height=" + height + ",left=" + PosX + ",top=" + PosY);
  	okno.focus();	
}

function SubmitForm(id)
{
	if(id == 'konfigurator')
	{
		if(SprawdzCene())
		{
			jQuery('#spam').val(2);
			jQuery('#'+id).submit();	
		}
		else
		{
			var komunikat = '';
			var szerokosc1 = jQuery('#atrybut_3').val();
			szerokosc = parseFloat(szerokosc1);
			
			var wysokosc1 = jQuery('#atrybut_4').val();
			wysokosc = parseFloat(wysokosc1);
			
			var komunikat_1 = '';
			var komunikat_2 = '';
			var komunikat_3 = '';
			var komunikat_4 = '';
			var komunikat_5 = '';
			var komunikat_6 = '';
			
			if( jQuery('#atrybut_1').attr("checked") != true && jQuery('#atrybut_2').attr("checked") != true)
			{
				komunikat_1 = 'Wybierz rodzaj mocowania rolety.\n\n';
			}
			
			if( szerokosc > 240 || szerokosc < 35 || szerokosc1 == '')
			{
				komunikat_2 =  'Podana szerokosc jest nieprawidlowa.\n\n';
			}
			
			if( wysokosc > 300 || wysokosc < 35 || wysokosc1 == '')
			{
				komunikat_3 = 'Podana wysokosc jest nieprawidlowa.\n\n';
			}
			
			if(wysokosc*szerokosc > 50000)
			{
				komunikat_6 = 'Za duza powierzchnia maty. Maksymalna powierzchnia maty wynosi 5m2.\n\n';
			}
			
			if( jQuery('#atrybut_13').attr("checked") != true && jQuery('#atrybut_14').attr("checked") != true)
			{
				komunikat_4 = 'Wybierz typ rolety rolety.\n\n';
			}
			
			if( jQuery('#atrybut_5').attr("checked") != true && jQuery('#atrybut_6').attr("checked") != true)
			{
				komunikat_5 = 'Wybierz strone obslugi rolety.\n\n';
			}
			
			alert(komunikat_1+komunikat_2+komunikat_3+komunikat_4+komunikat_5+komunikat_6);

		}
	}
	
	
}

function SprawdzCene()
{
	if(jQuery('#cena_calkowita').html() == '0.00')
	{
		return false;	
	}
	else
	{
		return true;	
	}
}

function SprawdzWartosc(towar_id, atr_id)
{
	var wartosc = jQuery('#'+atr_id).val();
	wartosc = wartosc.replace(/,/, ".");
	jQuery('#'+atr_id).val(wartosc);
	Przelicz(towar_id);
}

function ShowInfo(text)
{
	var okno = null;
	ScrWidth = 720;
	width = 720;
	ScrHeight = 480;
	height = 480;
	if(window.screen)
	{
		ScrWidth = window.screen.width;
		ScrHeight = window.screen.height;
	}
	if(okno != null && !document.layers)
	{
		okno.close();
	}
	PosX = Math.round((ScrWidth - width) / 2);
	PosY = Math.round((ScrHeight - height) / 2);
	okno = window.open("/opis.php?id="+text, "PrintPopUp", "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=" + width + ",height=" + height + ",left=" + PosX + ",top=" + PosY);
	okno.focus();
}

function Przelicz(t_id)
{
	 var ilosc = jQuery('.atrybuty').length;
	 var parametry = '';
	 for(var i = 0; i < ilosc; i++)
	 {
		var type = jQuery('.atrybuty').eq(i).attr("type");
		
		if(type == 'radio')
		{ 
			var checked = jQuery('.atrybuty').eq(i).attr("checked");
			if(checked == true)
			{
				var name = jQuery('.atrybuty').eq(i).attr("name");
				var id = jQuery('.atrybuty').eq(i).attr("id");
				var value = jQuery('.atrybuty').eq(i).attr("value");
				if(parametry == '')
				{
					parametry = '?'+name+'='+value;
				}
				else
				{
					parametry = parametry+'&'+name+'='+value;
				}
				
			}
			
		}
		else if(type == 'text')
		{
			var value = jQuery('.atrybuty').eq(i).attr("value");	
			if(value != '' && parseFloat(value) == value)
			{
				var id = jQuery('.atrybuty').eq(i).attr("id");
				if(parametry == '')
				{
					parametry = '?'+id+'='+value;
				}
				else
				{
					parametry = parametry+'&'+id+'='+value;
				}		
			}
		}
	 }
	
	if(parametry != '')
	{
		jQuery.get("/ajax/podsumowanie.php"+parametry+'&t_id='+t_id, { },
			function(data)
			{
			//	alert(data);
				jQuery('#podsumowanie').html(data);
			}
		);	
	}
}

// -->