/* ##### "Share" mailto: link generator                   ##### */
/* ##### This is a temporary solution until a server-side ##### */
/* ##### "formmail" script is implemented. This really    ##### */
/* ##### shouldn't be done on the client!                 ##### */

// Get the pub name from the <title>. Very dangerous! I'm just saving myself some gruntwork for today. 
var pubName = document.title.substring(8);

// Determine the page type (Issue or Page) to customize the email message
var pageType = document.getElementsByTagName("body")[0].id;

// Update the mailto: link Subject and Body text, depending on if it's an Issue or Page View
if (pageType == "page") {

var theShareLinks = document.getElementsByTagName("a");
	for (i=0;i<theShareLinks.length;i++) {
		if (theShareLinks[i].id == "shareLink") {
		theShareLinks[i].href = "mailto:?subject=Read "+pubName+" free on your iPhone!&body=Check out this page of "+pubName+" on Zinio\'s Mobile Newsstand for iPhone %26 iPod Touch: \n"+location.href;
		}
	}
}

else if (pageType == "issue") {
	document.getElementById("shareLink").href = "mailto:?subject=Browse "+pubName+" free on your iPhone!&body=Check out the new issue of "+pubName+" on Zinio\'s Mobile Newsstand for iPhone %26 iPod Touch: \n"+location.href;
}

else if (pageType == "newsstand") {
	document.getElementById("shareLink").href = "mailto:?subject=Zinio\'s Mobile Newsstand for iPhone %26 iPod Touch is here!&body=Demo the new magazine reader for iPhone %26 iPod Touch by zinio.com: \n"+location.href;
}	

