// JavaScript Document
function mapaClick(id) {
    refs = new Array("polnoc_zachod", "zachod", "poludnie_zachod", "poludnie", "poludnie_wschod", "wschod", "polnoc_wschod", "centrum", "srodkowy");
    url = document.URL;
    re = /[&?]/;
    splits = url.split(re);
    for (var i=0; i < splits.length; i++) {
        if(splits[i].indexOf("lang=") == 0) {
            lang = splits[i];
            lang = lang.replace("lang=", "");
        }
    }
    window.location.href="?lang="+lang+"&str=kontakt&d=3&"+""+"i="+refs[id-1];
}
function show_image(img, title, width, height) {
  s = 'toolbar=no,menubar=no,location=no,personalbar=no,scrollbars=no,directories=no,status=no,resizable=no,' + 'width=' + width + ',height=' + height;
  NewWin=window.open('','',s);
  NewWin.document.open();
  NewWin.document.write("<HTML><HEAD><TITLE>" + title + "</TITLE></HEAD><BODY onblur='window.close()' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' bgcolor='#000000'>");
  NewWin.document.write("<img src='"+img+"' width='"+width+"' height='"+height+"'>");
  NewWin.document.write("</BODY></HTML>");
  NewWin.document.close();
  NewWin.focus();
}

function show_flash(swf, title, width, height) {
	  s = 'toolbar=no,menubar=no,location=no,personalbar=no,scrollbars=no,directories=no,status=no,resizable=yes,' + 'width=' + (width +8) + ',height=' + (height+8);
	  NewWin=window.open('','',s);
	  NewWin.document.open();
	  NewWin.document.write("<HTML><HEAD><TITLE>" + title + "</TITLE></HEAD><BODY align='center' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' bgcolor='#ffffff'>");
	  NewWin.document.write("<div align='center'><OBJECT CLASSID='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='100%' height='100%' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#5,0,0,0'>");
	  NewWin.document.write("<PARAM name='movie' VALUE='"+swf+"'>");
	  NewWin.document.write("<param name='allowScriptAccess' value='sameDomain' />");
	  NewWin.document.write("<PARAM NAME='quality' VALUE='high'>");
	  NewWin.document.write("<PARAM NAME='play' VALUE='true'>");
	  NewWin.document.write("<PARAM NAME='loop' VALUE='true'>");
	  NewWin.document.write("<EMBED SRC='"+swf+"' 'http://www.macromedia.com/shockwave/download/' TYPE='application/x-shockwave-flash' width='100%' height='100%'>");
	  NewWin.document.write("</EMBED></OBJECT>");
	  NewWin.document.write("</DIV></BODY></HTML>");
	  NewWin.document.close();
	  NewWin.focus();
}
function toggle_display(element_id) {
    el = document.getElementById(element_id);
    show = el.style.display;
    if(show == "block") {
        el.style.display="none";
    } else {
        el.style.display="block";
    }
}

function wyczysc(sender) {
  if (!sender._flag) {
    sender._flag = true;
    sender._save = sender.value;
    sender.value = '';
  }
}

function restore(sender) {
  if (sender.value == '') {
    sender.value = sender._save;
    sender._flag = false;
  }
}
function decode64(t) {
    return 'dsfas';
}

function decode_m(m, cl) {
    mail = decode64(m);
    out = "<a class='"+cl+"' href=mailto:'" + mail + "'>" + mail + '</a>';
    document.write(out);
}


function hover(element,state) {
 if (state) {
    element.style.color = "white";
 } else {
 element.style.color = "#394C1F";
}
}

function setLang(lang) {
 document.cookie = "lang=" + lang;
 location.reload();
}
function popup(rada,is) {
 el = document.getElementById(rada);
 if(is)
  el.style.visibility = "visible";
 else
  el.style.visibility = "hidden";
}

function set_szt(element, szt) {
    el = document.getElementById(element);
    el_szt = document.getElementById(element.id+"_szt");
    el_szt.value = element.value * szt;
}
function set_euro(element, eur) {
    el = document.getElementById(element);
    el_eur = document.getElementById(element.id+"_eur");
    el_eur.value = element.value / eur;
}
function try_close(msg) {
window.close();
}

function validate_email(email) {
email_adres = email.value;
// alert(email_adres);
is_correct = email_adres.match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{1,6})$/)!=null;
if(!is_correct) {
    alert("Podany adres e-mail jest niepoprawny");
    return false;
}

return true;
}

var tooltip_el;
function tooltip(element, showing) {
// alert(element);
el = document.getElementById(element)
// alert(el);
if(showing)
  el.style.visibility="visible";
else
  el.style.visibility="hidden";

}
function tooltip_move(element, ev) {

if(navigator.userAgent.indexOf("Gecko") > -1) {
    var target = this.el.id;
    offY = ev.layerY;
    offX = ev.layerX;
} else {

    offY = event.y;
    offX = event.x;
}

el = document.getElementById(element);

iH = window.innerHeight;
iW = (window.innerWidth) ? window.innerWidth : document.body.clientWidth;
//alert(iW);
posY = (window.screenTop) ? offY + 10: offY + 10;
posX = offX + 10;
posX = (window.scrollLeft) ? posX-window.scrollLeft : posX;

// if( offY > ( iH / 2 ))
//     posY = posY - (el.offsetHeight) -20;

if( offX > ( iW / 2) )
     posX = posX - (el.offsetWidth) -20;

el.style.top  = posY + "px";
el.style.left = posX + "px";
}
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   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);
      }
   } while (i < input.length);

   return output;
}
function move_kat_head() {
el = document.getElementById("main_kat_head");
d_id  = document.getElementById("txt");
if(el && d_id) {
  tableHeight = el.clientHeight;
  d_id.style.backgroundPosition = "0px "+tableHeight+"px";
}
}

