/* 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]();
	}
}

$(document).ready(function()
{
	EditoStart.init();
});


$(document).ready(function()
{
	// Przegladarka zdjec
	$('a[@rel*=lightbox]').lightBox();
	$('a[@class*=lightbox]').lightBox();
	
	//zabezpieczenie przed 2-krotnym wysylaniem formularzy
	$('form').bind('submit', function(){
		$('input[type=submit]', this).attr('disabled', 'disabled');
	})
});



function insertActiveX(html)
{
	document.write(html);
}





/* Deflasherizer [Eolas Patent Remover] */
function deflasherizer()
{
	var objects = document.getElementsByTagName("noscript");
	for (var i = objects.length - 1; i >= 0 ; i--)
	{
		var html = objects[i].outerHTML;
		alert(html);
		html = html.replace(/.*<\!\[endif\]-->|<\!--\[if\sIE\]>.*/gi, '');
		objects[i].outerHTML = html;
	}
}
//EditoStart.Add(deflasherizer);


/* Galeria zdjec */
var EditoImg = new Object();
EditoImg.Keyword = new String("editoimg");
EditoImg.BorderSize = 1;
EditoImg.Index = 0;
EditoImg.Images = new Array();

EditoImg.init = function()
{
	var anchors = document.getElementsByTagName('a');
	
	for(var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		var rel = anchor.getAttribute('rel');
		
		if(anchor.getAttribute('href') && rel && rel.toLowerCase().match(EditoImg.Keyword))
		{
			anchor.onclick = EditoImg.Click;
		}
	}
	
	var html = '';
	html += '<div id="EditoImg$Overlay" class="PopupOverlay" style="display:none;"></div>';
	html += '<iframe src="/szablony/blank.html" id="EditoImg$Background" style="display:none;"></iframe>';
	html += '<table cellspacing="0" cellpadding="0" border="0" id="EditoImg$Panel" class="Popup" style="display:none;">';
	html += '	<tr>';
	html += '		<td id="EditoImg$Container" class="ImageContainer">';
	html += '			<img id="EditoImg$Preview" class="Preview"/>';
	html += '			<div id="EditoImg$Loader" class="Loader"></div>';
	html += '		</td>';
	html += '	</tr>';
	html += '	<tr id="EditoImg$Bottom"><td>';
	html += '		<table width="100%" cellspacing="0" cellpadding="0" border="0">';
	html += '			<tr>';
	html += '				<td id="EditoImg$Prev" class="Prev"><div></div></td>';
	html += '				<td id="EditoImg$Caption" class="Caption"></td>';
	html += '				<td id="EditoImg$Next" class="Next"><div></div></td>';
	html += '			</tr>';
	html += '		</table>';
	html += '	</td></tr>';
	html += '</table>';
	
	var body = document.getElementsByTagName("body")[0];
	var span = document.createElement("span");
	span.innerHTML = html;
	body.appendChild(span);
	
	EditoImg.Item("Prev").onclick = EditoImg.PrevImage;
	EditoImg.Item("Next").onclick = EditoImg.NextImage;
}

EditoImg.Item = function(id)
{
	return document.getElementById("EditoImg$" + id);
}

EditoImg.Screen = function()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		return [window.innerWidth, window.innerHeight];
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return [document.documentElement.clientWidth, document.documentElement.clientHeight];
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return [document.body.clientWidth, document.body.clientHeight];
	}
}

EditoImg.Scroll = function()
{
	if( typeof( window.pageYOffset ) == 'number' )
	{
		//Netscape compliant
		return [window.pageXOffset, window.pageYOffset];
	}
	else if( document.documentElement && ( typeof(document.documentElement.scrollLeft) != 'undefined' || typeof(document.documentElement.scrollTop) != 'undefined' ) )
	{
		//IE6 standards compliant mode
		return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
	}
	else if( document.body && ( typeof(document.body.scrollLeft) != 'undefined' || typeof(document.body.scrollTop) != 'undefined' ) )
	{
		//DOM compliant
		return [document.body.scrollLeft, document.body.scrollTop];
	}
}

