
function InitContactForm()
{
	document.getElementById( 'contact' ).reset();

	document.getElementById( 's_name' ).focus();
	
	if( document.cookie )
	{
		var strName, strMail, strPhone;
		var strValues = document.cookie.split( '#' );
		if( strValues.length == 3 )
		{
			// move focus immediately to 'subject'
			document.getElementById( 's_subject' ).focus();
			
			var nStart = strValues[0].indexOf( 'name:' );
			if( nStart >= 0 )
			{
				htmlName = document.getElementById( 's_name' ).value = strValues[0].substring( nStart + 5 );
			}
			if( strValues[1].indexOf( 'email:' ) == 0 )
			{
				htmlName = document.getElementById( 's_email' ).value = strValues[1].substring( 6 );
				strMail = strValues[1].substring( 6 );
			}
			if( strValues[2].indexOf( 'phone:' ) == 0 )
			{
				htmlName = document.getElementById( 's_phone' ).value = strValues[2].substring( 6 );
			}
			// set checkmark...
			document.getElementById( 'savedata' ).checked = true;
		}
	}

	var strBrowser;
	strBrowser = navigator.appName + ', ' + navigator.appVersion;
	document.getElementById( 'browser' ).value = strBrowser;
}

function ValidateForm()
{
	// check if name and valid eMail is specified
	var htmlName, htmlMail;
	
	htmlName = document.getElementById( 's_name' );
	htmlMail = document.getElementById( 's_email' );
	
	if( htmlName == null || htmlMail == null )
	{
		return false;
	}
	
	// name?
	if( htmlName.value == '' )
	{
		alert( 'Sie haben keinen Namen eingeben!' );
		htmlName.focus();
		return false;
	}
	// e-Mail?
	if( htmlMail.value == '' )
	{
		alert( 'Sie haben keine e-Mail Adresse eingeben!' );
		htmlMail.focus();
		return false;
	}
	
	// simple check of Mail (including '@' and '.' in domain)
	var strMail = htmlMail.value;
	var nAt, nDot;
	nAT = strMail.indexOf( '@' );
	nDot = strMail.indexOf( '.' );
	if( nAt == -1 || nDot == -1 || nDot < nAt )
	{
		alert( 'Die eingegebene e-Mail Adresse ist nicht korrekt!' );
		htmlMail.focus();
		return false;
	}
	
	// if valid, check if user want to save data in cookie
	if( document.getElementById( 'savedata' ).checked )
	{
		document.cookie = 'name:'+ htmlName.value + '#email:' + strMail + '#phone:' + document.getElementById( 's_phone' ).value;
	}
	else
	{
		document.cookie = 'x;expires=Thu, 01-Jan-70 00:00:01 GMT';
	}
	
	return true;
}

