function openCatcam()
{
	var win = window.open('http://catcam.kicks-ass.org/cgi-bin/push.html?hidelog=yes', 'catcam', 'width=375,height=400,resizable=yes,menubar=no,location=no,toolbar=no,scrollbars=yes');
	if (win) return(false);
	return(true);
}

function openOutliner()
{
	 var win = window.open('/software/ajaxoutliner/application/index.php', 'ajaxOutliner', 'width=950,height=550,location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=no');
}

function openOskat()
{
	window.open('/software/offiziersskat/application/index.html', 'OSkat', 'width=980,height=470,location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=yes');
}

function openOnGaps()
{
	window.open('/software/gaps/application/index.html', 'onGaps', 'width=1030,height=600,location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=yes');
}

function openUberDice()
{
	openPopup('/software/uberdice/spielen.html', 800, 600, 'UberDice');
}

function openPopupOpts(url, wintitle, opts)
{
	if (!url) return(true);
	if (!wintitle) wintitle = 'vphb';

	var newwin = window.open(url, wintitle, opts);
	if (newwin)
	{
		newwin.focus();
		return(false);
	}

	return(true);
}

function openPopup(url, width, height, wintitle)
{
	if (!width) width = 562;
	if (!height) height = 600;
	if (!url) return(true);
	if (!wintitle) wintitle = 'ubergeek';

	var newwin = window.open(url, wintitle, "location=no,resizable=yes,status=yes,menubar=yes,toolbar=no,dependent=yes,scrollbars=yes,width=" + String(width) + ",height=" + String(height));
	if (newwin)	return(false);

	return(true);
}

function weblogFav(el, id)
{
	var req = null;
	if (window.XMLHttpRequest)
		req = new XMLHttpRequest();
	else if (window.ActiveXObject)
		req = new ActiveXObject("Microsoft.XMLHTTP");

	if (req) {
		req.open('GET', '/weblog/fav.php?id=' + String(id) + '&js=1', true);
		req.send(null);
		el.className = 'favouritedone';
		el.onclick = function() { return false; };
		el.innerHTML = 'Danke!';
		return false;
	}
	
	return true;
}

function imgHighlight()
{
	var app = this;
	app.addEvent = function(obj, type, fn)
	{
		if (obj.addEventListener)
		{
			obj.addEventListener(type, fn, false);
		}
		else if (obj.attachEvent)
		{
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}

	app.hasClass = function(classname, classes)
	{
		var class_strings;
		var i;

		if (!classes) classes = '';
		class_strings = classes.split(' ');
		for (i = 0; i < class_strings.length; i++)
		{
			if (class_strings[i] == classname) return(true);
		}
		return(false);
	}

	app.setEventHandlers = function(classname)
	{
		if (!classname) classname = 'mo_highlight';

		var elems = document.getElementsByTagName('IMG');
		for (var i = 0; i < elems.length; i++)
		{
			if (app.hasClass(classname, elems[i].className))
			{
				app.addEvent(elems[i], 'mouseover', function() {
					var imgname = this.getAttribute('src');
					var matches = imgname.match(/^(.+)(\.[^\.]+)$/i);
					if (matches)
					{
						this.setAttribute('src', matches[1] + '-highlight' + matches[2]);
					}
				} );

				app.addEvent(elems[i], 'mouseout', function() {
					var imgname = this.getAttribute('src');
					var matches = imgname.match(/^(.+)(-highlight)(\.[^\.]+)$/i);
					if (matches)
					{
						this.setAttribute('src', matches[1] + matches[3]);
					}
				} );
			}
		}
	}
}

var highlighter;
highlighter = new imgHighlight();
highlighter.addEvent(window, 'load', function() { highlighter.setEventHandlers(); } );