EditoImg.Click = function()
{
	EditoImg.Images = new Array();
	EditoImg.Index = 0;
	EditoImg.Navigators(false);
	
	if(this.getAttribute('rel') != EditoImg.Keyword)
	{
		var counter = 0;
		var anchors = document.getElementsByTagName('a');
		
		for(var i=0; i<anchors.length; i++)
		{
			var anchor = anchors[i];
			var rel = anchor.getAttribute('rel');
			
			if(anchor.getAttribute('href') && rel == this.getAttribute('rel'))
			{
				EditoImg.Images[EditoImg.Images.length] = anchor;
				
				if(this == anchor)
				{
					EditoImg.Index = counter;
				}
				
				counter++;
			}
		}
		
		EditoImg.Navigators(true);
	}
	
	EditoImg.Show(this, EditoImg.Images);
	
	return false;
}

EditoImg.Show = function(imgLink, images)
{
	EditoImg.Item("Preview").style.display = "none";
	EditoImg.Item("Bottom").style.display = "none";
	EditoImg.Item("Loader").style.display = "";
	
	EditoImg.Item("Container").style.width = "500px";
	EditoImg.Item("Container").style.height = "400px";
	EditoImg.Item("Panel").style.width = "500px";
	EditoImg.Item("Panel").style.height = "400px";
	EditoImg.Item("Panel").style.position = "absolute";
	EditoImg.Item("Panel").style.display = "";
	EditoImg.ChangePosition();
	
	var img = new Image();
	img.onload = EditoImg.ImageLoad;
	img.title = imgLink.title;
	img.src = imgLink.href;
}

EditoImg.NextImage = function()
{
	EditoImg.Item("Preview").style.display = "none";
	EditoImg.Item("Loader").style.display = "";
	
	EditoImg.Index++;
	
	var img = new Image();
	img.onload = EditoImg.ImageLoad;
	img.title = EditoImg.Images[EditoImg.Index].title;
	img.src = EditoImg.Images[EditoImg.Index].href;
}

EditoImg.PrevImage = function()
{
	EditoImg.Item("Preview").style.display = "none";
	EditoImg.Item("Loader").style.display = "";
	
	EditoImg.Index--;
	
	var img = new Image();
	img.onload = EditoImg.ImageLoad;
	img.title = EditoImg.Images[EditoImg.Index].title;
	img.src = EditoImg.Images[EditoImg.Index].href;
}

EditoImg.ChangePosition = function()
{
	var screen = EditoImg.Screen();
	var scroll = EditoImg.Scroll();
	
	var offsetWidth = parseInt(EditoImg.Item("Panel").style.width);
	var offsetHeight = parseInt(EditoImg.Item("Panel").style.height);
	
	var left = ((screen[0] - offsetWidth) / 2);
	var top = ((screen[1] - offsetHeight) / 2);
	
	EditoImg.Item("Panel").style.zIndex = "100";
	EditoImg.Item("Panel").style.left = ((left > 0) ? left : 0) + "px";
	EditoImg.Item("Panel").style.top = scroll[1] + ((top > 0) ? top : 0) + "px";
	
	var overlayHeight = document.body.offsetHeight;
	if(overlayHeight < screen[1])
	{
		overlayHeight = screen[1];
	}
	if(parseInt(EditoImg.Item("Panel").style.top) + offsetHeight > overlayHeight)
	{
		overlayHeight = parseInt(EditoImg.Item("Panel").style.top) + offsetHeight;
	}
	
	if(!((document.getElementById && !document.all) || window.opera))
	{
		EditoImg.Item("Background").style.position = "absolute";
		EditoImg.Item("Background").style.zIndex = "95";
		EditoImg.Item("Background").style.left = EditoImg.Item("Panel").style.left;
		EditoImg.Item("Background").style.top = EditoImg.Item("Panel").style.top;
		EditoImg.Item("Background").style.height = offsetHeight;
		EditoImg.Item("Background").style.width = offsetWidth;
		EditoImg.Item("Background").style.display = "";
	}
	
	EditoImg.Item("Overlay").style.position = "absolute";
	EditoImg.Item("Overlay").style.zIndex = "90";
	EditoImg.Item("Overlay").style.left = "0px";
	EditoImg.Item("Overlay").style.top = "0px";
	EditoImg.Item("Overlay").style.height = overlayHeight + "px";
	EditoImg.Item("Overlay").style.display = "";
}

EditoImg.Navigators = function(visibility)
{
	var display = visibility  ? "" : "none";
	
	EditoImg.Item("Prev").style.display = display;
	EditoImg.Item("Next").style.display = display;
	
	if(visibility && EditoImg.Index == 0)
	{
		EditoImg.Item("Prev").style.display = "none";
	}
	if(visibility && EditoImg.Index == (EditoImg.Images.length - 1))
	{
		EditoImg.Item("Next").style.display = "none";
	}
}

