﻿var xmlind;
var xmlnot;
var catvideosel = "";
var tr = 0;
var idioma = "es";
var stats = 0;
var contenido_original = "";
var xmlfeed = "";

function portada()
{

$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "xml/portada.xml",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(xml) 
	{ 
		xml1 = xml;
		
		$("#titulo1").html ($(xml1).find('diapo[id=0]').attr ("titulo"));
		$("#texto1").html ($(xml1).find('diapo[id=0]').text());
		$("#cajatextoportada").show('blind', 500);
		panel();
		carga_noticias ();
				
		if (idioma == "es" || idioma == "Spanish")
		{
		if (contenido_original == "")
		{
		setTimeout ("contenido_original = $('#contenedor').html();", 1000);
		}
		else
		{
		$("#contenedor").html(contenido_original);
		}
		}
		
		activa_diapos ();
		
	}

});

}

function activa_diapos()
{

$("#flechaizq").click (function () { mdiapo (diapo-1); } );
$("#flechader").click (function () { mdiapo (diapo+1); } );

$("div[id*=cajatextob]").mouseenter ( function () { valtop = $(this).css ("top"); valtop = valtop.substring (0,valtop.length-2); valtop = parseInt (valtop) + 20; $("div[id*=cajatextob]").css("top", ""); $("div[id*=cajatextob] div[id*=titulo_ct]").css("color", "#f0f0f0"); $("div[id*=cajatextob] div[id*=titulo_ct] a").css("color", "#f0f0f0"); $(this).animate({top: valtop + 'px'}, 300); $("#" + $(this).attr("id") + " div[id*=titulo_ct]").css ("color", "#FFFEA1"); $("#" + $(this).attr("id") + " div[id*=titulo_ct] a").css ("color", "#FFFEA1"); });
$("div[id*=cajatextob]").mouseleave ( function () { valtop = parseInt(valtop) - 20; $("div[id*=cajatextob]").css("top", ""); $("div[id*=cajatextob] div[id*=titulo_ct]").css("color", "#f0f0f0"); $("div[id*=cajatextob] div[id*=titulo_ct] a").css("color", "#f0f0f0"); $(this).animate({top: valtop + 'px'}, 300);});

$("#menu1 ul li div").mouseenter (function () { $("#menu1 ul li div").css ("color","#eeeeee"); $(this).css ("color","#FFFEA1"); });
$("#menu1 ul li div").mouseleave (function () { $("#menu1 ul li div").css ("color","#eeeeee"); });
$("#noticias").css ("opacity","0.7");

$(document).pngFix(); 

}

function mdiapo (id)
{
id1 = id;
if (id == -1) { id1 = 0; }

if (diapo != id1 && id1 <= maxdiapo)
{
$("#cajatextoportada").hide();
$("#foto1").css ("background", "url(img/img_" + id1 + ".jpg) no-repeat 429px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#titulo1").css ("height","auto");
$("#titulo1").html ($(xml1).find('diapo[id=' + id1 +']').attr ("titulo"));
$("#texto1").html ($(xml1).find('diapo[id=' + id1 + ']').text());

diapo = id1;

if (diapo == 0) { $("#flechaizq").hide(); $("#noticias").show("blind", 1000); } else { $("#flechaizq").show(); $("#noticias").hide(); }
if (diapo == maxdiapo) { $("#flechader").hide(); } else { $("#flechader").show(); }

		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

if (idioma == 'es' || idioma == 'Spanish')
{
		$("#cajatextoportada").show('blind', 500);
		panel();
}

}

}

function panel ()
{

$('#panel1').jScrollPane(
{
showArrows:false, 
scrollbarWidth: 5,
topCapHeight: 5,
bottomCapHeight: 5,
animateStep: 4,
dragMinHeight: 30,
reinitialiseOnImageLoad: true,
maintainPosition: true
}
);

$("#catsvideo").remove();

$('#panel1')[0].scrollTo(0);

}

