var linkarray=new Array();
var flashinstalled = 0;//nie wiadomo czy zainstalowany
var flashversion = 0;//na razie zero, po zakonczeniu powinna przechowywac numer wersji plugina

if (navigator.plugins && navigator.plugins.length){
	x = navigator.plugins["Shockwave Flash"];
	if (x){
		flashinstalled = 2;//zainstalowany
		if (x.description)
		{
			y = x.description;
//			flashversion = y.charAt(y.indexOf('.')-1);
			flashversion = parseInt(y.replace(/^.*\s+(\d+)\.?\d*\s+\S+$/, "$1"), 10);
		}
	}
	else{
		flashinstalled = 1;//niezainstalowany
	}
	if (navigator.plugins["Shockwave Flash 2.0"]){
		flashinstalled = 2;//zainstalowany
		flashversion = 2;//plugin 2.0
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length){
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;//zainstalowany
	else
		flashinstalled = 1;//niezainstalowany
}else{

document.write('<SCRIPT LANGUAGE="VBScript">\n');
document.write('on error resume next\n');
document.write('\n');
document.write('If 1 = 1 Then\n');
document.write('	For i = 2 to 10\n');
document.write('		If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then\n');
document.write('\n');
document.write('		Else\n');
document.write('			flashinstalled = 2\n');
document.write('			flashversion = i\n');
document.write('		End If\n');
document.write('	Next\n');
document.write('End If\n');
document.write('\n');
document.write('If flashinstalled = 0 Then\n');
document.write('	flashinstalled = 1\n');
document.write('End If\n');
document.write('\n');
document.write('<\/script>');

}

function cc(){
  self.status="";
}

function imgComplete(){
    for(var numer=0; numer<9; numer++){
	if(document.getElementById('start_img_'+numer)){
	    if(!(document.getElementById('start_img_'+numer).complete)){
		document.getElementById('start_img_'+numer).src = document.getElementById('start_img_'+numer).src;
    	    }
	}else{}
    
    }
}
     

function getGifMsg(numer,gif,w,h ,linek,pw,ph){
    m = '';
	if(!(linek=='')){
		m+='<a href="'+linek+'">';
	}
	m+='<img src="'+gif+'" border="0" width="'+w+'" height="'+h+'" alt="" id="start_img_'+numer+'">';
	if(!(linek==''))m+='</a>';
    return m;
}//~

function window_clone(linek){
	window.open(linek);
}

function setFr(numer,hasGif,opr,flash,gif,instalowac,wersja,w,h,linek,flashvars,popup_width,popup_height){
 flashname='start_movie_'+numer;
 linkarray[numer]=linek;
 
 if(gif==''){    hasGif=0;    }

 if(isNaN(parseInt(popup_width))  || parseInt(popup_width)<0 || !popup_width) 		popup_width=0;
 if(isNaN(parseInt(popup_height)) || parseInt(popup_height)<0 || !popup_height) 	popup_height=0; 
 var msg='';

 if(!(linek=='')){
	if(window.link_w_nowym_oknie==1){
		linek='javascript:window_clone(\''+linek+'\')';
	} else if(window.link_w_nowym_oknie==2) {// oferta tygodnia 
		linek='javascript:openFWindow(\''+linek+'\',\'startwin_'+(new Date()).getTime()+'\');void(0);';
	} else if(popup_width==0){
	} else {
		linek='javascript:openNewWindow(\''+linek+'\',\'startwin_'+(new Date()).getTime()+'\',\'width='+popup_width+', height='+popup_height+'\')';
	}
 }

	if(flashinstalled==2 && !(flash == '')){
		if(wersja <= flashversion){
//			if((window.opera && opr!=1) || !window.opera){
				msg+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+wersja+',0,0,0" width="'+w+'" height="'+h+'" id="'+flashname+'">\
				<param name="movie" value="'+flash+'?link='+linek+'" />\
				<param name="allowScriptAccess" value="always" />\
				<param name="quality" value="high" />\
				<param name="flashvars" value="'+flashvars+'" />\
				<param name="wmode" value="transparent" />\
				<embed src="'+flash+'?link='+linek+'" wmode="transparent" allowScriptAccess="always" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" flashvars="'+flashvars+'" name="'+flashname+'"></embed>\
			    </object>';
//			}else if(window.opera && opr==1){
//			    msg+=getGifMsg(numer,gif,w,h,linek,popup_width,popup_height);
//			}
		}else if((wersja > flashversion && instalowac==0) && hasGif==1){
		    
		    msg+=getGifMsg(numer,gif,w,h,linek,popup_width,popup_height);
		    
		}else if(wersja > flashversion && instalowac==1){
			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');

		}
	}else{
		if(instalowac==0 && hasGif==1){
		
		    msg+=getGifMsg(numer,gif,w,h,linek,popup_width,popup_height);
		    
		}else if(instalowac==1){
			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');
		}
	}

	if(document.getElementById('start_baner_'+numer)){
		document.getElementById('start_baner_'+numer).innerHTML=msg;
		timeout1 = setTimeout('imgComplete()',5000);
	}
}




function loadScripts(rid, rid_dol, path) {
	var x,i,s = [13,2,3,4,5,6,7,8,9,5,10,11];
	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';

//	sts_init();
}

/* code:WAP */
var sts_sbanner = null;
var sts_nua = navigator.userAgent.toLowerCase();
var sts_opera = sts_nua.indexOf('opera') != -1;
var sts_msie = sts_nua.indexOf('msie') != -1 && (document.all && !sts_opera);
var sts_counter = 0;

function sts_init() {
  if (sts_readCookie('mb-logout'))
    return;
  sts_counter = sts_readCookie('sts_counter');
  if (!sts_counter)
    sts_counter = 1;
  else
    sts_counter = parseInt(sts_counter) + 1;
  sts_writeCookie('sts_counter', sts_counter);
  if (document.getElementById('nosts')) return;
  var path = document.location.pathname;
  if (path.indexOf('/oferta') == -1 && path.indexOf('/inwestycje') == -1)
    return;
  if (typeof startad != 'undefined') {
    var params = '';
    if (typeof STS_PAGEVIEWS_TS != 'undefined' && sts_counter >= STS_PAGEVIEWS_TS[0] && sts_counter <= STS_PAGEVIEWS_TS[1])
      params += '0,';
    if (typeof STS_PAGEVIEWS_BS != 'undefined' && sts_counter >= STS_PAGEVIEWS_BS[0] && sts_counter <= STS_PAGEVIEWS_BS[1])
      params += '1,';
    if (typeof STS_PAGEVIEWS_POP1 != 'undefined' && sts_counter >= STS_PAGEVIEWS_POP1[0] && sts_counter <= STS_PAGEVIEWS_POP1[1])
      params += '2,';
    if (typeof STS_PAGEVIEWS_POP2 != 'undefined' && sts_counter >= STS_PAGEVIEWS_POP2[0] && sts_counter <= STS_PAGEVIEWS_POP2[1])
      params += '3,';
    if (params.length > 0)
      params = params.substr(0, params.length - 1);
    sts_load(startad + '/sts.js?sts=' + params);
  }
}

function sts_go() {
  if (typeof STS_SLOTS == 'undefined' || STS_SLOTS == null)
    return;
  var clr1 = document.getElementById('clr1');
  if (clr1) {
    if (typeof STS_PAGEVIEWS_TS != 'undefined' && typeof STS_SLOTS['1'][0] != 'undefined' &&
	sts_counter >= STS_PAGEVIEWS_TS[0] && sts_counter <= STS_PAGEVIEWS_TS[1]) {
      var imgsrc1 = STS_SLOTS['1'][0];
      var imgsrc2 = imgsrc1.substring(0, imgsrc1.lastIndexOf('.')) + '_' + imgsrc1.substr(imgsrc1.lastIndexOf('.'));
      var tbody = clr1.parentNode.parentNode;
      var rowIndex = clr1.parentNode.rowIndex;
      if (tbody) {
	var row = tbody.insertRow(rowIndex + 1);
	row.id = 'sts_baner';
	var cell = row.insertCell(0);
	cell.colSpan = 3;
	cell.style.paddingTop = sts_msie ? '1px' : '3px';
	cell.style.textAlign = 'center';
	cell.style.background = 'white url('+ imgsrc2 +') repeat-x 0 3px;';
	cell.innerHTML = '<a href="'+ STS_SLOTS['1'][1] +'"><img src="' + imgsrc1 +'" border="0" alt="" /></a>';
      }
    }
    if (typeof STS_PAGEVIEWS_BS != 'undefined' && typeof STS_SLOTS['2'][0] != 'undefined' &&
	sts_counter >= STS_PAGEVIEWS_BS[0] && sts_counter <= STS_PAGEVIEWS_BS[1]) {
      var imgsrc1 = STS_SLOTS['2'][0];
      var imgsrc2 = imgsrc1.substring(0, imgsrc1.lastIndexOf('.')) + '_' + imgsrc1.substr(imgsrc1.lastIndexOf('.'));
      sts_sbanner = document.createElement('DIV');
      sts_sbanner.id = 'sts_sbanner';
      sts_sbanner.style.position = 'absolute';
      sts_sbanner.style.width = '100%';
      sts_sbanner.style.textAlign = 'center';
      sts_sbanner.style.zIndex = '9999';
      sts_sbanner.style.background = 'white url('+ imgsrc2 +') repeat-x top left;';
      sts_sbanner.innerHTML = '<a href="'+ STS_SLOTS['2'][1] +'"><img src="'+ imgsrc1 +'" border="0" alt="" /></a>';
      var xc = document.createElement('IMG');
      xc.src = '/images/sts/x.gif';
      xc.title = xc.alt = 'zamknij';
      xc.style.position = 'absolute';
      xc.style.right = '5px';
      xc.style.top = '10px';
      xc.onclick = function() { sts_sbanner.style.display = 'none'; };
      sts_sbanner.appendChild(xc);
      sts_sbanner.style.display = 'block';
      document.body.appendChild(document.createElement('BR'));
      document.body.appendChild(document.createElement('BR'));
      document.body.appendChild(sts_sbanner);
      sts_stickyBanner();
    }
  }
  if (typeof STS_PAGEVIEWS_POP2 != 'undefined' && sts_counter >= STS_PAGEVIEWS_POP2[0] && sts_counter <= STS_PAGEVIEWS_POP2[1]) {
    sts_openBanner2(4);
  }
  else if (typeof STS_PAGEVIEWS_POP1 != 'undefined' && sts_counter >= STS_PAGEVIEWS_POP1[0] && sts_counter <= STS_PAGEVIEWS_POP1[1]) {
    sts_openBanner2(3);
  }
}

var sts_banner2 = null;
function sts_openBanner2(id) {
  if (typeof STS_SLOTS[id][0] == 'undefined')
    return false;
  var m = 0;
  var len = STS_SLOTS[id][0].length;
  if (STS_SLOTS[id][0].substring (len - 5, len) == '.html') m = 1;
  else if (STS_SLOTS[id][0].substring (len - 4, len) == '.swf') m = 2;
  if (m == 0) return false;
  if (sts_banner2) {
    sts_popup(sts_banner2);
    return false;
  }
  if (m == 1) {
    sts_banner2 = document.createElement('IFRAME');
    sts_banner2.src = STS_SLOTS[id][0];
    sts_banner2.frameBorder = 0;
    sts_banner2.style.border = 'none';
    sts_banner2.style.position = 'absolute';
    sts_banner2.style.width = '613px';
    sts_banner2.style.height = '318px';
    sts_banner2.style.backgroundColor = 'white';
    sts_banner2.style.zIndex = '99999';
    sts_banner2.style.opacity = '0.93';
    sts_banner2.style.filter = 'alpha(opacity=93)';
    sts_banner2.style.display = 'block';
  }
  else if (m == 2) {
    sts_banner2 = document.createElement('DIV');
    sts_banner2.style.position = 'absolute';
    sts_banner2.style.width = '550px';
    sts_banner2.style.height = '400px';
    sts_banner2.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6" width="550" height="400"><param name="movie" value="'+ STS_SLOTS[id][0] +'?link='+ encodeURIComponent(STS_SLOTS[id][1]) +'"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+ STS_SLOTS[id][0] +'?link='+ encodeURIComponent(STS_SLOTS[id][1]) +'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed></object>';
    sts_banner2.style.display = 'block';
  }
  document.body.appendChild(sts_banner2);
  sts_popup(sts_banner2);
  return false;
}

function sts_closeBanner2() {
  document.body.removeChild(sts_banner2);
  sts_banner2 = null;
  return false;
}

function sts_getWindowHeight() {
  if (typeof window.innerHeight != 'undefined')
    return window.innerHeight;
  else if (document.documentElement && 
	   typeof document.documentElement.clientHeight != 'undefined' &&
	   document.documentElement.clientHeight != 0)
    return document.documentElement.clientHeight;
  else if (document.body && typeof document.body.clientHeight != 'undefined')
    return document.body.clientHeight;
  return 0;
}

function sts_getScrollY() {
  if (document.body && document.body.scrollTop)
    return document.body.scrollTop;
  else if (document.documentElement && document.documentElement.scrollTop)
    return document.documentElement.scrollTop;
  return 0;
}

function sts_stickyBanner() {
  sts_sbanner.style.top = (sts_getWindowHeight() + sts_getScrollY() - sts_sbanner.offsetHeight) + 'px';
  if (sts_sbanner.style.display != 'none')
    setTimeout(sts_stickyBanner, 50);
}

function sts_load(src) {
  var script  = document.createElement ('SCRIPT');
  script.type = 'text/javascript';
  script.src  = src;
  document.body.appendChild (script);
}

function sts_getStyle(x, styleProp) {
  if (document.defaultView && document.defaultView.getComputedStyle)
    return document.defaultView.getComputedStyle(x, null).getPropertyValue(styleProp);
  else if (x.currentStyle)
    return x.currentStyle[styleProp];
  return null;
}

function sts_popup(obj) {
  var innerWidth = 0;
  var innerHeight = 0;
  if (sts_opera) obj.style.display = 'block';
  var objWidth  = sts_getStyle(obj, 'width');
  var objHeight = sts_getStyle(obj, 'height');
  if (objWidth == '0px') {
    objWidth = obj.offsetWidth + 'px';
    objHeight = obj.offsetHeight + 'px';
  }
  if (objHeight.indexOf('px') == -1) {
    obj.style.display = 'block';
    objHeight = obj.clientHeight;
  }
  objWidth = parseInt(objWidth);
  objHeight = parseInt(objHeight);
  if (window.innerWidth) {
    innerWidth  = window.innerWidth/2;
    innerHeight = window.innerHeight/2 - 20;
  } else if (document.body.clientWidth) {
    innerWidth  = document.body.clientWidth/2;
    innerHeight = document.body.clientHeight/2 - 20;
  }
  var wleft = innerWidth - (objWidth/2);
  if (wleft < 0) wleft = 0;
  obj.style.left = wleft + 'px';
  obj.style.top  = sts_getScrollY() + innerHeight - (objHeight/2) + 'px';
  if (parseInt(obj.style.top) < 1)
    obj.style.top = '1px';
}

function sts_readCookie(name) {
  var nameeq = name + '=';
  var ca = document.cookie.split(';');
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ')
      c = c.substring(1, c.length);
    if (c.indexOf(nameeq) == 0)
      return c.substring(nameeq.length, c.length);
  }
  return null;
}

function sts_writeCookie(name, value) {
  document.cookie = name +'='+ value + '; path=/';
}