EditoImg.ImageLoad = function()
{
	EditoImg.Item("Background").style.display = "none";
	EditoImg.Item("Panel").style.width = "";
	EditoImg.Item("Panel").style.height = "";
	
	var sWidth = parseInt(EditoImg.Item("Container").style.width);
	var sHeight = parseInt(EditoImg.Item("Container").style.height);
	
	var pWidth = EditoImg.Item("Panel").offsetWidth - sWidth;
	var pHeight = EditoImg.Item("Panel").offsetHeight - sHeight;
	
	EditoImg.Item("Container").style.width = this.width + 2 * EditoImg.BorderSize + "px";
	EditoImg.Item("Container").style.height = this.height + 2 * EditoImg.BorderSize + "px";
	EditoImg.Item("Panel").style.width = this.width + 2 * EditoImg.BorderSize + pWidth + "px";
	EditoImg.Item("Panel").style.height = this.height + 2 * EditoImg.BorderSize + pHeight + "px";
	
	EditoImg.Item("Loader").style.display = "none";
	
	EditoImg.Item("Preview").onclick = EditoImg.Close;
	EditoImg.Item("Preview").src = this.src;
	EditoImg.Item("Preview").style.display = "";
	
	EditoImg.Item("Caption").innerHTML = this.title;
	
	if(EditoImg.Images.length == 0)
	{
		EditoImg.Navigators(false);
	}
	else
	{
		EditoImg.Navigators(true);
	}
	
	if(this.title.replace(/^\s*|\s*$/g, "") != "" || EditoImg.Images.length > 0)
	{
		EditoImg.Item("Bottom").style.display = "";
	}
	
	EditoImg.ChangePosition();
}

EditoImg.Close = function()
{
	EditoImg.Item("Preview").style.display = "none";
	EditoImg.Item("Panel").style.display = "none";
	EditoImg.Item("Overlay").style.display = "none";
	EditoImg.Item("Background").style.display = "none";
}

EditoStart.Add(EditoImg.init);


/* Pozostale skrypty */
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 = '/' + 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 == '' || 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, days, path, domain, secure) 
{
	var expires = null;
	
	if(days)
	{
		expires = new Date();
		var theDay = expires.getDate();
		theDay = theDay + days;
		expires.setDate(theDay);
	}
	
	var ciacho = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
	
    document.cookie = ciacho;
}

/* obiekt zakladek TabStrip */
function TabStrip(id, tabsCount)
{
	this.selected = id;
	this.tabsCount = tabsCount;
	
	this.renderTabs(this.selected);
}

TabStrip.prototype.renderTabs = function(selected)
{
	for(var i=0; i < this.tabsCount; i++)
	{
		if(i == selected)
			this.setActive(i);
		else
			this.setInactive(i);
	}
}

TabStrip.prototype.setActive = function(id)
{
	findObj('TabStrip_'+id).style.display = '';
	findObj('TabStripHeader_'+id).className = 'TabStripActive';
	setCookie('TabStrip_activeTab', id);
}

TabStrip.prototype.setInactive = function(id)
{
	findObj('TabStrip_'+id).style.display = 'none';
	findObj('TabStripHeader_'+id).className = 'TabStripInactive';
}

TabStrip.prototype.showTab = function(id)
{
	this.renderTabs(id);
}


/* System banerowy - Popupy */

var EditoPopup = new Object();
EditoPopup.BorderSize = 1;
EditoPopup.IcoCloseHeight = 26;
EditoPopup.PaddingWidth = 10;
EditoPopup.PaddingHeight = 10;

