// funkcje
function podmien(obrazek,nowy_obrazek){
	if (!document.getElementById) return;
	
	imageRef = document.getElementById(obrazek);
	eval ("document.images[imageRef.id].src =" + nowy_obrazek + ".src");
}

// newsletter
function sprawdz_newsletter(){
	if (document.newsletter.akcja.value == ""){
		alert('Kliknij "zapisz się" albo "wypisz się".');
		return false;
	}
}

function newsletter_akcja(co_robi){
	if (sprawdz_email()){
		document.newsletter.akcja.value = co_robi; 
		document.newsletter.submit();
	}	
}

function sprawdz_email(){
	f = document.newsletter;

   if (!validateNotNull(f.e_mail, 'E-mail')) return false;
   if (!validateMatch(f.e_mail, email_exp, 'E-mail','j.kowalski@abc.pl')) return false;
   
   return true;
			
}

// formularz zamówienia wydawnictwa
function oblicz(){
	f = document.zamowienie;

	ilosc = f.ilosc_egzemplarzy.value;	
	cena = f.cena_egzemplarza.value;

	if (ilosc == '' || isNaN(ilosc)){
		f.ilosc_egzemplarzy_powtorzona.value = '';
		f.kwota.value = '';
		f.kwota_powtorzona.value = '';
	}
	else {
		f.ilosc_egzemplarzy_powtorzona.value = ilosc;
		f.kwota.value = ilosc * cena;
		f.kwota_powtorzona.value = ilosc * cena;
	}
}

// wyskakujące okienko
function okno (plik, szerokosc, wysokosc) {
	eval("window.open (plik, 'okienko', 'toolbar=1, status=1, directories=0, location=0, menubar=1, resizable=1, left=20, top=20, scrollbars=yes, width=" + szerokosc + ", height=" + wysokosc + "')");
}


// kalendarze : START

var months = ["", "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Pa&#317;dziernik", "Listopad", "Grudzień"];
var daysamonth = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var dayofweek = ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota"];
var conf = Array();
var j = 0;

function pa(year, month, day, hlink, subject) {
	var temArray = new Array();
	temArray = [year, month, day, hlink, subject];
	conf.push(temArray);
}

function drawCal(year, month) {
	zindex = (navigator.userAgent.toLowerCase().indexOf("msie") != -1)? "z-index: " + (99-(++j)) : "";
	document.writeln('<div class="cal" style="' + zindex + '"><div class="off">' + makeCal(year, month) + '</div></div>');
}

function retDate(year, month, day) {
	var temp = "";
	temp += year;
	if (month < 10)
		temp += ".0" + month;
	else
		temp += "." + month;
	if (day < 10)
		temp += ".0" + day;
	else
		temp += "." + day;
	return temp;
}

