<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="__MSG_title__"
     directory_title="Instant Units Conversion"
     title_url="http://www.convert-me.com/__MSG_lang__/"
     author="Sergey Gershtein"
     author_email="suggest@convert-me.com"
     description="Online units conversion (U.S., British, metric, etc.)"
     author_affiliation="Convert-Me.Com"
     author_aboutme="Online units conversion (U.S., British, metric, etc.)"
     author_location="Yekaterinburg, Russia"
     screenshot="http://www.convert-me.com/GG/convert-me-280x300.png"
     thumbnail="http://www.convert-me.com/GG/convert-me-120x60.png"
     category="tools"
     category2="technology"
     scrolling="true"
     author_photo="http://www.convert-me.com/GG/sergey_gershtein_70x100.png"
     author_link="http://sergey.gershtein.net/"
     height="300">
     <Locale messages="http://www.convert-me.com/GG/convert-me.lng/ALL_ALL.xml"/>
     <Locale lang="en" country="ALL" messages="http://www.convert-me.com/GG/convert-me.lng/en_ALL.xml"/>
     <Locale lang="ru" country="ALL" messages="http://www.convert-me.com/GG/convert-me.lng/ru_ALL.xml"/>
     <Require feature="analytics"/>
  </ModulePrefs>
  <UserPref name="measure" display_name="__MSG_measurepref__" default_value="weight" datatype="enum" >
  	<EnumValue value="weight" display_value="__MSG_weight__" />
  	<EnumValue value="length" display_value="__MSG_length__" />
  	<EnumValue value="volume" display_value="__MSG_volume__" />
  	<EnumValue value="speed" display_value="__MSG_speed__" />
  	<EnumValue value="temperature" display_value="__MSG_temperature__" />
  	<EnumValue value="fuel" display_value="__MSG_fuel__" />
  	<EnumValue value="percent" display_value="__MSG_percent__" />
  </UserPref>
  <Content type="html">
  <![CDATA[
    <link rel=StyleSheet href="http://www.convert-me.com/GG/GG.css" media="screen" type="text/css">
    <center>
    <table border=0 cellpadding=0 cellspacing=0 align="center" height="31" align="center" style="margin-top: 2px">
    <tr><td><a href="http://www.convert-me.com/__MSG_lang__/?from=GG" target="_blank"><img
    src="http://www.convert-me.com/images/logo88x31.gif"
    width=88 height=31 border=0 alt="__MSG_imgalt__"
    title="__MSG_imgalt__"></a></td>
    <td>&nbsp;&nbsp;&nbsp;</td>
    <th><form name="navigation"><select name="othermeasure"
    class="othermeasure" onChange="changeMeasure(this[this.selectedIndex].value)">
    <option value="weight">__MSG_weight__</option>
    <option value="length">__MSG_length__</option>
    <option value="volume">__MSG_volume__</option>
    <option value="speed">__MSG_speed__</option>
    <option value="temperature">__MSG_temperature__</option>
    <option value="fuel">__MSG_fuel__</option>
    <option value="percent">__MSG_percent__</option>
    <option value="_go_" style="color: blue; font-weight: bold">__MSG_more__</option>
    </select></form></th>
    </tr></table>
    <table border=0 cellpadding=0 cellspacing=0 align="center" width="100%">
    <tr><td class="data1"><div id="content_div">
    <p>&nbsp;<br><i>__MSG_loading__</i></p>
    </div>
    <div style="padding-top: 3px; padding-bottom: 1px;"><center><a class="bottomline"
    href="http://www.convert-me.com/__MSG_lang__/?from=GG" title="__MSG_goto__"
    target="_blank">__MSG_bottomline__ &gt;&gt;</a></center>
    </td></tr></table>
    </center>

    <script language="JavaScript">

	// include conversion libraries
/***************************************************************/
/* translator.js script used at http://www.convert-me.com      */
/* Copyright (c) 2000-2006 by Anna Gershtein, Sergey Gershtein */
/* Unauthorized duplication is strictly prohibited             */
/* Contact suggest@convert-me.com if you have any questions    */
/***************************************************************/

var unitsArray = new Array();
var currentUnit;
var currentValue;
var oldValue;
var curField;
var showall = 1;
var showthis = {};


function unit ( name, title, sign, group ) {
	this.name = name;
	this.title = title;
	this.sign = sign;
	this.group = group;
	this.hidden = 0;
	this.coef = {};
}

function arrayOfUnits ( ) {
	var i = 0;
	var group;
	if ( mainArray[0] != "--" ) {
		group = "unique";
	}
	var j = 0;
    while ( i < mainArray.length ) {
    	if ( mainArray[i] == "--" ) {
			group = mainArray[++i];
			i+=2;
			continue;
		}
    	unitsArray[j] = new unit ( mainArray[i], mainArray[++i], mainArray[++i], group );
    	i++;
    	j++;
    }
}

function form () {
	var group;
	var text;
	var star='';
	var star1 = 0;
	var star2 = 0;
	var groupno = 0;
	var uno = 0;

	if ( lang == 'ru' ) {
		text = 'Количество значащих цифр:';
        } else if( lang == 'es' ) {
               	text = 'ES:Significant figures:';
	} else {
               	text = 'Significant figures:';
	}
	document.write ( "<div class=\"signfig\">" + text + " <select name=\"signFig\" " +
			"onChange=\"compute(currentUnit)\">" +
			"<option>1" +
			"<option>2" +
			"<option>3" +
			"<option selected>4" +
			"<option>5" +
			"<option>6" +
			"<option>7" +
			"</select></div>" );

	if ( lang == 'ru' ) {
        	text = 'Показывать числа с разделителем групп разрядов';
	} else if( lang == 'es' ) {
        	text = 'ES:Group digits in long numbers';
        } else {
        	text = 'Group digits in long numbers';
        }
        document.write ( "<div class\"groupfig\">" +
        	"<label><input type=\"checkbox\"" +
        	"checked=\"True\"" +
                "onClick=\"compute(currentUnit)\"" +
        	"name=\"separate\">" +
        	text +
                "</label>" +
        	"</div>" );

                // if there is subsArray, providing seceltion menu
                if( subsArray.length > 0 ) {
                	var stext;
                	var stext1;
			if ( lang == 'ru' ) {
				stext = 'Результаты зависят от конкретного вещества!<br>Выберите интересующее Вас вещество';
				stext1 = 'Для удобства можно выбрать вещество в списке внизу';
				stext2 = 'ВНИМАНИЕ! Плотности веществ сильно меняются в разных условиях!<br>Перевод масса/объем дает лишь приблизительные результаты.';
			} else if( lang == 'es' ) {
        			stext = 'ES:This conversion results depend on the particular substance.<br>Please start by picking your substance';
        			stext1 = 'ES:It might be more convenient to pick the substance from the list below';
        			stext2 = 'ES:Caution! The density of a substance can vary a lot depending on its conditions.<br>Weight to volume conversions are therefore only approximate.';
        		} else {
        			stext = 'This conversion results depend on the particular substance.<br>Please start by picking your substance';
        			stext1 = 'It might be more convenient to pick the substance from the list below';
        			stext2 = 'Caution! The density of a substance can vary a lot depending on its conditions.<br>Weight to volume conversions are therefore only approximate.';
                	}
			document.writeln( "<br><a name=\"subs\"><div class=\"selectSubs\">" + stext + ":<br>" );
			document.writeln( "<select class=\"selectSubs\" name=\"substance\" " +
				"onChange=\"compute(currentUnit)\">" );
                        for( var i=0; i<subsArray.length; i+=2 ) {
                        	document.writeln( "<option value=\"" + subsArray[i+1] + "\"" +
                        		( subsArray[i+1] == 1.00 ? " selected>" : ">" ) +
                        		subsArray[i] + "</option>" );
                        }
                        document.writeln( "</select></a>" +
                           "<table align=\"center\"><tr><td><a href=\"#subsList\" " +
                           "class=\"selectSubs\">" + stext1 + "</a></td></tr></table></div>" +
                           "<div class=\"subswarn\">" + stext2 + "</div><br>" );
                }

		document.writeln ( "<table border=0 cellspacing=0 class=\"utable\">" );

		if ( lang == 'ru' ) {
			text = 'Посчитать';
		} else if( lang == 'es' ) {
                	text = 'ES:Convert';
                } else {
                	text = 'Convert';
                }

		var j = 0;
		var uclass = '';
		for ( var i = 0; i < unitsArray.length; i++ ) {
			if ( group != unitsArray[i].group ) {
				// ad text above group heading
                                formInc( ++groupno );
				group = unitsArray[i].group;
				document.writeln ( "<tr><td colspan=2 class=\"uemptyrow\">&nbsp;</td></tr>" +
				"<tr><td class=\"utitle\">" + group + "</td>");
				document.writeln ( "<td class=\"ubutton\"><input type=\"button\" value=" +
				text +
				" onClick=\"compute(currentUnit)\"></td></tr>");
				while ( mainArray[j] != unitsArray[i].group ) {
					j++;
				}
				if ( mainArray[++j] != "" )
					document.writeln ( "<tr><td colspan=2 class=\"udescription\">" + mainArray[j] + "</td></tr>" );
                                uno = 0;
			}


           if ( unitsArray[i].title.substring (0, 2) == '**' ) {
            	star = '<sup><a href=\"#a\">**</a></sup>' + star;
				unitsArray[i].title = unitsArray[i].title.substring ( 2, unitsArray[i].title.length );
				star2 = 1;
			}
			else
				if ( unitsArray[i].title.substring (0, 1) == '*' ) {
					star = '<sup><a href=\"#a\">*</a></sup>' + star;
					unitsArray[i].title = unitsArray[i].title.substring ( 1, unitsArray[i].title.length );
					star1 = 1;
				}
		uclass = ( location.hash == ('#'+unitsArray[i].name)?
			'_hash' : (uno?'1':'') );

            document.writeln ( "<tr><td class=\"uname" + uclass + "\">" );
            document.writeln ( '<a name="' + unitsArray[i].name + '">' );
            if ( ( unitsArray[i].name.indexOf ( "_" ) != -1 && unitsArray[i].name.indexOf ( "_1" ) == -1 ) ||
            	unitsArray[i].name.indexOf ( "." ) != -1 ) {
	    	document.writeln( unitsArray[i].title );
            } else {
            	var fname = unitsArray[i].name;
            	var ch;
            	if( ( ch = fname.indexOf ( "/" ) ) != -1 ) {
			fname = fname.substring(0,ch) + "_" + fname.substring(ch+1,fname.length);
            	}
	    	document.writeln( "<a href=\"units/" + measure + "/" + measure +
	    	  "." + fname + "." + lang + ".html\">" +
	    	  unitsArray[i].title + "</a>");
            }

			if ( unitsArray[i].sign != '-' ) {
				document.writeln ( " (" + unitsArray[i].sign + ") " );
			}
			document.writeln ( star );
			star = '';

			document.writeln ( "</a>&nbsp;&nbsp;&nbsp;</td><td class=\"uvalue" + uclass + "\"><input type=text name=" +
			          unitsArray[i].name +
			          " size=15" +
			          " onFocus=\"oldValue=this.value; curField=this;\"" +
			          " onBlur=\"currentCompute(this.name, this.value); curField=''\"></td></tr>" );
                        uno = 1-uno;
		}
	        document.writeln ( "</table>" );
	        document.writeln ( "<a name=\"a\"><table width=450 class=\"footnote\">" );

		if ( star1 ) {
			document.writeln ( "<tr><td colspan=2 class=\"footnote\">*" +
				( lang == 'ru' ?
					" Величина не имеет точного значения. Используется приближенное." : lang == 'es' ? 
					" ES:The value is approximate. The unit does not have an exact value. "  :
					" The value is approximate. The unit does not have an exact value. " ) +
					"</td></tr>"
				);
	        }
		if ( star2 ) {
			document.writeln ( "<tr><td colspan=2 class=\"footnote\">**" +
				( lang == 'ru' ?
					" К сожалению, нам неизвестно точное значение этой величины." +
					" Если Вы обладаете такой информацией, пожалуйста, <a href=mailto:unitinfo@convert-me.com>сообщите нам " +
					"ее источник</a>." :
					lang == 'es' ?
					"ES: The value is approximate. We do not know the exact value of this unit." +
					"ES: If you have such information we would appreciate if you kindly <a href=mailto:unitinfo@convert-me.com>share it with us</a>." :
					" The value is approximate. We do not know the exact value of this unit." +
					" If you have such information we would appreciate if you kindly <a href=mailto:unitinfo@convert-me.com>share it with us</a>." ) +
					"</td></tr>"
				);
	        }
	        document.writeln ( "</table></a>" );

                // if there is subsArray, print selection list below
                if( subsArray.length > 0 ) {
                	var stext;
			if ( lang == 'ru' )
				stext = 'Альтернативный выбор вещества для вычислений';
			else if( lang == 'es' ) 
        			stext = 'ES:You can also pick the substance here';
        		else
        			stext = 'You can also pick the substance here';

			document.writeln( "<a name=\"subsList\"></a><br><div class=\"selectSubs\">" + stext + ":" +
			 "<table align=\"center\">" );
                        var cell = 0;
                        for( var i=0; i<subsArray.length; i+=2 ) {
                        	if( cell == 0 ) {
                        		document.writeln( "<tr>" );
                                }
                        	document.writeln( "<td><li><a class=\"selectSubs\" href=\"#subs\" "+
                        	"onClick=\"document.forms[\'main\'].substance.selectedIndex=" +
                        	i/2 + "; compute(currentUnit)\">" +
                        		subsArray[i] + "</a></li></td>" );
                                if( cell == 1 ) {
                                	document.writeln( "</tr>" );
                                } else {
                                	document.writeln("<td>&nbsp;&nbsp;&nbsp;</td>");
                                }
                                if( ++cell > 1 ) { cell = 0 };
                        }
                        if( cell != 0 ) { document.writeln( "<td>&nbsp;</td></tr>" ) }
                        document.writeln( "</table></div>" );
                        if( subsComment ) {
                        	document.writeln("<p class=\"subsComment\">"+subsComment+"</p>");
                        }
                }
	document.onkeydown = register;
}

function register(e) {
	// keypress
	var code;
	if( !e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;

	// enter
	if( code == 13 && curField ) {
		currentCompute( curField.name, curField.value );
        	return false; // do not do try to submit the form in Opera
        }
}

function addCoeff () {
	var k = 0;
	for( var i = 0; i < unitsArray.length; i++ ) {

		// пропускаем единицы без коэффициентов ( _ в имени, но не _1 )
		if( unitsArray[i].name.indexOf('_') != -1 &&
		    unitsArray[i].name.indexOf('_1') == -1)
			continue;

		for( var j = i+1; j < unitsArray.length; j++ ) {

			// пропускаем единицы без коэффициентов ( _ в имени, но не _1 )
			if( unitsArray[j].name.indexOf('_') != -1 &&
			    unitsArray[j].name.indexOf('_1') == -1 )
				continue;

                        // заносим прямой и обратный коэффициенты
			unitsArray[i].coef[unitsArray[j].name] = coeffArray[k];
			unitsArray[j].coef[unitsArray[i].name] = 1/coeffArray[k];

			k++;
		}
        }
	document.onkeydown = register;
}


function checkNum(val) {
	var text;
	if ( lang == 'ru' ) 
		text = "Введите, пожалуйста, правильное число!";
	else if( lang == 'es' ) 
		text = "ES:Please enter a valid number!";
	else
		text = "Please enter a valid number!";
	for (var i=0; i<currentValue.length; i++) {
		var ch = currentValue.substring(i, i + 1)
		if( ch=="," ) {
			currentValue =
				currentValue.substring(0,i) + "." + currentValue.substring(i+1,currentValue.length);
		} else if ( ch==" " ) {
			currentValue =
				currentValue.substring(0,i) + currentValue.substring(i+1,currentValue.length);
                                i--;
               	} else if (ch!="." && ch!="+" && ch!="-" && ch!="e" && ch!="E" && (ch < "0" || ch > "9")) {
			alert(text);
			document.forms["main"][val].focus ();
			document.forms["main"][val].select ();
			return false;
		}
	}
        document.forms["main"][val].value = currentValue;
	return true;
}

function roundOffSig ( value ) {
	var precision = parseInt(
		typeof(document.forms["main"].signFig) != 'undefined' ?
			document.forms["main"].signFig.selectedIndex+1 : 4
	);
	var result;
	value = String(value);
	var shift;
	var expPart = '';
	var signPart = '';
	if( !isFinite(value) )
		return ( lang=='ru'? 'бесконечность' : value );
	if ( value.indexOf( "e" ) != -1 ) {
		expPart = value.substring( value.indexOf( "e" ), value.length );
		value = value.substring( 0, value.indexOf( "e" ) );
	}
	else {
        if  ( value.indexOf( "E" ) != -1 ) {
        	expPart = value.substring( value.indexOf( "E" ), value.length );
        	value = value.substring( 0, value.indexOf( "e" ) );
        }
        if ( value.substring( 0, 1 ) == '-' ) {
        	signPart = '-';
        	value = value.substring( 1, value.length);
        }
	}
	if ( parseFloat(value) >= 1.0 ) {
		var point = value.indexOf( "." );
		if ( point == -1 ) {
			point = value.length;
		}
		shift = point-precision;
	}
	else {
		var notNull=String(value).lastIndexOf ( '.' ) + 1;
		if ( notNull == 1 ) notNull += 1;
		while ( String(value).charAt ( notNull ) == '0' ) {
			notNull++;
		}
		notNull -= 2;

		shift = -(precision+notNull);
	}

	result = Math.round(value/Math.pow(10, shift));
	if ( shift >=0 ) {
		for ( var i=1; i<=shift; i++ ) {
			result += '0';
		}
	}
	else {
		result += '';
		if ( result.length+shift>0 ) {
			result = result.substring ( 0, result.length+shift ) + '.' + result.substring ( result.length+shift, result.length );
		}
		else {
           	var result1 = '0.';
           	for ( var i=-1; i>=result.length+shift; i-- ) {
           		result1 += '0';
           	}
           	result = result1 + result;
		}
       	while ( result.charAt(result.length-1) == '0' ) {
       		result = result.substring ( 0, result.length-1 );
       	}
       	if ( result.charAt(result.length-1) == '.' ) {
       		result = result.substring ( 0, result.length-1 );
       	}
	}
//	if ( result <= 0 && result >= 0 ) expPart = '';
	result = signPart + result + expPart;

// разбиваем результат на группы разрядов, если это необходимо
		if ( typeof(document.forms["main"].separate) != 'undefined' &&
		     document.forms["main"].separate.checked ) {
                	var i = result.indexOf ( ".")>0 ? result.indexOf ( "." ) : result.length;
                	for ( var j=i-3; j>0; j-=3 ) {
                        	if ( result[j-1] != "-" )
                        		result = result.substring ( 0, j ) + " " + result.substring (j, result.length );
                        }
                }
	return result;

}

function compute ( val ) {

	var cvalue;

	if ( !currentUnit || !currentValue ) return;

        // фиксируем вычисление в google analytics
        //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // ВРЕМЕННО ЗАКОММЕНТИРОВАНО, Т.К. НА РУССКОЙ ВЕРСИИ ВЫДАЕТСЯ ОШИБКА JS
        //if( typeof(_uacct) != 'undefined' ) {
	//	eval('urchinTracker( location.pathname + "/JS:COMPUTE" )');
        //}

	if ( currentValue && checkNum( val ) ) {
		cvalue  = currentValue;
		if ( val.indexOf ( "_1" ) != -1 ) {
			cvalue = 1/currentValue;
		} else if ( val.indexOf ( "_" ) != -1 ) {
			var func = val.substring ( val.indexOf( "_" ) + 1, val.length ) + "('" + val +"')";
			eval ( func );
			return;
		}
		var vw = '';
		var substance_val = 1;
		if(  val.indexOf ( "." ) != -1 && subsArray.length > 0 ) {
			// участвуют единицы веса и объема
			vw=val.substring(0,1);
			if( vw != 'v' && vw != 'w' ) {
				alert("Sorry, exception found, please report to convert-me.com team");
				return;
			}
			substance_val = document.forms["main"].substance.options[document.forms["main"].substance.selectedIndex].value;
		}
		for ( var i = 0; i < unitsArray.length; i++ ) {
			if ( val == unitsArray[i].name ) break;
		}
		var csubs = 1;

		for ( var j in unitsArray[i].coef ) {
			if( showall == 0 && showthis[j] != 1 )
				continue; // hidden unit
			if( substance_val != 1 && j.substring(0,1) != vw ) {
				// вводим поправку на конкретное вещество
				if( vw == 'v' ) {
					// из объема в вес
					csubs = substance_val;
				} else {
					// из веса в объем
					csubs = 1/substance_val;
				}
			} else {
				csubs = 1;
                        }

			if ( j.indexOf ( "_1" ) != -1 ) {
				document.forms["main"][j].value = roundOffSig (
					1/(unitsArray[i].coef[j]*cvalue*csubs) );
			} else {
				document.forms["main"][j].value = roundOffSig (
					unitsArray[i].coef[j]*cvalue*csubs );
                        }
		}

		document.forms["main"][val].value = roundOffSig ( currentValue );
	}
}

function currentCompute ( name, value ) {
	if ( oldValue == value ) return;
	currentUnit = name;
	currentValue = value;
	compute ( name );
}

function tempr ( val ) {
	var text;
	if ( lang == 'ru' ) 
		text = "Это невозможно по законам природы!";
	else if( lang=='es' )
		text = "ES:This is impossible due to laws of nature!";
    	else 
		text = "This is impossible due to laws of nature!";
	if ( val == 'celsius_tempr' ) {
		if ( Number(currentValue) < -273.15 ) {
			alert (text);
			document.forms["main"][val].focus ();
			document.forms["main"][val].select ();
			return false;
		}
		document.forms["main"].farenheit_tempr.value = roundOffSig ( Number(currentValue)*1.8+32 );
		document.forms["main"].kelvin_tempr.value = roundOffSig ( Number(currentValue)+273.15 );
		document.forms["main"].reaumur_tempr.value = roundOffSig ( Number(currentValue)*0.8 );
		document.forms["main"].rankin_tempr.value = roundOffSig ( Number(currentValue)*1.8+491.67 );
		document.forms["main"].celsius_tempr.value = roundOffSig ( Number(currentValue) );
	}
	if ( val == 'farenheit_tempr' ) {
		if ( Number(currentValue) < -459.67 ) {
			alert (text);
			document.forms["main"][val].focus ();
			document.forms["main"][val].select ();
			return false;
		}
		document.forms["main"].celsius_tempr.value = roundOffSig ( (Number(currentValue)-32)/1.8 );
		document.forms["main"].kelvin_tempr.value = roundOffSig ( (Number(currentValue)+459.67)/1.8 );
		document.forms["main"].reaumur_tempr.value = roundOffSig ( (Number(currentValue)-32)/2.25 );
		document.forms["main"].rankin_tempr.value = roundOffSig ( Number(currentValue)+459.67 );
		document.forms["main"].farenheit_tempr.value = roundOffSig ( Number(currentValue) );
	}
	if ( val == 'kelvin_tempr' ) {
		if ( Number(currentValue) < 0 ) {
			alert (text);
			document.forms["main"][val].focus ();
			document.forms["main"][val].select ();
			return false;
		}
		document.forms["main"].celsius_tempr.value = roundOffSig ( Number(currentValue)-273.15 );
		document.forms["main"].farenheit_tempr.value = roundOffSig ( Number(currentValue)*1.8-459.67 );
		document.forms["main"].reaumur_tempr.value = roundOffSig ( (Number(currentValue)-273.15)*0.8 );
		document.forms["main"].rankin_tempr.value = roundOffSig ( Number(currentValue)*1.8 );
		document.forms["main"].kelvin_tempr.value = roundOffSig ( Number(currentValue) );
	}
	if ( val == 'reaumur_tempr' ) {
		if ( Number(currentValue) < -218.52 ) {
			alert (text);
			document.forms["main"][val].focus ();
			document.forms["main"][val].select ();
			return false;
		}
		document.forms["main"].celsius_tempr.value = roundOffSig ( Number(currentValue)*1.25 );
		document.forms["main"].farenheit_tempr.value = roundOffSig ( Number(currentValue)*2.25+32 );
		document.forms["main"].kelvin_tempr.value = roundOffSig ( Number(currentValue)*1.25+273.15 );
		document.forms["main"].rankin_tempr.value = roundOffSig ( Number(currentValue)*2.25+491.67 );
		document.forms["main"].reaumur_tempr.value = roundOffSig ( Number(currentValue) );
	}
	if ( val == 'rankin_tempr' ) {
		if ( Number(currentValue) < 0 ) {
			alert (text);
			document.forms["main"][val].focus ();
			document.forms["main"][val].select ();
			return false;
		}
		document.forms["main"].celsius_tempr.value = roundOffSig ( (Number(currentValue)-491.67)/1.8 );
		document.forms["main"].farenheit_tempr.value = roundOffSig ( Number(currentValue)-459.67 );
		document.forms["main"].kelvin_tempr.value = roundOffSig ( Number(currentValue)/1.8 );
		document.forms["main"].reaumur_tempr.value = roundOffSig ( (Number(currentValue)-491.67)/2.25 );
		document.forms["main"].rankin_tempr.value = roundOffSig ( Number(currentValue) );
	}

	if ( document.forms["main"].kelvin_tempr.value == 0 || document.forms["main"].rankin_tempr.value == 0 ) {
		document.forms["main"].kelvin_tempr.value = 0;
		document.forms["main"].rankin_tempr.value = 0;
	}

}



/******************************************************************/
/* ggform.js displays google gadget for http://www.convert-me.com */
/* Copyright (c) 2007 by Sergey Gershtein                         */
/* Unauthorized duplication is strictly prohibited                */
/* Contact suggest@convert-me.com if you have any questions       */
/******************************************************************/

// show only some units in the gadget.
ggshow = {
	weight: new Array(
		'kilogram','gram',
		'shortton','longton','pound','ounce'
        ),
        length: new Array(
		'kilometer','meter','centimeter',
		'mile','foot','inch'
        ),
        volume: new Array(
        	'liter','gallon','floz','brgallon','brfloz'
        ),
        speed: new Array(
        	'm/sec','km/hr',
        	'mile/hr',
        	'minperkm_1','minpermile_1'
	),
	temperature: new Array(
		'celsius_tempr','farenheit_tempr',
		'kelvin_tempr','reaumur_tempr','rankin_tempr'
	),
	fuel: new Array(
		'lp100kmfuel',
		'mpgfuel_1',
		'bmpgfuel_1',
		'bmplfuel_1'
	),
	percent: new Array(
		'percent',
                'permille',
		'uppm',
		'uppb',
                'mole'
	)
};

function ggform () {
	var group = '';
	var text;
	var star='';
	var star1 = 0;
	var star2 = 0;
	var groupno = 0;
	var uno = 0;
	var html = "";

	// prepare a boolean hash of units to show
	showall = 1;
	showthis = {};
        if( typeof(ggshow[measure]) != 'undefined' ) {
		showall = 0;
		for( var j=0; j<ggshow[measure].length; j++ ) {
			showthis[ggshow[measure][j]] = 1;
                }
        }

	html += ( "<table border=0 cellspacing=0 class=\"utable\">" );

	if ( lang == 'ru' ) {
		text = 'Посчитать';
	} else {
               	text = 'Convert';
	}

	var j = 0;
	var uclass = '';
	for ( var i = 0; i < unitsArray.length; i++ ) {
		if( showall == 0 && showthis[unitsArray[i].name] != 1 )
			continue;
		if ( group != unitsArray[i].group ) {
			group = unitsArray[i].group;
			html += ( "<tr><td colspan=2 class=\"uemptyrow\">&nbsp;</td></tr>" +
			"<tr><td class=\"utitle\">" + group + "</td>");
			html += ( "<td class=\"ubutton\"><input type=\"button\" value=" +
			text +
			" onClick=\"compute(currentUnit)\"></td></tr>");
			while ( mainArray[j] != unitsArray[i].group ) {
				j++;
			}
			if ( mainArray[++j] != "" )
				html += ''; // ( "<tr><td colspan=2 class=\"udescription\">" + mainArray[j] + "</td></tr>" );
			uno = 0;
		}

		if ( unitsArray[i].title.substring (0, 2) == '**' ) {
			star = '<sup><a href=\"#a\">**</a></sup>' + star;
			unitsArray[i].title = unitsArray[i].title.substring( 2, unitsArray[i].title.length );
//			star2 = 1;
		} else if ( unitsArray[i].title.substring (0, 1) == '*' ) {
			star = '<sup><a href=\"#a\">*</a></sup>' + star;
			unitsArray[i].title = unitsArray[i].title.substring ( 1, unitsArray[i].title.length );
//			star1 = 1;
		}
		uclass = ( location.hash == ('#'+unitsArray[i].name)?
			'_hash' : (uno?'1':'') );

		html += ( "<tr><td class=\"uname" + uclass + "\">" );
		html += ( '<a name="' + unitsArray[i].name + '">' );
		if ( ( unitsArray[i].name.indexOf ( "_" ) != -1 && unitsArray[i].name.indexOf ( "_1" ) == -1 ) ||
			unitsArray[i].name.indexOf ( "." ) != -1 ) {
			html += ( "<span class=\"uname" + uclass + "\">" + unitsArray[i].title + "</span>");
		} else {
			var fname = unitsArray[i].name;
			var ch;
			if( ( ch = fname.indexOf ( "/" ) ) != -1 ) {
				fname = fname.substring(0,ch) + "_" + fname.substring(ch+1,fname.length);
			}
			html += ( "<a target=\"_blank\" href=\"http://www." +
				(lang == 'ru'? 'ru.' : '') +
				"convert-me.com/" + lang +
		    		"/convert/units/" + measure + "/" + measure +
				"." + fname + "." + lang + ".html\" class=\"uname" + uclass + "\">" +
				unitsArray[i].title + "</a>");
		}

		if ( unitsArray[i].sign != '-' ) {
			html += ( "<span class=\"uname" + uclass + "\"> (" + unitsArray[i].sign + ") </span>" );
		}
//		html += ( star );
		star = '';

		html += ( "</a></td><td class=\"uvalue" + uclass + "\"><input type=text name=" +
			unitsArray[i].name +
			" size=8" +
			" onFocus=\"oldValue=this.value; curField=this;\"" +
			" onBlur=\"currentCompute(this.name, this.value); curField=''\"></td></tr>" );
			uno = 1-uno;
	}
	html += ( "</table>" );

        if( star1 || star2 ) {
		html += ( "<a name=\"a\"><table width=300 class=\"footnote\">" );
		if ( star1 ) {
			html += ( "<tr><td colspan=2 class=\"footnote\">*" +
				( lang == 'ru' ?
					" Величина не имеет точного значения. Используется приближенное." :
					" The value is approximate. The unit does not have an exact value. " ) +
					"</td></tr>"
				);
	        }
		if ( star2 ) {
			html += ( "<tr><td colspan=2 class=\"footnote\">**" +
				( lang == 'ru' ?
					" К сожалению, нам неизвестно точное значение этой величины." +
					" Если Вы обладаете такой информацией, пожалуйста, <a href=mailto:unitinfo@convert-me.com>сообщите нам " +
					"ее источник</a>." :
					" The value is approximate. We do not know the exact value of this unit." +
					" If you have such information we would appreciate if you kindly <a href=mailto:unitinfo@convert-me.com>share it with us</a>." ) +
					"</td></tr>"
				);
	        }
	        html += ( "</table></a>" );
	}
	return html;
}



        // create global vars
        var mainArray;
        var coeffArray;
        var subsArray;
	var measure = '';
	var lang="en";

	// update measures drop-down list
	function updateMeasureList() {
		for( var i = 0; i < document.navigation.othermeasure.length; i++ ) {
			if( document.navigation.othermeasure.options[i].value == measure ) {
				document.navigation.othermeasure.options[i].selected = true;
				break;
			}
		}
	}

        function changeMeasure(newmeasure) {
		if( newmeasure == measure ) return;
		if( newmeasure == '_go_' ) {
			top.location='http://www.convert-me.com/__MSG_lang__/?from=GG';
			return;
		}
		measure = newmeasure;
		updateMeasureList();
		_gel("content_div").innerHTML = "<p>&nbsp;<br><i>__MSG_loading__...</i></p>";
        	// load the coefficients data and display content when ready
        	_IG_FetchContent('http://www.convert-me.com/GG/js/units/utf8/' + lang + '_' + measure + '.js.utf8',
	        	showContent );
        }

	function showContent(responseText) {
		// process loaded coeficients data
		eval(responseText);
		unitsArray = new Array();
		arrayOfUnits();
		// construct the conversion form
		var content = '<form name="main" onSubmit="return false;">' + "\n" +
        		ggform() + "\n" + '</form>';
		_gel("content_div").innerHTML = content;
		// construct the cooficients
		addCoeff();
	        // track with google analytics
	        _IG_Analytics("UA-429041-1","/GG/convert-me.xml/"+measure);

        }

	var prefs = new _IG_Prefs(__MODULE_ID__);
	lang = prefs.getMsg("lang");
        changeMeasure( prefs.getString("measure") || 'weight' );
        document.onkeydown = register; // to process Enter key

    </script>
  ]]>
  </Content>
</Module>