function carga_videos (catvideo)
{
	$("#myytplayer").remove();
	$("#noticias").hide();
	$("#menu2").remove();
	$("#panel1").jScrollPaneRemove();
	$("#paspartu img").attr ("src","img/marco_foto.png");
	$("#flechaizq").hide();
	$("#flechader").hide();
	$("#breadcrumb").html ("");
	$("#foto1").css ("background","");
	$("#foto1").css ("background-color","#000000");
	$("#foto1").css ("padding-top","0px");
	$("#foto1").append ("<div id=\"video1\"></div>");
	$("#cajatextoportada").css ("left", "470px");
	$("#cajatextoportada").css ("width", "450px");
	$("#cajatextoportada").css ("top", "130px");
	
	$("#video1").html ("<div style=\"padding:30px;\"><h1>Este contenido solo puede ser visualizado si dispone del reproductor de archivos Flash.</h1><p>Puede descargarlo en la página de adobe. http://www.adobe.es<\/p></div>");
	
	var params = { wmode: "transparent", allowScriptAccess: "always", bgcolor: "#cccccc" };
    // this sets the id of the object or embed tag to 'myytplayer'.
    // You then use this id to access the swf and make calls to the player's API
	//video: 0yNCnRIKJ8s
    var atts = { id: "myytplayer" };
    swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer", "video1", "420", "304", "8", "swf/expressInstall.swf", null, params, atts);
	
if (stats == 1)
		{
			dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','xml/videos.xml');
		}
		
	$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "xml/videos.xml",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(xml) 
	{ 
		
		$("#panel1").jScrollPaneRemove();
		$("#titulo1").html ("Videos");
		$("#titulo1").css ("height","auto");
		
		var enlaces = "";
		var x=0;
		
		cats = "<select name='catsvideodrop' id='catsvideodrop' style='color: #aaaaaa; margin-left: 5px; font-size: 11px; padding: 1px; border: 1px solid #f0f0f0;' onchange='catvideosel = this.value; carga_videos(this.value)'><option value=''>(Todos)</option>";

		$(xml).find('cat').each (function () 
		{ 
		cats = cats + "<option value='" + $(this).attr("id") + "'>" + $(this).attr("nombre") + "</option>" 
		});

		cats = cats + "</select>"
		
		criterio = "";
		
		if (catvideo != "")
		{
		criterio = "[cat=" + catvideo + "]";
		}
		
		$(xml).find('video' + criterio).each(function()
			{
			
			enlaces = enlaces + "<div style=\"float: left; margin-right: 10px;\"><img id=\"vth" + x + "\" style=\"border:5px solid #f0f0f0;\" src=\"" + $(this).attr ("th") + "\" alt=\"\" /></div><div class=\"videolink\" style=\"float: left; font-size: 16px;\"><a href=\"javascript: void(null);\" onclick=\"$('#vth" + x + "').css ('border','5px solid #de6100');carga_tube ('" + $(this).attr("yt") + "');\">" + $(this).attr("titulo") + "<\/a></div><div style=\"float: none; clear: both;\">&nbsp;</div>"
			
			x++;
			
			});
		
		if (x==0)
		{
		enlaces = "<div>No existen videos en la categoría seleccionada</div>";
		}
		
		$("#texto1").html (enlaces + "<div style='float: none; clear: both; height: 30px;'>&nbsp;</div>");
		$(".videolink").css ("float","left");
		$(".videolink").css ("width","250px");
		$(".videolink a").addClass ("enlace1");
		
		$("#cajatextoportada").show('blind', 500);
		$("#cajatextoportada").append ("<div id='catsvideo' style='background-color: #ffffff; z-index: 2000; position: absolute; left: 0px; top: 260px; width: 400px; padding: 10px;'>FILTRAR VIDEOS " + cats + "</div>");
		panel(); 
		$("#catsvideodrop").val ('' + catvideosel);	
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
				$("#cajatextoportada").show('blind', 500);
				panel();
		}
		
	}

});
	
}

function carga_glosario()
{
$("#cajatextoportada").hide();
$("#reproductor").hide();
$("#noticias").hide();
$("#myytplayer").remove();
$("#menu2").remove();
$("#paspartu img").attr ("src","img/marco_foto_peq.png");
$("#foto1").css ("background", "url(img/glosario.jpg) no-repeat 429px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">Glosario</span>");

		$("#cajatextoportada").css ("left", "430px");
		$("#cajatextoportada").css ("width", "490px");
		$("#cajatextoportada").css ("height","26.364em");
		$("#cajatextoportada").css ("top", "130px");

if (stats == 1)
		{
		dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','xml/glosario.xml');
		}
		
$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "xml/glosario.xml",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(xml) 
	{ 
		
		$("#panel1").jScrollPaneRemove();
		$("#titulo1").html ("");
		$("#titulo1").css ("height","0px");
		
		var glosario = "";
		
		$(xml).find('def').each(function()
			{
			
			glosario = glosario + "<div class=\"termino\">" + $(this).attr ("definicion") + "</div><div class=\"definicion\">" + $(this).text() + "</div>"
			
			});
		
		$("#texto1").html (glosario);
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
		$("#cajatextoportada").show('blind', 500);
		panel();
		}
			
	}

});

}

