document.write("<script type=\"text/javascript\" src=\"http://progressive01.codistream.net/generalFiles/swfjs/swfobject.js\"></script>");
document.write("<script type=\"text/javascript\" src=\"http://connect.facebook.net/es_ES/all.js\"></script>");

function swfObjectMultistream(vars){
	
	/*document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
	document.write("<meta property=\"og:title\" content=\"Video Multistream\" />");
	document.write("<meta property=\"og:description\" content=\"Video Multistream\" />");
	document.write("<meta property=\"og:type\" content=\"video\" />");
	document.write("<meta property=\"og:url\" content=\"http://www.multistream.tv\"/>");
	document.write("<meta property=\"og:image\" content=\"" + vars.imageMobile + "/>");
	document.write("<meta property=\"og:site_name\" content=\"Multistream\"/>");
	document.write("<meta property=\"fb:admins\" content=\"100000936142315\"/>");
	
	document.write("<meta property=\"og:video\" content=\"http://api.codistream.net/videoplayergenerator/embedVideoPlayerAllDeve.swf\"/>");
	document.write("<meta property=\"og:video:width\" content=\"620\"/>");
	document.write("<meta property=\"og:video:height\" content=\"349\"/>");
	document.write("<meta property=\"og:video:type\" content=\"application/x-shockwave-flash\"/>");*/

	var idEmbed = vars.idEmbed;
	var userAgent;
	if( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i) ) || (navigator.userAgent.match(/iPad/i)) ) {
		
		
		if(navigator.userAgent.match(/iPad/i)) userAgent="iPad";
		else userAgent="iPhone";
		
		if(userAgent=="iPad" && vars.type=="video") {
			
			document.write("<video controls autoplay src='http://progressive01.codistream.net/video/" + vars.idUser + "/" + vars.pathVideoMobile +"' poster='" + vars.imageMobile +"' width=" + vars.playerWidth + " height=" + vars.playerHeight + "></video>");
		
		} else if(userAgent=="iPad" && (vars.type=="live" || vars.type=="audio")){
			
			document.write("<video controls autoplay src='http://streaming01.codistream.net:80/" + vars.idUser + "live/smil:" + vars.idUser + ".smil/playlist.m3u8' poster='" + (vars.imageMobile!=undefined ? ("http://progressive01.codistream.net/userdata/" + vars.idUser + "/" + vars.imageMobile) : ("http://progressive01.codistream.net/generalFiles/live.jpg")) + "' width=" + vars.playerWidth + " height=" + vars.playerHeight + "></video>");
		
		} else if(userAgent=="iPhone" && vars.type=="video"){
						
			document.write("<video controls autoplay src='http://streaming01.codistream.net:80/" + vars.idUser + "/smil:" + vars.idVideo + ".smil/playlist.m3u8' poster='" + vars.imageMobile +"' width=" + vars.playerWidth + " height=" + vars.playerHeight + "></video>");			
			
		} else if(userAgent=="iPhone" && (vars.type=="live" || vars.type=="audio")){
			
			document.write("<video controls autoplay src='http://streaming01.codistream.net:80/" + vars.idUser + "live/smil:" + vars.idUser + ".smil/playlist.m3u8' poster='" + (vars.imageMobile!=undefined ? ("http://progressive01.codistream.net/userdata/" + vars.idUser + "/" + vars.imageMobile) : ("http://progressive01.codistream.net/generalFiles/live.jpg")) + "' width=" + vars.playerWidth + " height=" + vars.playerHeight + "></video>");
			
		} else {
			
			document.write('<iframe scrolling="no" width=\"' + (vars.channelDirection=="footer" ? (vars.playerWidth+78) : (vars.playerWidth+140)) + '\" height=\"' + (vars.channelDirection=="footer" ? (vars.playerHeight+150) :  (vars.playerHeight+18)) + '\" src=\"http://www.multistream.tv/php/embedmobile/index.php?idUser=' + vars.idUser + '&userAgent=' + userAgent + '&function=' + vars.type + '&idChannel=' + vars.idChannel + '&videoWidth=' + vars.playerWidth + '&videoHeight=' + vars.playerHeight  + '&numberVideosView=' + vars.numberVideosView + '&channelDirection=' + vars.channelDirection + '\" frameborder=\"0\"></iframe>');
		
		}
		
	} else	if ( navigator.userAgent.match(/ppc/i) || navigator.userAgent.match(/windows ce/i) || navigator.userAgent.match(/blackberry/i) || navigator.userAgent.match(/opera mini/i) || navigator.userAgent.match(/mobile/i) || navigator.userAgent.match(/palm/i) || navigator.userAgent.match(/portable/i) || navigator.userAgent.match(/symbian/i) || navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/Linux/i)){
		
		userAgent = (navigator.userAgent.match(/Chrome/i)) ? "Chrome" : "";
		
		var xImagePLay = ((vars.playerWidth-54)/2);
		var yImagePLay = ((vars.playerHeight-54)/2);
		
		if(vars.type=="video") {
			document.write('<a href=\"http://progressive01.codistream.net/video/' + vars.idUser + '/' + vars.pathVideoMobile + '\" target="_blank">');
			document.write('<img src="http://multistream.tv/php/embedmobile/images/PlayAndroid.png" width="54" height="54" style="position:absolute; margin: ' + yImagePLay + 'px 0 0 ' + xImagePLay + 'px;">');
			document.write('<img src=\"' + vars.imageMobile + '\" width=\"'+ vars.playerWidth +'\" height=\"'+ vars.playerHeight +'\" />');
			document.write('</a>');
		
		} else if(vars.type=="live" || vars.type=="audio"){
			//document.write('<img src="http://multistream.tv/php/embedmobile/images/PlayAndroid.png" width="54" height="54" style="position:absolute; margin: ' + yImagePLay + 'px 0 0 ' + xImagePLay + 'px;">');			
			document.write('<iframe scrolling="no" width=\"' + vars.playerWidth + '\" height=\"' + vars.playerHeight + '\" src=\"http://www.multistream.tv/php/embedmobile/audio/index.php?idUser=' + vars.idUser + '&function=' + vars.type + '&videoWidth=' + vars.playerWidth + '&videoHeight=' + vars.playerHeight + '&imageMobile=' + vars.imageMobile +  '\" frameborder=\"0\"></iframe>');
		
		} else {					
			document.write('<iframe id="'+ vars.idEmbed + '" scrolling="no" width=\"' + (vars.channelDirection=="footer" ? (vars.playerWidth+78) : (vars.playerWidth+140)) + '\" height=\"' + (vars.channelDirection=="footer" ? (vars.playerHeight+150) :  (vars.playerHeight+18)) + '\" src=\"http://www.multistream.tv/php/embedmobile/index.php?idUser=' + vars.idUser + '&userAgent=' + userAgent + '&function=' + vars.type + '&idChannel=' + vars.idChannel + '&videoWidth=' + vars.playerWidth + '&videoHeight=' + vars.playerHeight  + '&numberVideosView=' + vars.numberVideosView + '&channelDirection=' + vars.channelDirection + '\" frameborder=\"0\"></iframe>');
		
		}
	} else {
		var strSocialStream="";
		if(Boolean(vars.socialStream)) strSocialStream=String(vars.socialStream).split("|");
		else {
			vars.socialStream="0|0|0";
			strSocialStream=String(vars.socialStream).split("|");
		}
		//alert(strSocialStream[0] + " " + strSocialStream[1] + " " + strSocialStream[2])
 		var playerWidthResize = 0;
		//if(vars.type=="live" && (strSocialStream[0]==0 || strSocialStream[1]==0 || strSocialStream[2]==0)){
		if(vars.type=="live"){
			playerWidthResize = Math.round((vars.playerWidth/(vars.playerWidth-vars.playerHeight))) == 4 ? Math.ceil(((vars.playerHeight-30)*4/3)) : Math.ceil(((vars.playerHeight-30)*16/9));
		} else playerWidthResize = vars.playerWidth;
				
		var videoWidth  = Number(playerWidthResize) + Number((vars.showLogo) ? 100 : 0) + Number((vars.channelDirection!="right") ? 0 : (vars.type!="video" && vars.type!="live") ? (vars.channelDirection=="footer") ? 0: 124 : 0) + Number((strSocialStream[0]!=0 || strSocialStream[1]!=0 || strSocialStream[2]!=0) ? 251 : 0);
		if(vars.type!="audio") var videoHeight = vars.type=="channel" ? (Boolean(vars.idChannel) || Boolean(vars.nameChannel)) ? vars.playerHeight + Number((vars.channelDirection=="right") ? 0 : (vars.channelDirection=="footer") ? 96 : 0) : vars.playerHeight : (vars.type=="emission" || vars.type=="mostView" || vars.type=="topRated" || vars.type=="recentVideos") ? vars.playerHeight + Number((vars.channelDirection=="right") ? 0 : (vars.channelDirection=="footer") ? 96 : 0) : vars.playerHeight; //+32 de la barra de controles + 96 PlayList
		else  var videoHeight = vars.playerHeight;
		
		var versionPLayer = vars.type!="audio" ? "10.1.0" : "9.0";
		
		if(vars.audio) {
			videoWidth = videoWidth-93;
			videoHeight = 29;
		}
		
		document.write('<div id="fb-root"></div>');
		document.write('<table border="0" cellpadding="0" cellspacing="0" vspace="0" hspace="0" width="' + videoWidth + '" height="' + videoHeight + '" ><td><div align="center" id="'+ vars.idEmbed + '"><a href="http://www.adobe.com/go/getflash"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Obtener Adobe Flash Player" /></a> <p>Esta p&aacute;gina necesita la versi&oacute;n ' + versionPLayer + ' de Flash Player o superior.</p> </div></td></table>');
		
		//if(vars.type=="live" && vars.playerHeight<349 && vars.socialStream) videoHeight = 349;
		
		var varsEmbed		= {//********************* Opciones Generales  *********************//
							idUser:vars.idUser, //Usuario de API (Campo de tipo Alfanumerico)
							nameChannel:vars.nameChannel, //Nombre del Canal a repoducir (Campo de tipo Alfanumerico)
							idChannel:vars.idChannel, //Id del Canal a reproducir (Campo de tipo Numerico)
							bandwidth:vars.bandwidth, // Bitrate inicial del video (0 = dinamyc Stream) (Campo de tipo Numerico)
							idVideo:vars.idVideo, // Id del video (Campo de tipo Número)
							type:vars.type, // Tipo de reproducción, (video, live, channel, emission, mostView, topRated, recentVideos) (Campo de tipo Alfanumerico)
							startPoint:vars.startPoint, // Punto inicial del video (Campo de tipo Numerico)
							endPoint:vars.endPoint, // Punto final del video (Campo de tipo Numerico)
							
							//********************* Opciones de Skin  *********************//
							backColor:vars.backColor, // Color de la barra del player (Campo de tipo Numerico)
							
							//********************* Opciones configuración del Player de Video *********************//
							optionVideo:vars.optionVideo ? vars.optionVideo : false, // Define si se activa o desactiva la opciones de Ajuste de Video y Ajuste de Pantalla (Campo de tipo Booleano)
							optionAudio:vars.optionAudio ? vars.optionAudio : false, // Define si se activa o desactiva la opciones de Ganancia y Balance (Campo de tipo Booleano)
							socialNetwork:vars.socialNetwork ? vars.socialNetwork : false, // Define si muestra los iconos de las redes sociales (Campo de tipo Booleano)
							download:vars.download ? vars.download : false, // Define si el video se puede descargar (Campo de tipo Booleano)
							embed:vars.embed ? vars.embed : false, // Define si el player se puede embeber en otro sitio o página web (Campo de tipo Booleano)
							playerWidth: vars.playerWidth , // Ancho del player (Campo de tipo Numerico)
							playerHeight: vars.playerHeight, // Alto el player (Campo de tipo Numerico)
							autoStart:vars.autoStart ? vars.autoStart : false, //Define si si el video inicia cuando carga (Campo de tipo Booleano)
							fullScreen:vars.fullScreen ? vars.fullScreen : false, //Define si el video puede tener pantalla completa (Campo de tipo Booleano)
							volume:vars.volume, // Nivel de volúmen, de 0 a 10 (Campo de tipo Numerico)
							channelDirection:vars.channelDirection, // Dirección del scroll cuando reproduce lista de videos de un canal (footer / right) (Campo de tipo Alfanumerico)
							urlSocialNetworks:vars.urlSocialNetworks, // Define la url donde esta el embed del player cuando se comparten la redes sociales (Campo de tipo Alfanumerico)
							idEmbed:idEmbed, // Id del Embed (Campo de tipo Alfanumerico)
							
							scaleMode:vars.scaleMode,
							language:vars.language,
							
							audio:vars.audio,
							
							//********************* Opciones configuración del Player de Audio *********************//
							marquee:vars.marquee, // Define el mensaje que se muestra en el player de audio (Campo de tipo Alfanumerico)
							colorMarquee:vars.colorMarquee, // Color del mensaje (Campo de tipo Numerico)
							showLogo:vars.showLogo ? vars.showLogo : false, //  Define si muestra el logo en el player de audio (Campo de tipo Booleano)
							
							//********************* Opciones configuración del Player de Emisión en Vivo *********************//	
							imageLive:vars.imageLive, // Nombre de la imagen que se muestra antes de la reproducciión (Campo de tipo Alfanumerico)
							socialStream:vars.socialStream, // Define si muestra el módulo del chat con redes sociales (Campo de tipo Booleano)
							idAppFacebook:vars.idAppFacebook, // Id del Api de Facebook (Campo de tipo Alfanumerico)
							apiKeyTwitter:vars.apiKeyTwitter, // Llave del Api de Twitter (Campo de tipo Alfanumerico)
							apiSecretTwitter:vars.apiSecretTwitter, // Id del Api Secreto de Twitter (Campo de tipo Alfanumerico)
							
							source:vars.source, // Opción que determina si el video se reproduce desde codistream
							da:vars.da,
							
							//********************* Opciones configuración del Player para Mobiles*********************//
							imageMobile:vars.imageMobile, // Nombre de la imagen a mostrar en el player (Campo de tipo Alfanumerico)
							pathVideoMobile:vars.pathVideoMobile, // Ruta de video para la reproducción en dispositivos móbiles
							numberVideosView:vars.numberVideosView // Número de videos a mostrar de los más vistos, lo más votados ó los videos recientes.
		}
	
		var params		= {	scale:			"noScale",
							menu:			"false",
							allowFullScreen:  "true",
							wmode: "direct",
							allowScriptAccess: "always",
							bgcolor: "#000000" };
		var attributes	= {
			id:idEmbed,
			name:idEmbed
		};
		
		swfobject.switchOffAutoHideShow();
		if(vars.type!="audio") swfobject.embedSWF("http://api.codistream.net/videoplayergenerator/embedVideoPlayerCodistream.swf", idEmbed, videoWidth, videoHeight, "10.2", "http://progressive01.codistream.net/generalFiles/swfjs/expressInstall.swf", varsEmbed, params, attributes);
		else swfobject.embedSWF("http://api.codistream.net/videoplayergenerator/embedAudioPlayer.swf", idEmbed, videoWidth, videoHeight, "9.0", "http://progressive01.codistream.net/generalFiles/swfjs/expressInstall.swf", varsEmbed, params, attributes);
		
		
		//document.write('<iframe scrolling="no" width="0" height="0" src="http://www.multistream.tv/php/logDomainEmbed/index.php" frameborder="0"</iframe>');
	}
}
