function printContents()
{
	iWidth = window.screen.width;
	iHeight = window.screen.height;
    wt = 630;
    ht = 460;
    lt = (iWidth - wt) / 2;
    tp = (iHeight - ht) / 2;
    window.open("print.php", '', 'height='+ht+',width='+wt+',top='+tp+',left='+lt+',toolbar=no,resizable=no,scrollbars=yes'); 
}

function popupImage(file, desc, width, height) {
  preview(file, desc, width, height);
}


function preview(file, desc, width, height)
{
 if (desc == null) {
   desc = '';
 }
 var left = (screen.width - width) / 2;
 var top = (screen.height - height + 20) / 2;
 window.open("preview.php?file="+file+"&desc="+desc, "_preview_", "width="+width+",height="+height+",top="+top+",left="+left);
}

function selectTown() {
  var town = document.getElementById('town').value;
  if (town != null && town > 0) {
    window.location = 'sklepy,' + town + '.html';
  }
}

function utf8_encode(string) {
  string = string.replace(/\r\n/g,"\n");
  var utftext = "";
  
  for (var n = 0; n < string.length; n++) {
    var c = string.charCodeAt(n);
    if (c < 128) {
      utftext += String.fromCharCode(c);
    } else if((c > 127) && (c < 2048)) {
      utftext += String.fromCharCode((c >> 6) | 192);
      utftext += String.fromCharCode((c & 63) | 128);
    } else {
      utftext += String.fromCharCode((c >> 12) | 224);
      utftext += String.fromCharCode(((c >> 6) & 63) | 128);
      utftext += String.fromCharCode((c & 63) | 128);
    }
  }
  return utftext;
}

with (navigator) if (appName.indexOf('Microsoft')!=-1 && appVersion.indexOf('Mac')==-1)
{
  document.write('<scr'+'ipt language="VBScript">\nMM_flash = NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash"))\n</scr'+'ipt>');
}
  
function MM_checkPlugin(plgIn)
{
    var result = false;
  if (navigator.appName.indexOf('Microsoft')==-1 || (navigator.plugins && navigator.plugins.length))
    {
      result = navigator.plugins[plgIn] != null ? true : false;
    }
    else
    {
      if (navigator.appName.indexOf('Microsoft')!=-1 && navigator.appVersion.indexOf('Mac')==-1)
    {
      result = MM_flash;
    }
  }
  result = result == true ? true : false;
  return result;      
}

var jestFlaszyk = MM_checkPlugin("Shockwave Flash");
var flashExists = jestFlaszyk;