function makeCal(year, month) {
	daysamonth[2] = (((year % 100 != 0) && (year % 4 == 0)) || (year % 400 == 0))? 29 : 28;
	var today = ((today = (new Date(year, month - 1, 1)).getDay()) == 0)? 7 : today;
	var numberofPanes = daysamonth[month] + today - 1;
	var actDayofWeek = 0;
	var actDay = 0;
	var actDayStr;
	var stringToShow = "";

//	stringToShow += months[month] + " " + year + "<br><br>";
	stringToShow += "<table border='0' cellpadding='2' cellspacing='0' class='textCal' style='border: solid 1px #efebef;'><tr bgcolor='#ffebd6'><td align='center' width='14'>Pn</td><td align='center' width='14'>Wt</td><td align='center' width='14'>Śr</td><td align='center' width='14'>Cz</td><td align='center' width='14'>Pt</td><td align='center' width='14'>Sb</td><td align='center' class='' width='14'>Nd</td></tr>";
	for(i = 1; i <= numberofPanes; i++) {
		actDayofWeek = (new Date(year, month - 1, i - today + 1)).getDay();
		actDay = i - today + 1;
		actDayStr = actDay;
		actDayStrConf = "";
		if(actDay >= 1) {
			for(k = 0; k < conf.length; k++) {
				if(conf[k][0] == year && conf[k][1] == month && conf[k][2] == actDay) {
//					actDayStrConf += "-&gt; <a href='" + conf[k][3] + "' onMouseOver='show(\"" + year + month + actDay + "\"); //document.getElementById(\"" + year + month + actDay + "\").style.display = \"block\";' class='niebieski'><b>" + conf[k][4] + "</b></a><br>\n";
					actDayStrConf += "<li><a href='" + conf[k][3] + "' onMouseOver='show(\"" + year + month + actDay + "\"); //document.getElementById(\"" + year + month + actDay + "\").style.display = \"block\";' class='textLinksCal niebieski'>" + conf[k][4] + "</a></li>\n";
					actDayStr = actDay;
					actDayStr = "<a href='javascript://' onClick='show(\"" + year + month + actDay + "\"); fade(0, 100, \"" + year + month + actDay + "\"); //show(\"" + year + month + actDay + "\");' class='orangeCal'>" + actDayStr + "</a>\n";
					actDayStr += "<div class='titleOver' style='' id='" + year + month + actDay + "' onMouseOver='show(\"" + year + month + actDay + "\");' onMouseOut='hide(\"" + year + month + actDay + "\");'>\n";
					actDayStr += "	<div class='title' style='' style=''>\n";
					actDayStr += "	<div style='position: absolute; left: -1px; top: -8px;'><img src='grafika/kalendarze/ng.gif' width='450' height='8' style=''></div>\n";
					actDayStr += "		<div>Data: <b>" + retDate(year, month, actDay) + "</b>, " + dayofweek[actDayofWeek] + "</div><div style='height: 7px;'></div>\n";
					actDayStr += "		<div style=''>\n";
					actDayStr += "<ul class='calList'>" + actDayStrConf + "</ul>";
					actDayStr += "		</div>\n";
					actDayStr += "	<div style='position: absolute; left: -1px; bottom: -8px;'><img src='grafika/kalendarze/nd.gif' width='450' height='8' style=''></div>\n";
					actDayStr += "	</div>\n";
					actDayStr += "</div>\n";
				}
			}
/*			if(actDayofWeek == 6)
				actDayStr = "<b>" + actDayStr + "</b>";
			else if(actDayofWeek == 0)
				actDayStr = "<span class='colorRed'><b>" + actDayStr + "</b></span>";*/
			stringToShow += "<td align='right'>" + actDayStr + "</td>";
		}
		else
			stringToShow += "<td></td>";
		stringToShow += (i % 7 == 0 && i % numberofPanes != 0)? "</tr><tr>" : "";
	}
	stringToShow += "</tr></table>";
	return stringToShow;
}

n4 = (document.layers)? true:false
op = (document.all && document.getElementById && navigator.userAgent.toLowerCase().indexOf("msie") == -1)? true:false
ie = (document.all && document.getElementById && navigator.userAgent.toLowerCase().indexOf("msie") != -1)? true:false
n6 = (!document.all && document.getElementById)? true:false

function objekt(id) {
   if (n6) var obj = document.getElementById(id).style;
   else if (n4) var obj = document.layers[id];
   else if (op) var obj = document.getElementById(id).style;
//   else if (ie) var obj = document.all[id].style;
   else if (ie) var obj = document.getElementById(id).style;
   return obj;
}
function show(id) {
	var obj = objekt(id);
   if (n6) obj.visibility = "visible";
   else if (n4) obj.visibility = "show";
   else if (op) obj.visibility = "visible";
   else if (ie) obj.visibility = "visible";
}
function hide(id) {
	var obj = objekt(id);
   if (n6) obj.visibility = "hidden";
   else if (n4) obj.visibility = "hide";
   else if (op) obj.visibility = "hidden";
   else if (ie) obj.visibility = "hidden";
}
function fade(pocz,kon,id){
	var obj = objekt(id);
   if (n6) obj.MozOpacity = pocz / 100;
   else if (n4) obj.visibility = "show";
   else if (op) obj.opacity = pocz / 100;
   else if (ie) obj.filter = "alpha(opacity = " + pocz + ")";
   pocz = pocz + 10;
   if (pocz <= kon) setTimeout("fade(" + pocz + "," + kon + ",'" + id + "')", 5);
}

// kalendarze : STOP

// mapy : START

var googlemap = null;
var geocoder = null;
function load(szerokosc, dlugosc, tekst) {
	if (GBrowserIsCompatible()) {
		var googlemap = new GMap2(document.getElementById("googlemap"));
		googlemap.setCenter(new GLatLng(szerokosc, dlugosc), 13);
	}
	googlemap.openInfoWindow(new GLatLng(szerokosc, dlugosc), '<div style="width: 200px; padding-right: 10px;">' + tekst + '<\/div>');
	googlemap.addControl(new GSmallMapControl());
	googlemap.addControl(new GMapTypeControl());
}

// mapy : STOP