window.onload = function()
{
 objects = document.getElementsByTagName("object");
 
 for (var i = 0; i < objects.length; i++)
 {
  objects[i].outerHTML = objects[i].outerHTML;
 }
}


var ie = !((document.getElementById && !document.all) || window.opera)
var moz = (document.getElementById && !ie);

var imageDivStatus = false;

function imageDiv(src, w, h ,t) {
	
	obrazek = document.getElementById("obrazek_wystawy");
	
	/*obrazek.src = 'images/spacer.gif';
	obrazek.width=w;
	obrazek.height=h;
	obrazek.alt='';
	obrazek.src=src;*/
	//document.getElementById("wystawyDivek").style.display ='';
		
	divek = document.getElementById("wystawyDivek");
	divek.style.display ='';

	foto = "<img src="+src+" height="+h+" width="+w+" onclick=javascript:closePopup();>";

	opisFoto = findObj("msgFoto");
	opisFoto.innerHTML = foto;
	opisFoto.style.display = "";
	
	//if(!imageDivStatus)
	//{
		if(ie)
		{	
			divek.style.top = document.documentElement.scrollTop + ((document.documentElement.clientHeight - divek.offsetHeight) / 2) + "px";
		}
		else
		{
			//divek.style.top = window.pageYOffset + ((window.innerHeight - divek.offsetHeight) / 2) + "px";
			
			divek.style.top = window.pageYOffset + 85 + "px";
			
		}
		
		divek.style.left = 	(document.body.clientWidth - divek.offsetWidth) / 2 + "px";
		
	//	imageDivStatus = true;
	//}
	
	tekst =t; 
	
	out = "|"; // replace this
	add = "<br/>"; // with this
	temp = "" + tekst; // temporary holder
	
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	
	}
	opisInfo = findObj("msgInfo");

	if (temp!='undefined') {
		opisInfo.innerHTML = temp;
		opisInfo.style.display = "";
	} else {
		opisInfo.innerHTML = "";
		opisInfo.style.display = "none";
	}

}

function closePopup() {
	
	divek = document.getElementById("wystawyDivek");
	divek.style.display ='none';
	
}

//FAQ-u
function display(id)
{	
	var paragraf = document.getElementById("p"+id);
	var tdd = document.getElementById("td_"+id);
	
	flag=0;
	if (tdd.className == "x") 
	{
		flag=1;
		tdd.className="y";
	}
	if (tdd.className == "y" && flag == 0) 
		tdd.className="x";
	
	
	if(paragraf.style.display != "none")
		paragraf.style.display = "none";
	else
		paragraf.style.display = "";
}

function replaceStyleFaq (symbol) 
{
	document.getElementById(symbol).className = 'tabelka_faq_hover';		
}

function replaceStyleFaq_ (symbol) 
{
	document.getElementById(symbol).className = 'tabelka_faq';		
}
//---//
function replaceStyle (symbol) 
{
	document.getElementById(symbol).className = 'tabelka_item_1_hover';		
}

function replaceStyle_ (symbol) 
{
	document.getElementById(symbol).className = 'tabelka_item_1';		
}

function replaceStyleLevel3 (symbol) 
{
	document.getElementById(symbol).className = 'tabelka_item_3_hover';		
}

function replaceStyleLevel3_ (symbol) 
{
	document.getElementById(symbol).className = 'tabelka_item_3';		
}


function findObj(obj) {
	return document.getElementById(obj);
}

function preloadimages(images) {
	if (!images) {
		var images = new Array();
	}
	var img = new Array();
	for (i=0; i<images.length; i++) {
		img[i] = new Image();
		img[i].src = images[i];
	}
}

function swapImage(id, img) {
	o = findObj(id);
	if(o) {
		o.src = img;
	}
}

function SendTo(before, after, user, host, label) {
	label = label.replace(' // ', '@');
	document.write('<a' + before + 'href="mailto:' + user + '@' + host + '"' + after+'>' + label + '</a>');
}

// zdjêcie bez opisu
function showImage(src, w, h) {
	noweOkienko = null;
	if (window.screen) {
		aw = screen.availWidth;
		ah = screen.availHeight;
	} else {
		aw = 640;
		ah = 450;
	}
	if (noweOkienko==null || noweOkienko.closed) {
		ustawienia=
		"left=" + (aw-w)/2 + ","
		+"top=" + (ah-h)/2 + ","
		+"screenX=" + (aw-w)/2 + ","
		+"screenY=" + (ah-h)/2 + ","
		+"width=" + w + ","
		+"height=" + h + ","
		+"innerWidth=" + w + ","
		+"innerHeight=" + h + ","
		+"toolbar=no,"
		+"location=no,"
		+"directories=no,"
		+"status=yes,"
		+"menubar=no,"
		+"scrollbars=no,"
		+"resizable=no"
		noweOkienko = window.open("/showImage.php?src="+src, 'obrazek', ustawienia);
	}
	try {
		noweOkienko.focus();
	}
	catch (e) {
	}
}

