// storyinfo defines meta info for sharetools
var storyinfo = {
	title : document.title,
	earl : document.URL,
	summary : null,
	icon : null,
	getMetaText : function (metaName) {
		metaCollection = document.getElementsByTagName('meta');
		regName = new RegExp(metaName, 'i');
		for (i=0;i<metaCollection.length;i++) {
			nameAttribute = metaCollection[i].name.search(regName);
			if (nameAttribute!= -1) { return metaCollection[i].content;}
		}
		return null;
	},
	test : function() {
		alert('i loaded');
		alert('URL : ' + this.earl + '; title : ' + this.title + '; Summary : ' + this.summary + '; author: ' + this.author + '; icon : ' + this.icon);
		return '';
	},
	init : function () {
		// set storyheadline
		var hOneElements = document.getElementsByTagName("h1");
		for (var n = 0; n < hOneElements.length; n++) {
			if(hOneElements[n].className == 'storyheadline') {
				this.title = hOneElements[n].innerHTML;
			}
		}

		// get story summary
		this.summary = this.getMetaText('description');

		// get story thumbnail
		var linkElements = document.getElementsByTagName('link');
		for (i in linkElements) {
			try{
				if(linkElements[i].attributes && linkElements[i].attributes.getNamedItem('rel').value == 'image_src') this.icon = linkElements[i].attributes.getNamedItem('href').value;
			}catch(e){}
		}


	}// init()
}//end storyinfo
storyinfo.init();