function carga_archivos(idioma1)
{
$("#reproductor").hide();
$("#noticias").hide();
$("#myytplayer").remove();
$("#menu2").remove();
$("#paspartu img").attr ("src","img/marco_foto_peq.png");
$("#foto1").css ("background", "url(img/archivos.jpg) no-repeat 429px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
if (idioma1 == "es")
{
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">Descarga de Archivos</span>");
$("#cajatextob1").show();
$("#cajatextob2").show();
$("#cajatextob3").show();
$("#cajatextob4").show();
$("#cajatextob5").show();
$("#menu1").show();
}
else
{
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Home (spanish)<\/a><span class=\"seph\">|</span><span class=\"naranja\">Downloads</span>");
$("#cajatextob1").hide();
$("#cajatextob2").hide();
$("#cajatextob3").hide();
$("#cajatextob4").hide();
$("#cajatextob5").hide();
$("#menu1").hide();
}

		$("#cajatextoportada").css ("left", "430px");
		$("#cajatextoportada").css ("width", "490px");
		$("#cajatextoportada").css ("height","26.364em");
$("#cajatextoportada").css ("top", "130px");
		
if (stats == 1)
		{
		dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','xml/archivos.xml');
		}
		
$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "xml/archivos.xml",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(xml) 
	{ 
		
		$("#panel1").jScrollPaneRemove();
		$("#titulo1").html ("");
		$("#titulo1").css ("height","0px");
		
		var archivos = "";
		
		$(xml).find('archivo[version=' + idioma1 + ']').each(function()
			{
			
			switch ($(this).attr ("tipo"))
			{
			case "doc":
			tipo = "word";
			break;			
			case "docx":
			tipo = "word";
			break;
			case "ppt":
			tipo = "pps";
			break;
			case "pptx":
			tipo = "pps";
			break;
			case "ppsx":
			tipo = "pps";
			break;
			case "pps":
			tipo = "pps";
			break;
			case "pdf":
			tipo = "pdf";
			break;
			}
			
			archivos = archivos + "<div class=\"termino\" style=\"border-bottom: 1px dotted #f0f0f0; padding-bottom: 5px;\"><img style=\"margin-right: 5px; vertical-align: middle;\" src=\"img/" + tipo + ".png\" alt=\"icono archivo\" /><a href=\"" + $(this).attr ("url") + "\" rel=\"external\">" + $(this).attr ("titulo") + "</a></div>"
			
			});
		
		$("#texto1").html (archivos);
		$(".termino a").addClass ("enlace2");
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
				$("#cajatextoportada").show('blind', 500);
				panel();
		}
					
	}

});

}

function carga_enlaces()
{
$("#reproductor").hide();
$("#myytplayer").remove();
$("#noticias").hide();
$("#menu2").remove();
$("#paspartu img").attr ("src","img/marco_foto_peq.png");
$("#foto1").css ("background", "url(img/enlaces.jpg) no-repeat 429px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">Enlaces de Interés</span>");

		$("#cajatextoportada").css ("left", "430px");
		$("#cajatextoportada").css ("width", "490px");
		$("#cajatextoportada").css ("height","26.364em");
$("#cajatextoportada").css ("top", "130px");

if (stats == 1)
		{
		dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','xml/enlaces.xml');
		}
		
$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "xml/enlaces.xml",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(xml) 
	{ 
		
		$("#panel1").jScrollPaneRemove();
		$("#titulo1").html ("");
		$("#titulo1").css ("height","0px");
		
		var enlaces = "";
		
		$(xml).find('enlace').each(function()
			{
			
			enlaces = enlaces + "<div class=\"termino\">" + $(this).attr ("titulo") + "</div><div class=\"definicion\"><a href=\"" + $(this).text() + "\" rel=\"external\">" + $(this).text() + "<\/a></div>"
			
			});
		
		$("#texto1").html (enlaces);
		$(".definicion a").addClass ("enlace2");
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
				$("#cajatextoportada").show('blind', 500);
				panel();
		}		
			
	}

});

}

