function addBookmark(url, title) {
	if (!url) url = location.href;
	if (!title) title = document.title;
	//Gecko
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
	//IE4+
	else if (typeof window.external == "object") window.external.AddFavorite(url, title);
	//Opera7+
	else if (window.opera && document.createElement) {
		var a = document.createElement('A');
		if (!a) return false; //IF Opera 6
		a.setAttribute('rel','sidebar');
		a.setAttribute('href',url);
		a.setAttribute('title',title);
		a.click();
	}
	else return false;
	return true;
}


function showModal(msg, options) {
	if(typeof(options) != 'object') options = {};
	if(!options.title || !options.color || !options.titleBg || !options.titleColor) {
		switch(options.modalType) {
			case 'warning':
				options.title = options.title ? options.title : 'Warning';
				options.titleBg = options.titleBg ? options.titleBg : "#FECE72";
				options.titleColor = options.titleColor ? options.titleColor : "#DD8922";
			break;
			case 'fatal':
				options.title = options.title ? options.title : 'Fatal error';
				options.titleBg = options.titleBg ? options.titleBg : "#E69288";
				options.titleColor = options.titleColor ? options.titleColor : "#B03722";
			break;
			case 'notice':
				options.title = options.title ? options.title : 'Notice';
				options.titleBg = options.titleBg ? options.titleBg : "#C4F13A";
				options.titleColor = options.titleColor ? options.titleColor : "#5DBB08";
			break;
			case 'layer':
			case 'loading':
				options.title = options.title ? options.title : 'Loading...';
				options.titleBg = options.titleBg ? options.titleBg : "#86EAFF";//"#DDDDDD";
				options.titleColor = options.titleColor ? options.titleColor : "#20A4FF";//"#000000";
			break;
			default:
				options.title = options.title ? options.title : 'Information';
				options.titleBg = options.titleBg ? options.titleBg : "#86EAFF";
				options.titleColor = options.titleColor ? options.titleColor : "#20A4FF";
			break;
		}
	}
	options.background = options.background ? options.background : "#FFF";
	options.width = options.width ? options.width : 300;
	//options.afterLoad = function() {Modalbox.resizeToContent();};

	if(options.modalType == 'loading') {
		options.close = false;
		options.overlayClose = false;
		var content = "<center>" + (msg ? '<b>' + msg + '</b><br />' : '') + "<img src='/images/loading1.gif' style='margin-top: 20px;'></center>";
	}
	else if(options.modalType == 'layer') {
		options.close = true;
		options.overlayClose = true;
		//if(!Prototype.Browser.IE) {
			if(options.width)
				options.width = options.width <= 1 ? document.viewport.getWidth()*options.width : options.width;
			if(options.height)
				options.height = options.height <= 1 ? document.viewport.getHeight()*options.height : options.height;
		//}
		var content = msg;
	}
	else {
		if(typeof(options.showOk) == 'undefined') options.showOk = true;
		options.close = true;
		options.overlayClose = true;
		var content = '<div style="text-align: center; font-size: 12px; font-weight: bold;">' +
					msg + '<br />' +
					(options.showOk ? '<input type="button" value="Ok" onclick="Modalbox.hide(); return false;" style="margin-top: 15px;" class="button" id="MB_ok_button">' : '') +
				'</div>';
	}

	Modalbox.show(content, options);
}

function showModalError(err) {
	$('modal-error').update(err);
	if(!$('modal-error').visible()) {
		Modalbox.resizeToInclude('modal-error', {afterResize: function(){
			new Effect.Appear('modal-error', {duration: 0.25});
		}});
	}
}

function hideModalError() {
	if($('modal-error').visible()) {
		new Effect.Fade('modal-error', {duration: 0.25, afterFinish: function() {
			$('modal-error').update('').hide();
			Modalbox.resizeToContent();
		}});
	}
}

/*Event.observe(document, 'dom:loaded', function() {
	if($('top-game-images-carousel')) {
		$('top-game-images-carousel').select('a.lightview').each(function(a) {
			var img = new Element('img', {src: a.href});
		});
	}
});*/
