if(document.all && !document.getElementById)
    document.getElementById = function(id) { return document.all[id]; }

if(document.all && !document.getElementsByTagName)
    document.getElementsByTagName = function(tag) { return document.all.tags(tag); }



function oW (path,Xsiz,Ysiz,popUnder) {
	var przed = '';
	if (!(Xsiz > 0)) { Xsiz = 450; }
	if (!(Ysiz > 0)) { Ysiz = 300; }
	w = window.open(przed+path, 'fotozoom', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,channelmode=no,width='+Xsiz+',height='+Ysiz+',top=30,left=30');
	if (popUnder) {
		w.blur();
		window.focus();
	}
	else {
		w.focus();
	}
	void(0);
}



function pobierz(nazwa) {
    if (document.cookie.length > 0) {
        startc = document.cookie.indexOf(nazwa + "=");
        if (startc != -1) {
            startc += nazwa.length + 1;
            endc = document.cookie.indexOf(";", startc);
            if (endc == -1) {
                endc = document.cookie.length;
            }
            return unescape(document.cookie.substring(startc,endc));
        }
	return false;
    }
    return false;
}

function rejestruj(nazwa, wartosc,dni) {
    var dzisiaj=new Date();
    var wygasnie=new Date();
    !dni ?dni=7 :"";
    wygasnie.setTime(dzisiaj.getTime()+1000*60*60*24*dni);
	document.cookie=nazwa+"="+escape(wartosc)+";expires="+wygasnie.toGMTString();
}

function sClear(obj,itxt) {
	if (obj.value == itxt) obj.value = '';
}
function sReturn(obj,itxt) {
	if (obj.value == '') obj.value = itxt;
}


function cq (kod,zm) {

		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");

		++tmpIl;

		--tmpIl;

		reszta = tmpIl%zm;

		if ((zm > 0) && (tmpIl < 999999) ) {

			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm - reszta;");

		}

		else if ((zm < 0) && (tmpIl > 0)){

			if ( reszta > 0 ) { eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;"); }

			else {	eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm;"); }

		}

	if (document.getElementById('zzm')) {

			

			document.getElementById('zzm').className  = "bma";

		}

}



function rq (kod,zm) {

		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");

		++tmpIl;

		--tmpIl;

		reszta = tmpIl%zm;

		if (!(tmpIl >= 0)) {

			alert ("Wprowadzono nie poprawna wartosc!");

			eval( "document.grupa[\"il["+kod+"]\"].value = 0;");

		}

		else if (reszta > 0) {

			alert ("Ilosc musi być wielokrotnoscia liczby "+zm);

			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;");

		}

		if (document.getElementById('zzm')) {

			

			document.getElementById('zzm').className  = "bma";

		}



}

function ocq (obj,zm) {
		
		var inp = obj.parentNode.firstChild;
		trobj = obj.parentNode.parentNode;
		inp = inp.nextSibling;
		
		var tmpIl = parseInt(inp.value,10);

		var reszta = tmpIl%zm;

		if ((zm > 0) && (tmpIl < 999999) ) {
			inp.value = tmpIl + zm - reszta;
		}

		else if ((zm < 0) && (tmpIl > 0)){

			if ( reszta > 0 ) { inp.value = tmpIl - reszta; }
			else {	inp.value = tmpIl + zm; }
			

		}
		trobj.className = (inp.value > 0)?'wyr':'';
calcSum();

}

function roundIl(obj,zm) {
		var tmpIl = parseInt(obj.value,10);
		reszta = tmpIl%zm;
		if (reszta > 0) {
			alert ("Ilość musi być wielokrotnością liczby "+zm);
			obj.value = tmpIl - reszta + zm;
		}
		else obj.value = 0;
	calcSum();
}


/* Made by Mathias Bynens <http://mathiasbynens.be/> */
function number_format(a, b, c, d) {

	if (b == null) b = 2;
	if (c == null) c = '.';
	if (d == null) d = '';
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}



function calcSum() {
	
	var cena, sumaold, cenaold, kcena, kcenab, ilosc, maraza, cw, vat, martyp, suma, sumab, ksuma, ksumab, msuma, msumab;
	
	
	if (document.getElementById('ofsum')) {
		//cw = document.getElementById('calcw').value;
		//martyp = document.getElementById('percent').value;
		lp = 1;
		sumaold = suma = sumab = ksuma = ksumab = msuma = msumab = 0;
		while (document.getElementById('itemAmount'+lp)) {
		
			if (document.getElementById('itemPrice'+lp)) {
			cena = parseFloat(document.getElementById('itemPrice'+lp).innerHTML.replace(',','.'));
			cenaold = parseFloat(document.getElementById('itemPriceOld'+lp).innerHTML.replace(',','.'));
			ilosc = parseInt(document.getElementById('itemAmount'+lp).value,10);
					
			suma += cena * ilosc;
			sumaold += cenaold * ilosc;
			
			}
			++lp;
		}
		document.getElementById('ofsum').innerHTML = number_format(suma, 2, ',', ' ');
		document.getElementById('ofbonus').innerHTML = number_format((sumaold - suma), 2, ',', ' ');

	}
	
}


function wPrzelicz() {
var wIn = document.getElementById('wIn').value;
var wOut = document.getElementById('wOut').value;
var wKwota = parseFloat(document.getElementById('wKwota').value.replace(',','.'));

var inPLn = wKwota * waluty[wIn][0]/waluty[wIn][1];

document.getElementById('wWynik').innerHTML = wKwota+' '+wIn+' = '+Math.round(inPLn*100/(waluty[wOut][0]/waluty[wOut][1]))/100+' '+wOut;
void(0);
}



function roundedCorners() {
	$("div.rounded").corner("8px keep");
	$(".rounded-small").corner("5px keep");

}


$(document).ready( function(){
	
	
	$('.sp-kill').hide();
	$('.display-none').hide();
	$('.sp-kill input').val('nospam');
	roundedCorners();




});
