var lista = new Array();
for (i=1;i<=6;i++) lista.push("mp4:testimonio2010-"+i+"testimonio");
lista.push("mp4:testimonio2010-8testimonio");
var aleatorio = Math.round(Math.random()*(lista.length-1));
document.getElementById('testimonio').innerHTML='<a class="rtmp" id="testimonio" href="'+lista[aleatorio]+'"></a>';


function extractCookieValue(val) {
	if ((endOfCookie = document.cookie.indexOf(";", val)) == -1) {
		endOfCookie = document.cookie.length;
	}
	return unescape(document.cookie.substring(val,endOfCookie));
}
function ReadCookie(cookiename) {
	var numOfCookies = document.cookie.length;
	var nameOfCookie = cookiename + "=";
	var cookieLen = nameOfCookie.length;
	var x = 0;
	while (x <= numOfCookies) {
		var y = (x + cookieLen);
		if (document.cookie.substring(x, y) == nameOfCookie)
		return (extractCookieValue(y));
		x = document.cookie.indexOf(" ", x) + 1;
		if (x == 0){
			break;
		}
	}
	return (null);
}
$(document).ready(function() {
	if (ReadCookie('mvideo') != null) {
		var val = ReadCookie('mvideo');
		val = !(val=='false');
		ejecutar_video(val);
	}
	else {
		jQuery.getJSON('mvideo.php',function(data) {
			var autop = data.autoplay;
			document.cookie="mvideo="+autop;
			ejecutar_video(autop);
		});
	}
});
function ejecutar_video(autop) {
	$f("a.rtmp", "http://videosmagister.s3.amazonaws.com/flowplayer-3.2.5.swf", {
		clip: { 
			provider: 'rtmp',
			autoPlay: autop,
			start: '1'
		},
		plugins: { 
			rtmp: { 
				url: 'http://videosmagister.s3.amazonaws.com/flowplayer.rtmp-3.2.3.swf',
				netConnectionUrl: 'rtmp://s18lmbst5pjbar.cloudfront.net/cfx/st'
			}
		}
	});
}