// zdjêcie z opisem
function showOImage(src, w, h, opis) {
	noweOkienko = null;
	if (window.screen) {
		aw = screen.availWidth;
		ah = screen.availHeight;
	} else {
		aw = 640;
		ah = 450;
	}
	if (noweOkienko==null || noweOkienko.closed) {
		w = w + 32;
		oldH = h;
		h = h + 45;
		ustawienia=
		"left=" + (aw-w)/2 + ","
		+"top=" + (ah-h)/2 + ","
		+"screenX=" + (aw-w)/2 + ","
		+"screenY=" + (ah-h)/2 + ","
		+"width=" + w + ","
		+"height=" + h + ","
		+"innerWidth=" + w + ","
		+"innerHeight=" + h + ","
		+"toolbar=no,"
		+"location=no,"
		+"directories=no,"
		+"status=yes,"
		+"menubar=no,"
		+"scrollbars=yes,"
		+"resizable=no"
		noweOkienko = window.open("/showImage.php?src="+src+":"+opis, 'obrazek', ustawienia);
	}
	try {
		noweOkienko.focus();
	}
	catch (e) {
	}
}

// popup
function popUpWindow(src, w, h) {
	noweOkienko = null;
	if (window.screen) {
		aw = screen.availWidth;
		ah = screen.availHeight;
	} else {
		aw = 640;
		ah = 450;
	}
	if (noweOkienko==null || noweOkienko.closed) {
		ustawienia=
		"left=" + (aw-w)/2 + ","
		+"top=" + (ah-h)/2 + ","
		+"screenX=" + (aw-w)/2 + ","
		+"screenY=" + (ah-h)/2 + ","
		+"width=" + w + ","
		+"height=" + h + ","
		+"innerWidth=" + w + ","
		+"innerHeight=" + h + ","
		+"toolbar=no,"
		+"location=no,"
		+"directories=no,"
		+"status=yes,"
		+"menubar=no,"
		+"scrollbars=yes,"
		+"resizable=no"
	//	var url = baseHref + src; 
		var url = '/' + src; 
		noweOkienko = window.open(url, 'plik', ustawienia);
		
	}
	try {
		noweOkienko.focus();
	}
	catch (e) {
	}
}

// drukuj
function printWindow(src) {
	popUpWindow(src, 640, 450);
}

// base64 decode script
function decode64(input) {
	var output = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;
	var keyStr = 	"ABCDEFGHIJKLMNOP" +
					"QRSTUVWXYZabcdef" +
					"ghijklmnopqrstuv" +
					"wxyz0123456789+/" +
					"=";

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	var base64test = /[^A-Za-z0-9\+\/\=]/g;
	if (base64test.exec(input)) {
		alert("There were invalid base64 characters in the input text.\n" +
					"Valid base64 characters are A-Z, a-z, 0-9, '+', '/', and '='\n" +
					"Expect errors in decoding.");
	}
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output = output + String.fromCharCode(chr1);

		if (enc3 != 64) {
			output = output + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			output = output + String.fromCharCode(chr3);
		}

		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";

	} while (i < input.length);

	return output;
}

// rozwijanie listy wynikow w wyszukiwarce
function showResult(id) {
	o = document.getElementById(id);
	if (o.style.display == 'none') {
		o.style.display = 'block';
	} else {
		o.style.display = 'none';
	}
}

function limiter(obj, limit) {
	if (obj.value.length > limit) {
		obj.value = obj.value.substring(0,limit);
	}
}

// obliczanie pozostalych znakow w textarea
function limit(obj, limit, msg) {
	if (obj.value.length > limit) {
		obj.value = obj.value.substring(0,limit);
		alert(msg);
	}
}

function getCookie(name)
{
	var dc = document.cookie;
	var cname = name + "=";
	var clen = dc.length;
	var cbegin = 0;
	
	while (cbegin < clen)
	{ 
		var vbegin = cbegin + cname.length;
	
		if (dc.substring(cbegin, vbegin) == cname)
		{ 
			var vend = dc.indexOf (";", vbegin);
			if (vend == -1) vend = clen;
	
			return unescape(dc.substring(vbegin, vend));
		}
	
		cbegin = dc.indexOf(" ", cbegin) + 1;
	
		if (cbegin== 0) break;
	}
	return null;
}

function setCookie(name, value, expires, path, domain, secure)
{
	path = '/';
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
