//Listado de Videos en JavaScript. Habría que cargarlo desde PHP.
/*
var id = 0;
var video = new Array();
video[0] = new Array ("mjOQ3PvOR8s", "Video 1");
video[1] = new Array ("h3a3Kdhueq4", "Video 2");
video[2] = new Array ("8JkvBbanxnA", "Video 3");
video[3] = new Array ("zu04iIn5btU", "Video 4");
video[4] = new Array ("exPitd_cIbc", "Video 5");   
*/

function cambia_video(num)
	{
	if (num == 'primero')
		id = 0;
	else if (num == 'ultimo')
		id = video.length-1;
	else
		id+=num;
//	for(var i=0 ; i<video.length ; i++) { alert(video[i]); }   
	if (id >= video.length-1) //ULTIMO
		{
		document.getElementById('a_fin').style.display = "none";
		document.getElementById('a_fin_gris').style.display = "block";
		
		document.getElementById('siguiente').style.display = "none";
		document.getElementById('siguiente_gris').style.display = "block";			
		}
	else
		{
		document.getElementById('a_fin').style.display = "block";
		document.getElementById('a_fin_gris').style.display = "none";
		
		document.getElementById('siguiente').style.display = "block";
		document.getElementById('siguiente_gris').style.display = "none";				
		}

	if (id <= 0) //INICIO
		{
		document.getElementById('a_ini').style.display = "none";
		document.getElementById('a_ini_gris').style.display = "block";

		document.getElementById('anterior').style.display = "none";
		document.getElementById('anterior_gris').style.display = "block";			
		}
	else
		{
		document.getElementById('a_ini').style.display = "block";
		document.getElementById('a_ini_gris').style.display = "none";
		
		document.getElementById('anterior').style.display = "block";
		document.getElementById('anterior_gris').style.display = "none";
		}

	document.getElementById("titulo").innerHTML = video[id][1];
	document.getElementById('estas').innerHTML = "Vídeo "+ String(id+1) + " de " + String(video.length);

	document.getElementById('video').innerHTML =
		"<a href='#' onclick=\"return ver_video("+id+")\">" +
		"<img alt='"+video[id][1]+"' src='http://img.youtube.com/vi/"+video[id][0]+"/0.jpg'  height='140'>"+
		"<img class='img_play' src='img/play-youtube.gif' alt='' title='' /></a>";
	/*document.getElementById("video").innerHTML =
		"<param name='movie' value='http://www.youtube.com/v/"+video[id][0]+"?fs=1&amp;hl=es_ES&amp;rel=0'></param>" +
		"<param name='allowFullScreen' value='true'></param>" +
		"<param name='allowscriptaccess' value='always'></param>" +
		"<param name='wmode' value='transparent'></param>" +
		"<embed src='http://www.youtube.com/v/"+video[id][0]+"?fs=1&amp;hl=es_ES&amp;rel=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='245' height='162' wmode='transparent'>";
		*/
	return false;
	}

function ver_video (id) {
	document.getElementById("video").innerHTML =
		"<param name='movie' value='http://www.youtube.com/v/"+video[id][0]+"?fs=1&amp;hl=es_ES&amp;rel=0&amp;autoplay=1'></param>" +
		"<param name='allowFullScreen' value='true'></param>" +
		"<param name='allowscriptaccess' value='always'></param>" +
		"<param name='wmode' value='transparent'></param>" +
		"<embed src='http://www.youtube.com/v/"+video[id][0]+"?fs=1&amp;hl=es_ES&amp;rel=0&amp;autoplay=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='245' height='162' wmode='transparent'>";
		return false;
}

