// Associative Array from Channels SOAP call
// TJ Nicolaides & Jason Zajac 
// tj@greaterphila.com 
// - requires jQuery

$(document).ready(function() {
	ChannelIDs = "6544";
	NumberOfItems = "1";
	StartDate = "";
	
	payload = '<?xml version="1.0" encoding="utf-8"?>' +
	'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + 
	' xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' + 
	' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> '+
		 ' <soap:Body> ' +
		   '<GetXMLChannelsContent xmlns="http://www.emmisinteractive.com/"> ' +
		   '   <ChannelIDs>'+ ChannelIDs +'</ChannelIDs> ' +
		   '   <NumberOfItems>'+ NumberOfItems +'</NumberOfItems>' +
		   '   <StartDate>'+ StartDate +'</StartDate> '+
			'</GetXMLChannelsContent>'+
		 ' </soap:Body>'+
		'</soap:Envelope>';

	$.ajax({
	   type:'POST',
	   url:'http://www.969bostontalks.com/_Shared/content/public/Channelservice.asmx?op=GetXMLChannelsContent',
	   dataType:"xml",
	   contentType: "text/xml; charset=\"utf-8\"",
	   data:payload,
	   success: function(xml){	
			var story = [];
			$(xml).find('Story').each(function(e) {
				story.push({
						"headline" : $(this).attr("Headline"),
						"text" : $(this).find("StoryContent").text(),
						"publishedDate" : $(this).attr("StoryPublishedDate")		 
				});

			});
			// use Firebug and console.log(); to examine objects, arrays, strings, etc. to see what the Javascript is spitting out:
			//console.log(story);
			$("#channel").html("<div class=hm1_Body>" + story[0].text + "</div><div class=hm1_Headline>~ " + story[0].headline + "</div>");
	   }
	});
});