function carga_pagina (pagina, div1)
{

$("#cajatextoportada").hide ();

if (stats == 1)
		{
			dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','contenidos/' + pagina);
		}
		
$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "contenidos/" + pagina,
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(htm) 
	{ 
		
		$("#" + div1).jScrollPaneRemove();
		$("#" + div1).html (htm);
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
		$("#cajatextoportada").show('blind', 500);
		panel();
		}
		
			
	}

});

}

function carga_pimundo()
{
$("#myytplayer").remove();
$("#reproductor").hide();
$("#noticias").hide();
$("#menu2").remove();
$("#texto1").html ("");
$("#paspartu img").attr ("src","img/marco_foto_peq2.png");
$("#foto1").css ("background", "url(img/pi_mundo.jpg) no-repeat 229px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">La PI en el mundo</span>");

$("#cajatextoportada").css ("left", "430px");
$("#cajatextoportada").css ("width", "490px");
$("#cajatextoportada").css ("height","26.364em");
$("#cajatextoportada").css ("top", "130px");

if ($("#menu2").length == 0)
{
$("#cajafoto").append ("<div id=\"menu2\" style=\"z-index: 200;\"></div>");
}

$("#menu2").html ("<ul><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('pimundo_introduccion.html', 'panel1')\">Introducción<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('pimundo_marcas.html', 'panel1')\">Marcas<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('pimundo_disenyos.html', 'panel1')\">Diseños Industriales<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('pimundo_patentes.html', 'panel1')\">Patentes<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('pimundo_espanya.html', 'panel1')\">España en el contexto internacional<\/a></li></ul>");
$("#menu2 ul li a").addClass ("enlace1");

setTimeout ('carga_pagina ("pimundo_introduccion.html", "panel1")', 500);

}

function carga_piesp()
{
$("#myytplayer").remove();
$("#reproductor").hide();
$("#noticias").hide();
$("#menu2").remove();
$("#texto1").html ("");
$("#paspartu img").attr ("src","img/marco_foto_peq2.png");
$("#foto1").css ("background", "url(img/pi_esp.jpg) no-repeat 229px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">La PI en España</span>");

$("#cajatextoportada").css ("left", "430px");
$("#cajatextoportada").css ("width", "490px");
$("#cajatextoportada").css ("height","26.364em");
$("#cajatextoportada").css ("top", "130px");

if ($("#menu2").length == 0)
{
$("#cajafoto").append ("<div id=\"menu2\" style=\"z-index: 200;\"></div>");
}

$("#menu2").html ("<ul><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_introduccion.html', 'panel1')\">Situación general de la PI en España<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_patentes.html', 'panel1')\">Patentes en España<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_internacional.html', 'panel1')\">La internacionalización de las patentes españolas<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_pverdes.html', 'panel1')\">Patentes verdes<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_pirateria.html', 'panel1')\">La falsificación y la piratería en la PI<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_oepm.html', 'panel1')\">La Oficina Española de Patentes y Marcas (OEPM)<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_conclusiones.html', 'panel1')\">Conclusiones al diagnóstico<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_fortalezas.html', 'panel1')\">Fortalezas<\/a> y <a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_oportunidades.html', 'panel1')\">Oportunidades<\/a>, <a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_debilidades.html', 'panel1')\">Debilidades<\/a> y <a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_amenazas.html', 'panel1')\">Amenazas<\/a> del sistema de protección de la PI en España</li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('piesp_meta.html', 'panel1')\">Meta y orientación estratégica <\/a></li></ul>");
$("#menu2 ul li a").addClass ("enlace1");

carga_pagina ("piesp_introduccion.html", "panel1");

}

function carga_indicadores()
{

$("#cajatextoportada").css ("left", "190px");
$("#cajatextoportada").css ("width", "730px");
$("#cajatextoportada").css ("height","20em");
$("#panel1").css ("height","22em");
$("#cajatextoportada").css ("top", "150px");

$("#myytplayer").remove();
$("#reproductor").hide();
$("#noticias").hide();
$("#menu2").remove();
$("#titulo1").html ("");
$("#texto1").html ("");

$("#paspartu img").attr ("src","img/marco_foto_peq2.png");
setTimeout ("$(\"#foto1\").css (\"background\", \"url(img/indicadores.jpg) no-repeat 229px 0px\"); $('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});",50);
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">Indicadores de actuaciones</span>");

if (stats == 1)
		{
			dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','xml/indicadores.xml');
		}
		
$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "xml/indicadores.xml",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(xml) 
	{ 
		
		xmlind = xml;
		$("#panel1").jScrollPaneRemove();
		$("#titulo1").html ("");
		$("#titulo1").css ("height","0px");
		
		var indicadores = "<div><table class='tablesorter' id='noticias_tabla'>"
		indicadores = indicadores + "<thead><tr><th style='width: 140px;'>EJE ESTRATÉG.</th><th>ACTUACIÓN</th><th style='width: 180px;'>ESTADO</th></tr></thead><tbody>";
		
		$(xml).find('indicador').each(function()
			{
			
			indicadores = indicadores + "<tr onclick=\"ver_actuacion (" + $(this).attr ("id") + ");\" id=\"tr" + $(this).attr ("id") + "\"><td>" + $(xml).find('eje[id=' + $(this).attr ("eje") + ']').attr("nombre") + "</td><td>" + $(this).attr ("actuacion") + "</td><td>" + $(this).attr ("estado") + "</td></tr>"
			
			});
		
		indicadores = indicadores + "</tbody></table></div>";
		//indicadores = indicadores + "<div id=\"pager\" class=\"pager\"><form><img src=\"../addons/pager/icons/first.png\" class=\"first\"/><img src=\"../addons/pager/icons/prev.png\" class=\"prev\"/><input type=\"text\" class=\"pagedisplay\"/><img src=\"../addons/pager/icons/next.png\" class=\"next\"/><img src=\"../addons/pager/icons/last.png\" class=\"last\"/><select class=\"pagesize\"><option selected=\"selected\"  value=\"10\">10</option><option value=\"20\">20</option><option value=\"30\">30</option><option  value=\"40\">40</option></select></form></div>";
		
		$("#texto1").html (indicadores);
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
			setTimeout ("$(\"#plpi_ind\").tablesorter({ sortList: [[0,0],[1,0]], widgets: ['zebra'],  headers: { 3: { sorter: false }} }); ;", 2000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
		$("#cajatextoportada").show('blind', 500);
		$("#panel1").css ("height","23em");
		panel();
		$("#plpi_ind").tablesorter({ sortList: [[0,0],[1,0]], widgets: ['zebra'],  headers: { 3: { sorter: false }} }); 
		}
		
		//$("#plpi_ind").tablesorterPager({container: $("#pager")});
			
	}

});

}

