


function checkGrusstext(obj){
  //if(obj.checked==false) getObj('grusstext').value = '' ;
}

function setGrusstext(obj, text){
	// Nutzt function getObj aus calendar.js !!!
	getObj(obj).value = text;
	//getObj('grusskarte').checked = true;
}


function getObj(objID){
    if (document.getElementById) {return document.getElementById(objID);}
    else if (document.all) {return document.all[objID];}
    else if (document.layers) {return document.layers[objID];}
}

function swapElementVisibility(elementId, checkbox){
	customerDiv = document.getElementById(elementId);
	if( checkbox.checked == false){
		customerDiv.style.display = 'none';
	} else {
		customerDiv.style.display = 'block';
	}
}


function openWindow(mode, url){

	if(mode=='garantie'){
		width="300px";
		height= "400px";
		options = 'scrollbars=yes,status=no,toolbar=no,location=no,directories=no,resizable=yes,menubar=no';
		options = options + ',width=' + width + ',height=' + height;
	}
	
	if(url!=''){
		window.open(url, "imagePopup", options);
	}
}



function check_ForGermanPublicHoliday( date ){
//  var thisDate = convert_ToGermanDate( date ).split('.');

  thisDate = date.split('.');
  var shortDay = thisDate[0] + '.' + thisDate[1] + '.';
  var thisYear = thisDate[2];
  if (shortDay == "01.01.") return "Neujahr";
//  if (shortDay == "02.01.") return "Neujahr Folgetag";
  
//  if (shortDay == "06.01.") return "Dreikönig";
  if (shortDay == "01.05.") return "Tag der Arbeit";
  if (shortDay == "02.05.") return "Tag der Arbeit Folgetag";
  
  if (shortDay == "03.10.") return "Tag der deutschen Einheit";
  if (shortDay == "04.10.") return "Tag der deutschen Einheit Folgetag";

//  if (shortDay == "01.11.") return "Allerheiligen";
//  if (shortDay == "24.12.") return "(Heilig Abend)";
  if (shortDay == "25.12.") return "1. Weihnachtstag";
  if (shortDay == "26.12.") return "2. Weihnachtstag";
  if (shortDay == "27.12.") return "2. Weihnachtstag Folgetag";

 // Temporär gesperrt
  if (shortDay == "23.12.") return "Weihnachtszeit";
  if (shortDay == "24.12.") return "Weihnachtszeit";
  if (shortDay == "28.12.") return "Sylvesterzeit";
  if (shortDay == "29.12.") return "Sylvesterzeit";
  
  
  if (shortDay == "28.12." && thisYear== "2010") return "Weihnachtszeit";

//  if (shortDay == "31.12.") return "(Sylvester)";
  
  var tmpDate;
  // test Weiberfastnacht
//  var tmpDate = check_mobilePublicHoliday( thisYear, -52);
//  if ( shortDay == tmpDate ) return "Weiberfastnacht";
  // test Rosenmontag
//  var tmpDate = check_mobilePublicHoliday( thisYear, -48);
//  if ( shortDay == tmpDate ) return "Rosenmontag";
  // test Fastnachtsdienstag
//  var tmpDate = check_mobilePublicHoliday( thisYear, -47);
//  if ( shortDay == tmpDate ) return "Fastnachtsdienstag";
  // test Aschermittwoch
//  var tmpDate = check_mobilePublicHoliday( thisYear, -46);
//  if ( shortDay == tmpDate ) return "Aschermittwoch";
  // test Gründonnerstag
//  var tmpDate = check_mobilePublicHoliday( thisYear, -3);
//  if ( shortDay == tmpDate ) return "Gründonnerstag";
  // test Karfreitag
  var tmpDate = check_mobilePublicHoliday( thisYear, -2);
  if ( shortDay == tmpDate ) return "Karfreitag";
  var tmpDate = check_mobilePublicHoliday( thisYear, -1);
  if ( shortDay == tmpDate ) return "Karfreitag Folgetag";

  // test Ostersonntag
  var tmpDate = check_mobilePublicHoliday( thisYear, 0);
  if ( shortDay == tmpDate ) return "Ostersonntag";
  // test Ostermontag
  var tmpDate = check_mobilePublicHoliday( thisYear, 1);
  if ( shortDay == tmpDate ) return "Ostermontag";
  var tmpDate = check_mobilePublicHoliday( thisYear, 2);
  if ( shortDay == tmpDate ) return "Ostermontag Folgetag";

  // test Christi Himmelfahrt
  var tmpDate = check_mobilePublicHoliday( thisYear, 39);
  if ( shortDay == tmpDate ) return "Christi Himmelfahrt";
  var tmpDate = check_mobilePublicHoliday( thisYear,40);
  if ( shortDay == tmpDate ) return "Christi Himmelfahrt Folgetag";

  // test Pfingstsonntag
  var tmpDate = check_mobilePublicHoliday( thisYear, 49);
  if ( shortDay == tmpDate ) return "Pfingstsonntag";

  // test Pfingstmontag
  var tmpDate = check_mobilePublicHoliday( thisYear, 50);
  if ( shortDay == tmpDate ) return "Pfingstmontag";
  var tmpDate = check_mobilePublicHoliday( thisYear, 51);
  if ( shortDay == tmpDate ) return "Pfingstmontag Folgetag";

  // test Fronleichnam
//  var tmpDate = check_mobilePublicHoliday( thisYear, 60);
//  if ( shortDay == tmpDate ) return "Fronleichnam";
  
  return '';
}


