// JavaScript

var suffix = '_over';
var preloadimages = new Array();

window.onload = initrolloverimages;

function initrolloverimages() {
	var images = document.getElementsByTagName('img');
	for (var i=0; i<images.length; i++) {
		var classValue = null;
		if (images[i].getAttribute('className'))
			classValue = images[i].getAttribute('className');
		else if (images[i].getAttribute('class'))
			classValue = images[i].getAttribute('class');
		if (classValue != null && classValue.indexOf('rollover') != -1 && images[i].src) {
			images[i].onmouseover = overmage;
			images[i].onmouseout = normalimage;
			preloadimages[i] = new Image();
			preloadimages[i].src = getrolloverimagefile(images[i].src);
		}
	}
}

function overmage() {
	if (this.src && this.src.indexOf('.') != -1) {
		this.src = getrolloverimagefile(this.src);
	}
}

function normalimage() {
	if (this.src && this.src.indexOf('.') != -1) {
		this.src = getoriginalimagefile(this.src);
	}
}

function getrolloverimagefile(path) {
	var filename = path.substring(0, path.lastIndexOf('.'));
	var extention = path.substring(path.lastIndexOf('.'), path.length);
	return filename + suffix + extention;
}

function getoriginalimagefile(path) {
	var filename = path.substring(0, path.lastIndexOf('.')-suffix.length);
	var extention = path.substring(path.lastIndexOf('.'), path.length);
	return filename + extention;
}

var PopupWindow = function() {};

PopupWindow.popupwindow = null;

PopupWindow.popup = function(url, width, height) {

	var left = (screen.width - width) / 2;
	var top =  (screen.height - height) / 2;
	
	if (this.popupwindow && !this.popupwindow.closed) {
		this.popupwindow.close();
	}
	
	var option = 'scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'';
	this.popupwindow = window.open(url, 'popupwindow', option);
	
	return false;
};