EditoPopup.Popup = function(popup_src,popup_link,popup_target,popup_width,popup_height,type,popup_id,popup_szablon,popup_padding)
{	
	if (type == 'popup_flash')
	{
		var html = '';
		html += '<div id="EditoPopup$Overlay'+popup_id+'" class="PopupOverlay" style="display:none;"></div>';
		html += '<iframe id="EditoPopup$Background'+popup_id+'" style="display:none;"></iframe>';
		html += '<table cellspacing="0" cellpadding="0" border="0" id="EditoPopup$Panel'+popup_id+'" class="Popup" style="display:none;">';
		html += '	<tr>';
		html += '		<td align="right">';
		html += '			<a href="javascript:void(0)" onclick="EditoPopupClose('+popup_id+')" id="EditoPopup$IcoClose'+popup_id+'" class="IcoClose"></a>';
		html += '		<td>';
		html += '	</tr>';
		html += '	<tr>';
		html += '		<td id="EditoPopup$Container'+popup_id+'" class="ImageContainer">';
		html += '			<div id="EditoPopup$Preview'+popup_id+'" class="Preview">';
		html += '				<object';
		html += '					classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		html += '					codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
		html += '					width="'+popup_width+'" height="'+popup_height+'">';
		html += '					<param name="movie" value="../../'+popup_src+'?alink1='+popup_link+'&amp;atar1='+popup_target+'" />';
		html += '					<param name="quality" value="high" />';
		html += '					<param name="flashvars" value="alink1='+popup_link+'&amp;atar1='+popup_target+'" />';
		html += '					<param name="wmode" value="transparent" />';
		html += '					<embed'; 
		html += '						src="../../'+popup_src+'?alink1='+popup_link+'&amp;atar1='+popup_target+'"';
		html += '						flashvars = "alink1='+popup_link+'&amp;atar1='+popup_target+'"';
		html += '						quality="high"'; 
		html += '						pluginspage="http://www.macromedia.com/go/getflashplayer"'; 
		html += '						type="application/x-shockwave-flash"'; 
		html += '						wmode="transparent"';
		html += '						width="'+popup_width+'"';
		html += '						height="'+popup_height+'">';
		html += '					</embed>';
		html += '				</object>';
		html += '			</div>';
		html += '			<div id="EditoPopup$Loader'+popup_id+'" class="Loader"></div>';
		html += '		</td>';
		html += '	</tr>';
		html += '</table>';
		
	}
	else if (type == 'popup_obrazek')
	{
		var html = '';
		html += '<div id="EditoPopup$Overlay'+popup_id+'" class="PopupOverlay" style="display:none;"></div>';
		html += '<iframe id="EditoPopup$Background'+popup_id+'" style="display:none;"></iframe>';
		html += '<table cellspacing="0" cellpadding="0" border="0" id="EditoPopup$Panel'+popup_id+'" class="Popup" style="display:none;">';
		html += '	<tr>';
		html += '		<td align="right">';
		html += '			<a href="javascript:void(0)" onclick="EditoPopupClose('+popup_id+')" id="EditoPopup$IcoClose'+popup_id+'" class="IcoClose"></a>';
		html += '		<td>';
		html += '	</tr>';
		html += '	<tr>';
		html += '		<td id="EditoPopup$Container'+popup_id+'" class="ImageContainer">';
		html += '			<a id="EditoPopup$ImgHref'+popup_id+'"><img id="EditoPopup$Preview'+popup_id+'" class="Preview"/></a>';
		html += '			<div id="EditoPopup$Loader'+popup_id+'" class="Loader"></div>';
		html += '		</td>';
		html += '	</tr>';
		html += '</table>';
	}
	
	var body = document.getElementsByTagName("body")[0];
	var span = document.createElement("span");
	span.innerHTML = html;
	body.appendChild(span);
	
	EditoPopup.Show(popup_src,popup_link,popup_target,popup_width,popup_height,type,popup_id,popup_szablon,popup_padding);
}

EditoPopup.Item = function(id)
{
	return document.getElementById("EditoPopup$" + id);
}

EditoPopup.Screen = function()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		return [window.innerWidth, window.innerHeight];
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return [document.documentElement.clientWidth, document.documentElement.clientHeight];
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return [document.body.clientWidth, document.body.clientHeight];
	}
}

EditoPopup.Show = function(popup_src,popup_link,popup_target,popup_width,popup_height,type,popup_id,popup_szablon,popup_padding)
{
	EditoPopup.Item("Preview"+popup_id).style.display = "none";
	EditoPopup.Item("IcoClose"+popup_id).style.display = "none";
	EditoPopup.Item("Loader"+popup_id).style.display = "";
	EditoPopup.Item("Container"+popup_id).style.width = "500px";
	EditoPopup.Item("Container"+popup_id).style.height = "400px";
	EditoPopup.Item("Panel"+popup_id).style.width = "500px";
	EditoPopup.Item("Panel"+popup_id).style.height = "400px";
	EditoPopup.Item("Panel"+popup_id).style.position = "absolute";
	EditoPopup.Item("Panel"+popup_id).style.display = "";
	
	EditoPopup.ChangePosition(popup_id,popup_szablon,popup_padding);
	
	var img = new Image();
	EditoPopup.ImageLoad(popup_src,popup_link,popup_target,popup_width,popup_height,type,popup_id,popup_szablon,popup_padding);
}