function cambia_video_anulada(pag) {
	if (typeof pag == "undefined")
		{
		for (i=1;i<=5;i++)
			{
			if (document.getElementById('pagina'+i).className =='div_pagina_primera_act' || document.getElementById('pagina'+i).className =='pagina_act')
				{
				pag = i+1;
				break;
				}
			}
		}
		switch(pag)
			{
			case 1:	
				document.getElementById("titulo").innerHTML ="Grupo FreshCo®";
				document.getElementById("video").innerHTML ="<iframe title='Video Formación Freshco' class='youtube-player'  width='245' height='213' src='http://www.youtube.com/v/mjOQ3PvOR8s?fs=1&amp;hl=es_ES&amp;rel=0' frameborder='0' ></iframe>";
				document.getElementById('pagina1').className ='div_pagina_primera_act';
				document.getElementById('pagina2').className ='div_pagina';
				document.getElementById('pagina3').className ='div_pagina';
				document.getElementById('pagina4').className ='div_pagina';
				document.getElementById('pagina5').className ='div_pagina';
				document.getElementById('siguiente').style.display = "block";
				document.getElementById('a_siguiente').setAttribute("title", "Formación en Comercio y Distribución");
				break;
			case 2:
				document.getElementById("titulo").innerHTML ="Formación en Comercio y Distribución";
				document.getElementById("video").innerHTML ="<iframe title='Video Formación Freshco' id='iframe_video' class='youtube-player'  width='245' height='213' src='http://www.youtube.com/v/h3a3Kdhueq4?fs=1&amp;hl=es_ES&amp;rel=0' frameborder='0' ></iframe>";
				document.getElementById('pagina1').className ='div_pagina_primera';
				document.getElementById('pagina2').className ='pagina_act';
				document.getElementById('pagina3').className ='div_pagina';
				document.getElementById('pagina4').className ='div_pagina';
				document.getElementById('pagina5').className ='div_pagina';
				document.getElementById('siguiente').style.display = "block";
				document.getElementById('a_siguiente').setAttribute("title", "Formación en manejo de maquinaria");
				break;
			case 3:
				document.getElementById("titulo").innerHTML ="Formación en manejo de maquinaria";
//				document.getElementById("video").innerHTML ="<iframe title='Video Formación Freshco' class='youtube-player'  width='245' height='213' src='http://www.youtube.com/v/8JkvBbanxnA?fs=1&amp;hl=es_ES&amp;rel=0&amp;wmode=transparent' frameborder='0'></iframe>";
				if (window.ActiveXObject)
					{
					document.getElementById("video").movie='http://www.youtube.com/v/8JkvBbanxnA?fs=1&amp;hl=es_ES&amp;rel=0';
					alert('si');
					
					}
				else
					{
					document.getElementById("video").innerHTML ="<param name='movie' value='http://www.youtube.com/v/8JkvBbanxnA?fs=1&amp;hl=es_ES&amp;rel=0'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/8JkvBbanxnA?fs=1&amp;hl=es_ES&amp;rel=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='245' height='162' wmode='transparent'>";
					alert('no');
					}

				document.getElementById('pagina1').className ='div_pagina_primera';
				document.getElementById('pagina2').className ='div_pagina';
				document.getElementById('pagina3').className ='pagina_act';
				document.getElementById('pagina4').className ='div_pagina';
				document.getElementById('pagina5').className ='div_pagina';
				document.getElementById('siguiente').style.display = "block";
				document.getElementById('a_siguiente').setAttribute("title", "Formación en Moda");
				break;
			case 4:
				document.getElementById("titulo").innerHTML ="Formación en Moda";
				document.getElementById("video").innerHTML ="<iframe title='Video Formación Freshco' class='youtube-player'  width='245' height='213' src='http://www.youtube.com/v/zu04iIn5btU?fs=1&amp;hl=es_ES' frameborder='0' ></iframe>";
				document.getElementById('pagina1').className ='div_pagina_primera';
				document.getElementById('pagina2').className ='div_pagina';
				document.getElementById('pagina3').className ='div_pagina';
				document.getElementById('pagina4').className ='pagina_act';
				document.getElementById('pagina5').className ='div_pagina';
				document.getElementById('siguiente').style.display = "block";
				document.getElementById('a_siguiente').setAttribute("title", "Formación en Hostelería");
				break;
			case 5:
				document.getElementById("titulo").innerHTML ="Formación en Hostelería";
				document.getElementById("video").innerHTML ="<iframe title='Video Formación Freshco' class='youtube-player'  width='245' height='213' src='http://www.youtube.com/v/exPitd_cIbc?fs=1&amp;hl=es_ES&amp;rel=0' frameborder='0' ></iframe>";
				document.getElementById('pagina1').className ='div_pagina_primera';
				document.getElementById('pagina2').className ='div_pagina';
				document.getElementById('pagina3').className ='div_pagina';
				document.getElementById('pagina4').className ='div_pagina';
				document.getElementById('pagina5').className ='pagina_act';
				document.getElementById('siguiente').style.display = "none";
				break;

			}
	return false;
}
