function $(id)
{
	return document.getElementById(id);
}

function swapImage(img, tag)
{
	$(tag).src = img;
}

function initArray() 
{
  this.length = initArray.arguments.length;
  for (var i = 0; i < this.length; i++) 
    {
    this[i] = initArray.arguments[i];
    }
}

function areCon() {
  // First, get the variables checked by the user
  for (var i = 0; i < 9; i++) {
    if (document.isnform04.arei[i].checked) {
      arei = i;
      areinm = document.isnform04.arei[i].value;
      }
    }
  for (var i = 0; i < 9; i++) {
    if (document.isnform04.areo[i].checked) {
      areo = i;
      areonm = document.isnform04.areo[i].value;
      }
    }
  // Now grab the numeric input by user and parse to be sure numeric
  useri = document.isnform04.areinp.value;
  if (useri == 0) {
    useri = 1;
    document.isnform04.areinp.value = useri;
    }
  mulstr = isn04[arei];
  picker = "~" + areo;
  ps = mulstr.indexOf(picker);
  areo++;
  picker = "~" + areo;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  picker = useri + " " + areinm + " = " + picker + " " + areonm
  document.isnform04.areout.value = picker;
  }
  
function lenCon() {
  // First, get the variables checked by the user
  for (var i = 0; i < 8; i++) {
    if (document.isnform01.leni[i].checked) {
      leni = i;
      leninm = document.isnform01.leni[i].value;
      }
    }
  for (var i = 0; i < 8; i++) {
    if (document.isnform01.leno[i].checked) {
      leno = i;
      lenonm = document.isnform01.leno[i].value;
      }
    }
  // Now grab the number input by user and parse to be sure numeric
  useri = document.isnform01.leninp.value;
  if (useri == 0) {
    useri = 1;
    document.isnform01.leninp.value = useri;
    }
  mulstr = isn01[leni];
  picker = "~" + leno;
  ps = mulstr.indexOf(picker);
  leno++;
  picker = "~" + leno;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  picker = useri + " " + leninm + " = " + picker + " " + lenonm
  document.isnform01.lenout.value = picker;
  }
  
function volCon() {
  // First, get the variables checked by the user
  for (var i = 0; i < 9; i++) {
    if (document.isnform05.voli[i].checked) {
      voli = i;
      volinm = document.isnform05.voli[i].value;
      }
    }
  for (var i = 0; i < 9; i++) {
    if (document.isnform05.volo[i].checked) {
      volo = i;
      volonm = document.isnform05.volo[i].value;
      }
    }
  // Now grab the numeric input by user and parse to be sure numeric
  useri = document.isnform05.volinp.value;
  if (useri == 0) {
    useri = 1;
    document.isnform05.volinp.value = useri;
    }
  mulstr = isn05[voli];
  picker = "~" + volo;
  ps = mulstr.indexOf(picker);
  volo++;
  picker = "~" + volo;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  picker = useri + " " + volinm + " = " + picker + " " + volonm
  document.isnform05.volout.value = picker;
  }
  
function weiCon() {
  // First, get the variables checked by the user
  for (var i = 0; i < 7; i++) {
    if (document.isnform02.weii[i].checked) {
      weii = i;
      weiinm = document.isnform02.weii[i].value;
      }
    }
  for (var i = 0; i < 7; i++) {
    if (document.isnform02.weio[i].checked) {
      weio = i;
      weionm = document.isnform02.weio[i].value;
      }
    }
  // Now grab the numeric input by user and parse to be sure numeric
  useri = document.isnform02.weiinp.value;
  if (useri == 0) {
    useri = 1;
    document.isnform02.weiinp.value = useri;
    }
  mulstr = isn02[weii];  //0
  picker = "~" + weio;   //~3
  ps = mulstr.indexOf(picker);
  weio++;
  picker = "~" + weio;
  ps1 = mulstr.indexOf(picker);
  mulstr = mulstr.substring((ps + 2),ps1);
  //alert("Index: "+weii+", Index: "+weio+" Result: "+mulstr+" ps: "+ps);
  ps = (useri * mulstr);
  picker = "";
  picker += ps
  ps1 = picker.indexOf(".");
  if (ps1 > -1) {
    // Correct for binary/floating point conversion error
    ps = ps + .000001;
    picker = "";
    picker += ps;
    ps2 = picker.indexOf("e");
    if (ps2 < 0) {
      picker = picker.substring(0,(ps1 + 6));
      }
    if (ps2 == 0 || ps2 > 0) {
      ps3 = picker.indexOf("00000");
      if (ps3 > 0) {
        picker = picker.substring(0,ps3 + 1) + picker.substring(ps2,picker.length);
        }
      }
    }
  picker = useri + " " + weiinm + " = " + picker + " " + weionm
  document.isnform02.weiout.value = picker;
  }
  
