
function checkEnter(e){ //e is event object passed from function invocation
var characterCode;  // literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e;
characterCode = e.which; //character code is contained in NN4's which property
}
else{
e = event;
characterCode = e.keyCode; //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
return true;
}
else{
return false;
}
}


function fmt_mins(k)
{
	var mins=Math.round(k);

	if ( mins<1 )
	{
		return '<1 min';
	}
	if ( mins<60 )
	{
		return mins+ ' mins';
	}
	var hrs=Math.floor( mins/60 );
	mins=mins- hrs*60;
	
	return hrs+' hrs '+mins+' mins';
}

function fmt_kms(k)
{
	var num=Math.round(k*10)/10;

	if ( num<0.1)
	{
		return ' <1 km';
	}
	return num+' kms';
}

function fmt_cost(k)
{
	var num=Math.round(k*100)/100;
	if ( num<0.01)
	{
		return ' <0.01$';
	}
	return '$'+num;
}
function fmt_emiss(k)
{
	var num=Math.round(k*10)/10;
	if ( num<0.01)
	{
		return ' <0.01 kg GHG';
	}
	return num+' kg GHG';
}



function get_color_wheel(i)
{
	if ( i==0 )return '#0000ff'; // blue
	if ( i==1 )return '#00ff00'; // green
	if ( i==2 )return '#ff0000'; // red
	if ( i==3 )return '#00ffff'; // blue+green
	if ( i==4 )return '#ff00ff'; // ??
	if ( i==5 )return '#ffff00';
	if ( i==6 )return '#ffaaaa';
	return '#0000ff';	
}



function show_wait(){ this.log('show wait'); $('xhr').show(); };
function hide_wait(){ this.log('hide wait'); $('xhr').hide(); };

wait_count=0;
function inc_wait(){ if ( wait_count==0 ) show_wait(); wait_count++; };
function dec_wait(){ 
	if ( wait_count==0 ) log('ASSERT: dec wait below zero!');
	if ( wait_count==1 ) hide_wait();
	wait_count--;
	};


function browser_get_window_size() 
{
	// see http://www.howto create.co.uk/ tutorials/javascript/browserwindow
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		 //IE 4 compatible
		 myWidth = document.body.clientWidth;
		 myHeight = document.body.clientHeight;
	}
	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );
	var a=[ myWidth, myHeight ];
	return a;
}

   // JS::DrawTheMap_

function hide_click(divid)
{
  Effect.BlindUp(divid+'_cont');
	//$(divid+'_cont').hide();
	$(divid+'_show').show();
	$(divid+'_hide').hide();	
}
function show_click(divid)
{
//	$(divid+'_cont').show();
  	Effect.BlindDown(divid+'_cont');
	$(divid+'_show').hide();
	$(divid+'_hide').show();	
}


