﻿/* $Id: macromedia.js,v3.0 03.11.2003 04:18:22 frame Exp $ */
/*
	Contains platform-independent image routines.


	Copyright (c) 1999-2003 console++ - insertcoin@console.cc
*/

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_showHideLayers() { //v6.0
			var i,p,v,obj,args=MM_showHideLayers.arguments;
			for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

var winx;

function openhilfe()
{

   //document.bewform.action = u_seitenname + "_hilfe.asp";
   //document.bewform.target = "_blank";
   //document.bewform.submit();
   winx = window.open(u_seitenname + "_hilfe.asp", "Hilfe", "top=100,left=100,height=470,width=600,menu=no,scrollbars=auto,status=no,resizable=yes");
}
function openhilfestandort()
{
   winx = window.open(u_seitenname + "_hilfe.asp", "Hilfe", "top=100,left=100,height=470,width=600,menu=no,scrollbars=auto,status=no,resizable=yes");
}

//document.oncontextmenu=new Function("return false")

function getDate(event,inp) 
{
   var wndx,wndy;
   try {
      if(window.event) {
        wndx = window.event.screenX;
        wndy = window.event.screenY;
      } else {
	wndx = event.screenX;
	wndy = event.screenY;
      }
   } catch(e) {
      x = y = 0;
   }

   if (inp.value.length == 10) 
   {
      var d = parseInt(inp.value.substring(0 ,2), 10);
      var m = parseInt(inp.value.substring(3 ,5), 10) - 1;
      var y = parseInt(inp.value.substring(6), 10);
      new calendar(wndx,wndy,inp, new Date(y,m,d)).show();
   } 
   else 
   {
      new calendar(wndx,wndy,inp).show();
   }
}


function plzort()
{
   var wert;
   wert = document.bewform.postleitzahl.value;
   var pos1;
   pos1 = wert.indexOf("|");
   document.bewform.dpw_data_ybwadr_plz.value = wert.substring(0,pos1);
   document.bewform.dpw_data_ybwadr_ort.value = wert.substring(pos1 + 1);
}

function changestelle(wert)
{
   document.bewform.varstelle.value = wert;
   document.bewform.dpw_data_ybwbew_stelle_ohne.value = "";
   document.bewform.dpw_data_ybwbew_stelle_ohne2.value = "";
   retour(u_seitenname + "_seite01.asp");
}

function stelle(name, wert)
{
//   if (name == "dpw_data_ybwbew_stelle" && wert != "")
//   {
//      document.bewform.dpw_data_ybwbew_stelle_ohne.disabled = true;
//      document.bewform.dpw_data_ybwbew_stelle_ohne2.disabled = true;

//   }
//   else if (name == "dpw_data_ybwbew_stelle_ohne" && wert != "") 
//   {

//      document.bewform.dpw_data_ybwbew_stelle.disabled = true;
//      document.bewform.dpw_data_ybwbew_stelle_ohne2.disabled = true;
//   }
//   else if (name == "dpw_data_ybwbew_stelle_ohne2" && wert != "") 
//   {

//      document.bewform.dpw_data_ybwbew_stelle.disabled = true;
//      document.bewform.dpw_data_ybwbew_stelle_ohne.disabled = true;
//   }
//   else if (wert == "") 
//   {
//      document.bewform.dpw_data_ybwbew_stelle_ohne2.disabled = false;
//      document.bewform.dpw_data_ybwbew_stelle_ohne.disabled = false;
//   }
}

function abbrechen()
{         
   var check = true;
   var frage;
   if (document.bewform.joblang.value == "E")
       frage = "Would you really like to quit your Online Application?";
   else
       frage = "Wollen Sie wirklich die Onlinebewerbung abbrechen?";
   check = confirm(frage);
   if (check == true)
   {
      if (document.bewform.current_window.value == u_seitenname + "_seite07")
      {
         document.bewform.target = "_parent";
         //document.bewform.enctype = "application/x-www-form-urlencoded";
         document.bewform.method  = "post";
      }
      else
      {
         document.bewform.target = "_self";
      }
      document.bewform.current_window.value = "abbrechen";
      document.bewform.action = u_seitenname + "_start.asp";
      document.bewform.submit();
   }
}
function Kinder()
{
   if (document.bewform.dpw_data_ybwsons_char01.readOnly) 
   {
      document.bewform.dpw_data_ybwsons_char01.readOnly = false;
      document.bewform.dpw_data_ybwsons_char01.disabled = false;
      document.bewform.dpw_data_ybwsons_zahl01.readOnly = false;
      document.bewform.dpw_data_ybwsons_zahl01.disabled = false;
   }
   else
   {
      document.bewform.dpw_data_ybwsons_char01.readOnly = true;
      document.bewform.dpw_data_ybwsons_char01.disabled = true;
      document.bewform.dpw_data_ybwsons_char01.value    = "";
      document.bewform.dpw_data_ybwsons_zahl01.readOnly = true;
      document.bewform.dpw_data_ybwsons_zahl01.disabled = true;
      document.bewform.dpw_data_ybwsons_zahl01.value    = "";
   }
} 

function start()
{
   if (document.bewform.dpw_data_ybwbew_stelle.value != "") 
   {
      document.bewform.dpw_data_ybwbew_stelle.readOnly = false;
      document.bewform.dpw_data_ybwbew_stelle.disabled = false;
      document.bewform.dpw_data_ybwbew_stelle_ohne.readOnly = true;
      document.bewform.dpw_data_ybwbew_stelle_ohne.disabled = true;
      document.bewform.dpw_data_ybwbew_stelle_ohne2.readOnly = true;
      document.bewform.dpw_data_ybwbew_stelle_ohne2.disabled = true;
      document.bewform.varstelle.disabled = true;
      document.bewform.varstelle.readOnly = true;
   }
   else
   {
      document.bewform.dpw_data_ybwbew_stelle.readOnly = true;
      document.bewform.dpw_data_ybwbew_stelle.disabled = true;
      document.bewform.dpw_data_ybwbew_bwqu.readOnly = true;
      document.bewform.dpw_data_ybwbew_bwqu.disabled = true;
   }
}
function getDate2(inp) 
{
   if (inp.value.length == 10) 
   {
      var d = parseInt(inp.value.substring(0 ,2), 10);
      var m = parseInt(inp.value.substring(3 ,5), 10) - 1;
      var y = parseInt(inp.value.substring(6), 10);
      return(new Date(y,m,d));
   } 
}

function retour(seite)
{
   document.bewform.action = seite;
   if (document.bewform.current_window.value == u_seitenname + "_seite07")
   {
      document.bewform.method  = "post";
      document.bewform.target = "_parent";
      //document.bewform.enctype = "application/x-www-form-urlencoded";
   }
   else
   {
      document.bewform.target = "_self";
   }
   if (check_input())
   {
      document.bewform.submit();
   }
}
function retouropen(seite)
{
   document.bewform.action = seite;
   document.bewform.target = "_blank";
   document.bewform.submit();
}
function get_id()
{
   var gebdat = document.bewform.dpw_data_ybw_gebdat.value.replace(new RegExp("\\D", "gi"), "");
   gebdat = gebdat.substring(0,4) + gebdat.substring(6,8);
   var id = document.bewform.dpw_data_ybw_svnr.value + gebdat;
   return id;
}
function check_id()
{
   var gebdat = document.bewform.dpw_data_ybw_gebdat.value.replace(new RegExp("\\D", "gi"), "");
   gebdat = gebdat.substring(0,4) + gebdat.substring(6,8);
   var id = document.bewform.dpw_data_ybw_svnr.value + gebdat;
   var sv1 = id.substring(0,1);
   var sv2 = id.substring(1,2);
   var sv3 = id.substring(2,3);
   var sv4 = id.substring(3,4);
   var sv5 = id.substring(4,5);
   var sv6 = id.substring(5,6);
   var sv7 = id.substring(6,7);
   var sv8 = id.substring(7,8);
   var sv9 = id.substring(8,9);
   var sv10 = id.substring(9,10);
   
   var ganze = ((sv1 * 3) + (sv2 * 7) + (sv3 * 9) + (sv5 * 5) + (sv6 * 8) + (sv7 * 4) + (sv8 * 2) + (sv9 * 1) + (sv10 * 6));
   var rest = parseInt(ganze / 11, 10);
   rest = rest * 11;
   rest = ganze - rest;
   if (rest <= 9 && rest != sv4) 
   {
      return false;
   }
   else
   {
      return true;
   }
}

/*------------------------------------------------------------------------------

  file:          validate.js

  written by:    gerfried aigner - dpw H.R. software GmbH
  written on:    Jan 2 2004

  description:   holds globally used javascript functions for validating
                 different data types in an input and aides for programming.

  ----------------------------- revision history -----------------------------

  date          author     change description

  Jan 02 2004   g aigner   initial release
  Feb 01 2004   g aigner   - added the calendar object and its functions
  Mar 29 2004   g aigner   - added the trim() function
  Apr 21 2004   g aigner   - calendar uses getFullYear() now, eliminates y2k
                             bug

------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------
  trim()

  returns the supplied text paramater without any spaces
------------------------------------------------------------------------------*/
function trim(text) {
   return text.replace(new RegExp(" ", "gi"), "");
}

/*------------------------------------------------------------------------------
  floatBlur()

  meant to be called upon the onblur-Event of an input. Formats the input's
  value to represent a float data type with the desired number of decimal
  places. NOTE: uses the German "," for the decimal point
------------------------------------------------------------------------------*/
function floatBlur(input, decimal_places) {
   // progress unknown value backdoor
   if (input.value == "?" || input.value == "") return;

   var rg = new RegExp("\\D", "gi");
   var number = input.value;
   var leading, trailing, pos, minus;
   
   if (arguments.length == 1) decimal_places = 2;
   if (number.indexOf("-") == 0) minus = "-";
   else minus = "";
   if ((pos = number.indexOf(",")) >= 0) {
      leading = number.substring(0, pos).replace(rg, "");
      trailing = number.substring(pos + 1).replace(rg, "");

      if (leading == "") leading = "0";
      while (trailing.length < decimal_places) trailing += "0";
      trailing = trailing.substring(0, decimal_places);
   }
   else {
      leading = number.replace(rg, "");
      trailing = "";
      if (leading == "") leading = "0";
      while (trailing.length < decimal_places) trailing += "0";
   }
   input.value = minus + leading + "," + trailing;
}

/*------------------------------------------------------------------------------
  intBlur()

  meant to be called upon the onblur-Event of an input. Formats the input's
  value to represent an integer data type
------------------------------------------------------------------------------*/
function intBlur(input) {
   // progress unknown value backdoor
   if (input.value == "?" || input.value == "") return;

   var number = input.value;
   var pos, minus;

   if (number.indexOf("-") == 0) minus = "-";
   else minus = "";
   if ((pos = number.indexOf(",")) >= 0) number = number.substring(0, pos);
   number = number.replace(new RegExp("\\D", "gi"), "");
   if (number == "") number = 0;
   input.value = minus + number;
}

/*------------------------------------------------------------------------------
  isLeapYear()

  helper; returns true if supplied year is a leap year. based on the Gregorian
  algorithm of 1582
------------------------------------------------------------------------------*/
function isLeapYear(y) {
   if (y%4) return false;
   if (y%100) return true;
   if (y%400) return false;
   return true;
}

/*------------------------------------------------------------------------------
  dateBlur()

  meant to be called upon the onblur-Event of an input. Formats the input's
  value to represent an date data type. uses warnings in German if an error
  occurs
------------------------------------------------------------------------------*/
function dateBlur(input) {
   // progress unknown value backdoor
   if (input.value == "?" || input.value == "") return;

   var date = input.value.replace(new RegExp("\\D", "gi"), "");
   var today = new Date();
   var months = new Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
   var d, m, y;

   switch (date.length) {
      case 4:
         d = date.substring(0, 2);
         m = date.substring(2, 4);
         y = today.getFullYear();
         break;
      case 6:
         d = date.substring(0, 2);
         m = date.substring(2, 4);
         y = date.substring(4, 6);
         if (y > 30) y = "19" + y;
         else y = "20" + y;
         break;
      case 8: 
         d = date.substring(0, 2);
         m = date.substring(2, 4);
         y = date.substring(4, 8);
         break;
      default:
         if (date.length == 0) {
            input.value = "";
            return;
         }
         d = m = y = 0;
         break;
   }
   if (document.bewform.joblang.value == "E")
   {
      if (d == 0 && m == 0 && y == 0) alert("Your input contains " + date.length + " digits.\n\n TIP: the following inputformats are ok:\n\t ddmmyy\n\t ddmmyyyy\n\t dd-mm-yyyy");
      else if (d < 1 || d > 31) alert("Value for day has to be between  1 and 31.");
      else if (m < 1 || m > 12) alert("Value for month has to be between 1 and 12.");
      else if (d == 31 && m == "04") alert("The month April has only 30 days.");
      else if (d == 31 && m == "06") alert("The month June has only 30 days.");
      else if (d == 31 && m == "09") alert("The month September has only 30 days.");
      else if (d == 31 && m == "11") alert("The month November has only 30 days.");
      else if (m == "02" && isLeapYear(y) && d > 29) alert("The month February has in the year " + y + " only 29 days.");
      else if (m == "02" && !isLeapYear(y) && d > 28) alert("The month February has in the year " + y + " only 28 days.");
      else {
         input.value = d + "-" + m + "-" + y;
         return;
      }
   }
   else
   {
      if (d == 0 && m == 0 && y == 0) alert("Ihre Eingabe enthält " + date.length + " Zeichen.\n\n TIP: Folgende Eingabeformate sind zulässig:\n\t ddmmyy\n\t ddmmyyyy\n\t dd-mm-yyyy");
      else if (d < 1 || d > 31) alert("Der Wert für Tag muß zwischen 1 und 31 liegen.");
      else if (m < 1 || m > 12) alert("Der Wert für Monat muß zwischen 1 und 12 liegen.");
      else if (d == 31 && m == "04") alert("Der Monat April hat nur 30 Tage.");
      else if (d == 31 && m == "06") alert("Der Monat Juni hat nur 30 Tage.");
      else if (d == 31 && m == "09") alert("Der Monat September hat nur 30 Tage.");
      else if (d == 31 && m == "11") alert("Der Monat November hat nur 30 Tage.");
      else if (m == "02" && isLeapYear(y) && d > 29) alert("Der Monat Februar hat im Jahr " + y + " nur 29 Tage.");
      else if (m == "02" && !isLeapYear(y) && d > 28) alert("Der Monat Februar hat im Jahr " + y + " nur 28 Tage.");
      else {
         input.value = d + "-" + m + "-" + y;
         return;
      }
   }
   input.select();
   input.focus();
   return false;
}

function dBlur(input) {
   // progress unknown value backdoor
   if (input.value == "?" || input.value == "") return;

   var date = input.value.replace(new RegExp("\\D", "gi"), "");
   var today = new Date();
   var months = new Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
   var d, m, y;

   switch (date.length) {
      case 4:
         d = date.substring(0, 2);
         m = date.substring(2, 4);
         y = today.getFullYear();
         break;
      case 6:
         d = date.substring(0, 2);
         m = date.substring(2, 4);
         y = date.substring(4, 6);
         if (y > 30) y = "19" + y;
         else y = "20" + y;
         break;
      case 8: 
         d = date.substring(0, 2);
         m = date.substring(2, 4);
         y = date.substring(4, 8);
         break;
      default:
         if (date.length == 0) {
            input.value = "";
            return;
         }
         d = m = y = 0;
         break;
   }
   input.value = d + "-" + m + "-" + y;
   if (document.bewform.joblang.value == "E")
   {
      if (d == 0 && m == 0 && y == 0) alert("Your input contains " + date.length + " digits.\n\n TIP: the following inputformats are ok:\n\t ddmmyy\n\t ddmmyyyy\n\t dd-mm-yyyy");
      else if (d < 1 || d > 31) alert("Value for day has to be between  1 and 31.");
      else if (m < 1 || m > 12) alert("Value for month has to be between 1 and 12.");
      else if (d == 31 && m == "04") alert("The month April has only 30 days.");
      else if (d == 31 && m == "06") alert("The month June has only 30 days.");
      else if (d == 31 && m == "09") alert("The month September has only 30 days.");
      else if (d == 31 && m == "11") alert("The month November has only 30 days.");
      else if (m == "02" && isLeapYear(y) && d > 29) alert("The month February has in the year " + y + " only 29 days.");
      else if (m == "02" && !isLeapYear(y) && d > 28) alert("The month February has in the year " + y + " only 28 days.");
      else {
         input.value = d + "-" + m + "-" + y;
         return;
      }
   }
   else
   {
      if (d == 0 && m == 0 && y == 0) alert("Ihre Eingabe enthält " + date.length + " Zeichen.\n\n TIP: Folgende Eingabeformate sind zulässig:\n\t ddmmyy\n\t ddmmyyyy\n\t dd-mm-yyyy");
      else if (d < 1 || d > 31) alert("Der Wert für Tag muß zwischen 1 und 31 liegen.");
      else if (m < 1 || m > 12) alert("Der Wert für Monat muß zwischen 1 und 12 liegen.");
      else if (d == 31 && m == "04") alert("Der Monat April hat nur 30 Tage.");
      else if (d == 31 && m == "06") alert("Der Monat Juni hat nur 30 Tage.");
      else if (d == 31 && m == "09") alert("Der Monat September hat nur 30 Tage.");
      else if (d == 31 && m == "11") alert("Der Monat November hat nur 30 Tage.");
      else if (m == "02" && isLeapYear(y) && d > 29) alert("Der Monat Februar hat im Jahr " + y + " nur 29 Tage.");
      else if (m == "02" && !isLeapYear(y) && d > 28) alert("Der Monat Februar hat im Jahr " + y + " nur 28 Tage.");
      else {
         input.value = d + "-" + m + "-" + y;
         return;
      }
   }
   input.select();
   input.focus();
   return;
}
/*------------------------------------------------------------------------------
  OBJECT calendar

  object representation of a choosable calendar. upon calling the show()
  method, a window will popup that holds the desired month. read through code
  for better understanding
------------------------------------------------------------------------------*/
function calendar(x,y,input, date, firstOfWeek) {
   // static porperties
   calendar.document = null;
   calendar.today = new Date();
   calendar.date = calendar.today;
   calendar.input = input;
   calendar.firstOfWeek = 1;

   switch (arguments.length) {
      case 4:
         calendar.date = date;
         break;
      case 5:
         calendar.date = date;
         calendar.firstOfWeeK = firstOfWeek;
         break;
   }

   try {
     calendar.x = x;
     calendar.y = y;
   } catch(e) {
      calendar.x = calendar.y = 0;
   }

   // static methods
   calendar.show = function() {
      if (calendar.document == null)
         calendar.document = window.open("", "Calender", "width=180px,height=140px,left=" + calendar.x + ",top=" + calendar.y).document;
      calendar.document.open();
      calendar.document.clear();
      calendar.document.writeln("<html><head><title>Kalender</title>");
      calendar.document.writeln("<style>");
      calendar.document.writeln("body {padding:0;margin:0;cursor:default;font:14,Arial}");
      calendar.document.writeln("table {font:14,Arial;text-align:center}");
      calendar.document.writeln(".today {background-color:#0080ff;color:#ffffff}");
      calendar.document.writeln(".nav {text-decoration:none;background-color:#707070;color:#ffffff}");
      calendar.document.writeln("th {background-color:#0010ff;color:#ffffff;font-weight:normal}");
      calendar.document.writeln("a {text-decoration:none;color:#000000}");
      calendar.document.writeln("</style></head>");
      calendar.document.writeln("<body onblur='window.focus()' style='padding:0;cursor:default'>");
      calendar.document.writeln("<table width='100%' cellspacing='0' cellpadding='0'>");
      calendar.document.writeln("<tr>");
      calendar.document.writeln("<td class='nav' colspan='2' align='right'>");
      calendar.document.writeln("<a class='nav' href='javascript:opener.calendar.prev(true)'>&laquo;</a>");
      calendar.document.writeln("<a class='nav' href='javascript:opener.calendar.prev(false)'>&lsaquo;</a>");
      calendar.document.writeln("</td><td class='nav' colspan='3' align='center'>");

      if ((calendar.date.getMonth() + 1) < 10) calendar.document.write("0");
      calendar.document.writeln(String(calendar.date.getMonth() + 1) + "/" + calendar.date.getFullYear());

      calendar.document.writeln("</td><td class='nav' colspan='2' align='left'>");
      calendar.document.writeln("<a class='nav' href='javascript:opener.calendar.next(false)'>&rsaquo;</a>");
      calendar.document.writeln("<a class='nav' href='javascript:opener.calendar.next(true)'>&raquo;</a>");
      calendar.document.writeln("</td></tr>");
      calendar.document.writeln("<tr><th>M</th><th>D</th><th>M</th><th>D</th><th>F</th><th>S</th><th>S</th></tr>");
      for (var i=0; i<calendar.getDay(new Date(calendar.date.getFullYear(), calendar.date.getMonth(), 1)); i++)
         calendar.document.writeln("<td>&nbsp;</td>");
      for (var i=1; i<=calendar.getDaysInMonth(calendar.date); i++) {
         calendar.document.write("<td");
         if (calendar.today.getFullYear() == calendar.date.getFullYear() && calendar.today.getMonth() == calendar.date.getMonth() && calendar.today.getDate() == i)
            calendar.document.write(" class='today' title='Heute'");
         calendar.document.write("><a href='javascript:opener.calendar.setDate(new Date(");
         calendar.document.write(calendar.date.getFullYear() + "," + calendar.date.getMonth() + "," + i + "));window.close()'>");
         calendar.document.writeln(i + "</td>");
         if (calendar.getDay(new Date(calendar.date.getFullYear(), calendar.date.getMonth(), i)) == 6)
            calendar.document.writeln("</tr><tr>");
      }
      calendar.document.writeln("</tr></table>");
      calendar.document.writeln("</body></html>");
      calendar.document.close();
      if(window.event) {
	calendar.document.focus();
      }
   }
   calendar.getDaysInMonth = function(date) {
      var month = date.getMonth();
      var year = date.getFullYear();

      if (month == 3 || month == 5 || month == 8 || month == 10) return 30;
      if (month == 1) {
         if (year % 4) return 28;
         if (year % 100) return 29;
         if (year % 400) return 28;
         return 29;
      }
      return 31;
   }
   calendar.getDay = function(date) {
      return ((date.getDay() + 7 - calendar.firstOfWeek) % 7);
   }
   calendar.jumpToDate = function(y, m) {
      calendar.date = new Date(y, m, 1);
      calendar.show();
   }
   calendar.next = function(moveFullYear) {
      if (moveFullYear) {
         calendar.jumpToDate(calendar.date.getFullYear() + 1, calendar.date.getMonth());
      } else {
         if (calendar.date.getMonth() == 11)
            calendar.jumpToDate(calendar.date.getFullYear() + 1, 0);
         else
            calendar.jumpToDate(calendar.date.getFullYear(), calendar.date.getMonth() + 1);
      }
   }
   calendar.prev = function(moveFullYear) {
      if (moveFullYear) {
         calendar.jumpToDate(calendar.date.getFullYear() - 1, calendar.date.getMonth());
      } else {
         if (calendar.date.getMonth() == 0)
            calendar.jumpToDate(calendar.date.getFullYear() - 1, 11);
         else
            calendar.jumpToDate(calendar.date.getFullYear(), calendar.date.getMonth() - 1);
      }
   }
   calendar.setDate = function(date) {
      var d, m, y;
      d = date.getDate();
      m = date.getMonth() + 1;
      y = date.getFullYear();
      if (d < 10) d = "0" + d;
      if (m < 10) m = "0" + m;
      calendar.input.value = d + "-" + m + "-" + y;
   }
   // instance methods
   this.show = calendar.show;
   // internal
   return this;
}