function vwCon()
{	
	var l = document.isnform03.vwlen.value;
	var w = document.isnform03.vwwid.value;
	var h = document.isnform03.vwhei.value;
	
	if (l < 0.1)
	{
	   l = 0.1;
	   document.isnform03.vwlen.value = l;	
	}
	if (w < 0.1)
	{
	   w = 0.1;
	   document.isnform03.vwwid.value = l;	
	}
	if (h < 0.1)
	{
	   h = 0.1;
	   document.isnform03.vwhei.value = l;	
	}
	
	cubed = eval(l * w * h);
	dividedcubed = eval(cubed / 166);
	var r = eval(dividedcubed * 0.45359237);
	document.isnform03.vwout.value = r.toFixed(3)+" Kilograms";
}

function temCon() {
  // First, get the variables checked by the user
  for (var i = 0; i < 3; i++) {
    if (document.isnform06.temi[i].checked) {
      temi = i;
      teminm = document.isnform06.temi[i].value;
      }
    }
  for (var i = 0; i < 3; i++) {
    if (document.isnform06.temo[i].checked) {
      temo = i;
      temonm = document.isnform06.temo[i].value;
      }
    }
  // Now grab the numeric input by user and parse to be sure numeric
  useri = document.isnform06.teminp.value;
  if (useri == 0) {
    useri = 1;
    document.isnform06.teminp.value = useri;
    }
  if (teminm == "Celsius") {
    if (temonm == "Fahrenheit") {
       res = ((9/5) * document.isnform06.teminp.value + 32);
    }else if (temonm == "Kelvin") {
       res = (document.isnform06.teminp.value - 0 + 273.15);
    } else {
       res = (document.isnform06.teminp.value);
    }
  } else if (teminm == "Fahrenheit") {
     if (temonm == "Celsius") {
        res = (5/9) * (document.isnform06.teminp.value - 32);
     }else if (temonm == "Kelvin") {
  	res = ((5/9) * (document.isnform06.teminp.value - 32)) + 273.15;
     } else {
        res = (document.isnform06.teminp.value);
     }
  } else if (teminm == "Kelvin") {
     if (temonm == "Celsius") {
     	res = (document.isnform06.teminp.value - 273.15);
     }else if (temonm == "Fahrenheit") {
     	res = ((9/5) * (document.isnform06.teminp.value - 273.15) + 32);
     } else {
        res = (document.isnform06.teminp.value);
     }
  }
  
  // only show 1 decimals
  var tot = res.toFixed(1);
  document.isnform06.temout.value = document.isnform06.teminp.value + " " + teminm + " = " + tot + " " + temonm;
}
  
// Calculate four digit year.
function fourdigits(number)	
{
	return (number < 1000) ? number + 1900 : number;
}

function today()
{
// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Array list of months.
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Join it all together
var res =  days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear()));

$("tday").innerHTML = res;
}

function GetTime() 
{ 
<!-- Original:  Emanuel Gavrilv (eltal@sprint.ca) -->
<!-- Web Site:  http://www.angelfire.com/on/eltal -->
var dt = new Date();
var def = dt.getTimezoneOffset()/60;
var gmt = (dt.getHours() + def);
$("lt").innerHTML = (IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));

var ending = ":" + IfZero(dt.getMinutes()) + ":" +  IfZero(dt.getSeconds());
var endingcar = ":" + IfZero(dt.getMinutes()+30) + ":" +  IfZero(dt.getSeconds());
var rom = check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));
rom += DST('eu'); //add daylight savings time
$("rom").innerHTML = (IfZero(rom) + ending);
$("bar").innerHTML = (IfZero(rom) + ending);
$("ber").innerHTML = (IfZero(rom) + ending);
$("par").innerHTML = (IfZero(rom) + ending);
$("zur").innerHTML = (IfZero(rom) + ending);

var isr =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
//document.clock.Israel.value = (IfZero(isr) + ending);
var msw =check24(((gmt + 3) > 24) ? ((gmt + 3) - 24) : (gmt + 3));
//document.clock.msw.value = (IfZero(msw) + ending);
var baku =check24(((gmt + 4) > 24) ? ((gmt + 4) - 24) : (gmt + 4));
//document.clock.baku.value = (IfZero(baku) + ending);
var del =check24(((gmt + 5) > 24) ? ((gmt + 5) - 24) : (gmt + 5));
//document.clock.del.value = (IfZero(del) + ending);
var dh =check24(((gmt + 6) > 24) ? ((gmt + 6) - 24) : (gmt + 6));
//document.clock.dh.value = (IfZero(dh) + ending);

