// JavaScript Document

function add_userhomestations(psid,userid,hstid,id)	{
	if (window.XMLHttpRequest)	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()	{
/*		if(HttPRequest.readyState == 3)	{
			document.getElementById("listingAJAX").innerHTML = '<img src="http://www.radioplein.nl/wp-content/themes/radioplein/images/loader.gif" align="center" />';
		}*/

		if (xmlhttp.readyState==4 && xmlhttp.status==200)	{
			if(xmlhttp.responseText == "duplicate")	{
				alert("Kijk nu al de geselecteerde radiostation is toegevoegd aan uw startpagina.");
			}
			else	{
				var strValue = xmlhttp.responseText.split('####');
				document.getElementById("recordsArray_"+strValue[0]).className = "radstation";
				document.getElementById("recordsArray_"+strValue[0]).style.backgroundImage = "url("+strValue[3]+")";
//				document.getElementById("recordsArray_"+strValue[0]).style.background-repeat = "no-repeat";
				document.getElementById("recordsArray_"+strValue[0]).style.backgroundColor = "#FFFFFF";
//				document.getElementById("recordsArray_"+strValue[0]).style.background-color = "#FFFFFF";
				document.getElementById("recordsArray_"+strValue[0]).innerHTML = strValue[2];
				$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
				alert("Radiostation succesvol toegevoegd aan de homepage.");
				window.location.reload();
			}
		}
	}
	xmlhttp.open("GET","http://www.radioplein.nl/add_homestations.php?psid="+psid+"&userid="+userid+"&hstid="+hstid+"&id="+id,true);
	xmlhttp.send();
}


function addsingleposttohome(pid,uid,title)	{
	if (window.XMLHttpRequest)	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()	{
/*		if(HttPRequest.readyState == 3)	{
			document.getElementById("listingAJAX").innerHTML = '<img src="http://bigbox/salal/radio/wp-content/themes/radioplein/images/loader.gif" align="center" />';
		}*/

		if (xmlhttp.readyState==4 && xmlhttp.status==200)	{
			if(xmlhttp.responseText == "duplicate")	{
				//alert("Al de geselecteerde radiozender is toegevoegd aan je homepage.");
				alert("De geslecteerde radiozender is toegevoegd aan je eigen homepage.");
				
			}
			else	{
				var strValue = xmlhttp.responseText.split('####');
				alert('"'+strValue[1]+'"'+ ' Radiostation succesvol toegevoegd aan de homepage.');
			}
		}
	}
	xmlhttp.open("GET","http://www.radioplein.nl/addsingleposttohome.php?pid="+pid+"&userid="+uid+"&title="+title,true);
	xmlhttp.send();
}

function remove_userhomestations(pid,uid,sid,psid)	{
	if (window.XMLHttpRequest)	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()	{
/*		if(HttPRequest.readyState == 3)	{
			document.getElementById("listingAJAX").innerHTML = '<img src="http://bigbox/salal/radio/wp-content/themes/radioplein/images/loader.gif" align="center" />';
		}*/

		if (xmlhttp.readyState==4 && xmlhttp.status==200)	{
			if(xmlhttp.responseText == "duplicate")	{
//				alert("Kijk nu al de geselecteerde radiostation is toegevoegd aan uw startpagina.");
			}
			else	{
				var strValue = xmlhttp.responseText.split('####');
				document.getElementById("recordsArray_"+strValue[0]).style.cursor = "pointer";
				document.getElementById("recordsArray_"+strValue[0]).style.background = "";
				document.getElementById("recordsArray_"+strValue[0]).onmouseover = "";
				document.getElementById("recordsArray_"+strValue[0]).className = "useraddmorestation";
				alert("Station is succesvol verwijderd van de homepage.");
				window.location.reload();
			}
		}
	}
	xmlhttp.open("GET","http://www.radioplein.nl/remove_homestations.php?pid="+pid+"&uid="+uid+"&sid="+sid+"&psid="+psid,true);
	xmlhttp.send();
}
