// deflasherizer [Eolas Patent Remover]
/*window.onload = function()
{
	objects = document.getElementsByTagName("noscript");
	for (var i = objects.length - 1; i >= 0 ; i--)
	{
		var html = objects[i].innerHTML;
		html = html.substring(12, html.length-12);
		objects[i].outerHTML = html;
	}
}
*/
/* Zarządzanie wykonywaniem skryptow po doczytaniu strony */
var EditoStart = new Object();
EditoStart.functions = new Array();

EditoStart.Add = function(fnc)
{
	EditoStart.functions[EditoStart.functions.length] = fnc;
}

EditoStart.init = function()
{
	for(var i = 0; i < EditoStart.functions.length; i++)
	{
		EditoStart.functions[i]();
	}
}

window.onload = function()
{
	EditoStart.init();
}


/* Deflasherizer [Eolas Patent Remover] */
function deflasherizer()
{
	var objects = document.getElementsByTagName("noscript");
	for (var i = objects.length - 1; i >= 0 ; i--)
	{
		var html = objects[i].innerHTML;
		html = html.replace(/.*<\!\[endif\]-->|<\!--\[if\sIE\]>.*/gi, '');
		objects[i].outerHTML = html;
	}
}
EditoStart.Add(deflasherizer);


//FAQ
function display(id)
{	
	var paragraf = document.getElementById("p"+id);
	
	if(paragraf.style.display == "none")
		paragraf.style.display = "";
	else
		paragraf.style.display = "none";
}
function replaceStyle (symbol) 
{
	document.getElementById(symbol).className = 'Tabstrip_hover';		
}

function replaceStyle_ (symbol) 
{
	document.getElementById(symbol).className = 'Tabstrip';		
}


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(baseHref + "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(baseHref + "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; 
		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" : "");
}