EditoPopup.ChangePosition = function(popup_id,popup_szablon,popup_padding)
{
	var screen = EditoPopup.Screen();
	
	var offsetWidth = parseInt(EditoPopup.Item("Panel"+popup_id).style.width) + EditoPopup.PaddingWidth + 4*EditoPopup.BorderSize;
	var offsetHeight = parseInt(EditoPopup.Item("Panel"+popup_id).style.height) + EditoPopup.PaddingHeight + EditoPopup.IcoCloseHeight + 4*EditoPopup.BorderSize;
	
	if (popup_szablon == 1)
	{
		var left = popup_padding;
		var top = popup_padding;
	}
	else if (popup_szablon == 2)
	{
		var left = ((screen[0] - offsetWidth) / 2);
		var top = popup_padding;
	}
	else if (popup_szablon == 3)
	{
		var left = screen[0] - offsetWidth - popup_padding;
		var top = popup_padding;
	}
	else if (popup_szablon == 4)
	{
		var left = popup_padding;
		var top = ((screen[1] - offsetHeight) / 2);
	}
	else if (popup_szablon == 5)
	{
		var left = ((screen[0] - offsetWidth) / 2);
		var top = ((screen[1] - offsetHeight) / 2);
	}
	else if (popup_szablon == 6)
	{
		var left = screen[0] - offsetWidth - popup_padding;
		var top = ((screen[1] - offsetHeight) / 2);
	}
	else if (popup_szablon == 7)
	{
		var left = popup_padding;
		var top = screen[1] - offsetHeight - popup_padding;
	}
	else if (popup_szablon == 8)
	{
		var left = ((screen[0] - offsetWidth) / 2);
		var top = screen[1] - offsetHeight - popup_padding;
	}
	else if (popup_szablon == 9)
	{
		var left = screen[0] - offsetWidth - popup_padding;
		var top = screen[1] - offsetHeight - popup_padding;
	}
	else
	{
		var left = ((screen[0] - offsetWidth) / 2);
		var top = ((screen[1] - offsetHeight) / 2);
	}
	
	EditoPopup.Item("Panel"+popup_id).style.zIndex = "100";
	EditoPopup.Item("Panel"+popup_id).style.left = ((left > 0) ? left : 0) + "px";
	EditoPopup.Item("Panel"+popup_id).style.top = ((top > 0) ? top : 0) + "px";
	
	var overlayHeight = document.body.offsetHeight;
	if(overlayHeight < screen[1])
	{
		overlayHeight = screen[1];
	}
	if(parseInt(EditoPopup.Item("Panel"+popup_id).style.top) + offsetHeight > overlayHeight)
	{
		overlayHeight = parseInt(EditoPopup.Item("Panel"+popup_id).style.top) + offsetHeight;
	}
	
	if(!((document.getElementById && !document.all) || window.opera))
	{
		EditoPopup.Item("Background"+popup_id).style.position = "absolute";
		EditoPopup.Item("Background"+popup_id).style.zIndex = "95";
		EditoPopup.Item("Background"+popup_id).style.left = EditoPopup.Item("Panel"+popup_id).style.left;
		EditoPopup.Item("Background"+popup_id).style.top = EditoPopup.Item("Panel"+popup_id).style.top;
		EditoPopup.Item("Background"+popup_id).style.height = offsetHeight;
		EditoPopup.Item("Background"+popup_id).style.width = offsetWidth;
		EditoPopup.Item("Background"+popup_id).style.display = "";
	}
	
	EditoPopup.Item("Overlay"+popup_id).style.position = "absolute";
	EditoPopup.Item("Overlay"+popup_id).style.zIndex = "90";
	EditoPopup.Item("Overlay"+popup_id).style.left = "0px";
	EditoPopup.Item("Overlay"+popup_id).style.top = "0px";
	EditoPopup.Item("Overlay"+popup_id).style.height = overlayHeight + EditoPopup.PaddingHeight + EditoPopup.IcoCloseHeight + 4*EditoPopup.BorderSize + "px";
	EditoPopup.Item("Overlay"+popup_id).style.display = "";
}

