function drukuj() {
self.print();
}

var pkobp_print;
function pageToPrint(link) {
	if (window.open('','pkobp_print',"scrollbars=1,status=0,menubar=0,toolbar=0,resizable=0,directories=0,height=500,width=656"));
	document.parametrystrony.action=link;
	document.parametrystrony.print.value=1;
	document.parametrystrony.target='pkobp_print';
	document.parametrystrony.submit();
}

var pkobp_sendto;
function pageSendTo(link) {
	if (window.open('','pkobp_sendto',"scrollbars=1,status=0,menubar=0,toolbar=0,resizable=0,directories=0,height=345,width=516"));
		
		var formularz = document.getElementById('parametrystrony');
		if(formularz==null){
			forml = document.createElement("form");
			aa = document.getElementsByTagName('body')[0];
			aa.appendChild(forml);
			forml.method='post';
			forml.target='pkobp_sendto'
			forml.action=link;
			forml.setAttribute('name','parametrystrony')
			forml.setAttribute('id','parametrystrony')
//			document.parametrystrony.submit();
			forml.submit();
		}else{
			document.parametrystrony.action=link;
	//		document.parametrystrony.print.value=0;
			document.parametrystrony.target='pkobp_sendto';
			document.parametrystrony.submit();
		}

}

function checkmail (obj)
{
	var field = obj;
	var str = field.value;
	if (window.RegExp) {

	  var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	  var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
	  var reg1 = new RegExp(reg1str);
	  var reg2 = new RegExp(reg2str);
	  if (!reg1.test(str) && reg2.test(str) && str.indexOf("@") >= 0){
		/*
		var pattern = "^([A-Za-z0-9\.])*[A-Za-z0-9\.]+\@([A-Za-z0-9\.])*{1,63}\.[a-zA-Z]{2,6}$";

		var reg = new RegExp(pattern);

		alert(pattern);
		if (!reg.test(str)){
		//document.form.submit();
		*/
		return 1;
	  }
	  field.focus();
	  field.select();
	  window.alert('Adres e-mail jest nieprawidłowy');
	  return 0;
	} else {
	  if(str.indexOf("@") >= 0)
		return 1;
	  field.focus();
	  field.select();
	  window.alert('Adres e-mail jest nieprawidłowy');
	  return 0;
	}
}

//funkcja checktel zwraca 1 jesli numer telefonu jest ok
function checktel (obj)
{
	var field = obj;
	var str = field.value;
	if (window.RegExp) {
	  var reg1str = /^[0-9\+]+/;
	  var reg1 = new RegExp(reg1str);
	  if (reg1.test(str)){

		//document.form.submit();
		return 1;
	  }
	  else
		{
		  field.focus();
		  field.select();
		  window.alert('Podany numer telefonu jest nieprawidłowy');
		  return 0;
		}
	}
	return 0;
}

function popup(href, windowname, width, height, scrollbars)
{
	if (width && height)
	{
		resizable=0
		rozmiar = ",height="+height+",width="+width;
	}
	else
	{
		rozmiar='';
		resizable=1;
	}
	if (scrollbars)
	{
		scrollbars=1;
	}
	else
	{
		scrollbars=0;
	}

	popup[windowname] = window.open(href,windowname,"scrollbars="+scrollbars+",status=0,menubar=0,toolbar=0,resizable="+resizable+",directories=0"+rozmiar);
}

function image(windowname, srcfile, width, height, info)
{
	width=width+0;
	height=height+0;

	x = "TITLEBAR=0,LOCATION=0,RESIZE=0, WIDTH="+width+", HEIGHT="+height;

	popup[windowname] = window.open('',windowname,x);
	popup[windowname].focus();
	popup[windowname].document.write('<html><head><title>PKO BP - '+info+'</title></head><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF"><img src="'+srcfile+'" alt="'+info+'" width="'+width+'" height="'+height+'" border="0"></body></html>');
}

// opoznienie w milisekundach
var delay=5000;
// adres serwera
var host="http://pro.hit.gemius.pl";

