function strip_tags (input, allowed) {
    allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>)
    var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
        commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
    return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
        return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
    });
}
function GetXmlHttpObject()
{

	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	return xmlHttp;
	
}
function item_doVote(type, id, score) {
	
	query = 'score=' + score + '&id=' + id + '&type=' + type + '&ajax_request=on';
	
	GetXmlHttpObject();
	
	xmlHttp.open('POST', start + 'files/ajax/vote.php', true);
	
	xmlHttp.onreadystatechange=function()
	{
	
		if(xmlHttp.readyState==4)
		{
			
			ajaxPage(start + 'files/ajax/vote.php?type=' + type + '&id=' + id + '&ajax_request=on&action=overview', 'vote_results', 'GET');
			
		}
		
	}
	
	
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
		
	xmlHttp.send(query);
	
}
function item_getComments(type, id, p) {
	
	ajaxPage(start + 'files/ajax/comments.php?type=' + type + '&aid=' + id + '&page=' + p + '&ajax_request=on', 'comments', 'GET');
	
}
function item_placeComment(type, id, newp) {
	
	query = 'action=place_comment&aid=' + id + '&type=' + type + '&txt=' + nicEditors.findEditor('comment_txt').getContent();

	GetXmlHttpObject();
	
	xmlHttp.open('POST', start + 'files/ajax/comments.php', true);
	
	xmlHttp.onreadystatechange=function()
	{
	
		if(xmlHttp.readyState==4)
		{
			
			item_getComments(type, id, newp);
			
		}
		
	}
	
	
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
		
	xmlHttp.send(query);
	
}
window.onload = function(){
document.getElementById('copyright').innerHTML = '&copy; Hip-Hop Music 2011 | Radioluisterenonline.nl';
};
function favorite(url, div) {
	
	query = '';
	
	GetXmlHttpObject();
	
	xmlHttp.open('GET', url, true);
	
	xmlHttp.onreadystatechange=function()
	{
	
		if(xmlHttp.readyState==4)
		{
			
			if(xmlHttp.responseText == "error") {
				
				alert("Er is een onbekende fout opgetreden.");
				
			}
			else {
				
				document.getElementById(div).innerHTML = xmlHttp.responseText;
				
			}
			
		}
		
	}
	
	xmlHttp.send(query);
	
}
function block(element) { 
	
	document.getElementById(element).style.display = 'inline-block';
	
}
function ajaxPage(url, div, method, query, special, specialq) {
	
	GetXmlHttpObject();
	
	if(!method) {
		
		method = 'GET';
		query = null;
		
	}
	if(!query || method == "GET") {
		
		query = null;
		
	}
	
	if(!specialq) {
		
		specialq = null;
	
	}
	
	xmlHttp.open(method, url, true);
	
	xmlHttp.onreadystatechange=function()
	{
	
		if(xmlHttp.readyState==4)
		{
			
			if(special == 'place_comment') {
				
				ajaxPage(start + 'files/ajax/news_comments.php?' + specialq, 'news_comments');
				
			}
			else if(special == 'place_comment_tracks') {

				ajaxPage(start + 'files/ajax/tracks_comments.php?' + specialq, div);
				
			}
			else {
				
				if(document.getElementById(div).style.display == "none") {
					
					document.getElementById(div).style.display = 'block';
				
				}
				
				document.getElementById(div).innerHTML = xmlHttp.responseText;
				
				if(document.getElementById('ajax_loader')) {
					
					document.getElementById('ajax_loader').style.visibility = 'hidden';
					
				}
			
			}
			
		}
		else {
		
			if(special == null) {
			
				if(document.getElementById('ajax_loader')) {
				
					document.getElementById('ajax_loader').style.visibility =='visible';
					
				}
			
			}
			
		}
		
	}
	
	if(method == "POST") {
	
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	
	}
	
	xmlHttp.send(query);
	
}
function composeMsg() {
	
	msg = nicEditors.findEditor('compose_msg').getContent();
	tid = document.getElementById('compose_tid').value;
	sub = document.getElementById('compose_subject').value;
	
	if(msg.length > 250 || msg.length < 10) {
		alert('Vul een bericht in tussen de 10 en de 250 tekens.');
	}
	else if(sub.length > 20 || sub.length < 5) {
		alert('Vul een onderwerp in tussen de 5 en de 20 tekens.');
	}
	else {
		
		document.getElementById('compose_submit').style.display = 'none';
		
		query = 'compose_msg=' + msg + '&compose_tid=' + tid + '&compose_subject=' + sub;
		
		GetXmlHttpObject();
		
		xmlHttp.open('POST', start + 'files/ajax/sendpm.php', true);
		
		xmlHttp.onreadystatechange=function()
		{
		
			if(xmlHttp.readyState==4)
			{
				
				msg = '';
				sub = '';
				
				iBox.hide();
				
				alert(xmlHttp.responseText);
				
			}
			
		}
		
		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
			
		xmlHttp.send(query);
		
	}

}

