function getTimeZone() {
    var now = new Date();
    return -now.getTimezoneOffset()/60;
}

function mapTimeZoneHack (tz) {
    var the_tz = 0;

    var tz_array = new Array(
        [-12, 1],
        [-11, 2],
        [-10, 3],
        [-9, 11],
        [-8, 12],
        [-7, 13],
        [-6, 15],
        [-5, 19],
        [-4, 21],
        [-3, 23],
        [-2, 26],
        [-1, 27],
        [0, 31],
        [1, 32],
        [2, 41],
        [3, 43],
        [4, 44],
        [5, 47],
        [6, 48],
        [7, 49],
        [8, 50],
        [9, 51],
        [9.5, 52],
        [10, 57],
        [11, 55],
        [12, 56]
        );

    for(i = 0; i < tz_array.length; i++) {
        temp_tz = tz_array[i];
        if(temp_tz[0] <= tz) {
            the_tz = temp_tz[1];
        }
    }
    
    return the_tz;
}

function getHackedTimezoneID() {
    var tz = getTimeZone();
    return mapTimeZoneHack(tz);
}

function populateTimezone() {
    var tz_id = getHackedTimezoneID();
    document.forms['regForm'].timeZoneID.value = tz_id;
}

function populateTimezoneById(id) {
    var obj = document.getElementById(id);
	if (obj != null) {
		var tzId = getHackedTimezoneID();
		obj.value = tzId;
	}
}