function carga_feed_google()
{
$("#myytplayer").remove();
$("#reproductor").hide();
$("#noticias").hide();
$("#menu2").remove();
$("#panel1").jScrollPaneRemove();
$("#titulo1").html ("");
$("#texto1").html ("");
$("#paspartu img").attr ("src","img/marco_foto_peq2.png");
$("#foto1").css ("background", "url(img/indicadores.jpg) no-repeat 229px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">La OEPM en los medios</span>");

$("#cajatextoportada").css ("left", "190px");
$("#cajatextoportada").css ("width", "730px");
$("#cajatextoportada").css ("height","20em");
$("#panel1").css ("height","22em");
$("#cajatextoportada").css ("top", "150px");

if (stats == 1)
		{
			dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','xml/indicadores.xml');
		}
		
if (xmlfeed)
{
carga_feed_detalle ();
}
else
{

$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "feed_google.asp",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) { alert (XMLHttpRequest.responseText); },
	success: function(xml) 
	{ 
		
		xmlfeed = xml;
		carga_feed_detalle ();
					
	}

});

}
}

function ver_actuacion (id1)
{
if (xmlind)
{

actuacion = "<div class=\"actuaciones\"><div><span>Código</span><p>" + $(xmlind).find('indicador[id=' + id1 + ']').attr ("codigo") + "</p></div>";
actuacion = actuacion + "<div><span>Actuación</span><p>" +$(xmlind).find('indicador[id=' + id1 + ']').attr ("actuacion") + "</p></div>";
actuacion = actuacion + "<div><span>Indicador</span><p>" +$(xmlind).find('indicador[id=' + id1 + ']').attr ("indicador") + "</p></div>";
actuacion = actuacion + "<div><span>Objetivo</span><p>" +$(xmlind).find('indicador[id=' + id1 + ']').attr ("objetivo") + "</p></div>";
actuacion = actuacion + "<div><span>Estado</span><p>" +$(xmlind).find('indicador[id=' + id1 + ']').attr ("estado") + "</p></div>";
actuacion = actuacion + "<div><span>Grupo de Trabajo</span><p>" +$(xmlind).find('indicador[id=' + id1 + ']').attr ("grupo_trabajo") + "</p></div>";
actuacion = actuacion + "<div><span>Área</span><p>" +$(xmlind).find('indicador[id=' + id1 + ']').attr ("area") + "</p></div></div>";

$("#dialogo").dialog("destroy");
$("#dialogo").dialog({
			height: 400,
			width: 800,
			modal: false,
			resizable: false,
			open: function(event, ui) 
			{ 
			
			$("#dialogo_contenido").html("");
			
			if (tr==1 && idioma != "es" && idioma != "Spanish")
			{
				
				$("#dialogo").dialog ("option","title","");
				$.translate(actuacion, $("#idiomas select").val(), { error: function () { }, complete: function (tr) { $("#dialogo_contenido").html(tr); } });
								
			}

			if (idioma == 'es' || idioma == 'Spanish')
			{
			$("#dialogo").dialog ("option","title","Detalle de indicador");
			$("#dialogo_contenido").html(actuacion);			
			}
			
			
			}});

}
}

