// ****************************************************************************
// checkDate(Datum, m): Check for correct date by rechecking month of date obj.
// ****************************************************************************
function checkDate(Datum, m) {
	if ( m == Datum.getMonth() + 1 )
    	return(true);
  	else
    	return(false);
}

// ****************************************************************************
// checkDateStr(str, format): Returns false if str not format, otherwise true
// format like YYYY/MM/DD, MM/DD/YYYY, DD.MM.YYYY
// ****************************************************************************
function checkDateStr(str, format) {
	var day, mon, year;
	var dDate;
	year = str.substring(format.indexOf('Y'), format.lastIndexOf('Y')+1);
	mon = str.substring(format.indexOf('M'), format.lastIndexOf('M')+1);
	day = str.substring(format.indexOf('D'), format.lastIndexOf('D')+1);
	if ( day < 1 || day > 31 ) 			return(false);
	if ( mon < 1 || mon > 12 ) 			return(false);
	if ( year < 1800 || year > 2100 ) 	return(false);
	dDate = new Date(year, mon - 1, day);
	return(checkDate(dDate, mon));
}

// ****************************************************************************
// compareDates(dat1, dat2, format): Returns true if dat2 later than dat1, 
// otherwise false; format like YYYY/MM/DD, MM/DD/YYYY, DD.MM.YYYY
// ****************************************************************************
function compareDates(dat1, dat2, format) {
	var d1, m1, y1;
	var d2, m2, y2;
	var dDat1, dDat2;
	y1 = dat1.substring(format.indexOf('Y'), format.lastIndexOf('Y')+1);
	m1 = dat1.substring(format.indexOf('M'), format.lastIndexOf('M')+1);
	d1 = dat1.substring(format.indexOf('D'), format.lastIndexOf('D')+1);
	y2 = dat2.substring(format.indexOf('Y'), format.lastIndexOf('Y')+1);
	m2 = dat2.substring(format.indexOf('M'), format.lastIndexOf('M')+1);
	d2 = dat2.substring(format.indexOf('D'), format.lastIndexOf('D')+1);
	dDat1 = new Date(y1, m1 - 1, d1);
	dDat2 = new Date(y2, m2 - 1, d2);
	return(dDat1<dDat2);
}

function checkEmail(emailStr) {
        if ((emailStr.length == 0) ||
                 (emailStr.indexOf('@') >= 0 && emailStr.indexOf('.') >= 0))
                return true;
        else
                return false;
}
function checkRadio(radioButton) {
	var i;
	if ( radioButton.checked ) return(0);
	for ( i=0; i<radioButton.length; i++ ) {
		if ( radioButton[i].checked ) return(i);
	}
	return(-1);
}

function getFilename(filename) {
	filename = filename.toLowerCase();
	filename = filename.replace(/ /g, "_");
	filename = filename.replace(/ä/g, "ae");
	filename = filename.replace(/ö/g, "oe");
	filename = filename.replace(/ü/g, "ue");
	filename = filename.replace(/ß/g, "ss");
	filename = filename.replace(/[\+!\"§$%\'\?\/\\=,;:#]/g, "");
	filename = escape(filename);
	return(filename);
}

function jumpTo(anchor) {
	var oldloc, newloc, pos;
	oldloc = self.location + "";
	pos = oldloc.indexOf("#");
	if ( pos > 0 ) {
		oldloc = oldloc.substr(0, pos);
	}
	newloc = oldloc + "#" + anchor;
	self.location = newloc;
	return(true);
}

function openDetailWindow(theURL) {
	DetailWindow = window.open(theURL,'DetailWindow', 'scrollbars=no,resizable=no,width=610,height=350');
	setTimeout('DetailWindow.focus();',250);
}

function openPasswordWindow(theURL) {
	PasswordWindow = window.open(theURL,'PasswordWindow', 'scrollbars=no,resizable=no,width=610,height=150');
	setTimeout('PasswordWindow.focus();',250);
}

function openTestWindow(theURL) {
	TestWindow = window.open(theURL,'TestWindow', 'scrollbars=no,resizable=yes,width=610,height=550');
	setTimeout('TestWindow.focus();',250);
}

function openSmallWindow(theURL) {
	SmallWindow = window.open(theURL,'SmallWindow', 'scrollbars=no,resizable=no,width=10,height=10');
	setTimeout('SmallWindow.focus();',250);
}

function refreshTaisMain(theURL) {
	tais_main = window.open(theURL,'tais_main','');
}

function diff(val1, val2) {
	if ( val1 != val2 )
		return(1);
  	else
    	return("");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  NewWin = window.open(theURL,winName,features);
	setTimeout('NewWin.focus();',250);
  
}
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 call_preload() {
  MM_preloadImages('/files/sysimages/menu_quadrat_sw.gif')
}

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_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 checkEmail(emailStr)
{
	if ((emailStr.length == 0) ||
		 (emailStr.indexOf('@') >= 0 && emailStr.indexOf('.') >= 0))
			return true;
	else
			return false;
}
function checkData()
{
	if ( document.formular.Name.value.length == 0 ) {
		alert("Bitte geben Sie Ihren Namen an!");
			document.formular.Name.focus();
		return false;
	}
	if ( checkEmail(document.formular.EMAIL.value) == false ) {
		alert("Bitte geben Sie eine korrekte E-Mail-Adresse ein!");
			document.formular.EMAIL.focus();
		return false;
	}
	return true;
}

function openScrollWin(loc, dx, dy) {
	ScrollWin=window.open(loc,'ScrollWin','toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=' + dx + ',height=' + dy);
	//if ( javascript_version > 1.0 )
		setTimeout('ScrollWin.focus();',250);
	return(true);
}

function startIFrame(loc) {
	if ( navigator.userAgent.indexOf('MSIE') > -1 && navigator.appVersion.charAt(0) >= 3 || 
		 navigator.userAgent.indexOf('Mozilla') > -1 && navigator.appVersion.charAt(0) >= 5 )
		return(false);
	openScrollWin(loc, 700, 600);
	return(true);
}

