// Seite empfehlen
function recommend( QS ) {
	var	fenster	=	window.open("empfehlen.asp?"+QS+"", "fenster", "width=350,height=360,scrollbars=no,menubar=no,resizable=no,status=no,toolbar=no,dependent=yes" );
}
function get( ID ) {
	return document.getElementById( ID );
}
function showMap( Bild ) {
	if( Div = get( "SHOWMAP" ) ) {
		grey						=	document.getElementById( "GREY" );
		grey.style.height			=	getOffsetHeight() + "px";
		grey.style.display			=	"block";
		if( window.innerWidth ) {																			// Prüfen, ob Netscape, Mozilla, Opera
			width	=	window.innerWidth;																	// Breite setzen
		}
		else {																								// oder IE
			width	=	window.document.body.offsetWidth;													// Breite setzen
		}
		Div.style.zIndex			=	11;
		Div.style.display			=	"block";
		left	=	( width - parseInt( Div.offsetWidth ) - 16 ) / 2;
		Div.style.left	=	left + "px";
	}
}
var	GlbOffsetHeight	=	0;
function getOffsetHeight() {
	if( GlbOffsetHeight == 0 ) {
		GlbOffsetHeight	=	get( "TOP" ).offsetHeight + get( "HEADER" ).offsetHeight + get( "MAIN" ).offsetHeight + get( "BOTTOM" ).offsetHeight + get( "FOOTER" ).offsetHeight + 80;
//		GlbOffsetHeight	=	document.body.offsetHeight;
	}
	return GlbOffsetHeight;
}
function hideMap( Bild ) {
	if( Div = get( "SHOWMAP" ) ) {
		Div.style.display			=	"none";
		get( "GREY" ).style.display	=	"none";
	}
}
InfoAbstand	=	0;
InfoCheck	=	Array();
function showInfo( ID ) {
	InfoAbstand	=	0;
	if( Div = get( ID ) ) {
		Div.style.display	=	"block";
		if( !document.all ) {
			if( !InfoCheck[ ID ] ) {
				InfoCheck[ ID ]	=	true;
				Div.style.left	=	( Div.offsetLeft + 80 ) + "px";
				if( parseInt( Div.offsetHeight ) < 150 ) {
					Div.style.top	=	( Div.offsetTop + 25 ) + "px";	
				}
			}
		}
		if( Div.offsetTop + Div.offsetHeight > getOffsetHeight() ) {
			Div.style.top	=	( getOffsetHeight() - Div.offsetHeight - InfoAbstand ) + "px";
		}
		else {
//			Div.style.top	=	( parseInt( Div.offsetTop ) ) + "px";;
		}
	}
}
function hideInfo( ID ) {
	if( Div = get( ID ) ) {
		Div.style.display	=	"none";
	}
}
function changeDiv( ID ) {
	if( Div = get( ID ) ) {
		if( Div.style.display == "none" ) {
			Div.style.display	=	"block";
		}
		else {
			Div.style.display	=	"none";
		}
	}
}
function checkMail( Adr ) {
	if( Ind = Adr.indexOf(' ') ) {
		if( Ind != -1 )	{
			return	false;
		}
	}
	if( Ind = Adr.indexOf('@') ) {
		if( Ind > 0 && Ind < Adr.length - 3 ) {
			return	true;
		}
	}
	return	false;
}
function checkNewsletter() {
	Erg	=	true;
	ErrMsg	=	"";
	if( NL_Email = get( "nl_email" ) ) {
		if( NL_Name = get( "nl_name" ) ) {
			if( ! checkMail( NL_Email.value ) ) {
				ErrMsg	+=	FormFailure[ "falsche_email" ] + "\n";
				Erg		=	false;
			}
			if( NL_Name.value == "" || NL_Name.value == NL_Name.defaultValue ) {
				ErrMsg	+=	FormFailure[ "name_fehlt" ] + "\n";
				Erg		=	false;
			}
		}
		else {
			Erg	=	false;
		}
	}
	else {
		Erg	=	false;
	}
	if( Erg == false ) {
		alert( ErrMsg );
		return false;
	}
	return true;
	
}
function markTF( TF ) {
	if( TF.value == "" ) {
		TF.style.backgroundColor	=	Marked;
	}
	else {
		TF.style.backgroundColor	=	"";
	}
}
function markCB( CB ) {
	if( CB.checked ) {
		CB.style.backgroundColor	=	"";
	}
	else {
		CB.style.backgroundColor	=	Marked;
	}
}
function markGSCode( TF ) {
	if( TF.value == "" || TF.value.length == 4 ) {
		TF.style.backgroundColor	=	"";
	}
	else {
		TF.style.backgroundColor	=	Marked;
	}
}
function checkContactForm() {
	Err	=	false;
	ErrorMessage	=	"";
	Muss	=	Array( "surname", "firstname", "street", "hnr", "pc", "phoneday", "town", "email", "message", "Sicherheitscode" );
	for( i=0; i<Muss.length; i++ ) {
		if( TF = get( Muss[ i ] ) ) {
			if( TF.value == "" ) {
				Err	=	true;
				TF.style.backgroundColor	=	Marked;
			}
			else {
				TF.style.backgroundColor	=	"";
				if( Muss[ i ] == "email" ) {
					if( checkMail( TF.value ) ) {
						TF.style.backgroundColor	=	"";
					}
					else {
						Err	=	true;
						TF.style.backgroundColor	=	Marked;
						ErrorMessage	+=	FormFailure[ "falsche_email" ] + "\n";
					}
				}
			}
		}
		else {
			alert( FormFailure[ "critical_error" ] );
			return	false;
		}
	}
	if( Err ) {
		alert( FormError + "\n" + ErrorMessage );
		return	false;
	}
	return	true;

	Erg	=	true;
	ErrMsg	=	"";
	if( CF_Email = get( "email" ) ) {
		if( CF_Name = get( "surname" ) ) {
			if( CF_Strasse = get( "street" ) ) {				
				if( ! checkMail( CF_Email.value ) ) {
					ErrMsg	+=	FormFailure[ "falsche_email" ] + "\n";
					Erg		=	false;
				}
				if( CF_Name.value == "" ) {
					ErrMsg	+=	FormFailure[ "name_fehlt" ] + "\n";
					Erg		=	false;
				}
				if( CF_Strasse.value == "" ) {
					ErrMsg	+=	FormFailure[ "strasse_fehlt" ] + "\n";
					Erg		=	false;
				}
			}
		}
		else {
			Erg	=	false;
		}
	}
	else {
		Erg	=	false;
	}
	if( Erg == false ) {
		alert( ErrMsg );
		return false;
	}
	return true;
	
}