var kok =check24(((gmt +7 ) > 24) ? ((gmt +7 ) - 24) : (gmt + 7));
$("ban").innerHTML = (IfZero(kok) + ending);
$("jak").innerHTML = (IfZero(kok) + ending);

var ho =check24(((gmt + 8) > 24) ? ((gmt + 8) - 24) : (gmt + 8));
$("bei").innerHTML = (IfZero(ho) + ending);
$("hon").innerHTML = (IfZero(ho) + ending);
$("sin").innerHTML = (IfZero(ho) + ending);

var tky =check24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));
$("tok").innerHTML = (IfZero(tky) + ending);
var sdn =check24(((gmt + 10) > 24) ? ((gmt + 10) - 24) : (gmt + 10));
sdn += DST('aus'); //add daylight savings time
$("syd").innerHTML = (IfZero(sdn) + ending);

var mag =check24(((gmt + 11) > 24) ? ((gmt + 11) - 24) : (gmt + 11));
//document.clock.mag.value = (IfZero(mag) + ending);
var wll =check24(((gmt + 12) > 24) ? ((gmt + 12) - 24) : (gmt + 12));
//document.clock.wll.value = (IfZero(wll) + ending);

var _GMT =check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));
//var rgmt = (IfZero(_GMT) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));
$("gmt").innerHTML = (IfZero(_GMT) + ending);
_GMT += DST('eu'); //add daylight savings time
$("lon").innerHTML = (IfZero(_GMT) + ending);


var eniw =check24(((gmt + (24-12)) > 24) ? ((gmt + (24-12)) - 24) : (gmt + (24-12)));
//document.clock.eniw.value = (IfZero(eniw) + ending);
var sam =check24(((gmt + (24-11)) > 24) ? ((gmt + (24-11)) - 24) : (gmt + (24-11)));
//document.clock.sam.value = (IfZero(sam) + ending);
var haw =check24(((gmt + (24-10)) > 24) ? ((gmt + (24-10)) - 24) : (gmt + (24-10)));
//document.clock.Hawaii.value = (IfZero(haw) + ending);
var ala =check24(((gmt + (24-9)) > 24) ? ((gmt + (24-9)) - 24) : (gmt + (24-9)));
//document.clock.alaska.value = (IfZero(ala) + ending);
var pacif =check24(((gmt + (24-8)) >= 24) ? ((gmt + (24-8)) - 24) : (gmt + (24-8)));
pacif += DST('usa'); //add daylight savings time
$("lax").innerHTML = (IfZero(pacif) + ending);

var mount =check24(((gmt + (24-7)) > 24) ? ((gmt + (24-7)) - 24) : (gmt + (24-7)));
//document.clock.mount.value = (IfZero(mount) + ending);
var center =check24(((gmt + (24-6)) > 24) ? ((gmt + (24-6)) - 24) : (gmt + (24-6)));
$("gua").innerHTML = (IfZero(center) + ending);
center += DST('usa'); //add daylight savings time
$("ord").innerHTML = (IfZero(center) + ending);
$("hou").innerHTML = (IfZero(center) + ending);


var east =check24(((gmt + (24-5)) > 24) ? ((gmt + (24-5)) - 24) : (gmt + (24-5)));
$("lim").innerHTML = (IfZero(east) + ending);
$("car").innerHTML = (IfZero(east) + endingcar);
east += DST('usa'); //add daylight savings time
$("atl").innerHTML = (IfZero(east) + ending);
$("bal").innerHTML = (IfZero(east) + ending);
$("mia").innerHTML = (IfZero(east) + ending);
$("nyc").innerHTML = (IfZero(east) + ending);
$("orf").innerHTML = (IfZero(east) + ending);
var atl =check24(((gmt + (24-4)) > 24) ? ((gmt + (24-4)) - 24) : (gmt + (24-4)));
atl = (atl >= 24) ? atl - 24 : atl;

atl += DST('cl');
$("san").innerHTML = (IfZero(atl) + ending);

var bra =check24(((gmt + (24-3)) > 24) ? ((gmt + (24-3)) - 24) : (gmt + (24-3)));
bra = (bra >= 24) ? bra - 24 : bra;
$("bue").innerHTML = (IfZero(bra) + ending);
var ur = bra+DST('ur'); //add daylight savings time
var br = bra+DST('br');
$("mon").innerHTML = (IfZero(ur) + ending);
$("rio").innerHTML = (IfZero(br) + ending);
$("sao").innerHTML = (IfZero(br) + ending);

