/*

        Filename:          script.js
        Description:       Javascript functions
        Site:              JoffreyTower.com
        Author:            Steven Dahlman, DCM Software
        Start date:        07-25-08
        Last modification: 03-09-10

*/

// Base URL
var sBaseURL = "http://www.joffreytower.com/";

//
// Function:    mainmenu
//
// Description: Display main menu
//
// Arguments:
//
// eform = 1 to display email update signup form
//       = 0 to not display form
//
// page  = 1 if appearing on "sales" page (default)
//       = 2 if appearing on "rentals" page
//       = 3 if appearing on Home page
//
// Return code:
//  0 = Success
//
function mainmenu (eform, page) {

	var salerent; // "sale" or "rent"

	if ( page == 2 ) {
		salerent = "rent";
	} else if ( page == 3 ) {
		salerent = "sale";
	} else {
		salerent = "sale";
	}

	// Start column
	document.write('<TD width=200 height=600 bgcolor="#ffffff" align="center" valign="top">');

	//
	// Display main menu
	//
	// -Light Slate Gray background
	//
	document.write('<TABLE width="100%" border=1 cellpadding=4 cellspacing=0 bgcolor="#778899">');

	if ( page != 3 ) {
		document.write('<TR><TD align="center"><A href="index.html" class="mainmenu">HOME</A></TD></TR>');
	}

	document.write('<TR><TD align="center"><A href="listing.htm" class="mainmenu">SALES</A></TD></TR>');

	document.write('<TR><TD align="center"><A href="rental.htm" class="mainmenu">RENTALS</A></TD></TR>');

	document.write('<TR><TD align="center"><A href="transfers.htm" class="mainmenu">TRANSFERS</A></TD></TR>');

	document.write('<TR><TD align="center"><A href="reservice.htm" class="mainmenu">REAL ESTATE SERVICES</A></TD></TR>');

	document.write('<TR><TD align="center"><A href="highlight.htm" class="mainmenu">BUILDING HIGHLIGHTS</A></TD></TR>');

	document.write('<TR><TD align="center"><A href="floorplan.htm" class="mainmenu">FLOOR PLANS</A></TD></TR>');

	document.write('<TR><TD align="center"><A href="news.htm" class="mainmenu">NEWS</A></TD></TR>');

	document.write('<TR><TD align="center"><A href="contact.htm" class="mainmenu">CONTACT</A></TD></TR>');

	document.write('</TABLE>');

	//
	// Display photo
	//
	if ( page != 3 ) {
		document.write('<P><IMG src="image/joffrey_nw.jpg" width=185 height=229 border=0 alt="Photograph by Steven Dahlman"></IMG></P>');
	}

	//
	// Email update signup form
	//
	if ( eform == 1 ) {

		document.write('<P><TABLE border=1 cellpadding=8 cellspacing=0 class="medium1"><TR><TD>');

		document.write('<CENTER><B>EMAIL UPDATES</B></CENTER>');

		document.write('<P>Signup for daily MLS listings of units for ' + salerent + ' at Joffrey Tower.</P>');
		document.write('<P>Enter your email address here and click on the Signup button...</P>');

		if ( salerent == "rent" ) { salerent = "rental"; }

		document.write('<CENTER><FORM name="signup" action="http://www.loopnorth.com/cgi-bin/signup.pl" method="post">');
		document.write('<INPUT type="hidden" name="sitecode" value="JT" />');
		document.write('<INPUT type="hidden" name="sitename" value="JoffreyTower.com" />');
		document.write('<INPUT type="hidden" name="etype" value="listing" />');
		document.write('<INPUT type="hidden" name="misc1" value="' + salerent + '" />');
		document.write('<INPUT type="hidden" name="copyto" value="mikesellschicago@gmail.com" />');
		document.write('<INPUT type="text" name="eaddress" size="25" maxlength="50" /><BR />');
		document.write('<INPUT type="submit" value="Signup" />');
		document.write('</FORM></CENTER>');

		document.write('</TD></TR></TABLE></P>');

	}

	// End column
	document.write('</TD>');

	return(0);

}

//
// Function:    pagehead
//
// Description: Display page header
//
// Input:
// title = Page title
// icon  = Icon filename (in image/ sub-directory)
//
// Return code:
//  0 = Success
//
function pagehead (title, icon) {

	// "Joffrey Tower"
	document.write('<IMG src="image/joffrey_tower.jpg" width=600 height=50 border=0 alt="Joffrey Tower"></IMG>');

	// Vertical space
	document.write('<P></P>');

	// Page title and icon
	document.write('<TABLE border=0 cellpadding=0 cellspacing=4><TR>');
	if (icon) { document.write('<TD><IMG src="image/' + icon + '"></IMG></TD>'); }
	document.write('<TD class="large1"><B>' + title + '</B></TD>');
	document.write('</TR></TABLE>');

	// Horizontal line
	document.write('<HR />');

	return(0);

}

//
// Function:    showimg
//
// Description: Display image in new window
//
// Input:
// file     = Filename (in image/ directory) of image to display
// width    = Width (pixels) of image
// height   = Height (pixels) of image
// title    = Window title
// sBaseURL = Base URL
//
// Return code:
//  0 = Success
//
function showimg (file, width, height, title) {

	var wwidth = width + 40;   // Window width (pixels)
	var wheight = height + 80; // Window height (pixels)

	var maxwidth = screen.availWidth - 10;   // Maximum width (pixels)
	var maxheight = screen.availHeight - 10; // Maximum height (pixels)

	// Shrink to fit available space
	if ( wwidth > maxwidth )   { wwidth = maxwidth; }
	if ( wheight > maxheight ) { wheight = maxheight; }

	// Center window on screen
	var wleft = (screen.availWidth - wwidth) / 2;
	var wtop = (screen.availHeight - wheight) / 2;

	// Window features
	var wfeatures = 'width=' + wwidth + ',height=' + wheight + ',left=' + wleft + ',top=' + wtop;
	wfeatures += ',resizable=yes,scrollbars=yes,titlebar=no,menubar=no,directories=no,personalbar=no,status=no';

	// Open window
	var imgWin = window.open('','',wfeatures);

	// Display image
	var wcontent = '<HTML>\n';

	wcontent += '\t<HEAD>\n';
	wcontent += '\t\t<TITLE>Joffrey Tower - ' + title + '</TITLE>\n';
	wcontent += '\t\t<BASE href="' + sBaseURL + '"></BASE>\n';
	wcontent += '\t</HEAD>\n';

	wcontent += '\t<BODY leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>\n';
	wcontent += '\t\t<TABLE width="100%" height="100%" border=0 cellpadding=0 cellspacing=0><TR><TD align="center">\n';

	wcontent += '\t\t\t<IMG src="' + sBaseURL + 'image/' + file + '" width=' + width + ' height=' + height + '></IMG>\n';

	wcontent += '\t\t\t<P><A href="" onClick="window.close();"><INPUT type="button" value="Close"></INPUT></A>\n';
	wcontent += '\t\t\t<A href="" onClick="window.print();"><INPUT type="button" value="Print"></INPUT></A></P>\n';

	wcontent += '\t\t</TD></TR></TABLE>\n';
	wcontent += '\t</BODY>\n</HTML>';

	imgWin.document.write(wcontent);
	imgWin.document.close();

	return(0);

}