function printMap()
{
  if (jestFlaszyk)
  {
    document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
             'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'+
             'WIDTH="300" HEIGHT="230" id="mapka_got" ALIGN="">'+
             '<PARAM NAME=movie VALUE="images/map.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=devicefont VALUE=true> <PARAM NAME=bgcolor VALUE=white> <EMBED src="images/map.swf" quality=high devicefont=true bgcolor=white  WIDTH="300" HEIGHT="230" NAME="mapka_got" ALIGN=""'+
             'TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>'+
             '</OBJECT>');
  }
  else
  {
    document.write('<img src="images/map.gif" border="0" usemap="#mapMapka">'+
    '<map name="mapMapka">'+
    '<area shape="poly" coords="50,136,46,150,54,150,56,157,80,162,76,167,87,181,96,176,96,166,116,143,108,126,99,131,85,119" href="javascript:showMiasta(1)" alt="dolnośląskie">'+
    '<area shape="poly" coords="159,64,163,72,148,104,112,89,109,59,123,52" href="javascript:showMiasta(2)" alt="kujawsko-pomorskie">'+
    '<area shape="poly" coords="211,156,210,126,211,114,236,109,239,102,253,109,253,127,255,136,267,153,267,167,258,173,252,168,240,171,228,169,233,163" href="javascript:showMiasta(3)" alt="lubelskie">'+
    '<area shape="poly" coords="42,90,74,72,76,84,72,90,74,112,86,120,76,122,59,131,49,135,42,122" href="javascript:showMiasta(4)" alt="lubuskie">'+
    '<area shape="poly" coords="127,142,143,104,150,101,168,105,182,124,177,128,179,139,166,144,164,152,149,147" href="javascript:showMiasta(5)" alt="łódzkie">'+
    '<area shape="poly" coords="157,201,149,181,169,164,181,176,195,170,201,204,190,208,177,206,171,213,163,212" href="javascript:showMiasta(6)" alt="małopolskie">'+
    '<area shape="poly" coords="163,73,204,64,221,85,225,97,239,101,235,109,212,114,208,124,211,147,181,139,178,125,185,123,174,115,168,103,163,105,151,101" href="javascript:showMiasta(7)" alt="mazowieckie">'+
    '<area shape="poly" coords="97,166,115,143,129,142,132,148,137,167,129,176,124,177,124,185,121,189,111,182,112,177,104,177" href="javascript:showMiasta(8)" alt="opolskie">'+
    '<area shape="poly" coords="213,158,232,164,227,170,240,172,250,168,256,173,233,201,241,217,215,213,216,209,202,204,196,169" href="javascript:showMiasta(9)" alt="podkarpackie">'+
    '<area shape="poly" coords="231,28,246,38,250,61,258,72,259,88,248,95,246,103,226,97,222,85,204,65,226,51,220,35" href="javascript:showMiasta(10)" alt="podlaskie">'+
    '<area shape="poly" coords="100,59,119,55,124,51,145,58,156,49,150,38,159,29,123,14,91,25" href="javascript:showMiasta(11)" alt="pomorskie">'+
    '<area shape="poly" coords="128,142,163,152,162,162,168,165,162,171,154,175,148,183,157,199,146,207,125,187,124,178,130,176,137,166" href="javascript:showMiasta(12)" alt="śląskie">'+
    '<area shape="poly" coords="168,144,165,152,164,162,174,167,181,176,205,165,212,157,209,148,180,140" href="javascript:showMiasta(13)" alt="świętokrzyskie">'+
    '<area shape="poly" coords="147,58,161,65,164,72,177,69,211,60,226,50,221,34,229,28,159,28,152,38,156,47" href="javascript:showMiasta(14)" alt="warminsko-mazurskie">'+
    '<area shape="poly" coords="75,76,92,67,92,62,98,57,107,59,112,88,146,102,124,142,117,142,108,126,99,130,84,120,73,111" href="javascript:showMiasta(15)" alt="wielkopolskie">'+
    '<area shape="poly" coords="90,24,98,55,89,62,94,66,78,75,74,72,42,89,35,82,41,70,40,42" href="javascript:showMiasta(16)" alt="zachodnio-pomorskie">'+
    '</map>');
  }
}

function printPromotions(var_haslo)
{
	document.write('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
					+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '
					+ 'WIDTH="540" HEIGHT="38" id="promotion" ALIGN=middle>'
					+ '<PARAM NAME=allowScriptAccess VALUE=sameDomain />'
					+ '<PARAM NAME=movie VALUE="images/BricoMarcheHaslo_540X38.swf" />'
					+ '<PARAM NAME=quality VALUE=high />'
					+ '<PARAM NAME=bgcolor VALUE=#ffffff />'
					+ '<PARAM NAME=flashVars VALUE="haslo='+var_haslo+'" />'
					+ '<EMBED src="images/BricoMarcheHaslo_540X38.swf" quality=high bgcolor=#ffffff'
					+ ' flashVars="haslo='+var_haslo+'"'
					+ ' WIDTH="540" HEIGHT="38" NAME="promotion" ALIGN="middle"'
					+ ' allowScriptAccess="sameDomain" TYPE="application/x-shockwave-flash"'
					+ ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" /></EMBED>'
					+ '</OBJECT>');
}

function showMiasta(regionId) {
  if (regionId == 10) {
    regionId = 9;
  } else if (regionId == 10) {
    regionId = 10;
  } else if (regionId == 3) {
    regionId = 4;
  } else if (regionId == 4) {
    regionId = 3;
  }
  HTML_AJAX.replace('shopList','sklepy,lista,' + regionId + '.html');
}

function showService(servId, shopId) {
  HTML_AJAX.replace('shopServices','ajax,service,' + servId + ',' + shopId + '.html');
}