function checkCatalogueForm() {
	Err	=	false;
	ErrorMessage	=	"";
	Muss	=	Array( "surname", "firstname", "street", "hnr", "pc", "town", "email", "message", "Sicherheitscode" );
	for( i=0; i<Muss.length; i++ ) {
		if( TF = get( Muss[ i ] ) ) {
			if( TF.value == "" ) {
				Err	=	true;
				TF.style.backgroundColor	=	Marked;
			}
			else {
				TF.style.backgroundColor	=	"";
				if( Muss[ i ] == "email" ) {
					if( checkMail( TF.value ) ) {
						TF.style.backgroundColor	=	"";
					}
					else {
						Err	=	true;
						TF.style.backgroundColor	=	Marked;
						ErrorMessage	+=	FormFailure[ "falsche_email" ] + "\n";
					}
				}
			}
		}
		else {
			alert( FormFailure[ "critical_error" ] );
			return	false;
		}
	}
	Counter	=	0;
	CBCheck	=	false;
	while( CB = get( "katalog_" + Counter ) ) {
		if( CB.checked ) {
			CBCheck	=	true;
			break;
		}
		Counter++;
	}
	if( ! CBCheck ) {
		Err	=	true;
		ErrorMessage	+=	"Bitte wählen Sie einen Katalog aus.";
	}

	if( Err ) {
		alert( FormError + "\n" + ErrorMessage );
		return	false;
	}
	return	true;
}


function checkEmptyVal( TF, Val ) {
	if( TF.value == "" ) {
		TF.value	=	Val;
	}
}
function focusClear( TF ) {
	if( TF.value == TF.defaultValue ) {
		TF.value	=	"";
	}
}
/*function callInsertImage(InputFieldId)  
{
	var editor = obj_CuteEditor;

	editor.FocusDocument();  
	_Format(editor, "New"); 
	_Format(editor, "InsertImage");

	InputURL();

	document.getElementById(InputFieldId).setAttribute('autocomplete', 'off');
	document.getElementById(InputFieldId).focus();

	function InputURL()
	{
		var editdoc = editor._frame.contentWindow.document;
		var params = editdoc.getElementsByTagName("img");

		if(params.length>0)  
		{
			//imgs[imgs.length-1].src
			var string = params[0].getAttribute('src');				
			var string_pos;

			string = string.replace("http://", "");
			string_pos = string.indexOf("/");
			string = string.substr(string_pos);

			document.getElementById(InputFieldId).value = string;
		}  
		else
		{
			setTimeout(InputURL,500);
		}
	}
}*/
var GlbInputFieldId	=	0;
 // die übergebene InputFieldId wird nun global gesetzt, da sie beim Timeout nicht übergeben wird - dadurch kann der FF sie auch wieder aus den globalen Variablen holen.
 // die bisherige InputFieldId bei InputURL wird komplett ignoriert
 function callInsertImage(InputFieldId) {  
	GlbInputFieldId	=	InputFieldId;
	var editor1 = document.getElementById('CE_CuteEditor_ID');
	editor1.FocusDocument();  
	var editdoc = editor1.GetDocument();  
	editor1.ExecCommand('new');
	editor1.ExecCommand('InsertImage');
	InputURL(InputFieldId);
	// document.getElementById("docFld").focus(); 
	document.getElementById(InputFieldId).setAttribute('autocomplete', 'off');
	document.getElementById(InputFieldId).focus();
}    

	function setAttribAll()
	{
		try {
			document.getElementById("CE_CuteEditor_ID_Frame").style.height = "0";
			document.getElementById("CE_CuteEditor_ID_Frame").style.width = "0";
			document.getElementById("CE_CuteEditor_ID_Frame").style.border = "0px";
		}
		catch( e ) {
			
		}
	}

                            
