function outputCont(html) {
	emailE='tpwd.'; emailE=('hello' + '@' + emailE); document.write("<" + 'a href="mailto:' + emailE + 'pt?subject=Hello!"' + '>');
	document.write(html);
	document.write("<" + '/a' + ">");
}

var player;
function playerReady(obj) {
	player = document.getElementById(obj['id']);
	player.addControllerListener("ITEM","playTracker");
	player.addControllerListener("PLAY","playTracker");
}
function playTracker(obj) {
	if (obj.index != null || obj.state == true) {
		setPlayPauseText(obj.id, "Pause");
	} else {
		setPlayPauseText(obj.id, "Play");
	}
}

function setPlayPauseText(id, text) {
	document.getElementById('play_pause-'+id).innerHTML = text;
}


window.addEvent("load", function() {
/*
	var mySmoothScroll = new Fx.SmoothScroll({
	    links: '.smoothAnchor',
	    wheelStops: false
	});
	
	$('nextProject').addEvent('click', function() {
		mySmoothScroll.toElement('aquameeting.com'); 
	});
*/

	var morphs = []
	var slideshows = []
	
	var onChangedSlide = function() {
		var progress = this.getChildren('.progress')
		var index = progress.get('index')
		animateProgress(index)
	}
	var animateProgress = function(index) {
		morphs[index].start({ 'width': [0, 562] })
	}





	$$('.slideshow').each(function(slideshow, index) {
		var url = slideshow.get('url');
		
		//create images string
	    var images_array = []
	    for (var i=1; i <= slideshow.get('totalimages'); i++) images_array.push("/images/public/scaffold_portfolio/medium/" + url.split(".")[0] + i + ".png");
	    	    
	    //create slideshow
		slideshows.push( new MooSlideshow(slideshow, images_array, {slideMode: 1, slideDuration: 2000, fadeDuration: 800, autoSlideshow: false}) );
		
		//add progress bar
		var progress = new Element('div', {
			'class': 'progress',
    		'id': 'progress-'+url,
    		'index': index
    	}).inject(slideshow)
    	var newMorph = new Fx.Morph(progress, {duration: 1800, transition: Fx.Transitions.Quad.easeOut});;
    	morphs.push( newMorph );
		
		//add events
		var onThisChangedSlide = onChangedSlide.bind(slideshow);
		slideshow.addEvents({
			"mouseenter": function() {
				progress.fade(1)
				slideshows[index].start();
				animateProgress(index);
				slideshows[index].addEvent('changedSlide', onThisChangedSlide);
			},
			"mouseleave": function() {
				progress.fade(0)
				slideshows[index].stop();
				slideshows[index].changeToSlide(0);
				slideshows[index].removeEvent('changedSlide', onThisChangedSlide);
			}
		})
	});
	
	
	
	
	
	$$('.video').each(function(video, index) {
		var url = video.get('url');
		var so = new SWFObject('template/swf/player.swf',url,'562','378','9');
		so.addParam('allowfullscreen','true');
		so.addParam('allowscriptaccess','always');
		so.addParam('wmode','transparent');
	  	so.addVariable('file','../../public/scaffold_portfolio/video/' + url.split(".")[0] + ' - Computador.m4v');
		so.addVariable('image','public/scaffold_portfolio/video/' + url.split(".")[0] + '.jpg');
		so.addVariable('controlbar','none');
		//so.addVariable('backcolor','333333');
		//so.addVariable('frontcolor','FFFFFF');
		//so.addVariable('lightcolor','f36b21');
		//so.addVariable('screencolor','FFFFFF');
		//so.addVariable('fullscreen','true');
  		so.addVariable('link','http://trinachallenge.com/');
  		so.addVariable('bufferlength',3);
		so.addVariable('volume','50');
		so.addVariable('stretching','fill');
		so.write('video-'+url);
		
		
		var playPause = $('play_pause-'+url)
		playPause.addEvent('click', function(evt) {
			if (playPause.get('text') == "Pause") {
			player.sendEvent("PLAY","false");
				playPause.set('text','Play')
			} else {
				player.sendEvent("PLAY","true");
				playPause.set('text','Pause')
			}
		});

	});
	
	
});
