var help_win='';
var panel_win='';
function open_help ( help_panel, x, y )
{
	help_win=window.open(help_panel,'login_help','height='+y+',width='+x+',left=0,top=0');
}
function close_help ()
{
	if ( help_win != '' ) { help_win.close(); }
}

function open_panel (panel, x, y, s, r)
{
	var scrollbars = '';
	if ( s == 1 ) scrollbars = ',scrollbars';
	var resizable = '';
	if ( r == 1 ) resizable = ',resizable';
	panel_win=window.open(panel, 'panel','height='+y+',width='+x+',left=0,top=0'+scrollbars+resizable);
}

function flash_panel ( FP_Width, FP_Height, FlashPanel, clientString  ) {
	var clientString = unescape(clientString);
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"\n');
	document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \n');
	document.write('width="' + FP_Width + '" \n');
	document.write('height="' + FP_Height + '" \n');
	document.write('id="' + FlashPanel + '" \n');
	document.write('align="middle">\n');
	
	document.write('<param name="Flashvars" value="' + clientString + '">\n');
	document.write('<param name="allowScriptAccess" value="always" />\n');
	document.write('<param name="movie" value="graphics/' + FlashPanel + '.swf" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="salign" value="T" />\n');
	//document.write('<param name="wmode" value="opaque" />\n');
	document.write('<param name="scale" value="No Border" />\n');
	//document.write('<param name="bgcolor" value="##000063" />\n');
	document.write('<param name="play" value="false" />\n');
	document.write('<param name="loop" value="false" />\n');
			
	document.write('<embed src="graphics/' + FlashPanel + '.swf" \n');
	document.write('Flashvars="' + clientString + '"\n');
	document.write('quality="high" \n');
	//document.write('bgcolor="##000063" \n');
	document.write('width="' + FP_Width + '" \n');
	document.write('height="' + FP_Height + '" \n');
	document.write('name="' + FlashPanel + '" \n');
	document.write('align="middle" \n');
	document.write('salign="T" \n');
	//document.write('wmode="opaque" \n');
	document.write('scale="No Border" \n');
	document.write('play="false" \n');
	document.write('loop="false" \n');
	document.write('allowScriptAccess="always" \n');
	document.write('type="application/x-shockwave-flash" \n');
	document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
}

function image_fade (id, ft, fd) {
	this.img_id = id;
	this.fade_dir = fd;
	var fade_time = ft * 1000; // millisecs
	this.cycle_time = 24; // millisecs
	this.fade_increment = 100 / ( fade_time / this.cycle_time ); 
	
	// alert ( document.getElementById(id).src );
	
	if ( this.fade_dir == 'in' ) { this.visibility_index = - this.fade_increment; }
	else { this.visibility_index = 100 + this.fade_increment; }
	
	var local = this;
	this.display_image = function  ( ) {
		if ( local.fade_dir == 'in' ) { local.visibility_index += local.fade_increment; }
		else { local.visibility_index -= local.fade_increment; }
		
		local.image.style.opacity = local.visibility_index/100;  // mozilla + international standard
		local.image.style.filter = 'alpha( opacity =  ' + local.visibility_index + ')';  // Microsoft

		if (( local.visibility_index > 100 ) || ( local.visibility_index < 0 )) clearInterval ( local.timer ); 
	};
}

image_fade.prototype.start = function() {
	this.image = document.getElementById(this.img_id);

	if ( this.fade_dir == 'in' ) this.visibility_index = 0; 
	else this.visibility_index = 100;

	this.timer = setInterval(this.display_image, this.cycle_time);
};

function images_hide ( ) {
	for ( var i = 0; i < document.images.length; i++ ) {
		if ( document.images[i].src.search( /Train_Ride_Map/i  ) >= 0 )  {
			document.images[i].style.opacity = 0;
			document.images[i].style.filter = 'alpha( opacity =  0 )';
		}
	}
}

function char_count ( src, dest, max_num, msg ) {
	var chr_num = document.getElementById( src ).value.length;
	var d = document.getElementById( dest );
	d.innerHTML = chr_num;
	if ( chr_num == max_num + 1 ) { alert ( msg ); }
	if ( chr_num > max_num ) { d.style.color = '#cc0000'; }
	else { d.style.color = '#0000cc'; }
}

// the following 3 functions are used for mouse-over + linking to another web page  -  eg. HotPrintz home page
function m_over ( item, image ) {
	document.getElementById(item).style.backgroundImage='URL('+image+')';
	document.getElementById(item).style.cursor='pointer';
}

function m_out ( item, image ) {
	document.getElementById(item).style.backgroundImage='URL('+image+')';
}

function jump_to ( page ) {
	window.location = page;
}


