var linkarray = [];
var __installedFlashPluginVersion = null;
var __ua = {
	ie : /MSIE/.test(navigator.appVersion),
	wi : /win/.test(navigator.appVersion.toLowerCase())
};

//detecting installed flash player version
if (typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") {
	d = navigator.plugins["Shockwave Flash"].description;
	__installedFlashPluginVersion = parseInt(d.replace(/^.*\s+(\d+)\.?\d*\s+\S+$/, "$1"), 10);
}
else if (typeof window.ActiveXObject != "undefined") {
	for (var i = 10; i >= 5; i--) {
		var actXObject = 'ShockwaveFlash.ShockwaveFlash' + (i < 6 ? '' : '.' + i);
		try {
			if (new ActiveXObject(actXObject)) {
				__installedFlashPluginVersion = i;
				break;
			}
		} catch(e) {}
	}
}

function createPicHtml(n, p, w, h, l) {
	var html = '<img src="' + p + '" border="0" width="' + w + '" height="' + h + '" alt="" id="start_img_' + n + '" />';
	if (l && l != '') {
		html = '<a href="' + l + '">' + html + '</a>';
	}
	return html;
}

/*atrybuty funkcji setFr, kolejno:
- bn: numer banera
- hp: czy mamy obrazek
- op: opera (?)
- fp: sciezka do pliku .swf
- pp: sciezka do obrazka
- fi: czy instalować flasha
- pv: wymagana wersja pluginu flasha
- bw: szerokosc banera
- bh: wysokosc banera
- lh: adres linka
- fv: zmienne dla obiektu flash (flashVars)
- pw: szerokosc okna popup
- ph: wysokosc okna popup
- txt: html reklamy tekstowej*/
function setFr(bn, hp, op, fp, pp, fi, pv, bw, bh, lh, fv, pw, ph, txt) {
	var swfName = 'start_movie_' + bn,
			html = '';
	linkarray[bn] = lh;
 
	hp = pp == '' ? 0 : hp;
	pw = parseInt(pw);
	ph = parseInt(ph);
	if(isNaN(pw) || pw < 0)	pw = 0;
	if(isNaN(ph) || ph < 0)	ph = 0; 

	if (lh != '') {
		if (window.link_w_nowym_oknie == 1) {
			lh = 'javascript:window.open(\'' + lh + '\');void(0);';
		} else if (window.link_w_nowym_oknie == 2) {// oferta tygodnia 
			lh = 'javascript:openFWindow(\'' + lh + '\',\'startwin_'+(new Date()).getTime()+'\');void(0);';
		} else if (pw == 0) {
		} else {
			lh = 'javascript:window.open(\'' + lh + '\',\'startwin_'+(new Date()).getTime()+'\',\'width=' + pw + ', height=' + ph + '\');void(0);';
		}
	}

	if (txt && txt != '') {
		var p = document.createElement('P');
		var a = document.createElement('A');
		a.href = lh;
		a.innerHTML = '<b>więcej &raquo;</b>';
		p.appendChild(a);
		var e = document.createElement('DIV');
		e.style.padding = '2px';
		e.innerHTML = txt;
		e.appendChild(p);
		html = e;
	}
	else {
		if (fp != '') {
			if (pv <= __installedFlashPluginVersion) {
				if (__ua.ie && __ua.wi) {
					html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
					html += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + pv + ',0,0,0" ';
					html += 'width="' + bw + '" height="' + bh + '" id="' + swfName + '">';
					html += '<param name="movie" value="' + fp + '?link=' + lh + '" />';
					html += '<param name="allowScriptAccess" value="always" />';
					html += '<param name="quality" value="high" />';
					html += '<param name="flashVars" value="' + fv + '" />';
					html += '<param name="wmode" value="transparent" />';
					html += '</object>';
				} else {
					html += '<embed src="' + fp + '?link=' + lh + '" wmode="transparent" allowscriptaccess="always" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + bw + '" height="' + bh + '" flashvars="' + fv + '" name="' + swfName + '"></embed>';
				}
			} else {
				html += createPicHtml(bn, pp, bw, bh, lh);
			}
		} else {
			if (hp == 1) {
				html += createPicHtml(bn, pp, bw, bh, lh);
			}
			if (fi == 1) {
				html += "Wymagany jest dodatek Adobe Flash Player w wersji " + pv + ".<br />Zainstaluj najnowszą wersję ze <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\">strony producenta</a>.";
				window.open('http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','mm','left=20,top=20,width=450,height=350,scrollbars=1');
			}
		}
	}
	var x;

	if (x = document.getElementById('start_baner_' + bn)) {
		if (txt && txt != '') {
//			x.style.width = bw + 'px';
//			x.style.height = bh + 'px';
			x.style.background = '#fff';
			x.innerHTML = '';
			x.appendChild(html);
		} else {
			x.innerHTML = html;
		}
	}
}

function loadScripts(rid, rid_dol, path) {
	var x,i = [1];
	var s = [1,2,3,1,1,1,1,1,1,1];
	//for (var i = 0; i < s.length; i++) {
	for (var i = 0; i < s.length; i++) {
		if (x = document.getElementById('scr_' + i))
			x.src = startad+'/black.js?rid='+rid+'&nr='+i+'&size='+s[i]+path+'&lang=pl';
	}
	if (x = document.getElementById('gemius'))
		x.src = '/.templates/js/gemius.js';
}
