var imgs = null;
var texts = null;
var opened = null;
Event.observe(window, 'load', function() {
	imgs = $('logos').getElementsByTagName('img');
	texts = $$('#texts .popup');
	for (var i=0; i<texts.length; i ++) {
		if (!top.Typeroom) {
			imgs[i].text = texts[i];
			texts[i].hide();
			var newAnchor = document.createElement('a');
			newAnchor.id = 'anchor_' + imgs[i].id;
			newAnchor.name = newAnchor.id;
			texts[i].anc = newAnchor.id;
			$(imgs[i]).observe('mouseover', show);
		}
	}
});
function show(event) {
	clicked = Event.element(event);
	opened ? opened.hide() : null;
	loc = Position.page(clicked);
	opened = clicked.text;
	var top = loc[1] + 40;
	var left = loc[0] + clicked.getWidth()/2 - opened.getWidth()/2;
	if (left+opened.getWidth()>getClientWidth()) {
	   left = getClientWidth() - opened.getWidth() - 20;
	} else if (left < 0) {
	    left = 0;
	}
	opened.setStyle({
		position: 'absolute',
		top: top + 'px',
		left: left + 'px'
	});
	opened.show();
	opened.observe('mouseout', hideIt);
	opened.observe('mouseover', showIt);

};
function showIt() {
	opened.show();
}
function hideIt() {
	opened.hide();
}
function getClientWidth() {
    if (self.innerWidth) {
        return parseFloat(self.innerWidth);
    } else if (document.documentElement && document.documentElement.clientWidth) {
        return parseFloat(document.documentElement.clientWidth);
    } else if (document.body) {
        return parseFloat(document.body.clientWidth);
    }
    return 0.0;
}
function getPageWidth() {
    return document.documentElement.scrollWidth;
}