function carga_feed_detalle()
{

		$("#panel1").jScrollPaneRemove();
		$("#titulo1").html ("");
		$("#titulo1").css ("height","0px");
		
		var indicadores = "<div><table class='tablesorter' id='noticias_tabla'>"
		indicadores = indicadores + "<thead><tr ><th>Fecha</th><th>Titular</th></tr></thead><tbody>";
		
		$(xmlfeed).find('entry').each(function()
			{
			
			indicadores = indicadores + "<tr style=\"cursor: default;\" id=\"tr" + $(this).find ("id").text() + "\"><td style=\"cursor: default;\">" + $(this).find ("published").text().substring(0,10) + "</td><td style=\"cursor: default;\"><div>" + $(this).find ("title:first").text() + "</div>" + $(this).find ("content").text() + "<div></div></td></tr>"
			
			});
		
		indicadores = indicadores + "</tbody></table></div>";
		
		$("#texto1").html (indicadores);
		$("#panel1").css ("height","23em");
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
		$("#cajatextoportada").show('blind', 500);
		panel();
		}
		
		$("#noticias_tabla").tablesorter({ sortList: [[0,1]], widgets: ['zebra'], dateFormat: 'uk' }); 

}

function carga_noticias_detalle()
{
$("#myytplayer").remove();
$("#reproductor").hide();
$("#noticias").hide();
$("#menu2").remove();
$("#paspartu img").attr ("src","img/marco_foto_peq2.png");
$("#foto1").css ("background", "url(img/indicadores.jpg) no-repeat 229px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">Noticias</span>");

$("#cajatextoportada").css ("left", "190px");
$("#cajatextoportada").css ("width", "730px");
$("#cajatextoportada").css ("height","20em");
$("#panel1").css ("height","22em");
$("#cajatextoportada").css ("top", "150px");

if (stats == 1)
{
			dcsMultiTrack('DCS.dcssip','www.planpi.es','DCS.dcsuri','xml/noticias.xml');
}
		
if (xmlnot)
{

		
		$("#panel1").jScrollPaneRemove();
		$("#titulo1").html ("");
		$("#titulo1").css ("height","0px");
		
		var indicadores = "<div><table class='tablesorter' id='noticias_tabla'>"
		indicadores = indicadores + "<thead><tr ><th>Fecha</th><th>Titular</th></tr></thead><tbody>";
		
		$(xmlnot).find('noticia').each(function()
			{
			
			indicadores = indicadores + "<tr onclick=\"ver_noticia (" + $(this).attr ("id") + ");\" id=\"tr" + $(this).attr ("id") + "\"><td>" + $(this).attr ("fecha") + "</td><td>" + $(this).attr ("titular") + "</td></tr>"
			
			});
		
		indicadores = indicadores + "</tbody></table></div>";
		
		$("#texto1").html (indicadores);
		$("#panel1").css ("height","23em");
		
		if (tr==1 && idioma != "es" && idioma != "Spanish")
		{
			setTimeout ("traduce_textos();", 1000);
		}

		if (idioma == 'es' || idioma == 'Spanish')
		{
		$("#cajatextoportada").show('blind', 500);
		panel();
		}
		
		$("#noticias_tabla").tablesorter({ sortList: [[0,1]], widgets: ['zebra'], dateFormat: 'uk' }); 
		

}



}

function link1 (id1)
{
$("#plpi_ind tr td[id=td" + id1 +"]").html ("<a style=\"color: #de6100;\" href=\"javascript: void(null);\" onclick=\"ver_actuacion (" + id1 + ");\">[+] información</a>");
}

function ver_noticia (id1)
{

if (xmlnot)
{

noticia = $(xmlnot).find('noticia[id=' + id1 + ']').text() + "<br/>";
titular = $(xmlnot).find('noticia[id=' + id1 + ']').attr("titular") + "<br/>";
fecha = $(xmlnot).find('noticia[id=' + id1 + ']').attr("fecha") + "<br/>";

$("#dialogo").dialog("destroy");
$("#dialogo").dialog({
			height: 400,
			width: 800,
			modal: false,
			resizable: false,
			open: function(event, ui) 
			{ 
			
			$("#dialogo_contenido").html("");
			
			if (tr==1 && idioma != "es" && idioma != "Spanish")
			{
				
				$.translate(titular, $("#idiomas select").val(), { error: function () { }, complete: function (tr) { titular = tr; $.translate(noticia, $("#idiomas select").val(), { error: function () { }, complete: function (tr) { noticia = tr; $("#dialogo").dialog ("option","title","Noticias - " + fecha); $("#dialogo_contenido").html("<p>" + titular + "</p>" + noticia); } }); }});
								
			}

			if (idioma == 'es' || idioma == 'Spanish')
			{
			$("#dialogo").dialog ("option","title","Noticias - " + fecha);
			$("#dialogo_contenido").html("<p>" + titular + "</p>" + noticia);			
			}
			
			}
			});

}
}

function carga_tendencias()
{
$("#myytplayer").remove();
$("#reproductor").hide();
$("#noticias").hide();
$("#paspartu img").attr ("src","img/marco_foto_peq2.png");
$("#foto1").css ("background", "url(img/tendencias.jpg) no-repeat 229px 0px");
$('#foto1').animate({backgroundPosition: '0px 0px'}, {duration:1000});
$("#flechaizq").hide();
$("#flechader").hide();
$("#breadcrumb").html ("<a class=\"enlace1\" href=\"index.html\">Inicio<\/a><span class=\"seph\">|</span><span class=\"naranja\">Tendencias</span>");

$("#cajatextoportada").css ("left", "430px");
$("#cajatextoportada").css ("width", "490px");
$("#cajatextoportada").css ("height","26.364em");
$("#cajatextoportada").css ("top", "130px");

if ($("#menu2").length == 0)
{
$("#cajafoto").append ("<div id=\"menu2\" style=\"z-index: 200;\"></div>");
}

$("#menu2").html ("<ul><li id=\"t1\"><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_introduccion.html', 'panel1')\">Tendencias<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_politicas.html', 'panel1')\">Políticas<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_organizativas.html', 'panel1')\">Organizativas<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_economicas.html', 'panel1')\">Económicas<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_financieras.html', 'panel1')\">Financieras<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_socioculturales.html', 'panel1')\">Socioculturales<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_medioambientales.html', 'panel1')\">Medioambientales<\/a></li><li><a href=\"javascript: void(null);\" onclick=\"carga_pagina ('tendencias_tecnologicas.html', 'panel1')\">Tecnológicas<\/a></li></ul>");
$("#menu2 ul li").css ("list-style-image","url(img/flecha_fina_der.png)");
$("#menu2 ul li").css ("margin-left","15px");
$("#menu2 ul li[id=t1]").css ("list-style-image","url(img/flecha_ab.png)");
$("#menu2 ul li[id=t1]").css ("margin-left","0px");
$("#menu2 ul li[id=t1]").css ("margin-bottom","10px");
$("#menu2 ul li a").addClass ("enlace1");

carga_pagina ("tendencias_introduccion.html", "panel1");

}

function carga_tube (id)
{
if (ytplayer)
{
ytplayer.loadVideoById(id, 0);
$("#reproductor").show('blind', 500);
}
else
{
alert ("No se ha creado correctamente el reproductor de YouTube.");
}
}

var ytplayer;

function onYouTubePlayerReady(playerId) 
{
		  ytplayer = document.getElementById("myytplayer");
		  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
          ytplayer.addEventListener("onError", "onPlayerError");
}

function play() 
{
          if (ytplayer) { ytplayer.playVideo(); }
}

        function pause() {
          if (ytplayer) {
            ytplayer.pauseVideo();
          }
        }

        function stop() {
          if (ytplayer) {
            ytplayer.stopVideo();
			ytplayer.clearVideo();
			$("#reproductor").hide();
			$("img[id*=vth]").css ("border","5px solid #f0f0f0");
          }
        }
		
function carga_noticias ()
{

	$.ajax({
    
	type: "GET",
	cache: false,
	async: false,
	data: "ms=" + new Date().getTime(),
	url: "xml/noticias.xml",
	dataType: "xml",
	error: function (XMLHttpRequest, textStatus, errorThrown) {  },
	success: function(xml) 
	{ 
		xmlnot = xml;
		nn = $(xml).find("noticia").length;
		var noticias = "<h3>Últimas noticias</h3><div id='cuerpo_noticias'><table id='tabla1'><thead><tr style='display: none;'><th>Fecha</th><th>Titular</th></tr></thead><tbody></tbody></table></div><div id='pie_noticias'><a href='javascript: void(null);' onclick='carga_noticias_detalle()'>Ver noticias</a></div>";
		$("#noticias").html (noticias);
		
		var n = 1
		
		$(xml).find("noticia").each (function () {
		
		if (n>(nn-2))
		{ 
		$("#tabla1 tbody").append ("<tr style=\"cursor: pointer;\" onclick=\"ver_noticia (" + $(this).attr ("id") + ");\"><td style=\"border-bottom: 1px dashed #dedede;\">" + $(this).attr ("fecha") + "</td><td style=\"border-bottom: 1px dashed #dedede;\">" + $(this).attr ("titular") + "</td></tr>");
		}
		
		n++;
		
		});
		
		
		$("#tabla1").tablesorter({ sortList: [[0,1]]});
		
		if (nn > 0) { $("#noticias").show("blind", 1000); }
		
	}

});

}

function carga_traductor()
{

tr = 1;

$.translate(function(){ //when the Google Language API is loaded 
	
    $.translate.ui('select', 'option') //generate dropdown 
      .val('Spanish') //select spanish as default 
      .appendTo('#idiomas'); //insert the dropdown to the page 
    
	$.fn.translate.defaults = { fromOriginal:true, not: 'select', data: true, toggle: true }; 
    
	//insert Google's logo after the dropdown: 
    $.translate.getBranding().appendTo('#idiomas');
	$("#idiomas select").change (function () {
	
		idioma = $("#idiomas select").val();
		
		if (idioma == "es" || idioma == "Spanish")
		{
		$("#contenedor").html(contenido_original);activa_diapos();
		}
		else
		{		
		traduce_textos();
		}
		
	});
			
  }); 

}

function traduce_textos()
{
	
	cargador(1);
	$.translate($("#contenedor").html(), $("#idiomas select").val(), 
	{ 
		fromOriginal:true, 
		data: true, 
		toggle: true, 
		error: function () 
		{ 
			alert ('El sistema automático de traducción no se encuentra disponible en este momento. Automatic translator is not available at this moment.'); 
			cargador(0); 
			$("#contenedor").html(contenido_original);
			activa_diapos();
			$("#idiomas select").val("Spanish");
			idioma = 'es';
		}, 
		complete: function(translation)
		{ 
			$("#contenedor").html(translation); 
			$("#cajatextoportada").show('blind', 500); 
			panel(); 
			activa_diapos(); 
			cargador(0); 
		} 
	}); 
	
};

function cargador(acc)
{

if (acc==1)
{

x1 = parseInt ($("#cargador").outerWidth()/2)-parseInt($("#cargador_contenido").outerWidth()/2);
y1 = parseInt ($("#cargador").outerHeight()/2)-parseInt($("#cargador_contenido").outerHeight()/2);;

$("#cargador_contenido").css("left",x1 + "px");
$("#cargador_contenido").css("top",y1 + "px");
$("html").css("overflow","hidden");
$("#cargador").css("top", $(window).scrollTop());

if (idioma != "es" && idioma != "spanish")
{
$.translate($("#cargador_contenido").html(), idioma, { complete: function (tr) { $("#cargador_contenido").html(tr); $("#cargador").show(); }});
}
else
{
$("#cargador").show();
}
}

if (acc==0)
{
$("#cargador").hide();
$("html").css("overflow","auto");
}

}
