// Java Scripts

function DynaWin(url, h, w, l, t)
{
	poph = + h + 70
	popw = + w + 30
	disp = window.open("","pop","height=" + poph + ",width=" + popw + ",left=" + l + ",top=" + t + "");
	content = '<HTML>';
	content += '<TITLE>Pop-up Window</TITLE>';
	content += '</HEAD>';
	content += '<BODY onBlur="self.close()">';
	content += '<P ALIGN="CENTER"><img src="' + url + '" height="' + h + '" width="' + w + '"></P>';
	content += '<H3 ALIGN="CENTER"><A HREF="#" onClick="self.close()">Close Window</A></H3>';
	content += '</BODY></HTML>';
	disp.document.write(content);
	disp.document.close();
}

function newImage(arg)
{
	if (document.images)
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages()
{
	if (document.images && (preloadFlag == true))
	{
		for (var i=0; i<changeImages.arguments.length; i+=2)
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages()
{
	if (document.images)
	{
		menu_main_01_over = newImage("rcr.gif");
		menu_main_02_over = newImage("rcr2.gif");
        acc_over = newImage("ACChead_copy.jpg");
        acc_ott_over = newImage("ottawa_copy.jpg");
		preloadFlag = true;
	}
}

//  Debugging functions
var dbWin = null;
var debug = false;

function dbOpenWin()
{
	if( debug )
	{
		var options =
			"toolbar=no," +
			"directories=no," +
			"location=no," +
			"status=no," +
			"menubar=no," +
			"resizable=yes," +
			"scrollbars=yes," +
			"width=" + 800 + "," +
			"height=" + 500 + "," +
			"screenX=" + 0 + "," +
			"left=" + 0 + "," +
			"screenY=" + 0 + "," +
			"top=" + 0;
		//document.write( options );  //  For test purposes only
		dbWin = window.open( "",  //  No document to display
							 "DebugOutput",  // Name of Window
							 options );
	}
}

function dbWrite( s )
{
	if( debug )
	{
		if( dbWin == null )
		{
			dbOpenWin();
		}
		var date = new Date();
		dbWin.document.write( date.getFullYear() + "-" +
							  makeTwoDigits( date.getMonth() + 1 ) + "-" +
							  date.getDate() );
		dbWin.document.write( " " );
		dbWin.document.write( makeTwoDigits( date.getHours() ) + ":" +
							  makeTwoDigits( date.getMinutes() ) + ":" +
							  makeTwoDigits( date.getSeconds() ) );
		dbWin.document.write( " : " );
		dbWin.document.write( s );
	}
}

function dbWriteln( s )
{
	dbWrite( s + "<br/>" );
}

//	Last Updated Functions
function makeTwoDigits( value )
{
	var result;
	if( value <= 9 )
		result = "0" + value;
	else
		result = value;
	return result;
}

function makeDateObj( str )
{
	var d = null;
	var ms = Date.parse( str );
	if( ms > 0 )
		d = new Date( ms );
	return d;
}

function getLastUpdated( str, lang )
{
	var result = "(unknown)";
	var d = makeDateObj( str );
	
	if( d != null )
		if( lang == 'f' )
			result = makeTwoDigits( d.getDate() ) + "-" +
				makeTwoDigits( d.getMonth() + 1 ) + "-" +
				d.getFullYear();
		else
			result = d.getFullYear() + "-" +
				makeTwoDigits( d.getMonth() + 1 ) + "-" +
				makeTwoDigits( d.getDate() );
	return result;
}

function lastUpdated( lang )
{
	if( lang == 'd'  ||  lang == 'D' )
		document.write( "Aktualisiert am: " + getLastUpdated( document.lastModified, 'd' ) );
	if( lang == 'e'  ||  lang == 'E' )
		document.write( "Last updated: " + getLastUpdated( document.lastModified, 'e' ) );
	if( lang == 'f'  ||  lang == 'F' )
		document.write( "Mise au jour le " + getLastUpdated( document.lastModified, 'f' ) );
}


/**
 *	E-Mail Function Descriptions
 *
 *	Introduction
 *		The function CreateEMailAddress is just a helper
 *		function that makes an e-mail address out of the
 *		texts provided as parameters. It is seldom used
 *		on an HTML page. It's used internally by all the
 *		other functions that DO occur frequently on HTML
 *		pages. Each of the other functions displays a
 *		link on the web page. If the visitor clicks on
 *		the link, the function opens an e-mail window.
 *		The visitor then completes and sends the e-mail.
 *
 *	General Description of Parameters
 *		"name" should be the part of an e-mail address
 *			that comes BEFORE the @.
 *		"domain" should be the part of an e-mail address
 *			that comes AFTER the @.
 *		"text" is text that will appear on the page as
 *			the link for the user to click.
 *		"subject" is text that is to appear in the
 *			"subject" line.
 *
 *	Examples of Use
 *
 *	CreateEMailAddress( "abc", "xyz.com" );
 *		returns the string "abc@xyz.com"
 *
 *	OpenEMailPage( "abc", "xyz.com" );
 *		displays abc@xyz.com as a link for the user to
 *		click on. If the user clicks on that link, a
 *		new e-mail, pre-addressed to abc@xyz.com, is
 *		opened.
 *
 *	OpenEMailPageWithText( "abc", "xyz.com", "e-mail me" );
 *		displays "e-mail me" as a link for the user to
 *		click on. If the user clicks on that link, a
 *		new e-mail, pre-addressed to abc@xyz.com, is
 *		opened.
 *
 *	OpenEmailPageWithSubject( "abc", "xyz.com",
 *			"From our web site: " );
 *		displays abc@xyz.com as a link for the user to
 *		click on. If the user clicks on that link, a
 *		new e-mail, pre-addressed to abc@xyz.com and with
 *		"From our web site: " on the subject line, is
 *		opened.
 *
 *	OpenEMailPageWithText( "abc", "xyz.com", "e-mail me",
 *			"From our web site: " );
 *		displays "e-mail me" as a link for the user to
 *		click on. If the user clicks on that link, a
 *		new e-mail, pre-addressed to abc@xyz.com and with
 *		"From our web site: " on the subject line, is
 *		opened.
 */

function CreateEMailAddress( name, domain )
{
	if( name == "" )
		name = "Webmaster";
	if( domain == "" )
		domain = "Austrian-Canadian-Council.ca";
	return name + "@" + domain;
}

function OpenEMailPage( name, domain )
{
	document.write( "<a href=\"mailto:" +
		CreateEMailAddress( name, domain ) + "\">" +
		CreateEMailAddress( name, domain ) + "</a>" );
}

function OpenEMailPageWithText( name, domain, text )
{
	document.write( "<a href=\"mailto:" +
		CreateEMailAddress( name, domain ) +
		"\">" + text + "</a>" );
}

function OpenEMailPageWithSubject( name, domain, subject )
{
	document.write( "<a href=\"mailto:" +
		CreateEMailAddress( name, domain ) +
		"?subject=" + subject + "\">" +
		CreateEMailAddress( name, domain ) + "</a>" );
}

function OpenEMailPageWithTextAndSubject( name, domain, text, subject )
{
	document.write( "<a href=\"mailto:" +
		CreateEMailAddress( name, domain ) +
		"?subject=" + subject + "\">" +
		text + "</a>" );
}

/*
 * End E-Mail Functions
 */


//FOR IMPLEMENTING SUBMENUS

function setStyleAttr( id, attrValue )
{
	if( document.getElementById )
	{
		var style = document.getElementById( id ).style;
		style.display = attrValue;
		//	Why this one-line version won't work isn't clear to me
		//	document.getElementByID( id ).style.display = attrValue;
		return true;
	}
	else
		return false;
}

function resetAllSubmenus( id )
{
	setStyleAttr( "montreal-submenu", "none" );
	setStyleAttr( "ottawa-submenu", "none" );
	setStyleAttr( "toronto-submenu", "none" );
	setStyleAttr( "vancouver-submenu", "none" );
	if( id != null )
		setStyleAttr( id, "block" );
	return true;
}


