/*

	Filename:          script.js
	Description:       Javascript functions
	Site:              Marina City Online
	Author:            Steven Dahlman, DCM Software
	Start date:        02-11-07
	Last modification: 01-26-12

*/

/* Base URL */
var baseURL = "http://www.marinacityonline.com/";

//
// Function:    footer
//
// Description: Display page footer
//
// Input:
// line = "H" to display footer for history pages
//
// -Required style classes: red, web
//
// Return code:
//  0 = Success
//
function footer (line) {

	// General disclaimer
	var disclaimer = "Not sponsored by, endorsed by or affiliated with LaSalle Hotel Properties or Marina Towers Condominium Association. Marina City Online, Marina City News, Marina City Mobile, and Loop North are registered service marks in Illinois.";

	// History page disclaimer
	var history = "Presented for non-profit educational purposes.";

	// Disclaimer style
	var dstyle = "font-family: Helvetica, Arial; font-size: 8pt; color: #000080";

	if ( line == 'H' ) {
		// Use history page disclaimer
		disclaimer = history;
	}

	// Start table
	document.write('<P><CENTER><TABLE border=0 cellpadding=0 cellspacing=0 style="background-color: #ffffff">');

	// Start first row
	document.write('<TR><TD align="center"><TABLE width=650 border=0 cellpadding=0 cellspacing=4 style="border: 1px solid #000000"><TR>');

	// "MCO" logo (153 x 50)
	document.write('<TD align="right"><A href="http://www.marinacityonline.com"><IMG src="image/logo/mco.jpg" height=30 border=0 alt="Marina City Online"></IMG></A></TD>');

	// Facebook icon
	document.write('<TD><A href="http://www.facebook.com/home.php?sk=group_64312587896" target="new"><IMG src="image/logo/facebook_f50.jpg" height=30 border=0 alt="Facebook"></IMG></A></TD>');

	// Twitter icon
	document.write('<TD><A href="http://twitter.com/marinacitynews" target="new"><IMG src="image/logo/twitter_t50.jpg" height=30 border=0 alt="Twitter"></IMG></A></TD>');

	// Flickr icon
	document.write('<TD><A href="http://www.flickr.com/photos/marinacity" target="new"><IMG src="image/logo/flickr_f50.jpg" height=30 border=0 alt="Flickr"></IMG></A></TD>');

	// YouTube icon
	document.write('<TD><A href="http://www.youtube.com/user/MarinaCityOnline" target="new"><IMG src="image/logo/youtube_50.jpg" height=30 border=0 alt="YouTube"></IMG></A></TD>');

	// LinkedIn icon
	document.write('<TD><A href="http://www.linkedin.com/company/737069" target="new"><IMG src="image/logo/linkedin_50.jpg" height=30 border=0 alt="LinkedIn"></IMG></A></TD>');

	// RSS icon
	document.write('<TD><A href="http://www.marinacityonline.com/rss.xml" type="application/rss+xml" target="new"><IMG src="image/logo/rss_50.jpg" height=30 border=0 alt="RSS"></IMG></A></TD>');

	// Line
	document.write('<TD width=2></TD>');
	document.write('<TD width=1 style="background-color: #0047ab"></TD>');
	document.write('<TD width=2></TD>');

	//
	// Disclaimer
	//
	document.write('<TD style="' + dstyle + '">');
	document.write(disclaimer);
	document.write('</TD>');

	// End first row and start second row
	document.write('</TR></TABLE></TD></TR><TR><TD align="center" style="' + dstyle + '">');

	//
	// Shortcut & mobile domains
	//
	if ( line == 'H' ) {
		document.write('Shortcut: <A href="http://www.cityincity.org" class="red">cityincity.org</A>');
	} else {
		document.write('Shortcut: <A href="http://www.marinacity.co" class="red">marinacity.co</A> &#149; Mobile: <A href="http://www.marinacity.mobi" class="red">marinacity.mobi</A>');
	}

	// End second row
	document.write('</TD></TR>');

	// End table
	document.write('</TABLE></CENTER></P>');

	return(0);

}

//
// Function:    google_ad
//
// Description: Display Google ad
//
// Input:
//
// size = 1 for 160x600 "wide skyscraper"
//      = 2 for 250x250 "square"
//      = 3 for 200x200 "square" (text ad)
//      = 4 for 200x200 "square" (image ad)
//
// Return code:
//  0 = Success
// -1 = Invalid argument
//
function google_ad (size) {

	document.write('<SCRIPT type="text/javascript">');
	document.write('google_ad_client = "pub-4458809128970208"; google_ad_channel = "";');

	if ( size == 1 ) {

		document.write('google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as";');
		document.write('google_ad_type = "image";');

	} else if ( size == 2 ) {

		document.write('google_ad_width = 250; google_ad_height = 250; google_ad_format = "250x250_as";');
		document.write('google_ad_type = "image";');

	} else if ( size == 3 ) {

		document.write('google_ad_slot = "2844485081"; google_ad_width = 200; google_ad_height = 200;');

	} else if ( size == 4 ) {

		document.write('google_ad_slot = "4244447034"; google_ad_width = 200; google_ad_height = 200;');

	} else {

		return(-1);

	}

	document.write('</SCRIPT><SCRIPT type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></SCRIPT>');
	return(0);

}

