function updateEmailMessage()
{
	var senderName = document.getElementById('senderName').value;
  document.getElementById('message').value = 'Hi,\n\nYou won\'t believe this. Google just dedicated a separate homepage for me.\n\nYou can check it out here.\nhttp://www.BlingMySearch.com/bms/google/' + escape(senderName.replace(' ', '+')) + '\n\n' + senderName;
}

function generateSearchPage() {
	// get elements
	var errorMessageDisplay = document.getElementById('errorMessageDisplay');
	var nameField = document.getElementById('nameField');
	var typeField = document.forms['InviteForm'].type;

	// reset the error message display
	errorMessageDisplay.style.display = 'none';

	// validate the name
	if(nameField.value.length > 30) {
		errorMessageDisplay.innerHTML = "Name is too long: maximum characters is 30";
		errorMessageDisplay.style.display = 'block';

		return false;
	}
	else if(nameField.value.length == 0)
	{
    errorMessageDisplay.innerHTML = "Please type your Name";
    errorMessageDisplay.style.display = 'block';

    return false;
	}

	// get the Type
	var typeSelected = false;
	var typeValue = '';
	for(var i = 0; i < typeField.length; i ++) {
		if(typeField[i].checked) {
			typeValue = typeField[i].value;
			typeSelected = true;
			break;
		}
	}

  // ensure that a Type has been selected
	if(! typeSelected) {
    errorMessageDisplay.innerHTML = "Please select a Logo type";
    errorMessageDisplay.style.display = 'block';

    return false;
	}
	else {
		// ensure that the Logo-type is correct
		switch(typeValue) {
			case 'google':
			case 'bling':
			case 'blue-glitter':
			case 'red-glitter':
			case 'hearts':
			case 'candy-cane':
			case 'flames':
			case 'inferno':
			case 'blue-inferno':
			  break;
			default:
		    errorMessageDisplay.innerHTML = "Please select a VALID Logo type";
		    errorMessageDisplay.style.display = 'block';

		    return false;
		    break;
		}
	}

	// build the full URL to the Search page
	var fullLogoURL = 'http://' + document.domain + '/bms/' + typeValue + '/' + escape(nameField.value);
	
	// set as Homepage (on IE) only
	if(navigator.appVersion.indexOf('MSIE') != -1 && document.getElementById) {
	  document.getElementsByTagName('body')[0].style.behavior = 'url(#default#homepage)';
	  document.getElementsByTagName('body')[0].sethomepage(fullLogoURL);
	}

	// go to the personal Search page
	location = fullLogoURL;

	// do not post the form
	return false;
}