/**
 *
 * @author Ralf Pfeifer (www.arstechnica.de)
 * leicht modifiziert 
 * immer von Ostern aus Tagesdifferenz = 0 
 */
function check_mobilePublicHoliday( Jahr, TagesDifferenz ) { 

        // Falls kein Datum angegeben, aktuelles Jahr verwenden.
        if ((Jahr == "") || (Jahr == null)) { Jahr = new Date().getYear() }

        // Falls ausserhalb des gültigen Datumsbereichs, kein Ergebnis zurueckgeben
        if ((Jahr < 1970) || (2099 < Jahr)) {  return "Datum muss zwischen 1970 und 2099 liegen"; }

        // Falls keine TagesDifferenz angegeben, TadgesDifferenz auf 0 setzen.
        if ((TagesDifferenz == "") || (TagesDifferenz == null)) { TagesDifferenz = 0; }

        var a = Jahr % 19;
        var d = (19 * a + 24) % 30;
        var Tag = d + (2 * (Jahr % 4) + 4 * (Jahr % 7) + 6 * d + 5) % 7;
        if ((Tag == 35) || ((Tag == 34) && (d == 28) && (a > 10))) { Tag -= 7; }

        var EasterDate = new Date(Jahr, 2, 22)
        // 86400000 = 24 h * 60 min * 60 s * 1000 ms
        // Die Zahl 86400000 nicht ausklammern, sonst gibt's Probleme bei der Typumwandlung !!
        EasterDate.setTime(EasterDate.getTime() + 86400000 * TagesDifferenz + 86400000 * Tag)
        
        var shortDate = make_doubleDigit( EasterDate.getDate() ) + '.' + make_doubleDigit( (EasterDate.getMonth() + 1) ) + '.';
        //alert(EasterDate.getDate())
        return shortDate;

/*
        // Uhrzeit aus dem Datum entfernen
        EasterDate = EasterDate.toLocaleString()
        EasterDate = EasterDate.substring(0, EasterDate.length - 9);
        
        var tmpArr = EasterDate.split('.');
        var shortDate = make_doubleDigit(tmpArr[0]) + '.' + make_doubleDigit(tmpArr[1]) + '.';
        return shortDate;
        //return EasterDate;
        */
        
        
}


/* führende Null */
function make_doubleDigit( value ){
  //var doubleDigit = ((value < 10) ? "0" : "")+ value;
  var doubleDigit = ((String(value).length < 2) ? "0" : "")+ value;
  return doubleDigit;
}
 



