function updateImage(city) {

	try {
		var str = '';
		var type = '';
		var local_time;
		var client_date = new Date();
		var utc_hour = client_date.getUTCHours();
		
		switch (city) {
			case 'amsterdam':
				local_time = (utc_hour + 2) % 24;
				break;
			case 'newyork':
				local_time = (utc_hour - 4) % 24;
				break;
			case 'shanghai':
				local_time = (utc_hour + 8) % 24;
				break;
		}
		type = getDagDeel(local_time);
		document.getElementById('bovenbalk').sendTextFromHtml(city, type);
		//showHome(city);
	} catch (e) { alert(e); }
	
	try {
		//showHome(city);	
	} catch (e) { alert (e) };
}

function getDagDeel(hour) {
	if (hour < 7) {
		return '4';
	} else if (hour > 6 && hour < 12) {
		return '1';
	} else if (hour > 11 && hour < 18) {
		return '2';
	} else {
		return '3';
	}
}

var loadHomeMovie = 1;

function showHome(s) {
	try {
		var divs = document.getElementById('maincontent').getElementsByTagName('div');
		for (var i=0; i<divs.length; i++) {
			var elm = divs[i].id;
			document.getElementById(elm).style.display = (elm == s) ? 'block' : 'none';
		}
		loadHomeMovie = 0;
	} catch (e) { alert(e) }
}

var date = new Date();
var timestamp = date.getTime();
var teller = 3547261;

function updateTeller() {
	
	var teller1 = document.getElementById('teller1');
	if (typeof(teller1) == 'undefined') {
		return;
	}
	
	try {
		var r_numbers = Array(1,2,3,4);
		var randno = Math.floor ( Math.random() * r_numbers.length );
		teller = parseInt(teller) + r_numbers[randno];
		teller1.innerHTML = formatFloat(teller);
	} catch (e) { alert(e); }
	
	setTimeout('updateTeller()', 15000);
}

var thousand_sep = ".";
var decimal_point = ".";
var default_precision = 0;

function formatFloat(aFloat, aPrecision){
try {
precision = default_precision;
if(!isNaN(aPrecision))
if(Math.abs(aPrecision)<=10)
precision = aPrecision;
} catch(e) {
precision = default_precision;
}
try {
number = parseFloat(aFloat+'');
if(isNaN(number))
return "NaN";
} catch(e) {
return "NaN";
}

number = Math.round(number * Math.pow(10, precision)) / Math.pow(10,
precision);
integerpart = '' + ((number<0) ? Math.ceil(number) :
Math.floor(number));
decimalpart = Math.abs(Math.round((number - integerpart)*(Math.pow(10,
precision))));
if(decimalpart<10)
decimalpart="0"+decimalpart;
if(decimalpart==0)
decimalpart="00";
var buff = "";
for(j=-1, i=integerpart.length; i>=0; i--, j++){
if((j%3) == 0 && j>1)
buff = thousand_sep + buff;
buff = integerpart.charAt(i) + buff;
}
if(precision>0)
return buff+decimal_point+decimalpart;
return buff;
}

function formatInt(aInt){
return formatFloat(aInt,0);
}

function openWin(url) {
	window.open(url, name, 'width=417, height=600, scrollbars=no'); //, 'toolbar='+toolbar, 'location='+location);
	return;
}
function openRecomWin(url) {
	mywin=window.open(url, '_recom', 'width=417, height=600, scrollbars=no'); //, 'toolbar='+toolbar, 'location='+location);
	mywin.focus();
	return;
}


function swapOfficeLinks(office, fast) {
	var lineHeight = 16;
	var children = $('swapping').childElements();

	for (i = 0; i < children.length; i++) {
		switch (children[i].getStyle('top').replace(/px$/, '')) {
			case '0':
				c1 = children[i];
				break;
			case '16':
				c2 = children[i];
				break;
			case '32':
				c3 = children[i];
				break;
			default:
				// if this happens
				//     better not to do anything
				// perhaps the previous move
				//     hasn't finished yet
				// or other bad things
				//     could have happened
				return;
		}
	}

	if (c3.identify() == "office-" + office) {
		//alert('bottom!');
	} else if (c2.identify() == "office-" + office) {
		new Effect.Move(c2, {y: lineHeight});
		new Effect.Move(c3, {y: (lineHeight * -1)});
	} else if (c1.identify() == "office-" + office) {
		new Effect.Move(c1, {y: (lineHeight * 2)});
		new Effect.Move(c2, {y: (lineHeight * -1)});
		new Effect.Move(c3, {y: (lineHeight * -1)});
	}
}

function displayOffice(activeOffice) {
	var offices = ['asia', 'europe', 'us'];

	for (i = 0; i < offices.length; i++) {
		if (offices[i] == activeOffice) {
			$$('#office-' + offices[i] + ' a').first().addClassName('active');
			$('office-info-' + offices[i]).appear({duration: 0.5});
			$('globe-' + offices[i]).appear({duration: 0.5});
			$('referencebox-' + offices[i]).appear({duration: 0.5});
			$('officepic-' + offices[i]).appear({duration: 0.5});
		} else {
			$$('#office-' + offices[i] + ' a').first().removeClassName('active');
			$('office-info-' + offices[i]).hide();
			$('globe-' + offices[i]).hide();
			$('referencebox-' + offices[i]).hide();
			$('officepic-' + offices[i]).hide();
		}
	}

	swapOfficeLinks(activeOffice);
}

