addCssClass = function(objectOrId, cssClass) {
	var obj = ((typeof(objectOrId) == 'string') ? document.getElementById(objectOrId) : objectOrId);
	var c = obj.className + ' ';
	if (c.indexOf(cssClass + ' ') == -1) obj.className = c + cssClass;
}	

removeCssClass = function(objectOrId, cssClass) {
	var obj = ((typeof(objectOrId) == 'string') ? document.getElementById(objectOrId) : objectOrId);
	var c = obj.className + ' ';
	obj.className = c.replace(cssClass + ' ', '');
}	

inputReset = function(o) {
	if (o.value == 'Uw e-mailadres') {
		o.value = '';
		removeCssClass(o, 'inactive');
	}
}

createMailto = function(pers, domain, customText) {
	var email = pers + '@' + domain;
	(customText == null) ? lnk = email : lnk = customText;
	document.write('<a href="mailto:'+email+'">'+lnk+'</a>');
}

isEnter = function(e) {
	 var characterCode;
	 if (e && e.which) {           
		e = e; characterCode = e.which;
	 } else { 
		e = event; characterCode = e.keyCode 
	 }
	 return (characterCode == 13);
}

limitChars = function(fld, maxlimit, displayId) {
	if (fld.value.length > maxlimit) {
		fld.value = fld.value.substring(0, maxlimit);
	} else { 
		document.getElementById(displayId).innerHTML = maxlimit - fld.value.length;
	}
}

showYouTubeVideo = function(code, w, h) {
	var str = '';
	str += '<object width="'+w+'" height="'+h+'"><param name="movie" value="http://www.youtube.com/v/'+code+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+code+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+w+'" height="'+h+'"></embed></object>';
	document.write(str);
}

initCategoryIcons = function() {
	$('img.caticon').each(function(index) {
		$(this).css('background-image', 'url('+$(this).attr('src')+')');
		$(this).attr('src', '/_img/space.gif');
		$(this).show();
	});
}

initLinkTitles = function() {
	$('#main a[title=""]').each(function(index) {
		var $this = $(this);
		if ($this.html().toLowerCase().indexOf('<img') == -1) {
			$this.attr('title', $this.html());
		}
	});
}

initTickerTape = function() {
	if (window.XMLHttpRequest) {
		$('#tickertape ul').liScroll({travelocity: 0.03});
	}
}


$(document).ready(function() {
	initCategoryIcons();
	initLinkTitles();
	initTickerTape();
});
