// Addtext

function popup(url, pagename, w, h, scoll) {
 if(scoll === undefined) {
	 scoll = "no";
 }
 
 var width = w;
 var height = h;
 var left = (screen.width - width)/2;
 var top = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=' + scoll;
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'Liveplayer',params);
}

function popupLive() {
	popup('/webplayer/', 'Radio Lelystad - luister LIVE', 640, 420, 'no');
}

function addtext(veld,text)
{
    document.form.elements[veld].value += " "+text+" ";
    document.form.elements[veld].focus();
}

function update()
{
	$.ajax({
		type: 'GET',
		url: '/nowPlaying.php',
		timeout: 10000,
    	success: function(data)
    	{
		$("#nowPlaying").html(data);
    		window.setTimeout(update, 8000);
    	},
   		error: function (XMLHttpRequest, textStatus, errorThrown)
   		{
   			window.setTimeout(update, 2500);
   		}
    });
}

function fadeImages()
{
	$('#artistGallery').innerfade({
		speed: '2000',
 		timeout: 5000,
  		type: 'sequence',
   		containerheight: '190px'
  	});
}

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(pagina){
	
	
	
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.5"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
	
	$("#contentArea").html('Bezig met laden...');
	
	$.ajax({
		type: 'POST',
		url: 'contact.php',
    		
		success: function(data)
    		{
   		
			$("#contentArea").html(data);
 
    		}
 
    	});
	
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

}

function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}