function InputURL(InputFieldId) { 
	var editor1 = document.getElementById('CE_CuteEditor_ID');
	var editdoc = editor1.GetDocument();  
	var params = editdoc.getElementsByTagName("img");
	
	if(params.length>0) {
		//imgs[imgs.length-1].src
		var string = params[0].getAttribute('src');	
		var string_pos;
		
		string = string.replace("http://", "");
		string_pos = string.indexOf("/");
		string = string.substr(string_pos);
		// Globale Variable für get Funktion nutzen
		document.getElementById(GlbInputFieldId).value = string;
	}  
	else {
		setTimeout(InputURL,500);
	}
}       

function changePerSite( SF ) {
	location.href	+=	"&persite=" + SF.options[ SF.selectedIndex ].value;
}
function print_site() {
	window.print();
}
	// Datumsprüfung und gegebenenfalls formatierung
	function checkDate( TF ) {
		if( !DateError ) {
			var	DateError	=	"Bitten geben Sie ein korrektes Datum an (tt.mm.yyyy)";
		}
		Fehler	=	true;
		if( TF.value != "" ) {
			Data	=	TF.value.split( "." );
			if( Data.length == 3 ) {
				Tag		=	Data[ 0 ]; 
				Monat	=	Data[ 1 ];
				Jahr	=	Data[ 2 ];
				if( ! isNaN( Tag ) && ! isNaN( Monat ) && ! isNaN( Jahr ) ) {
					if( Datum = new Date( Jahr, Monat-1, Tag ) ) {
						if( Datum.getDate() == Tag && Datum.getMonth() == Monat - 1 && Jahr < 9999 ) {
							if( Tag < 10 || Monat < 10 || Jahr.length < 4 ) {
								if( Tag.length < 2 ) Tag = "0" + Tag;
								if( Monat.length < 2 ) Monat = "0" + Monat;
								if( Jahr < 1000 ) {
									if( Jahr.length == 0 ) {
										T_Jahr	=	new	Date();
										Jahr	=	T_Jahr.getYear();
									}
									else {
										if( Jahr.length == 1 ) {
											Jahr	=	"200" + Jahr;
										}
										else {
											if( Jahr.length == 2 ) {
												Jahr	=	"20" + Jahr;
											}
											else {
												Jahr	=	"2" + Jahr;
											}
										}
									}
								}
								T_Jahr	=	new	Date();
								if( Jahr < T_Jahr.getYear() ) Jahr = T_Jahr.getYear();
//								if( new Date( Jahr, Monat-1, Tag ) < T_Jahr ) {
//									Jahr = T_Jahr.getYear() + 1;
//								}
								TF.value	=	Tag + "." + Monat + "." + Jahr;
							}
							Fehler	=	false;
						}
					}
				}
			}
			if( Fehler ) {
				alert( DateError );
				TF.value	=	"";
				TF.focus();
				TF.select();
				return false;
			}
		}
		return true;
	}
	
	function toDate( Str ) {
		Erg	=	new	Date();
		Data	=	Str.split( "." );
		if( Data.length == 3 ) {
			Tag		=	Data[ 0 ];
			Monat	=	Data[ 1 ];
			Jahr	=	Data[ 2 ];
			if( ! isNaN( Tag ) && ! isNaN( Monat ) && ! isNaN( Jahr ) ) {
				if( Datum = new Date( Jahr, Monat-1, Tag ) ) {
					Erg	=	Datum;
				}
			}
		}
		return Erg;
	}
//
function pageflip () {
	var	fenster	= window.open("katalog/index.html", "fenster", "width=680,height=560,scrollbars=no,menubar=no,resizable=no,status=no,toolbar=no,dependent=yes" );
}