var mid =check24(((gmt + (24-2)) > 24) ? ((gmt + (24-2)) - 24) : (gmt + (24-2)));
mid = (mid >= 24) ? mid - 24 : mid;
//document.clock.mid.value = (IfZero(mid) + ending);
var azo =check24(((gmt + (24-1)) > 24) ? ((gmt + (24-1)) - 24) : (gmt + (24-1)));
azo = (azo >= 24) ? azo - 24 : azo;
//document.clock.azo.value = (IfZero(azo) + ending);
setTimeout("GetTime()", 1000);
}

function IfZero(num) 
{
return ((num <= 9) ? ("0" + num) : num);
}

function check24(hour) 
{
return (hour >= 24) ? hour - 24 : hour;
}

function DST(locale)
{
	var dat = new Date;
	var year = dat.getFullYear();
	var startdate = new Date;
	var enddate = new Date;
	var offset = 0;
	
	if (locale == "usa")
	{	
		offset =0;
		//first get the first day of the month
		var firstday = new Date(year, 2, 1);
		//find out what day of the week it is
		var weekday = firstday.getDay();
		//now figure out the second Sunday
		var startday = ((8-weekday)+7);
		startdate.setFullYear(year, 2, startday)
		
		var firstdayend = new Date(year, 10, 1);
		var weekdayend = firstdayend.getDay();
		var startdayend = (8-weekdayend);
		enddate.setFullYear(year, 10, startdayend); 
		
		if (dat < enddate & dat >= startdate)
		{
		  offset++;			
		}
	}
	if (locale == "aus")
	{
		offset = 0;
		startdate.setMonth(2); // March
		startdate.setDate(31);
		var day = startdate.getDay();// day of week of 31st
		startdate.setDate(31-day); // last Sunday
		enddate.setMonth(9); // October
		enddate.setDate(31);
		day = enddate.getDay();
		enddate.setDate(31-day);
		if (dat < startdate || dat >= enddate) 
		{
			offset++;
		}
	}
	if (locale == "eu")
	{
		offset = 0;
		startdate.setMonth(2); // March
		startdate.setDate(31);
		var day = startdate.getDay();// day of week of 31st
		startdate.setDate(31-day); // last Sunday
		enddate.setMonth(9); // October
		enddate.setDate(31);
		day = enddate.getDay();
		enddate.setDate(31-day);
		if (dat < enddate & dat >= startdate) 
		{
			offset++;
		}
	}
	if (locale == "ur")
	{
		offset =0;
		//first get the first day of the month
		var firstday = new Date(year, 2, 1);
		//find out what day of the week it is
		var weekday = firstday.getDay();
		//now figure out the second Sunday
		var startday = ((8-weekday)+7);
		startdate.setFullYear(year, 2, startday)
		
		var firstdayend = new Date(year, 9, 1);
		var weekdayend = firstdayend.getDay();
		var startdayend = (8-weekdayend);
		enddate.setFullYear(year, 9, startdayend); 
		
		if (dat < startdate || dat >= enddate)
		{
		  offset++;			
		}
	}
	if (locale == "br")
	{
		offset =0;
		//first get the first day of the month
		var firstday = new Date(year, 1, 1);
		//find out what day of the week it is
		var weekday = firstday.getDay();
		//now figure out the second Sunday
		var startday = (8-weekday);
		if (startday < 11)
		{
			startday + 7;
		}
		startdate.setFullYear(year, 2, startday);
		
		var firstdayend = new Date(year, 9, 1);
		var weekdayend = firstdayend.getDay();
		var startdayend = (8-weekdayend);
		enddate.setFullYear(year, 9, startdayend); 
		
		if (dat < startdate || dat >= enddate)
		{
		  offset++;			
		}
	}
	if (locale == "cl")
	{
		offset =0;
		//first get the first day of the month
		var firstday = new Date(year, 9, 1);
		//find out what day of the week it is
		var weekday = firstday.getDay();
		//now figure out the second Sunday
		var startday = (8-weekday);
		startdate.setFullYear(year, 2, startday);
		
		var firstdayend = new Date(year, 1, 1);
		var weekdayend = firstdayend.getDay();
		var startdayend = (8-weekdayend);
		if (startdayend < 11)
		{
			startdayend + 7;
		}
		enddate.setFullYear(year, 9, startdayend); 
		
		if (dat < startdate || dat >= enddate)
		{
		  offset++;			
		}
	}
	return offset
}

function switchvis(id)
{
	a = id+"adr";
	if ($(a).className == "addresshide")
	{
		$(a).className = "addressshow";
		$(id).src = "../images/btn_down.gif"
	}
	else
	{
		$(a).className = "addresshide";
		$(id).src = "../images/btn_more.gif"
	}
}