//
// Function:    headline
//
// Description: Display headline on news page
//
// Input:
// txt = Text to display
//
// Return code:
//  0 = Success
//
function headline (txt) {

	// White text on Cobalt Blue background
	document.write('<TABLE width="100%" border=0 cellspacing=0 cellpadding=8 bgcolor="#0047ab" style="border: 2px outset #ffffff #000000 #000000 #ffffff; font-family: Helvetica, Arial; font-size: 10pt; font-weight: bold; color: #ffffff"><TR><TD>');

	document.write(txt);

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

	return(0);

}

//
// Function:    mainmenu
//
// Description: Display Main Menu
//
// Input:
// orient  = "H" for horizontal orientation (default)
//         = "V" for vertical orientation
//         = "R" for vertical menu on real estate page
//
// baseURL = Base URL
//
// Return code:
//  0 = Success
//
// -Required function: searchform()
// -Required style classes: menuhead, mainmenu
//
function mainmenu (orient) {

	// Shades of blue (24)
	var blues = new Array( '', '#0000ff', '#0000f8', '#0000f0', '#0000e8', '#0000e0', '#0000d8', '#0000d0', '#0000c8', '#0000c0', '#0000ba', '#0000b2', '#0000aa', '#0000a2', '#00009a', '#000092', '#00008a', '#000082', '#00007a', '#000072', '#00006a', '#000062', '#00005A', '#000052', '#00004A' );

	// Button style
	bstyle = "width: 110px; background-color: #0047ab; border-width: 1px; border-style: outset; border-color: #ffffff #f0f0f0 #f0f0f0 #ffffff; font-family: Helvetica, Arial; font-size: 8pt; font-weight: bold; color: #ffffff";

	// Menu arrays
	var hmenu = new Array();
	var option = new Array();
	var pages = new Array();
	var titles = new Array();

	// Counters
	var counter = 0;
	var index = 0;

	var cwidth = 220; // Default column width (pixels)

	//
	// Menu options
	//
	// -Maximum 16 items in horizontal menu
	//

	//
	// Links
	//
	pages[0] = 'index.html';
	pages[1] = 'news.htm';
	pages[2] = 'stocks.htm';
	pages[3] = 'opinion.htm';
	pages[4] = 'history/index.html';
	pages[5] = 'fastfacts.htm';
	pages[6] = 'funfacts.htm';
	pages[7] = 'floorplate.htm';
	pages[8] = 'photo/photo12.htm';
	pages[9] = 'video/video1.htm';
	pages[10] = 'listing.htm';
	pages[11] = 'rental.htm';
	pages[12] = 'transfers.htm';
	pages[13] = 'beehive.htm?COM';
	pages[14] = 'restaurant.htm';
	pages[15] = 'crimedata.htm';
	pages[16] = 'beehive.htm?MCBP';
	pages[17] = 'residential.htm';
	pages[18] = 'beehive.htm?CAL';
	pages[19] = 'http://www.marinacity.org/cgi-bin/blogmngr.pl?MW';
	pages[20] = 'whatnew.htm';
	pages[21] = 'eupdate.htm';
	pages[22] = 'about.htm';

	//
	// Menu option text
	//
	titles[0] = 'HOME PAGE';
	titles[1] = 'LOOP NORTH NEWS';
	titles[2] = 'STOCKS';
	titles[3] = 'OPINION';
	titles[4] = 'MARINA CITY HISTORY';
	titles[5] = 'FAST FACTS';
	titles[6] = 'FUN FACTS';
	titles[7] = 'FLOOR PLATES &amp; MAPS';
	titles[8] = 'IMAGES';
	titles[9] = 'VIDEO';

	titles[10] = 'MLS LISTINGS';
	titles[11] = 'RENTALS';
	titles[12] = 'RECENT TRANSFERS';

	titles[13] = 'PLACES TO GO @ MC';
	titles[14] = 'RIVER NORTH RESTAURANT GUIDE';
	titles[15] = 'CRIME DATABASE';
	titles[16] = 'BUILDING PERMITS';
	titles[17] = 'INFO FOR RESIDENTS';
	titles[18] = 'UPCOMING EVENTS';
	titles[19] = 'MARINA WATCHDOG';

	titles[20] = 'WHAT&#146;S NEW';
	titles[21] = 'SIGNUP FOR EMAIL UPDATES';
	titles[22] = 'ABOUT MCO';

	if ( orient == 'H' ) {

		// Short titles
		titles[0] = 'HOME';
		titles[1] = 'NEWS';
		titles[3] = 'OPINION';
		titles[4] = 'HISTORY';
		titles[5] = 'FAST FACTS';
		titles[6] = 'FUN FACTS';
		titles[8] = 'IMAGES';
		titles[9] = 'VIDEO';
		titles[10] = 'MLS LISTINGS';
		titles[11] = 'RENTALS';
		titles[12] = 'TRANSFERS';
		titles[20] = 'WHAT&#146;S NEW';
		titles[21] = 'EMAIL UPDATES';
		titles[22] = 'ABOUT';

		// Include option in horizontal menu (0=No 1=Yes)?
		hmenu[0] = 1;
		hmenu[1] = 1;
		hmenu[2] = 0;
		hmenu[3] = 1;
		hmenu[4] = 1;
		hmenu[5] = 1;
		hmenu[6] = 1;
		hmenu[7] = 0;
		hmenu[8] = 1;
		hmenu[9] = 1;
		hmenu[10] = 1;
		hmenu[11] = 1;
		hmenu[12] = 1;
		hmenu[13] = 0;
		hmenu[14] = 0;
		hmenu[15] = 0;
		hmenu[16] = 0;
		hmenu[17] = 0;
		hmenu[18] = 0;
		hmenu[19] = 0;
		hmenu[20] = 1;
		hmenu[21] = 1;
		hmenu[22] = 1;

	}

	// Assemble menu options
	for ( index = 0; index < pages.length; index ++ ) {
		option[index] = '<A href="' + pages[index] + '" class="mainmenu">' + titles[index] + '</A>';
	}

	if ( orient == 'V' ) {

		//
		// Vertical orientation
		//
		// -Main Menu on HOME page
		//
		// #0047ab = Cobalt Blue
		//

		// Start border
		document.write('<TABLE width=250 border=0 cellpadding=4 cellspacing=0 style="border: 1px solid #0047ab"><TR><TD align="center" valign="top">');

		// Start menu
		document.write('<TABLE width="100%" border=0 cellpadding=4 cellspacing=2>');

		// News and information
		document.write('<TR><TD width="100%" class="menuhead">News and information</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[1] + '">' + option[1] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[2] + '">' + option[2] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[3] + '">' + option[3] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[4] + '">' + option[4] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[5] + '">' + option[5] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[6] + '">' + option[6] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[7] + '">' + option[7] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[8] + '">' + option[8] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[9] + '">' + option[9] + '</TD></TR>');

		// Real estate
		document.write('<TR><TD width="100%" class="menuhead">Resources for buyers, sellers &amp; renters</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[10] + '">' + option[10] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[11] + '">' + option[11] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[12] + '">' + option[12] + '</TD></TR>');

		// Directories
		document.write('<TR><TD width="100%" class="menuhead">Resources for residents, neighbors &amp; visitors</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[13] + '">' + option[13] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[14] + '">' + option[14] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[15] + '">' + option[15] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[16] + '">' + option[16] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[17] + '">' + option[17] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[18] + '">' + option[18] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[19] + '">' + option[19] + '</TD></TR>');

		// Other
		document.write('<TR><TD width="100%" class="menuhead">Related pages</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[20] + '">' + option[20] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[21] + '">' + option[21] + '</TD></TR>');
		document.write('<TR><TD bgcolor="' + blues[22] + '">' + option[22] + '</TD></TR>');

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

		// Start search table
		document.write('<TABLE width="100%" border=0 cellspacing=2 cellpadding=4><TR><TD>');

		// Search form
		searchform();

		// End search table
		document.write('</TD></TR></TABLE>');

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

	} else if ( orient == 'R' ) {

		//
		// Real estate page
		//

		// Start column
		document.write('<TD bgcolor="#0047ab" align="center" valign="top">');

		//
		// Main menu
		//
		document.write('<P><TABLE border=0 cellpadding=2 cellspacing=2>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="index.html" class="mainmenu">HOME PAGE</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="listing.htm" class="mainmenu">MLS LISTINGS</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="rental.htm" class="mainmenu">RENTALS</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="transfers.htm" class="mainmenu">RECENT TRANSFERS</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="floorplate.htm" class="mainmenu">FLOOR PLATES &amp; MAPS</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="residential.htm" class="mainmenu">INFO FOR RESIDENTS</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="attract.htm" class="mainmenu">NEIGHBORHOOD ATTRACTIONS</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="eupdate.htm" class="mainmenu">SIGNUP FOR EMAIL UPDATES</A></TD></TR>');

		// End main menu
		document.write('</TABLE></P>');

		//
		// Realtor's menu
		//
		document.write('<P><TABLE border=0 cellpadding=2 cellspacing=2>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="restate/reservice.htm" class="mainmenu">REAL ESTATE SERVICES</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="restate/testimony.htm" class="mainmenu">TESTIMONIALS</A></TD></TR>');

		document.write('<TR><TD width=' + cwidth + ' bgcolor="#0000ff" style="border: 1px #f0f0f0 outset" align="center"><A href="http://marinatowers.blogspot.com/" target="new" class="mainmenu">REAL ESTATE BLOG</A></TD></TR>');

		// End Realtor's menu
		document.write('</TABLE></P>');

		// AD: Michael Michalak
		document.write('<P><A href="" onclick="location.href=\'http://www.loopnorth.com/cgi-bin/adtrack.pl?ADD,MCO,0141,1,C,http://www.marinacityonline.com/restate/reservice.htm\'; return false;"><IMG src="image/banner/michalak_200x237.jpg" width=200 height=237 border=0 alt="Michael Michalak"></IMG></A></P>');

		document.write('<SCRIPT type="text/javascript" src="http://www.loopnorth.com/cgi-bin/adtrack.pl?ADD,MCO,0141,1,I"><\/SCRIPT>');

		// AD: KnK Renovations
		document.write('<P><A href="" onclick="location.href=\'http://www.loopnorth.com/cgi-bin/adtrack.pl?ADD,MCO,0175,1,C,http://www.knkrenovations.com/\'; return false;"><IMG src="image/banner/knk_renovations_200x600.jpg" width=200 height=600 border=0 alt="KnK Renovations"></IMG></A></P>');

		document.write('<SCRIPT type="text/javascript" src="http://www.loopnorth.com/cgi-bin/adtrack.pl?ADD,MCO,0175,1,I"><\/SCRIPT>');

		// PROMO: Loop North News
		document.write('<P><A href="news.htm"><IMG src="image/thumb/lnnscn.jpg" width=200 style="border: 1px solid #ffffff"></IMG></A></P>');

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

	} else {

		//
		// Horizontal orientation (default)
		//

		// Start outer table
		document.write('<TABLE width="100%" border=0 cellpadding=4 cellspacing=0><TR><TD align="center">');

		// Start inner table
		document.write('<TABLE border=0 cellpadding=2 cellspacing=0 style="background-color: #000000"><TR>');

		//
		// Display menu options
		//
		// pages.length = Number of options
		// hmenu[N]     = 1 if option N should be displayed
		//
		// -Menu options have Cobalt Blue background
		//
		for ( index = 0; index < pages.length; index ++ ) {

			if ( hmenu[index] == 1 ) {
				counter ++;
				document.write('<TD width=110><INPUT type="button" value="' + titles[index] + '" style="' + bstyle + '" onmouseover="" onclick="location.href=\'' + baseURL + pages[index] + '\'" /></TD>');
			}

			if ( counter == 7 ) {
				// Start new row
				document.write('</TR></TABLE><TABLE border=0 cellpadding=2 cellspacing=0 style="background-color: #000000"><TR>');
			}

		}

		// End inner table
		document.write('</TR></TABLE>');

		// End outer table
		document.write('</TD></TR></TABLE>');

	}

	return(0);

}

//
// Function:    pagenav
//
// Description: Display page navigation buttons
//
// Input:
// prevpage  = Previous page (HTML file)
// nextpage  = Next page (HTML file)
// nexttitle = Title of next page
//
// -Required style class: small1
//
// Return code:
//  0 = Success
//
function pagenav (prevpage, nextpage, nexttitle) {

	if ( nexttitle ) { document.write('<P class="small1" align="center"><B>Next page: ' + nexttitle + '</B></P>'); }

	document.write('<P align="center"><A href="'+ prevpage + '"><IMG src="image/icon/back.gif" border=0 hspace=4 alt="Previous page"></IMG></A>');
	document.write('<A href="' + nextpage + '"><IMG src="image/icon/next.gif" border=0 hspace=4 alt="Next page"></IMG></A></P>');

	return(0);

}

//
// Function:    playflv
//
// Description: Play FLV Flash video in new window
//
// Input:
// vfile   = Video file path/basename (video/[path/][basename].flv)
// baseURL = Base URL
//
// Return code:
//  0 = Success
//
function playflv (vfile) {

	// Video path/filename
	vfile = baseURL + 'video/' + vfile + '.flv';

	var vwidth = 800;           // Video width (pixels)
	var vheight = 600;          // Video height (pixels)

	var wwidth = vwidth + 20;   // Window width (pixels)
	var wheight = vheight + 80; // Window height (pixels)

	// 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=no,scrollbars=no,titlebar=no,menubar=no,directories=no,personalbar=no,status=no';

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

	//
	// Display video
	//
	var wcontent = '<HTML>';

	wcontent += '<HEAD><TITLE>Marina City Online</TITLE><BASE href="' + baseURL + '"></BASE></HEAD>';

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

	wcontent += '<OBJECT type="application/x-shockwave-flash" width="' + vwidth + '" height="' + vheight + '" wmode="transparent" data="video/player.swf?file=' + vfile + '&autostart=true">';

	wcontent += '<PARAM name="movie" value="video/player.swf?file=' + vfile + '&autostart=true" />';
	wcontent += '<PARAM name="wmode" value="transparent" />';

	wcontent += '</OBJECT>';

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

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

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

	return(0);

}

//
// Function:    playsound()
//
// Description: Play (or stop) sound file
//
// Input:
//
// sfile = Audio file path/filename
//
// id    = Unique number to identify sound object
//
// mode  = 1 to play sound (default)
//       = 0 to stop sound
//
// -Uses SoundManager API
//
// -Required files:
//  audio/soundmanager2.js
//  audio/soundmanager2.swf
//
// Return code:
//  0 = Success
// -1 = Invalid argument
//
function playsound (sfile, id, mode) {

	if ( ! sfile ) {
		// Missing argument
		return(-1);
	} else if ( ! id ) {
		// Missing argument
		return(-1);
	}

	//
	// Audio path/filename
	//
	var position;
	var soundfile;

	position = sfile.length - 3;

	if ( sfile.substring(position) == 'mp3' ) {
		// Path/filename passed
		soundfile = sfile;
	} else {
		// Invalid argument
		return(-1);
	}

	// Sound ID
	var soundID = 'sound' + id;

	// Stop any currently-playing sound
	soundManager.stopAll();

	if ( mode != 0 ) {

		// Create sound
		soundManager.createSound( { id: soundID, url: soundfile, autoPlay: false } );

		// Play sound
		soundManager.play(soundID);

	}

	return(0);

}

//
// Function:    radioref
//
// Description: Play "RadioReference.com" audio feed
//
// Input:
// option = 1 for Chicago Police (default)
//        = 2 for Chicago Fire
//
// Return code:
//  0 = Success
//
// RadioReference.com:
//  Username: sdahlman
//  Password: sdahl49
//
function radioref (option) {

	var key = "20319234"; // Domain key
	var feed;             // Feed ID

	if ( option == 2 ) {
		// Chicago Fire Department (Analog VHF)
		feed = "115";
	} else {
		// Chicago Police Zone 4 (Districts 1 and 18)
		feed = "6353";
	}

	// Call RR API
	document.write('<script type="text/javascript" src="http://api.radioreference.com/js/?key=' + key + '&feedId=' + feed + '&as=1"><\/script>');

	// Return
	return(0);

}

//
// Function:    realtor_header
//
// Description: Display Realtor header
//
// Input:
//  txt = Text to display in bottom center of header
//
// Return code:
//  0 = Success
//
function realtor_header (txt) {

	// Start table
	document.write('<TABLE width=600 border=0 cellpadding=1 cellspacing=4 bgcolor="#ffffff"><TR>');

	// Photo of Realtor
	document.write('<TD width=150>');
	document.write('<IMG src="http://www.loopnorth.com/image/graphic/mmichalak3.jpg" width=150 border=0 alt="Michael Michalak"></IMG>');
	document.write('</TD>');

	document.write('<TD align="center" class="mlsfontdark">');

	// Name and contact information
	document.write('<P><B>Michael Michalak</B><BR />Real Estate Broker / Realtor<BR />RE/MAX Signature<BR />2901 North Clybourn Avenue<BR />Chicago, IL 60618<BR />312-527-4417</P>');

	// Email link
	document.write('<P><A href="mailto:mikesellschicago@gmail.com" class="listlink">mikesellschicago@gmail.com</A></P>');

	// Text unique to page
	document.write('<P><B>' + txt + '</B></P>');

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

	// Logo
	document.write('<TD width=150>');
	document.write('<IMG src="http://www.loopnorth.com/image/logo/remax.jpg" width=150 border=0 alt="remax"></IMG>');
	document.write('</TD>');

	// End table
	document.write('</TR></TABLE>');

	return(0);

}

//
// Function:    searchform
//
// Description: Display (Atomz) search form
//
// -Required style class: button1
//
// Return code:
//  0 = Success
//
function searchform () {

	document.write('<P><CENTER><FORM name="searchbox" action="http://search.atomz.com/search/" method="get">');

	document.write('<INPUT type="hidden" name="sp_a" value="sp10041b1b" />');

	document.write('<TABLE border=0 cellpadding=0 cellspacing=4><TR>');
	document.write('<TD><INPUT type="text" name="sp_q" size="15" /></TD>');
	document.write('<TD><INPUT type="submit" size="15" value="Search MCO" class="button1" /></TD>');
	document.write('</TR></TABLE>');

	document.write('<INPUT type="hidden" name="sp_p" value="all" />');
	document.write('<INPUT type="hidden" name="sp_f" value="ISO-8859-1" />');

	document.write('</FORM></CENTER></P>');

	return(0);

}

//
// Function:    showimg
//
// Description: Display image in new window
//
// Input:
//
// file    = Path/filename of image to display
// width   = Width (pixels) of image
// height  = Height (pixels) of image
// szimg   = Resize image? 1=Yes (default) 0=No
// title   = Text to display in window title bar
// baseURL = Base URL
//
// Return code:
//  0 = Success
//
function showimg (file, width, height, szimg, 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)

	if ( szimg == 1 ) {
		// 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;

	if ( szimg == 1 ) {
		wfeatures += ',resizable=yes,scrollbars=no,titlebar=yes,menubar=no,directories=no,personalbar=no,status=no';
	} else {
		wfeatures += ',resizable=yes,scrollbars=yes,titlebar=yes,menubar=no,directories=no,personalbar=no,status=no';
	}

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

	//
	// Display image
	//
	var wcontent = '<HTML>';
	wcontent += '<HEAD>';

	if ( title ) {
		wcontent += '<TITLE>Marina City Online - ' + title + '</TITLE>';
	} else {
		wcontent += '<TITLE>Marina City Online</TITLE>';
	}

	wcontent += '<BASE href="' + baseURL + '"></BASE>';
	wcontent += '</HEAD>';

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

	if ( szimg == 0 ) {
		// Do not specify image size
		wcontent += '<IMG src="' + file + '" style="border: 1px #000000 solid"></IMG>';
	} else {
		wcontent += '<IMG src="' + file + '" width=' + width + ' height=' + height + ' style="border: 1px #000000 solid"></IMG>';
	}

	var bstyle = "font-family: Helvetica, Arial; font-size: 11pt; font-weight: normal; color: #191970; background-color: #ffffff; border: 1px outset #f0f0f0 #000000 #000000 #f0f0f0;";

	wcontent += '<P><TABLE border=0 cellpadding=0 cellspacing=4><TR>';
	wcontent += '<TD><A href="" onClick="window.close();"><INPUT type="button" value="Close" style="' + bstyle + '"></INPUT></A></TD>';
	wcontent += '<TD><A href="" onClick="window.print();"><INPUT type="button" value="Print" style="' + bstyle + '"></INPUT></A></TD>';
	wcontent += '</TR></TABLE></P>';

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

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

	return(0);

}

//
// Name:        showmap()
// Description: Display Google Map in new window
//
// Input:
// [argument 1] = Address to pass to Google
//
// Return code:
//  0 = Success
// -1 = Invalid argument
//
function showmap ( address ) {

	if ( ! address ) {
		// Invalid argument
		return(-1);
	}

	var width = 800;  // Window width (pixels)
	var height = 600; // Window height

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

	// Other window features
	var features = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no';
	features = features + ',height=' + height + ',left=' + left + ',top=' + top + ',width=' + width;

	var mapwidth = width - 50;    // Map width (pixels)
	var mapheight = height - 100; // Map height
	var zoom = 16;                // Default zoom level

	//
	// Map types
	//
	// maptypes[1] = Standard roadmap image
	// maptypes[2] = Satellite image
	// maptype     = Current map type
	// maptype_alt = Other map type
	//
	var maptypes_lc = new Array ( "", "roadmap", "satellite" );
	var maptype = maptypes_lc[1];
	var maptype_alt = maptypes_lc[2];;

	// Button style
	var buttonstyle = "background-color: #ffffff; width: 120px; font-family: Helvetica, Arial; font-size: 9pt; color: #2B3856; font-weight: normal";

	// Open window
	var mapwin = window.open( '', '', features );

	// Display address in title bar
	var title = address;
	title = title.replace( /\+/g, ' ' );
	address = address.replace( / /g, '\+' );

	// Start HTML
	mapwin.document.write('<HTML>');

	// Start HEAD element
	mapwin.document.write('<HEAD>');

	// Title
	mapwin.document.write('<TITLE>' + title + '</TITLE>');

	// Javascript function to display map
	mapwin.document.write('<SCRIPT type="text/javascript">function statmap ( address, zoom, mapwidth, mapheight, maptype ) { var url = \'http://maps.google.com/maps/api/staticmap?center=\' + address + \'&zoom=\' + zoom + \'&size=\' + mapwidth + \'x\' + mapheight + \'&maptype=\' + maptype + \'&markers=size:mid|color:blue|\' + address + \'&sensor=false\'; var map = document.getElementById(\'map\'); map.src = url; }</SCRIPT>');

	// Javascript function to toggle map type
	mapwin.document.write('<SCRIPT type="text/javascript">function togglemap ( m1, m2, address, zoom, mapwidth, mapheight ) { var btn = document.getElementById("btnmaptype"); var txt = btn.value; if ( txt == m2 ) { txt = m1; statmap( address, zoom, mapwidth, mapheight, m2 ); } else { txt = m2; statmap( address, zoom, mapwidth, mapheight, m1 ); } btn.value = txt; }</SCRIPT>');

	// End HEAD element
	mapwin.document.write('</HEAD>');

	// Start BODY element
	mapwin.document.write('<BODY leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>');

	// Start outer table
	mapwin.document.write('<TABLE width="100%" height="100%" border=0 cellpadding=0 cellspacing=0><TR><TD align="center">');

	// Map goes here
	mapwin.document.write('<IMG id="map" style="border: 1px solid #000000"></IMG>');

	// Start button table
	mapwin.document.write('<P><TABLE border=0 cellpadding=0 cellspacing=4><TR>');

	// Hidden zoom level
	mapwin.document.write('<TD><SPAN id="zoomlevel" style="font-family: Helvetica, Arial; font-size: 8pt; color: #ffffff">' + zoom + '</SPAN></TD>');

	// Button to close window
	mapwin.document.write('<TD><INPUT type="button" value="CLOSE" style="' + buttonstyle + '" onclick="window.close();" /></TD>');

	// Button to zoom in
	mapwin.document.write('<TD><INPUT type="button" value="ZOOM IN" style="' + buttonstyle + '" onclick="var s = document.getElementById(\'zoomlevel\'); var zoom = s.innerHTML; var btn = document.getElementById(\'btnmaptype\'); var txt = btn.value; if ( zoom < 20 ) { zoom ++; } s.innerHTML = zoom; if ( txt == \'' + maptypes_lc[1] + '\' ) { txt = \'' + maptypes_lc[2] + '\'; } else { txt = \'' + maptypes_lc[1] + '\'; } statmap( \'' + address + '\', zoom, ' + mapwidth + ', ' + mapheight + ', txt );" /></TD>');

	// Button to zoom out
	mapwin.document.write('<TD><INPUT type="button" value="ZOOM OUT" style="' + buttonstyle + '" onclick="var s = document.getElementById(\'zoomlevel\'); var zoom = s.innerHTML; var btn = document.getElementById(\'btnmaptype\'); var txt = btn.value; if ( zoom > 10 ) { zoom --; } s.innerHTML = zoom; if ( txt == \'' + maptypes_lc[1] + '\' ) { txt = \'' + maptypes_lc[2] + '\'; } else { txt = \'' + maptypes_lc[1] + '\'; } statmap( \'' + address + '\', zoom, ' + mapwidth + ', ' + mapheight + ', txt );" /></TD>');

	// Button to change map type
	mapwin.document.write('<TD><INPUT type="button" id="btnmaptype" value="' + maptype_alt + '" style="' + buttonstyle + '" onclick="togglemap( \'' + maptypes_lc[1] + '\', \'' + maptypes_lc[2] + '\', \'' + address + '\', ' + zoom + ', ' + mapwidth + ', ' + mapheight + ' );" /></TD>'); 

	// End button table
	mapwin.document.write('</TR></TABLE></P>');

	// End outer table
	mapwin.document.write('</TD></TR></TABLE>');

	// End BODY element
	mapwin.document.write('</BODY>');

	// Display initial map
	mapwin.document.write('<SCRIPT type="text/javascript">statmap( \'' + address + '\', ' + zoom + ', ' + mapwidth + ', ' + mapheight + ', \'' + maptype + '\' );</SCRIPT>');

	// End HTML
	mapwin.document.write('</HTML>');

	// Close output stream
	mapwin.document.close();

	return(0);

}

//
// Function:    showport
//
// Description: Display image in table cell from SDP portfolio
//
// Input:
// imgbase  = Basename of JPEG file
// imgwidth = ( Width  / 100 )  of large version of image (e.g, 9=900)
// caption  = Optional caption to display next to image
//
// Return code:
//  0 = Success
//
function showport (imgbase, imgwidth, caption) {

	imgwidth = imgwidth * 100;

	document.write('<TD>');

	document.write('<A href="" onclick="showimg(\'http://www.stevendahlman.com/image/large/' + imgbase + '.jpg\', ' + imgwidth + ', 600, 0, \'Photo by Steven Dahlman\'); return false;">');

	document.write('<IMG src="http://www.stevendahlman.com/image/thumb/' + imgbase + '.jpg" height=150 border=0 style="border: 4px #ffffff solid"></IMG>');

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

	document.write('<LI><A href="http://www.stevendahlman.com/cgi-bin/showport.pl?' + imgbase + '" target="new" class="webs">Details</A></LI>');

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

	if (caption) { document.write('<TD width=150 class="caption">' + caption + '</TD>'); }

	return(0);

}

//
// Function:    startpage
//
// Description: Start (or end) BODY element of page
//
// Input:
//
//    mode = 1 to start page
//         = 0 to end page (default)
//
//  signup = 1 to include "signup" link in footer
//         = 0 to not include "signup" link in footer
//
// Return code:
//  0 = Success
//
function startpage (mode, signup) {

	if ( mode == 1 ) {

		//
		// Start page
		//

		// Start outer border
		document.write('<TABLE width="100%" height="100%" border=0 cellspacing=0 cellpadding=0><TR><TD align="center" valign="top">');

		// Main Menu
		mainmenu('H');

	} else {

		//
		// End page
		//

		// Disclaimer
		footer(signup);

		// End outer border
		document.write('</TD></TR></TABLE>');

		//
		// Google Analytics
		//
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

		document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

		try {
			var pageTracker = _gat._getTracker("UA-2285099-2");
			pageTracker._trackPageview();
		} catch(err) {}

	}

	return(0);

}

//
// Function:    subhead
//
// Description: Display bullet points below headline on news page
//
// Input:
// line1 = First sub-headline
// line2 = Second sub-headline (optional)
// line3 = Third sub-headline (optional)
//
// Return code:
//  0 = Success
// -1 = Invalid argument
//
function subhead (line1, line2, line3) {

	if ( ! line1 ) { return(-1); }

	// Start table
	document.write('<TABLE width="100%" border=0 cellspacing=0 cellpadding=4>');

	// Insert space
	document.write('<TR><TD height=4></TD></TR>');

	//
	// Bullet points
	//
	document.write('<TR><TD style="background-color: #f0f0f0; font-family: Helvetica, Arial; font-size: 10pt; font-weight: bold; font-style: italic; color: #000080"><UL>');

	if ( line1 ) { document.write('<P><LI>' + line1 + '</LI></P>'); }
	if ( line2 ) { document.write('<P><LI>' + line2 + '</LI></P>'); }
	if ( line3 ) { document.write('<P><LI>' + line3 + '</LI></P>'); }

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

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

	return(0);

}

//
// Function:    submenu
//
// Description: Display sub-menu at top of page
//
// Input:
//  pg = 1 for "images" page
//     = 2 for history page
//
// Return code:
//  0 = Success
//
function submenu (pg) {

	// Start table
	document.write('<P><TABLE border=0 cellpadding=4 cellspacing=0><TR>');

	if ( pg == 1 ) {

		//
		// Image options
		//
		document.write('<TD><INPUT type="button" value="PHOTOS FROM 2012" class="button1" onclick="location.href = \'	http://www.marinacityonline.com/photo/photo12.htm\'" /></TD>');

		document.write('<TD><INPUT type="button" value="PHOTOS FROM 2011" class="button1" onclick="location.href = \'	http://www.marinacityonline.com/photo/photo11.htm\'" /></TD>');

		document.write('<TD><INPUT type="button" value="PHOTOS FROM 2010" class="button1" onclick="location.href = \'http://www.marinacityonline.com/photo/photo10.htm\'" /></TD>');

		document.write('<TD><INPUT type="button" value="HISTORICAL" class="button1" onclick="location.href = \'http://www.marinacityonline.com/history/images.htm\'" /></TD>');

	} else if ( pg == 2 ) {

		//
		// History options
		//
		document.write('<TD><INPUT type="button" value="CONTENTS" class="button1" onclick="location.href = \'http://www.marinacityonline.com/history/contents.htm\'" /></TD>');

		document.write('<TD><INPUT type="button" value="IMAGE INDEX" class="button1" onclick="location.href = \'http://www.marinacityonline.com/history/images.htm\'" /></TD>');

		document.write('<TD><INPUT type="button" value="ACKNOWLEDGEMENTS" class="button1" onclick="location.href = \'http://www.marinacityonline.com/history/acknowledge.htm\'" /></TD>');

	}

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

	return(0);

}

//
// Function:    videowin
//
// Description: Display video in pop-up window
//
// Input:
//  title    = Title of video
//  vidid    = YouTube video ID
//  duration = Video duration (M:SS)
//  descript = Information to display below video
//  baseURL  = Base URL
//
// Return code:
//  0 = Success
//
function videowin (title, vidid, duration, descript) {

	var wwidth = 800;  // Window width (pixels)
	var wheight = 600; // Window height (pixels)

	// 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 + ', directories=no, menubar=no, personalbar=no, resizable=no, scrollbars=no, status=no, titlebar=yes';

	// Button style
	var bstyle = "font-family: Helvetica, Arial; font-size: 11pt; font-weight: normal; color: #191970; background-color: #ffffff; border: 1px outset #f0f0f0 #000000 #000000 #f0f0f0;";

	// Build page
	var wcontent = '<HTML>';

	// HEAD section
	wcontent += '<HEAD>';
	wcontent += '<TITLE>Marina City Online - ' + title + '</TITLE>';
	wcontent += '<BASE href="' + baseURL + '"></BASE>';
	wcontent += '</HEAD>';

	// BODY section
	wcontent += '<BODY style="background-color: #000000; margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0">';

	// Start table
	wcontent += '<TABLE width="100%" height="100%" border=0 cellpadding=0 cellspacing=0><TR><TD align="center">';

	// Video frame
	wcontent += '<P><IFRAME width=420 height=315 src="http://www.youtube.com/embed/' + vidid + '" frameborder=0 allowfullscreen></IFRAME></P>';

	// Description
	wcontent += '<TABLE width=420 border=0 cellpadding=8 cellspacing=0 style="font-family: Helvetica, Arial; font-size: 10pt; font-weight: normal; color: #ffffff"><TR><TD>' + descript + ' (Duration: ' + duration + ')</TD></TR></TABLE>';

	// CLOSE button
	wcontent += '<P><A href="" onClick="window.close();"><INPUT type="button" value="CLOSE" style="' + bstyle + '"></INPUT></A></P>';

	// End table
	wcontent += '</TD></TR></TABLE>';

	// End page
	wcontent += '</BODY></HTML>';

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

	// Display page
	vwin.document.write(wcontent);
	vwin.document.close();

	return(0);

}
