function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	return [ myWidth, myHeight ];
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function odpal_chmurke(idh) {
	var pokaz_chmurke = document.getElementById(idh);
	pokaz_chmurke.style.display='block';
	var wymiar_okna = alertSize();
	var przesuniecie_okna = getScrollXY();
	var bodyheight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);
	pokaz_chmurke.style.left = Math.round((wymiar_okna[0]-pokaz_chmurke.offsetWidth)/2) + "px";
	if((przesuniecie_okna[1] + wymiar_okna[1] - pokaz_chmurke.offsetHeight) <= 0) {
		pokaz_chmurke.style.top="0px";
	} else if((wymiar_okna[1] - pokaz_chmurke.offsetHeight) <= 0) {
		pokaz_chmurke.style.top=Math.round((bodyheight - pokaz_chmurke.offsetHeight) / 2)+"px";
	} else {
		pokaz_chmurke.style.top=Math.round(przesuniecie_okna[1] + ((wymiar_okna[1]-pokaz_chmurke.offsetHeight)/2))+"px";
	}
}

function odpal_chmurke2(idh) {
	var pokaz_chmurke = document.getElementById(idh);
	pokaz_chmurke.style.display='block';
	var wymiar_okna = alertSize();
	var przesuniecie_okna = getScrollXY();
	var bodyheight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);
	pokaz_chmurke.style.left = Math.round((wymiar_okna[0]-pokaz_chmurke.offsetWidth)/2) + "px";
}

function zamknij_chmurke(idh2) {
	var chmurka = document.getElementById(idh2);
	chmurka.style.display='none';
}

function kalkulator_cennik() {
	var liczba_uczniow = document.getElementById('liczba_uczniow');
	var rabat_szkoly = document.getElementById('rabat_szkoly').value;
	
	var koszt_uczen;
	if(liczba_uczniow.value <= 200) {
		koszt_uczen = 17;
	} else if(liczba_uczniow.value >= 201 && liczba_uczniow.value <= 500) {
		koszt_uczen = 15.3;
	} else if(liczba_uczniow.value >= 501 && liczba_uczniow.value <= 800) {
		koszt_uczen = 13.6;
	} else if(liczba_uczniow.value >= 801) {
		koszt_uczen = 11.9;
	}
	
	var cena = liczba_uczniow.value * koszt_uczen;
	var cena_calkowita = cena - (cena * rabat_szkoly);
	
	var cena_5 = cena_calkowita - (cena_calkowita*0.05);
	var cena_10 = cena_calkowita - (cena_calkowita*0.10);
	var cena_15 = cena_calkowita - (cena_calkowita*0.15);
	
	document.getElementById('cena_dziennika').innerHTML = Math.round(cena_calkowita) + ' zł';
	document.getElementById('cena_dziennika2').innerHTML = Math.round(cena_calkowita) + ' zł';
	document.getElementById('cena_dziennika_5').innerHTML = Math.round(cena_5) + ' zł';
	document.getElementById('cena_dziennika_10').innerHTML = Math.round(cena_10) + ' zł';
	document.getElementById('cena_dziennika_15').innerHTML = Math.round(cena_15) + ' zł';
	
	var wyliczenia = document.getElementById('wyliczenia');
	wyliczenia.style.display='block';
}