var timArr=new Array();
var imgArr=new Array();
var urlArr=new Array();
var popArr=new Array();

function redir(url,id,name,param){
        var idx=imgArr.length;
        popArr[idx]=new Array();
        popArr[idx][0]=name;
        popArr[idx][1]=param;
        urlArr[idx]=new Array();
        urlArr[idx][0]=url;
        urlArr[idx][1]=host+"/hitredir?id="+id+"&url="+url;
        timArr[idx]=new Array();
        timArr[idx][0]=setTimeout('dload('+idx+',0)',delay);
        imgArr[idx]=new Image();
        imgArr[idx].src=host+"/dot.gif";
        timArr[idx][1]=setTimeout('imageLoaded('+idx+')',100);
}

function noredir(url,id,name,param){
document.location.href=url;
}

function imageLoaded(i){
        if(imgArr[i].width == 1 && imgArr[i].height == 1){
                dload(i,1);
        }else{
                timArr[i][1]=setTimeout("imageLoaded("+i+")",100);
        }
}
function dload(i,j){
        clearTimeout(timArr[i][0]);
        clearTimeout(timArr[i][1]);
        if(popArr[i][0]==''){
                document.location.href=urlArr[i][j];
        }else{
                window.open(urlArr[i][j],popArr[i][0],popArr[i][1]);
        }
}

function show(divid) {
	elt = document.getElementById(divid);
	if (elt) {
		if (elt.style.visibility=='visible')
		{
			elt.style.visibility='hidden';
			elt.style.display='none';
		}
		else
		{
			elt.style.visibility='visible';
			elt.style.display='block';
		}
	}
}


function loadBackground(id, img, color)
{
        var host="http://img.www.pkobp.pl/wielkanoc/";
        document.getElementById(id).style.backgroundImage = 'url('+host+img+')';
        document.getElementById(id).style.backgroundColor = color;
}

function loadBackgrounds()
{
        loadBackground('top_wielkanoc', 'top.jpg', '#ffffff');
        loadBackground('left_wielkanoc', 'left.jpg', '#566e14');
        loadBackground('right_wielkanoc', 'right.jpg', '#566e14');
        document.getElementById('body_wielkanoc').style.backgroundColor = '#566e14';

}

function imgPopup(url,name,scale)
{
    this.imgURL = url;
    this.name   = name;
    this.scale  = scale;
    this.delay  = 1000;

    this.img = img = new Image();
    this.img.src = this.imgURL;

    var me = this;

    this.preloadCheck = function () {
        //if (me.img.complete && me.img.width && me.img.height) {
        if (me.img.width && me.img.height) {
            me.showPopup();
        } else {
            window.setTimeout(me.preloadCheck, me.delay);
        }
    }

    this.showPopup = function () {

        var width  = me.img.width;
        var height = me.img.height;
        var x = "TITLEBAR=0,LOCATION=0,RESIZE=0, WIDTH="+width+", HEIGHT="+
                height;
        var newwindow = window.open("","name",x);
        var d = newwindow.document;
        d.open();
        d.write('<html><head><title>'+me.name+
                '</title></head>' +
                '<body leftmargin="0" topmargin="0" ' +
                ' rightmargin="0" bottommargin="0" ' +
                ' marginwidth="0" marginheight="0" ' +
                ' bgcolor="#FFFFFF"><img src="'+me.img.src+'" ' +
                ' alt="" width="'+width+'" height="'+height+
                '" border="0" onclick="window.close()">' +
                '</body></html>');
        d.close();
    }
    me.preloadCheck();
}

function eWyciagG()
{
	var gemius_identifier = new String('nceQ1Db5d70pY0DG1BH4kccQ.uz8gnsqSr7YRr9nynP.b7');
  	var gemius_url=new String('https://pro.hit.gemius.pl/_'+(new Date()).getTime()+'/redot.gif?l=11&id=');
  	gemius_url+=gemius_identifier;
  	gemius_url+=gemius_parameters();
  	var gemius_image = new Image(1,1);
  	gemius_image.src = gemius_url;
  	return true;
}
