var submitted_by_button=0;

function CheckSingleFileBox(id)
{
	a	= document.getElementById(id).value;
	if (a.length==0)
	{
		window.alert('FEHLER: Keine Datei von Ihrer Festplatte ausgewaehlt!');
		return false;
	}
	else
	{
		return true;
	}
}

function CheckFileUploadBox(id_filebox,id_textbox)
{
	//parameter
	//id: id der File-Upload-Box
	//id: id der Dokument-Titel-Textbox

	f	= document.getElementById(id_filebox).value;
	t	= document.getElementById(id_textbox).value;

	if (f.length==0 && t.length==0)
	{
		window.alert('FEHLER: Keine Datei ausgewaehlt und kein Dokument-Titel angegeben!');
		return false;
	}
	else if (f.length==0 && t.length > 0)
	{
		window.alert('FEHLER: Keine Datei ausgewaehlt!');
		return false;
	}
	else if (f.length>0 && t.length == 0)
	{
		window.alert('FEHLER: Kein Dokument-Titel angegeben!');
		return false;
	}
	else if (f.length>0 && t.length>0)
	{
		return true;
	}
	else
	{
		window.alert('FEHLER: Formular nicht vollstaendig ausgefuellt!');
		return false;
	}
}

function CheckFileRenameBox(id_textbox)
{
	//parameter
	//id: id der Dokument-Titel-Textbox

	t	= document.getElementById(id_textbox).value;

	if (t.length==0)
	{
		window.alert('FEHLER: Kein Dokument-Titel angegeben!');
		return false;
	}
	else
	{
		return true;
	}
}

function CheckMaxLength(obj, MaxLen)
{
	if(obj.value.length > MaxLen)
	{
		window.alert('Ihr Eingabetext ist zu lang ...');
		obj.value = obj.value.substring(0, MaxLen);
	}
}

function CheckTel(obj)
{
	if (String(obj.value).match(/^01|070/gi))
	{
		;
	}
	else
	{
		var neustr	= obj.value.replace(/[ ]*\/[ ]*/, '/');
		neustr		= neustr.replace(/[^0-9\,\-\/]/, '');
		obj.value	= neustr;
	}
}

function CheckEmail(obj)
{
	var neustr	= obj.value.replace(/[ ]+/, '');
	obj.value	= neustr;
}

function CheckHomepage(obj)
{
	var neustr	= obj.value.replace(/[ ]+/, '');
	obj.value	= neustr;
}

function MW_trim(str)
{
	str	= str.replace(/^\s*|\s*$/g,"");
	str	= str.replace(/^\t*|\t*$/g,"");
	str	= str.replace(/^\s*|\s*$/g,"");
	return str;
}

function ReallySendForm()
{
	if (submitted_by_button > 0)
	{
		return true;
	}
	else
	{
		check	= confirm("Formular jetzt abschicken?");
		if (check)
		{ return true; }
		else
		{ return false; }
	}
}

function ReallySendForm_Custom(str)
{
	check	= confirm(str);
	if (check)
	{ return true; }
	else
	{ return false; }
}

function newwindow(desturl,winname)
{
        var dynimg=0;
		var getstr_sep = "?";
        //browsname = navigator.appName;
        //browsver = parseInt(navigator.appVersion);

		var wwidth=740;
		var wheight=500;

        if (screen.width >= 1024 && screen.height >= 768)
        {
        	//wwidth = screen.width - 150;
        	//wheight = screen.height - 200;
        	wwidth = 740;
        	wheight = 600;
        }
        
        if (winname=='')
        {       jetzt = new Date();
                winname=jetzt.getTime(); 
        }
        desturl = desturl;
		if (desturl.indexOf("?") >= 0)
		{
			getstr_sep = "&amp;";
		}
        var fenster = window.open(desturl + getstr_sep + "mode=nw1", winname, "width=" + wwidth + ",height=" + wheight + ",left=20,top=20,toolbar=1,location=1,status=1,menubar=0,scrollbars=1,resizable=1");
		fenster.window.focus();
}


