function popupWindowNew(url, width, height, space) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + width + ',height=' + height + ',screenX=' + space + ',screenY=' + space + ',top=' + space + ',left=' + space + '');
  return false;

}


/* jQuery FlyOut - Jolyon Terwilliger, Nixbox Web Designs - http://nixboxdesigns.com/jquery.flyout.php */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$.1L.19({1M:6(1a){7 c=8;7 h=8;7 $l;7 $g;7 a;7 m;7 n;7 i=1b 1c();7 B=\'C\';7 D;j.1d(6(){9(h==E){F 8}9(c){J(j)}k{K(j)}F 8});7 o=1N.19({L:1O,M:1e,N:\'1f\',O:\'1f\',P:Q,b:\'b\',1g:1e,1h:1i,1j:1i,R:"1P...",S:" - 1Q 1R 1S 1T",T:20,U:0,V:0,W:0,X:0,1k:6(){},1l:6(){},1m:6(){},1n:6(){},Y:\'c\'},1a);6 K(p){h=E;$l=$(p);$g=$(\'C\',p);i=1b 1c();1o=$(q).1U();1p=$(q).1V();a=$g.D();a.d+=o.U;a.e+=o.V;m=(o.W>0?o.W:$g.3());n=(o.X>0?o.X:$g.4());$(\'<1q></1q>\').f(\'1W\',o.b).1X(\'1Y\').r({\'Z\':\'1Z\',\'e\':a.e,\'d\':a.d,\'3\':m,\'4\':n,\'1r\':.5,\'1s\':\'21\',\'22\':\'23 #24 25\',\'z-26\':o.1g});9(o.P){$(\'#\'+o.b).10($(\'<C/>\').1t(6(){$(j).r({\'Z\':\'1u\',\'e\':m/2-(j.3/2),\'d\':n/2-(j.4/2)}).f(\'11\',o.R)}).f(\'12\',o.P))}k{$(\'#\'+o.b).r(\'27-1v\',\'#28\').10($(\'<1w></1w>\').29(o.R).r({\'Z\':\'1u\',\'e\':\'1x\',\'d\':\'1x\',\'1v\':\'#2a\',\'2b-2c\':\'2d\'}))}$(i).1t(6(){1y=$(\'<C/>\').f(\'12\',$l.f(\'1z\')).f(\'1A\',$g.f(\'1A\')+o.S).f(\'11\',$g.f(\'11\')+o.S).3(m).4(n);o.1k.G(p);9(o.13){7 $s=$(o.13);14=$s.2e()-(o.T*2);15=$s.2f()-(o.T*2)}k{14=$(q).4()-o.1h;9($.1B.1C)t=1D.1E(\'1F\')[0].1G;k t=$(q).3();15=t-o.1j}4=i.4;3=i.3;y=14/4;A=15/3;9(y<=A){A=y}k{y=A}u=v.w(4*y);x=v.w(3*A);9(u>4){u=4}9(x>3){x=3}9(o.13){16=$s.D();17=v.w(($s.2g()/2)-(u/2)+16.d);18=v.w(($s.2h()/2)-(x/2)+16.e)}k{17=v.w(($(q).4()/2)-(u/2)+1o);9($.1B.1C)t=1D.1E(\'1F\')[0].1G;k t=$(q).3();18=v.w((t/2)-(x/2)+1p)}$(\'#\'+o.b).2i().r(\'1r\',1).10(1y).4(\'1H\').3(\'1H\').H({e:18,d:17},{1I:o.L,1J:8,1K:o.N});$(\'#\'+o.b+\' \'+B).H({3:x,4:u},o.L,o.N,6(){o.1l.G(p);c=p;$l.2j(o.Y);h=8;$(\'#\'+o.b+\' \'+B).1d(6(){J(Q)})})});i.12=$l.f(\'1z\')}6 J(I){9(h==E||c==8){F 8}o.1m.G(c);h=E;a=$g.D();a.d+=o.U;a.e+=o.V;$(\'#\'+o.b).H({e:a.e,d:a.d},{1I:o.M,1J:8,1K:o.O});$(\'#\'+o.b+\' \'+B).H({3:m,4:n},o.M,o.O,6(){$(\'#\'+o.b).r(\'1s\',\'2k\').2l();o.1n.G(c);h=8;i=Q;9(I&&I!=c){c=8;K(I)}c=8;$l.2m(o.Y)})}F j}});',62,147,'|||height|width||function|var|false|if|tloc|loader|shown|left|top|attr|thumb|animating|bigimg|this|else|holder|th|tw||it|window|css|dest|wh|dw|Math|round|dh|x_dim||y_dim|subType|img|offset|true|return|call|animate|next|putAway|flyOut|outSpeed|inSpeed|outEase|inEase|loadingSrc|null|loadingText|closeTip|destPadding|startOffsetX|startOffsetY|startHeight|startWidth|shownClass|position|append|alt|src|destElement|max_x|max_y|dPos|dl|dt|extend|options|new|Image|click|500|swing|loaderZIndex|widthMargin|40|heightMargin|flyOutStart|flyOutFinish|putAwayStart|putAwayFinish|sL|sT|div|opacity|display|load|relative|color|span|2px|imgtag|href|title|browser|opera|document|getElementsByTagName|html|clientHeight|auto|duration|queue|easing|fn|flyout|jQuery|1000|Loading|Click|here|to|close|scrollLeft|scrollTop|id|appendTo|body|absolute||block|border|4px|d2deee|solid|index|background|000|text|FFF|font|size|9px|innerWidth|innerHeight|outerWidth|outerHeight|empty|addClass|none|remove|removeClass'.split('|'),0,{}));

/* * jQuery.vAlign * */

$.fn.vAlign = function()

{

	return this.each(function()

	{

		var ah = $(this).height();

			

		var ph = $(this).parent().height();

		var mh = (ph - ah) / 2;



		if (mh > 0) $(this).css('margin-top', mh);

	});

};

eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4($){2.d.e=4(1){1=2.f({5:\'g\',6:\'h\'},1);2(b).i(4(){j 0=2(b);7(0.3()==""){0.3(0.8(\'9\')).a(1.5);0.k(4(){7(0.3()==0.8(\'9\')){0.3(\'\').c(1.5).a(1.6)}});0.l(4(){7(0.3()==\'\'){0.3(0.8(\'9\')).c(1.6).a(1.5)}})}});m 2}})(2);',23,23,'el|settings|jQuery|val|function|blurClass|activeClass|if|attr|rel|addClass|this|removeClass|fn|clearField|extend|clearFieldBlurred|clearFieldActive|each|var|focus|blur|return'.split('|'),0,{}));

$.fn.clearForm = function() {
	return this.each(function()
	{
		var type = this.type, tag = this.tagName.toLowerCase();
		
		if (tag == 'form') return $(':input',this).clearForm();
		
		if ($(this).attr('rel') == this.value) this.value = '';
	});
};
$(document).ready(_initPage);
function _initPage()
{
	// centrowanie obrazow w pionie wewnatrze kontenera
	$('img.vAlign').vAlign();
	// obrazy uruchamiane w lightboxie
	//$("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'});
$('.clearField').clearField();
	$('form').submit(function(){
		$(this).clearForm();
	});
	
	$('a.photo-fly').flyout({

		destPadding: 20,
		startOffsetX: -4,
		startOffsetY: -4,
		outSpeed: 500,
		inSpeed: 300,
		loadingText: 'Wcztywanie...',
		closeTip: 'Kliknij aby schować'
	});
}


/////////////////////////////////////////////////////
/////////////////////////////////////////////////////

function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target = i;
        break;
      }
    }
  }

  var TargetForm = document.forms[target];
    
  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();

      if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function CheckDateRange(from, to) {
var fromS=from.value.split("-");
var toS=to.value.split("-");

var fromD = new Date(fromS[2],fromS[1],fromS[0]);
var toD = new Date(toS[2],toS[1],toS[0]);

var fromDT = fromD.getTime(); // milliseconds
var toDT = toD.getTime();

if (fromDT <= toDT){return true;} else {return false;}

}

function osCheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value)) {
    return true;
  } else {
    return false;
  }
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}

