/* 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();
});


/* Przegladarka zdjec */
$(document).ready(function()
{
	$('a[@rel*=lightbox]').lightBox();
	$('a[@class*=lightbox]').lightBox();
});



function insertActiveX(html)
{
	document.write(html);
}

/* 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, '', ustawienia);
		//alert(noweOkienko);		
	}
	try {
		noweOkienko.focus();
	}
	catch (e) {
	}
}

// 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);
	}
}
// obliczanie pozostalych znakow w textarea i informuje ile zostało jeszcze znaków do wykorzystania
function limit2(obj, obj2, limit, msg) {
	findObj(obj2).innerHTML = limit-obj.value.length;
	if (obj.value.length > limit) {
		obj.value = obj.value.substring(0,limit);
		findObj(obj2).innerHTML = 0;
		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);
}

var EditoCalendar = new Object();

/* wywolanie kalendarza */
EditoCalendar.showCalendar = function(obj, field, btn)
{
    Calendar.setup({
        inputField		:	field,
        ifFormat		:	"%Y-%m-%d",
        button			:	btn,
        singleClick		:	true,
		align			:	"Lt"
    });
	obj.onclick();
	
	return false;
}

/* wydarzenia */
function clickDay(o, blok)
{
	var dzien = o.id;
	dzien = dzien.substring(1, 11);	
	document.getElementById('dzionek'+blok).value = dzien;	
	$('#wybranydzien'+blok).submit();
}

/* bannery */
var EditoBannery = new Object();
EditoBannery._kontener = '';
EditoBannery._bannerList = '';
EditoBannery.show = function(bannerList, kontener, mode, idBloku)
{
	this._kontener = kontener;
	this._bannerList = bannerList;
	
	if(mode == 'all')
	{
		for(bannerIndex in bannerList)
		{
			var cBanner = bannerList[bannerIndex];
			EditoBannery.showElement(kontener, cBanner);
		}
	}
	else if(mode == 'single_view_popup' && getCookie(kontener) == 1)
	{
		return;
	}
	else if(mode == 'all_in_one_random')
	{
		this._zmienna = 0;
		for(bannerIndex in bannerList)
		{
			var cBanner = bannerList[bannerIndex];
			EditoBannery.showElement(kontener, cBanner);
		}
		
		//var int=setInterval(EditoBannery.showElementBanerek(),2000);
		this._zmienna = 0;
		this.showElementBanerek();
		//this._t = setInterval("EditoBannery.showElementBanerek()",5000);
	}
	else if(bannerList.length > 0)
	{
		// wylosuj banner z listy
		var randomIndex = Math.floor(Math.random() * bannerList.length);
		var cBanner = bannerList[randomIndex];
		
		// ustawianie ciacha jezeli popup ma sie pokazac tylko 1 raz
		if(mode == 'single_view_popup')
			setCookie(kontener, 1);
		
		EditoBannery.showElement(kontener, cBanner);
	}
}

EditoBannery.showElement = function(kontener, cBanner)
{
	switch( cBanner.params.type )
	{
		case 'flash':
		
			var box = Math.random();
			$("#"+kontener).append('<div class="reklama" id="' + kontener + box + '"></div>');
			
			var so = new SWFObject(cBanner.file, "", cBanner.width, cBanner.height, "8");
			so.useExpressInstall('images/flash/expressinstall.swf');
			so.addParam("wmode", "transparent");
			so.addParam("quality", "high");
			so.addParam("menu", "false");
			so.write(kontener + box);
		break;
		
		case 'flash_link':
		
			var box = Math.random();
			$("#"+kontener).append('<div class="reklama" id="' + kontener + box + '"></div>');
			
			var so = new SWFObject(cBanner.file + "?alink1=" + cBanner.params.link + "&amp;atar1=" + cBanner.params.target, "", cBanner.width, cBanner.height, "8");
			so.useExpressInstall('images/flash/expressinstall.swf');
			so.addParam("wmode", "transparent");
			so.addParam("quality", "high");
			so.addParam("menu", "false");
			so.addParam("flashvars", "alink1=" + cBanner.params.link + "&amp;atar1=" + cBanner.params.target);
			so.write(kontener + box);
		break;
		
		case 'flash_popup':
			EditoStart.Add( function()
				{
					EditoPopup.Popup(cBanner.file, cBanner.params.link, cBanner.params.target, cBanner.width, cBanner.height, 'popup_flash', cBanner.params.popup_id, cBanner.params.popup_szablon, cBanner.params.popup_padding);
				}
			);
		break;
		
		case 'obrazek':
			$("#"+kontener).append('<div class="reklama"><img src="' + cBanner.file + '" width="' + cBanner.width + '" height="' + cBanner.height + '" border="0" alt="" /></div>');
		break;
		
		case 'obrazek_link':
			$("#"+kontener).append('<div class="reklama"><a href="' + cBanner.params.link + '" target="' + cBanner.params.target + '"><img src="' + cBanner.file + '" width="' + cBanner.width + '" height="' + cBanner.height + '" border="0" alt="" /></a></div>');
		break;
		
		case 'obrazek_popup':
			EditoStart.Add( function()
				{
					EditoPopup.Popup(cBanner.file, cBanner.params.link, cBanner.params.target, cBanner.width, cBanner.height, 'popup_obrazek', cBanner.params.popup_id, cBanner.params.popup_szablon, cBanner.params.popup_padding);
				}
			);
		break;
		
		case 'obrazekAllInOne':
			$("#"+kontener).append('<div class="reklama" id="reklama_'+this._zmienna+'" style="display:none;"><img src="' + cBanner.file + '" width="' + cBanner.width + '" height="' + cBanner.height + '" border="0" alt="" /></div>');
			this._zmienna++;
		break;
				
		case 'obrazekAllInOne_link':
			$("#"+kontener).append('<div class="reklama" id="reklama_'+this._zmienna+'" style="display:none;"><a href="' + cBanner.params.link + '" target="' + cBanner.params.target + '"><img src="' + cBanner.file + '" width="' + cBanner.width + '" height="' + cBanner.height + '" border="0" alt="" /></a></div>');
			this._zmienna++;
		break;
	}
}


