
	function print_mail_to_link(lhs,domain,name,msg,type)
	{
		var plaintext = "";

		if (domain == "") {
			domain = "dandelionradio.com";
		}

		if (name == "" ){
			name = lhs;
		}

		if (type == "") {
			type = "mailonly";
		}

		if (type == "all") {
			plaintext = name + " - &lt;" +lhs + "@" + domain + "&gt;";
		}

		if (type == "mailonly") {
			plaintext = lhs + "@" + domain;
		}

		if (type == "name") {
			plaintext = name;
		}

		if (msg == "") {
			msg = "?subject=Message from a visitor to www.DandelionRadio.com";
		}

		if (msg == "#") {
			msg = "";
		}

		document.write("<" + "a href=\"mail" + "to" + ":" + lhs + "@" + domain + msg + "\">");
		document.write(plaintext);
		document.write("<" + "/a" + ">");

	}

	function print_mail_simple(lhs)
	{
		print_mail_to_link(lhs,"","","","");
	}


	function getHTTPObject()
	{ 
		if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); 
		else
		if (window.XMLHttpRequest) return new XMLHttpRequest(); 
		else
		{
			// alert("Browser does not support AJAX.");
			return null;
		}
	}

	var cachebreak=0;
	var oldcontent='';

	function callNowPlaying()
	{ 
		cachebreak++;
		httpObject = getHTTPObject();

		if (httpObject != null) { 
			httpObject.open("GET", "/playing.php?cachebreak="+cachebreak+"&nohead=1&showbio=1&lastfm=1&showtweet=1&buy=0", true);
			httpObject.send(null);
			httpObject.onreadystatechange = function() {setDivNowPlaying("nowplaying");}

			// value is in milliseconds
			t1 = setTimeout("callNowPlaying()", 30000);
		}
	}

	function callNowPlayingMini()
	{ 
		cachebreak++;
		httpObjectmini = getHTTPObject();

		if (httpObjectmini != null) { 
			httpObjectmini.open("GET", "/playing.php?cachebreak="+cachebreak+"&mini=1&maxlist=1&nosynopsis=1&nohead=1&showbio=0&lastfm=1&buy=0", true);
			httpObjectmini.send(null);
			httpObjectmini.onreadystatechange = function() {setDivNowPlaying("nowplayingmini");}

			// value is in milliseconds
			t2 = setTimeout("callNowPlayingMini()", 30000);
		}
	}


	function setDivNowPlaying(divname)
	{
		if(divname == "nowplayingmini")
		{
		    thishttpobj = httpObjectmini;
		}
		else thishttpobj = httpObject;

		if(thishttpobj.readyState == 4)
		{
			// alert("Now setting "+divname);
			// The div might not exist (yet) - which can lead to the browser detecting a javascript error
			// so assign to an object and then use that ... and if the div is not there then should branch
			var checkobj=document.getElementById(divname);
			if(checkobj)
			{
			    var thiscontent = thishttpobj.responseText;

			    if (thiscontent != oldcontent){
			        document.getElementById(divname).innerHTML = thiscontent;
				oldcontent = thiscontent;
			    }
			}
		}
	}
