/*@cc_on
   /*@if (@_jscript_version >= 5)
		window.onbeforeprint = OnBeforePrint;
		window.onafterprint = OnAfterPrint;
   @else @*/
      //alert("Non IE Browser (one that doesn't support JScript)");
   /*@end
@*/


/// <summary>
/// Just before a print operation, hide the menu, the buttons, and resize
/// the thumbnail images to make them fit on the printed page.
/// </summary>
function OnBeforePrint()
{
	ModifyPage(170, 128, "none", "")
}

/// <summary>
/// After a print operation, display all the items that we made hidden,
/// and resize thumbnail images back to their real size.
/// </summary>
function OnAfterPrint()
{
	ModifyPage(200, 150, "", "none")
}

/// <summary>
/// Modify the page according to the values passed to this function.
/// This entails changeing the widths of some items and the visibility of others.
/// </summary>
/// <param name="width1">The width of landscape photos.</param>
/// <param name="width2">The width of portrait photos.</param>
/// <param name="display1">The visibility of navigation elements.</param>
/// <param name="display2">The visibility of the company logo.</param>
function ModifyPage(width1, width2, display1, display2)
{
	SetDisplay( "MenuCell,FooterMenuRow,tblButtons", display1 );
	SetDisplay( "TopLeftLogoImage", display2 );

	var coll = document.all.tags("IMG");
	if ( coll != null )
	{
		for ( i=0; i<coll.length; i++ )
		{
			if (coll[i].id != "MainPropertyImage" && coll[i].id != "imgLogo" && coll[i].id != "imgPanPhoto")
			{
				if (coll[i].width > coll[i].height)
					coll[i].width = width1;
				else
					coll[i].width = width2;
			}
		}
	}
}

/// <summary>
/// Iterate through the named elements and set their display style to the 
/// specified value.
/// </summary>
/// <param name="items">A string containing the element ids separated by commas.</param>
/// <param name="state">Either 'none' or ''. The state to which the item is set.</param>
function SetDisplay( items, state )
{
	list = items.split(',');
	for(index=0; index<list.length; index++)
	{
		el = document.getElementById( list[index] );
		if (el == null) 
			alert("can't find element: " + list[index])
		else
			el.style.display = state;
	}
}