EditoBannery.showElementBanerek = function()
{//alert(this._zmienna);
	//this._zmienna = this._zmienna + 1;
	var i = 0;
	
	
	function pokaz2()
	{
		$("#reklama_" + EditoBannery._zmienna).fadeIn(500);
	}
	//var baners = $("#" + this._kontener+" .reklama");
	//document.write(baners[0]);
	//alert("#reklama_" + this._zmienna);
	
	
	//$("#reklama_" + this._zmienna).css('display','block');
	
	
		if(this._zmienna == 0)
		{
			//$("#reklama_" + (EditoBannery._bannerList.length-1)).fadeOut(500, pokaz2);
			$("#reklama_" + (this._bannerList.length-1)).css('display','none');			
			$("#reklama_" + (this._zmienna)).css('display','block');
		}
		else
		{
			if(this._zmienna-1 < 0)
			{
				$("#reklama_" + (this._bannerList.length-1)).css('display','none');
				$("#reklama_" + (this._zmienna)).css('display','block');
				//$("#reklama_" + (EditoBannery._bannerList.length-1)).fadeOut(500, pokaz2);
			}
			else
			{
				//$("#reklama_" + (this._zmienna-1)).fadeOut(500, pokaz2);
				$("#reklama_" + (this._zmienna-1)).css('display','none');
				$("#reklama_" + (this._zmienna)).css('display','block');
			}			
		}
	
	if(this._zmienna == this._bannerList.length-1)
	{
		this._zmienna = 0;
	}
	else
	{//alert(this._zmienna);
		this._zmienna++;
	}

	//clearTimeout(this._t);
//	alert('aaa');
	this._t = setTimeout("EditoBannery.showElementBanerek()",10000);
		
}

	function pokaz(id_bloku)
	{
		//tablica=document.getElementsByName('test[]');
/*		var dlugosc = $('div.none').length;
		for (i = 0; i < dlugosc; i++)
		{
			if(id_bloku != i)
			{
				if($('#slowa_' + i).css('display') != 'none')
				{
					$('#nag_' + i).removeClass('active');
					$('#slowa_' + i).slideToggle('fast');
				}
				
			}
		}*/
		if($('#slowa_' + id_bloku).css('display') != 'none')
		{
			$('#nag_' + id_bloku).removeClass('active');
		}
		else
		{
			$('#nag_' + id_bloku).addClass('active');			
		}
		
		$('#slowa_' + id_bloku).slideToggle('fast');
	}
	
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;



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 id="EditoPopup$Container'+popup_id+'" class="ImageContainer">';
		html += '			<div onclick="EditoPopupClose('+popup_id+')" id="EditoPopup$IcoClose'+popup_id+'" class="IcoClose"></div>';
		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 id="EditoPopup$Container'+popup_id+'" class="ImageContainer">';
		html += '			<div onclick="EditoPopupClose('+popup_id+')" id="EditoPopup$IcoClose'+popup_id+'" class="IcoClose"></div>';
		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 = (980-offsetWidth)/2;
		var top = (screen[1] - offsetHeight) / 2;
	}
	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 = (980-offsetWidth)/2;;
		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 = (980-offsetWidth)/2;;
		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";
}

