/*

	Filename:          script.js
	Description:       Javascript functions
	Client:            Jeff Feldman
        Start date:        01-16-06
	Last modification: 12-05-08

*/

//
// Function:    showheader()
//
// Description: Display RE/MAX header
//
function showheader () {

	var header_fill = screen.width - 800;

	document.write('<TABLE border=0 cellpadding=0 cellspacing=0><TR>');
	document.write('<TD valign="top"><IMG src="image/remax_header.jpg" width=770 height=130></IMG></TD>');
	document.write('<TD valign="top"><IMG src="image/header_pattern.jpg" width=' + header_fill + ' height=110></IMG></TD>');
	document.write('</TR></TABLE>');

	return(0);

}

//
// Function:    showfooter()
//
// Description: Display header pattern as footer
//
function showfooter () {

	var footer_width = screen.width - 30;

	document.write('<TABLE border=0 cellpadding=0 cellspacing=0><TR><TD>');
	document.write('<IMG src="image/header_pattern.jpg" width=' + footer_width + ' height=10></IMG>');
	document.write('</TD></TR></TABLE>');

	return(0);

}

//
// Function:    openform()
//
// Description: Open form, centered in new window
//
// Input:
//  file   = Filename of document to open
//  width  = Width (pixels) of new window
//  height = Height (pixels) of new window
//
function openform (file, width, height) {

	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	var options = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",resizable=0,scrollbars=no";

	window.open(file,'',options);

	return(0);

}

//
// Function:    submitform()
//
// Description: Validate "Contact" form and submit
//
function submitform () {

	var f = document.contactform;

	if ( ! f.realname.value ) {

		// Invalid Name
		alert("Please enter your name.");
		f.realname.focus();

	} else if ( ( f.ContactPref[0].checked == true ) && ( ! f.email.value ) ) {

		// Invalid Email address
		alert("Please enter your email address or select Telephone as contact preference.");
		f.email.focus();

	} else if ( ( f.ContactPref[1].checked == true ) && ( ! f.Telephone.value ) ) {

		// Invalid Telephone number
		alert("Please enter your telephone number or select Email as contact preference.");
		f.Telephone.focus();

	} else {

		// Submit form
		f.submit();

		// Display confirmation
		document.location.href = "econfirm.htm";

	}

	return(0);

}