/*
	-> Video Clips
	load and show youtube clips in a click.
	
	coded in january 2007 by pinit.
	http://me.pinit.it

	(feel free to use but please keep this comment!)
*/
var videoclips = {
	opened : null,
	fire : function() {
		//this finds 'cliplnk' class links and add them an onclick event for the show job.
		//important: name your parent div id with 'vid' + youtube video id!
		var mytags = document.getElementsByTagName("a");
		for (i=0; i<mytags.length; i++) {
			if (mytags[i].className=="cliplnk") {
				mytags[i].onclick = function() {videoclips.show(this.parentNode.id);return false;}
				mytags[i].href = "#";
			}
		}
	},
	show : function(id) {
		div = document.getElementById(id);
		video = id.slice(3);
		code = '<a href="#" onclick="videoclips.close(this.parentNode.id);return false;" title="chiudi la clip video"><span class="playvideo closevideo">CHIUDI</span></a>';
		code+= '<br /><object width="450" height="370" data="http://www.youtube.com/v/' + video +'" type="application/x-shockwave-flash"><param name="movie" value="http://www.youtube.com/v/' + video +'" /></object>';
		div.innerHTML = code;
		if (document.opera) {bottom = window.innerHeight;} else {bottom = document.body.offsetHeight;}
		window.scrollTo(0, bottom);
		videoclips.opened = id;
	},
	close : function(id) {
		div = document.getElementById(id);
		code = '<a href="#" onclick="videoclips.show(this.parentNode.id);return false;" title="guarda una clip video"><span class="playvideo">VIDEO</span></a>';
		div.innerHTML = code;
		videoclips.opened = null;
	}
}