﻿function InsertFLASH(lang)
{
	var bg = new Image();
	bg.onload = function () {

	var logo = document.getElementById('marleszFlash');

	if(logo)
	{
		logo.innerHTML = '<object type="application/x-shockwave-flash" id="marleszFlash_SWF" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="835" height="253" align="middle">'+
						'<param name="allowScriptAccess" value="sameDomain" />'+
						'<param name="movie" value="flash/index'+lang+'.swf" />'+
						'<param name="quality" value="best" />'+
						'<param name="bgcolor" value="#b6cf59" />'+
						'<param name="wmode" value="transparent" />'+
						'<embed src="flash/index'+lang+'.swf" quality="best" wmode="transparent" bgcolor="#3A6A32" width="835" height="253" name="marleszFlash_SWF" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
						'</object>';

		if(!document.getElementById('marleszFlash_SWF'))
		{
			alert('Wystapił błąd ładowania animacji Flash serwisu Marlesz.com.pl. Nie stanowi ona żadnej formy reklamy podmiotów trzecich. Odśwież stronę lub zmień ustawienia oprogramowania blokującego reklamy itp.');
		}
	}

	};
	bg.src = 'site/interface/bg.jpg';
}

function ShowIMG()
{
	var regexp = /imgSrc=([^&]*)/i;
	var matches_array = this.src.match(regexp);

	window.location = './?load=IMG&src='+matches_array[1];
}

/*
function ShowIMG()
{
	if(document.getElementById('curtainIMG'))
		document.getElementsByTagName('BODY')[0].removeChild(document.getElementById('curtainIMG'))

	var regexp = /imgSrc=([^&]*)/i;
	var matches_array = this.src.match(regexp);

	var img = new Image();

	pozycja = findPos(this);

	imgHTML = document.createElement('IMG');

	imgHTML.id = 'curtainIMG';
	imgHTML.style.top = pozycja[1];
	imgHTML.style.left = pozycja[0];
	imgHTML.style.display = 'none';

	document.getElementsByTagName('BODY')[0].appendChild(imgHTML);

	document.getElementsByTagName('BODY')[0].appendChild(imgHTML);
	img.onload = function () {

			imgHTML = document.getElementById('curtainIMG');

			imgHTML.src = this.src;
			imgHTML.style.display = 'block';

			imgHTML.onclick = function () {
			document.getElementsByTagName('BODY')[0].removeChild(document.getElementById('curtainIMG'));
		}
	}

	img.onerror = function () { document.getElementsByTagName('BODY')[0].removeChild(document.getElementById('curtainIMG')); }
	img.onabort = function () { document.getElementsByTagName('BODY')[0].removeChild(document.getElementById('curtainIMG'));}

	img.src = 'site/structure/'+matches_array[1];
}*/

function InitIMG()
{
	var images = document.getElementsByTagName('IMG');

	if(images.length > 0)
	{
		for(var i = 0; i < images.length; i++)
		{
			if(images[i].src.match('gpx_resampler.php'))
			{
				images[i].onclick = ShowIMG;
				images[i].style.cursor = 'pointer';
			}
		}
	}
}
/*
function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
	}

	return [curleft,curtop];
}*/


window.onload = InitIMG;