EditoPopup.ImageLoad = function(popup_src,popup_link,popup_target,popup_width,popup_height,type,popup_id,popup_szablon,popup_padding)
{
	EditoPopup.Item("Background"+popup_id).style.display = "none";
	EditoPopup.Item("Panel"+popup_id).style.width = "";
	EditoPopup.Item("Panel"+popup_id).style.height = "";
		
	EditoPopup.Item("Container"+popup_id).style.width = parseInt(popup_width) + "px";
	EditoPopup.Item("Container"+popup_id).style.height = parseInt(popup_height) + "px";
	EditoPopup.Item("Panel"+popup_id).style.width = parseInt(popup_width) + "px";
	EditoPopup.Item("Panel"+popup_id).style.height = parseInt(popup_height) + "px";
	
	EditoPopup.Item("Loader"+popup_id).style.display = "none";
	
	EditoPopup.Item("Preview"+popup_id).style.display = "";
	EditoPopup.Item("IcoClose"+popup_id).style.display = "";
	
	if (type == 'popup_obrazek')
	{
		EditoPopup.Item("Preview"+popup_id).src = popup_src;
		EditoPopup.Item("ImgHref"+popup_id).href = popup_link;
		EditoPopup.Item("ImgHref"+popup_id).target = popup_target;
	}
	
	EditoPopup.ChangePosition(popup_id,popup_szablon,popup_padding);
	
}

function EditoPopupClose(popup_id)
{
	EditoPopup.Item("Preview"+popup_id).style.display = "none";
	EditoPopup.Item("IcoClose"+popup_id).style.display = "none";
	EditoPopup.Item("Panel"+popup_id).style.display = "none";
	EditoPopup.Item("Overlay"+popup_id).style.display = "none";
	EditoPopup.Item("Background"+popup_id).style.display = "none";
}

/* System banerowy - Popupy - koniec */

/* sklep porownywarka */
function makeCompare(typ_oferty, id_uniq)
{
	var form = document.getElementById('porownaj_' + id_uniq);
	var typhidden = document.getElementById('typ_oferty_' + id_uniq);
	
	typhidden.value = typ_oferty;
	form.submit();
}

function delCompare(id_uniq, suma, komunikat)
{
	var form = document.getElementById('porownaj_' + id_uniq);
	var akcjausun = document.getElementById('por_akcja_usun_' + id_uniq);	
	var hiddenakcja = document.getElementById('usun_hidden_' + id_uniq);	
	var zaznaczone = false;
	
	for(i=0; i < suma; i++)
	{
		if(document.getElementById('prd' + id_uniq + '_' + i).checked == true)
			zaznaczone = true;
	}
	if(zaznaczone)
	{
		form.action = akcjausun.value;
		hiddenakcja.value = 'usun';
		form.submit();
	}
	else
	{
		alert(komunikat);
	}
}
/* sklep porownywarka - koniec */

/* sklep wyszukiwarka */
function ShowHideOpction(grupa)
{
	var region = document.getElementById(grupa);
	var ico = document.getElementById('i'+grupa);
	
	var tab = region.getElementsByTagName("input");
	
	if(region.style.display == 'none')
	{
		region.style.display = '';
		ico.src = 'images/ikon/up.gif';
	}
	else
	{
		region.style.display = 'none';
		ico.src = 'images/ikon/down.gif';
		
		//zeruj pola
		for(i=0; i < tab.length; i++)
		{
			if(tab[i].getAttribute('type') == 'checkbox')
			{
				tab[i].checked = false;
			}
		}	
	}		
}

function MarkOpctions(grupa)
{
	var region = document.getElementById(grupa);
	var tab = region.getElementsByTagName("input");
	
	//zaznacz pola
	for(i=0; i < tab.length; i++)
	{
		if(tab[i].getAttribute('type') == 'checkbox')
		{
			tab[i].checked = true;
		}
	}
}

function ClearOpctions(grupa)
{
	var region = document.getElementById(grupa);
	var tab = region.getElementsByTagName("input");
	
	//zeruj pola
	for(i=0; i < tab.length; i++)
	{
		if(tab[i].getAttribute('type') == 'checkbox')
		{
			tab[i].checked = false;
		}
	}
}
/* sklep wyszukiwarka - koniec */

/* FAQ */

var obrazki = new Array();
	
	function showResult1(id,img1, img2) {
		obrazki[0] = img1;
		obrazki[1] = img2;
		o = document.getElementById(id);
		t = document.getElementById("a"+id);	
		if ( o.style.display == 'none') {
			o.style.display = 'block';	
			t.style.backgroundImage = obrazki[1];
			t.style.backgroundRepeat = 'no-repeat';	
		} else {
			o.style.display = 'none';
			t.style.backgroundImage = obrazki[0];
			t.style.backgroundRepeat = 'no-repeat';	
		}
	}

