// -*- Mode: Javascript; tab-width: 4; -*-
function getPlatform(){
	return getPlatform.platform || (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase();
};
function platformRedirect(pageBaseName){
	var win = platformRedirect.win || window;
	pageBaseName = pageBaseName || '';
	if (pageBaseName && !(/\/$/).test(win.location)) pageBaseName = '/'+pageBaseName;
	var regex = new RegExp((pageBaseName?"("+pageBaseName+")?":'')+"(-(mac|linux))?(\.jsp)?(\\?.*)?$" );
	switch(getPlatform()){
	case 'other' :
	case 'linux' : !(/-linux.jsp/      ).test(win.location) && (win.location = (''+win.location).replace(regex, pageBaseName+'-linux.jsp')); break;
	case 'mac'   : // !(/-mac.jsp/        ).test(win.location) && (win.location = (''+win.location).replace(regex, pageBaseName+'-mac.jsp')); break;
	case 'win'   :  (/-(mac|linux).jsp/).test(win.location) && (win.location = (''+win.location).replace(regex, pageBaseName+'.jsp')); break;
	default:
	}
	return win.location;
};
