var zero = "mailto:"
var first = "lorenza"
var second = "@"
var third = "intersectionwine"
var fourth = "."
var fifth = "com"
var wSubject = "?subject=Wine Inquiry"
var theMail = zero+first+second+third+fourth+fifth
var wMail = theMail+wSubject
var theOutput = "";
imgArray = new Array()
theImages = new Array()
imgArray[0] = "belongHi.gif"
imgArray[1] = "butt_2008Hi.gif"
imgArray[2] = "butt_2009Hi.gif"
imgArray[3] = "castHi.gif"
imgArray[4] = "getsomeHi.gif"
imgArray[5] = "homeHi.gif"
imgArray[6] = "lorenzaHi.gif"
imgArray[7] = "mailHi.gif"
imgArray[8] = "newsHi.gif"
imgArray[9] = "whereHi.gif"
imgArray[10] = "butt_2010Hi.gif"

function $(theID) {
	return document.getElementById(theID)
}

preLoader()

function preLoader() {
	thePath = "images/"
	//preload images
	for (i in imgArray) {
		theImages[i] = new Image()
		theImages[i].src = thePath+imgArray[i]
	}
}

function pasteMail() {
   $("mailer").href = theMail
}

function pasteWMail() {
	$("wInquiryEmail").href = wMail
}


/*GOOGLE DATA API*/
// Load the latest version of the Google Data JavaScript Client

function setupMyService() {
	var bloggerService = new google.gdata.blogger.BloggerService('lorenza');
	return bloggerService;
}

function onGoogleDataLoad() {
	// Put your code here
	/* 
	* Retrieve a list of blog posts
	*/

	// Create the blogger service object
	//var bloggerService = new google.gdata.blogger.BloggerService('GoogleInc-jsguide-1.0');


	// The feed URI ued to retrieve a list of blogs for a particular logged-in user
	//var feedUri = 'http://www.blogger.com/feeds/11252123672496679549/blogs';
	var feedUri = 'http://lorenzaevents.blogspot.com/feeds/posts/default';
	bloggerService = setupMyService();

	// The callback method invoked when getBlogFeed() returns the list of our blogs
	var handleBlogFeed = function(blogFeedRoot) {
		var blogEntries = blogFeedRoot.feed.getEntries();

		// Get list of posts for each blog
		//for (var i = 0, blogEntry; blogEntry = blogEntries[i]; i++) {
			//var postsFeedUri = blogEntry.getEntryPostLink().getHref();
			//var query = new google.gdata.blogger.BlogPostQuery(postsFeedUri);
			var query = new google.gdata.blogger.BlogPostQuery('http://lorenzaevents.blogspot.com/feeds/posts/default');

			// Set the maximum number of blog posts to return
			query.setMaxResults(25);

			bloggerService.getBlogPostFeed(query, handleBlogPostFeed, handleError);
		//}
	};

	// A callback method invoked getBlogPostFeed() returns data
	var handleBlogPostFeed = function(postsFeedRoot) {
		var posts = postsFeedRoot.feed.getEntries();

		// Display blog's title
		//theOutput = 'Blog title: ' + postsFeedRoot.feed.getTitle().getText();

		for (var i = posts.length-1, post; post = posts[i]; i--) {
			var postTitle = post.getTitle().getText();
			var postURL = post.getHtmlLink().getHref();

			//theOutput += '<a href="' + postURL + '" target="_blank">' + postTitle + '</a><br /><br />';
			theOutput += '<p>' + postTitle + '</p>';
		}
		$("eventsBlog").innerHTML = theOutput;
	};

	var handleError = function(error) {
		alert(error);
	};
	bloggerService.getBlogFeed(feedUri, handleBlogFeed, handleError);
}


google.load('gdata', '2.x', {packages: ["blogger"]});
// Call function once the client has loaded
google.setOnLoadCallback(onGoogleDataLoad);

