// parameters
// http://spreadsheets.google.com/feeds/list/pVabH0j6EqpMOY1usFUgVXg/od6/public/basic
var param_wsId = "od6";
var param_ssKey = "pVabH0j6EqpMOY1usFUgVXg";
var param_newstitle = "title";
var param_newsdate = "dateofnews";
var param_unpublish = "disappear";
var param_newscontent = "content";
var param_newssource = "source";

// use the loaded data to generate gigs
function LoadNews(jsonnews) {
	// loop through all rows
	for (var i = 0; i < jsonnews.feed.entry.length; i++) {
		// get feed
		var entry = jsonnews.feed.entry[i];
		
/*				<div class="news">
					<h2 class="title">Nr.1</h2>
					<p>As you may have seen on our myspace blog we are proud to have reached the nr.1 position in the Dutch <a href="http://www.likeitlive.nl/" target="_blank" title="Like it Live">Like it Live Charts</a>.  We got invited to play live on their radio show and pulled off an exclusive acoustic set, a new definition of the I wish I knew sound - you can hear at <a href="http://www.urock.nl/pagina_radio.htm" title="I Wish I Knew at URock" target="_blank">urock radio</a> until the end of the month.</p>
				</div>
*/

		// create holder div
		var iwiknews = document.createElement("div");
		iwiknews.setAttribute("class", "news");
		// and as usual we need a fucking hack for IE...
		iwiknews.setAttribute("className", "news");
		// create date
		var iwikdate = document.createElement("span");
		iwikdate.setAttribute("class", "date");
		iwikdate.setAttribute("className", "date");
		if (entry["gsx$"+param_newsdate]) {
			iwikdate.appendChild(document.createTextNode(entry["gsx$"+param_newsdate].$t));
		}
		// add date to holder
		iwiknews.appendChild(iwikdate);
		
		// title
		var iwiktitle = document.createElement("h2");
		iwiktitle.setAttribute("class", "title");
		if (entry["gsx$"+param_newstitle]) {
			iwiktitle.appendChild(document.createTextNode(entry["gsx$"+param_newstitle].$t));
		}
		// add details to holder
		iwiknews.appendChild(iwiktitle);
		
		// and the content			
		var content = document.createElement("p");
		if (entry["gsx$"+param_newscontent]) {
			content.appendChild(document.createTextNode(entry["gsx$"+param_newscontent].$t));
		}
		// add address to holder
		iwiknews.appendChild(content);
		
		// get the main holder div on the website
		var maindiv = document.getElementById("right_text");
		// and add the whole thing in one go
		maindiv.appendChild(iwiknews);
	}
}

// load JSON feed
function LoadUpNews() {
	var script = document.createElement('script');
	script.setAttribute('src', 'http://spreadsheets.google.com/feeds/list' + '/' + param_ssKey + '/' + param_wsId + '/public/values' + '?alt=json-in-script&callback=LoadNews');
	script.setAttribute('id', 'jsonScript');
	script.setAttribute('type', 'text/javascript');
	document.documentElement.firstChild.appendChild(script);
}
