// JavaScript Document

function fillForm ()
	{
	// Retrieve all input elements
	formElements = document.getElementsByTagName('input');
	
	// Retrieve all the textarea elements
	textareaElements = document.getElementsByTagName('textarea');
	
	// Fill all the input elements
	for( var x = 0; x < formElements.length; x++ )
		{
		if( window.location.keyVal( formElements.item(x).name) != false )
			{
			formElements.item(x).value = unescape( window.location.keyVal( formElements.item(x).name));
			}
		}
		
	// Fill all the textarea elements
	for( var x = 0; x < textareaElements.length; x++ )
		{
		if( window.location.keyVal( textareaElements.item(x).name) != false )
			{
			textareaElements.item(x).value = unescape( window.location.keyVal( textareaElements.item(x).name));
			}
		}
	}
	
// This function extends the window object so that it can
// retrieve and return the value of the named GET parameter
window.location.keyVal = function ( keyName )
	{
	// Check to see if we have already retrieved the key value pairs
	// if we haven't then we need to retrieve them
	if( window.location.variablePairs == null )
		{
		if( window.location.href.indexOf('?') == -1)
			{
			return false;	
			}
		window.location.variablePairs = window.location.href.substr( window.location.href.indexOf('?') + 1).split('&');
		}
	
	// Search for the key that matches the keyName supplied
	for( var x = 0; x < window.location.variablePairs.length; x++ )
		{
		// If we find the key name then we retun the value associated with it
		if( keyName == window.location.variablePairs[x].substr( 0, window.location.variablePairs[x].indexOf('=')))
			{
			return window.location.variablePairs[x].substr( window.location.variablePairs[x].indexOf('=') + 1);
			}
		}
	
	// If we couldn't find the key in the GET parameters
	// then we return false
	return false;
	}
	
fillForm();