// JavaScript Document


CONST_HOME= "imagenes/cabeceras3/Cabecera_Home.jpg";
CONST_SOBREAECOC = "imagenes/cabeceras3/Cabecera_Home.jpg";
CONST_SERVICIOS= "imagenes/cabeceras3/Cabecera_Servicios.jpg"
CONST_SALAPRENSA = "imagenes/cabeceras3/Cabecera_Salaprensa.jpg";
CONST_PUBLICACIONES = "imagenes/cabeceras3/Cabecera_Publicaciones.jpg";
CONST_GS1 = "imagenes/cabeceras3/Cabecera_GS1.jpg";
CONST_FORMCAION = "imagenes/cabeceras3/Cabecera_Formacion.jpg";
CONST_EVENTOS = "imagenes/cabeceras3/Cabecera_Home.jpg";
CONST_COLABORADORES = "imagenes/cabeceras3/Cabecera_Colaborador.jpg";
CONST_ASOCIESE = "imagenes/cabeceras3/Cabecera_Asociese.jpg";
CONST_AREASACTUACION = "imagenes/cabeceras3/Cabecera_Areasactuacion.jpg";
CONST_SECTORES = "imagenes/cabeceras3/Cabecera_Home.jpg";
CONST_NEWSLETTER  = "imagenes/cabeceras3/Cabecera_Home.jpg";

function cargaInscripcionCurso(){

	var codiAecoc = window.parent.document.getElementById("params").value;
	var ciutat = document.getElementById("mainSecciones").value;
	var fecha = document.getElementById("main2Secciones").value;

	if(ciutat == "*" || ciutat == 'null'){
		alert("Debe seleccionar una ciudad");
		return false;
	}
	else if(fecha == "*" || fecha == 'null'){
		alert("Debe seleccionar una fecha");
		return false;
	}
	else{
		
		fecha = fecha.replace("/", "");
		fecha = fecha.replace("/", "");
		window.top.document.getElementById('mainframe').style.height='1075px';
		window.top.document.getElementById('mainframe').src= "http://sede.aecoc.es/secmgr.nsf/multiregistro?OpenForm&SUBSCTO=" + codiAecoc + "_" + ciutat + "_" + fecha;
	}
}


function params_values(szId, szCodigoAecoc){
	/*var str;
	var cadena;
	var nv = new Array();
	var codigoAecoc;
	var cargaForm = 0;
	str = document.getElementById("params").value;
	cadena = str.split('|');
	for (i = 0; i < cadena.length; i++){
	  nv[i] = cadena[i].split('#')
	  //alert(nv[i][0] + ' = ' + nv[i][1]);
	  alert
	  if(nv[i][0] == "codigo_aecoc" ){
		cargaForm = 1;
		document.getElementById('cuerpoCentral').style.height='1300px';
		document.getElementById('cuerpoCentral').src='http://sede.aecoc.es/secmgr.nsf/multiregistro?OpenForm&SUBSCTO=' + nv[i][1];
		
	  } 
	}
	if (cargaForm == 0){
		document.getElementById('cuerpoCentral').style.height='670px';
		document.getElementById('cuerpoCentral').src='/admin/web/gc_search.php?tipo=3&entidad=14&plantilla=51&Id='+a;
	}*/
	str = document.getElementById("params").value;
	if(trim(str) == "N"){
		document.getElementById('cuerpoCentral').style.height='670px';
		document.getElementById('cuerpoCentral').src='/admin/web/gc_search.php?tipo=3&entidad=14&plantilla=51&Id='+ szId;
	}
	else{
		document.getElementById('cuerpoCentral').style.height='1300px';
		document.getElementById('cuerpoCentral').src='http://sede.aecoc.es/secmgr.nsf/multiregistro?OpenForm&SUBSCTO='+ szCodigoAecoc;
	}
}

function ltrim(s) {
   return s.replace(/^\s+/, "");
}

function rtrim(s) {
   return s.replace(/\s+$/, "");
}

function Ntrim(s) {
   return rtrim(ltrim(s));
}

function programaFicha(c){
	var todo = c.split("<br/>");
	document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>');
	for(j = 0; j < todo.length; j++){
		if(todo[j].substring(0,2) == "T|"){
			document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%" ><tr height="5px"><td ></td></tr>');
			document.write('<tr><td><span class="dia_programa_ficha">' + todo[j].substring(2) + '</span><br /></td></tr></table>');
		}else if(todo[j].substring(0,2) == "H|"){
			temp = todo[j].substring(2).split("|");
			document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%" ><tr class="texto_ficha"><td valign="top" width="20%">' + temp[0] + '</td><td width="3%">&nbsp;</td><td>' + temp[1] + '</td></tr></table>');		
		}else if(todo[j].substring(0,2) == "C|"){
			num = parseInt(todo[j].substring(2).substring(0,1));
			document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%" ><tr class="texto_ficha">');
			if(num == 0){
				document.write('<td><span class="campos_texto_ficha">> </span>' + todo[j].substring(4+num) + '</td>');
			}else{
				for(i = 0; i < num; i++){
					document.write('<td width="3%">&nbsp;</td>');
				}
				document.write('<td><span class="campos_texto_ficha">- </span>' + todo[j].substring(3+num) + '</td>');
			}
			document.write('</tr></table>');
		}
		
	}
	document.write('</td></tr></table>');
	
	/*var todo = c.split("<br/>");
	document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
	for(j = 0; j < todo.length; j++){
		if(todo[j].substring(0,2) == "T/"){
			document.write('<tr height="5px"><td colspan="3"></td></tr>');
			document.write('<tr><td colspan="3"><span class="dia_programa_ficha">' + todo[j].substring(2) + '</span><br /></td></tr>');
		}else if(todo[j].substring(0,2) == "H/"){
			temp = todo[j].substring(2).split("/");
			document.write('<tr class="texto_ficha"><td valign="top" width="20%">' + temp[0] + '</td><td width="3%">&nbsp;</td><td>' + temp[1] + '</td></tr>');		
		}else if(todo[j].substring(0,2) == "C/"){
			document.write('<tr class="texto_ficha"><td colspan="3"><span class="campos_texto_ficha">> </span>' + todo[j].substring(2) + '</td></tr>');
		}
	}
	document.write('<tr><td colspan="3"><br /></td></tr>');
	document.write('</table>');*/
}

function ponerMayorQue(c){
	var texto = c.split("<br/>");
	if (texto.length == 1){
		document.write(texto[0] + '<br />');
	} else {
		for (i = 0; i < texto.length; i++){
			document.write('<span class="campos_texto_ficha">> </span>' + texto[i] + '<br />');
		}
	}
}

function mostarContenido(titulo,contenido){
	document.getElementById('titulo').innerHTML = titulo;
	document.getElementById('menu').innerHTML = contenido;
}

function swapTexto(esconder, mostrar) {
	document.getElementById(esconder).style.display = "none";
	document.getElementById(mostrar).style.display = "block";
	ultimateRedimensiona();
}


function obreVentanaMax(szId, szCodigoAecoc){
	
	document.getElementById('carregant').style.display = 'none';
	document.getElementById('carrega').style.display = '';
	//params_values(szId, szCodigoAecoc);	

	this.moveTo(0,0);
	if (document.all) {
		this.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (this.outerHeight<screen.availHeight||this.outerWidth<screen.availWidth){
			this.outerHeight = screen.availHeight;
			this.outerWidth = screen.availWidth;
		}
	}
}

function toTop() {
	window.parent.scrollTo(0, 0);
}


function redimensiona2(id){
	if(window.top.document.getElementById(id)){
		window.top.document.getElementById(id).style.height= ( parseInt(this.document.body.scrollHeight, 10) ) +"px";
		toTop();
	}
}	
function redimensiona3(id){
	if(document.all){
		if(window.top.document.getElementById(id)){
			window.top.document.getElementById(id).style.height= ( parseInt(this.document.body.scrollHeight, 10) ) +"px";
			toTop();
		}
	}	
}

function redimensionaV2(id){
	if(parent.document.getElementById(id)){
		if( parseInt(this.document.body.scrollHeight, 10) > 400)
			parent.document.getElementById(id).style.height	= ( parseInt(this.document.body.scrollHeight, 10) ) +"px";
	}
}

function redimensionaV3(id){                                       
	if(parent.document.getElementById(id)){
			parent.document.getElementById(id).style.height	= ( parseInt(this.document.body.scrollHeight, 10) ) +"px";
	}
}


function redimensionaOrganigrama(id){
	if(document.getElementById(id)){
		document.getElementById(id).style.height= "100px";
		return true;
	}
}
function redimensionaNewsLetter(id){

	var len = parseInt(this.document.body.scrollHeight, 10) 
	var len2 = window.parent.document.getElementById(id).style.height
	if( len > len2 ){
		if(window.parent.document.getElementById(id)){
			window.parent.document.getElementById(id).style.height= (len + 100) + "px";
		}
	}
}

function redimensionaSite(id){
	if(parent.document.getElementById(id)){
		var sum = parseInt(this.document.body.scrollHeight, 10) + 22;
		parent.document.getElementById(id).style.height= sum +"px";
		toTop();
	}
}

function trim(cadena)
{
if (cadena){
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}else
{ return "";}
}
function cargamenuderecha(url){
	if(window.top.document.getElementById('framederecha')){
        url = url.split("?");
        window.top.loadUrl("/"+url[0],"framederecha",url[1]+"&count=0","");
        //window.top.loadScript("/"+url[0],"framederecha",url[1]+"&count=0",functionAfter);
		//window.top.document.getElementById('framederecha').src = url + "&count=0";
	}
}

function cargadoc(url){
	if(document.getElementById('mainframe')){
		document.getElementById('mainframe').src= url;
	}
}
///////////////////// PAGINADOR ///////////////////////////////////////
/*
	PAGINADOR DE TAULES
	===================
	
	Si els registres de la taula de registres tenen mes d'un <tr> per registre, seria convenient posar cada registre en una subtaula per no tenir problemes d'estructura a l'hora de mostrar i amagar registres.
	La taula inferior amb les pagines haria de tenir una estructura semblant a la seguent.
<table border="0" id="tablaPaginador">
	<tr>
    	<td>
        	Resultats totals del cercador <span class="numeroOrange"></span>
		</td>
        <td class="dreta">
			<TABLE>...a ompir dinamicamnet...</TABLE>
          </td>
     </tr>
</table>
	OBS: La id que passem sera la de la taula principal, per poder mostrar el numero de registres totals trobats, pero la chicha de les paginacions s'incertara dinamicament en la TABLE del segon <td>.
	El resultat final hauria de ser del tipus:
	Resultats totals (numero)					1 2 3 4 5 6 7
*/

//Variables globals.
esIE = (navigator.appName == "Microsoft Internet Explorer");
//Les inicialitzem amb valor DEFAULT per que no dongui error la consola de javascript.
idTable = "";	//id de la taula on mostrarem els registres.
idPages = "";	//id de la taula on mostrarem el paginador.
numDocsTotal = 0;	//numero de tots els registres que tenim en la taula
numDocs = 0;	//numero de registres que mostrarem per pagina.
totalPages = 0;	//total de pagines que tindrem.
numDocsFinal = 0;	//registres que tindra la ultima pagina.
currentPage = 1;	//Definim la pagina actual com la primera.

//Funcio que rep les id's de les dues taules i el numero de registres que s'han de mostrar per pagina. La primera es la taula on tindrem tots els registres i la segona es la taula on tindrem el paginador.
function inicialitzaPages(idTablaReg, idTablaPag, numRegPage) {
	//Enviem les dues id's y el numero de registres per pagina a la funcio loadPagesTool() per obtenir poder assignar els valors a les variables globals.
	loadPagesTools(idTablaReg, idTablaPag, numRegPage);
	
	return true;
}

//Rep les dues id's de les taules i el numero de registres a mostrar per pagina. Assigna els valors a les variables globals. Tambe defineix el contingut de la taula amb les pagines.
function loadPagesTools(idTablaReg, idTablaPag, numRegPage) {

	//Assignem les ID's de les taules
	idTable = idTablaReg;
	idPages = idTablaPag;
	//Assignem el numero de registres que mostrarem per pagina
	numDocs = numRegPage;
	//Capturem el numero de docs/registres de la taula
	numDocsTotal = document.getElementById(idTable).rows.length;

	//Capturem el numero total de pagines

	if (numDocsTotal % numDocs == 0)	//Si els registres cuadren en les pagines (la ultima pagina te el mateix num de regs que la resta)
		totalPages = parseInt(numDocsTotal / numDocs);
	else {		//Si la ultima pagina te diferent numero de registres, capturem aquest valor
		totalPages = parseInt(numDocsTotal / numDocs) + 1;
		numDocsFinal = numDocsTotal % numDocs;
	}


	//Omplim les dades de la taula amb les pagines. Capturem els dos <TD> de l'unic <TR> de la <TABLE>
	var objcPagResultat = document.getElementById(idTablaPag).rows.item(0).cells.item(0);
	var objcPagPaginacio = document.getElementById(idTablaPag).rows.item(0).cells.item(1);
	
	//Mostrem el numero total de registres trobats accedint al node <SPAN> que tenim definit en HTML
	objcPagResultat.childNodes.item(1).innerHTML = numDocsTotal;
	//Printem la taula amb les paginacions

	if(numDocsTotal == 0) {
		var objcTB = document.createElement('tbody');
		var objcTR = document.createElement('tr');
		var objcTd = document.createElement('td');
		objcTd.setAttribute('style', 'text-align: center;');
		objcTd.appendChild(document.createTextNode('No hay ningún registro'));
		objcTR.appendChild(objcTd);
		objcTB.appendChild(objcTR);
		document.getElementById(idTable).appendChild(objcTB);
		document.getElementById(idTable).style.display = '';
	} else {
		creaTaulaPaginacio(objcPagPaginacio);
	}
	
	return true;
}

//Funcio que creara l'estructura "1 2 3 4...". No rep una taula. Rep un <td> on tenim dos <spans>, on colocarem els enllasos per a "anterior" i "seguent", i una taula buida on posarem els numeros de les pagines. 
function creaTaulaPaginacio(tdTaula) {

//alert(taula.childNodes.item(1).rows.item(0));									<-- Firefox
//alert(taula.childNodes.item(0).firstChild.childNodes.item(0).nodeName);		<-- IExplorer
	for (var i = 1; i <= totalPages; i++) {

		var objcTd = document.createElement('td');	//Creem el <td>
		if (esIE)	//IE
			objcTd.style.setAttribute('width', '10px');
		else		//NS
			objcTd.style.width = '10px';
		var objcLink = document.createElement('a');	//Creem el <a> i afegim els atributs
		if (esIE) {		//IE
			objcLink.setAttribute('href', '#this');
			objcLink.setAttribute('onclick', new Function("showPage(" + i + ");"));
		} else {		//NS
			objcLink.href = '#this';
			objcLink.setAttribute('onclick', 'showPage('+i+')');
		}
		objcLink.className = "linksBuscador";	//Definim el class dels links
		objcLink.appendChild(document.createTextNode(i));		

		//Incrustem el <a> en el <td>
		objcTd.appendChild(objcLink);
		//Incrustem el <td> en el <tr> de la taula
		if (esIE) {	//IE
			tdTaula.childNodes.item(0).firstChild.childNodes.item(0).appendChild(objcTd);
		} else	{	//NS		(REVISAR)
			tdTaula.childNodes.item(1).rows.item(0).appendChild(objcTd);					//Firefox
		}
	}
	
	//Si tenim mes de 10 pagines, afegim un TD al final dels enllassos per indicar el numero total de pagines
	if (totalPages > 10) {
		var objcTdNumPagines = document.createElement('td');
		//Mostrem el numero de pegines
		objcTdNumPagines.appendChild(document.createTextNode("("+totalPages+")"));
		//Assignem el class "numeroPagines"
		objcTdNumPagines.className = "numeroPagines";
		//Afegim el TD just despres del ultim TD que es un enllas de pagina
		if (esIE) {
			tdTaula.childNodes.item(0).firstChild.childNodes.item(0).appendChild(objcTdNumPagines);
		} else {
			tdTaula.childNodes.item(1).rows.item(0).appendChild(objcTdNumPagines);
		}
	}
	
		//Mostrem dos TD mes per als butons de "siguiente" i "anterior". No carregarem les funcions de on click fins que haguem carregar la primera pagina, unes 5 linies mes avall. Dintre de la funcio "SHOWPAGE" actualitzarem els "onclicks" dels TD de "anterior" i "siguiente",ja que tindrem carregada en una variable global quina es la pagina que esta carregada en cada moment.
	var objcTdAnterior = document.createElement('td');
	var objcTdSeguent = document.createElement('td');
	//Els hi assignem ID per poder accedir facilment mes tard desde la funcio refreshPreviousNext() que sera l'encarregada d'anar refrescant la funcio on click d'aquests TDs
	objcTdAnterior.id = 'idAnterior';
	objcTdSeguent.id = 'idSeguent';
	objcTdAnterior.className = 'botonAnterior';
	objcTdSeguent.className = 'botonSeguent';
	if (esIE) {
		tdTaula.childNodes.item(0).firstChild.childNodes.item(0).appendChild(objcTdAnterior);
		tdTaula.childNodes.item(0).firstChild.childNodes.item(0).appendChild(objcTdSeguent);
	} else {
		tdTaula.childNodes.item(1).rows.item(0).appendChild(objcTdAnterior);
		tdTaula.childNodes.item(1).rows.item(0).appendChild(objcTdSeguent);
	}
	//Mostrem la primera pagina de registres si hi han registres
	if (numDocsTotal > 0) {
		showPage(1);
	}
	return true;
}

//Funcio que rep la pagina ha mostrar i calcula quins registres mostrar i els fa visibles.
function showPage(numPagina) {
	var nInici;		//Primer registre de la pagina
	var nFinal;		//Ultim regisres de la pagina
	var objcTabla = document.getElementById(idTable);

	//Si es la primera pagina
	if (numPagina == 1) {
		nInici = 0;
		nFinal = numDocs -1;
	} else if (numPagina < totalPages){		//Si no es ni la primera ni la ultima pagina
		nInici = (numPagina - 1) * numDocs;
		nFinal = nInici + numDocs - 1;
	} else {		//Si es la ultima pagina
		nInici = (numPagina -1) * numDocs;
		nFinal = nInici + numDocs - 1;
	}

	//Fem visibles els <tr> que faci falta
	for (var i = 0; i <= numDocsTotal - 1; i++) {
		//Si no l'hem de mostrar...
		if (i < nInici || i > nFinal)
			//objcTabla.rows.item(i).style.setAttribute('display', 'none');
			objcTabla.rows.item(i).style.display = 'none';
		else 	//Si l'hem de mostra...
			//objcTabla.rows.item(i).style.removeAttribute('display');
			objcTabla.rows.item(i).style.display = '';
	}
	//Si es la primera vegada que arrivem a aquesta funcio, hem d'amagar el gif animat de carrega i mostrar les taules amb els resultats i la del paginador
	if (objcTabla.style.display == "none") {
		//document.getElementById('gifLoader').style.display = 'none';
		if(totalPages > 1) {
			document.getElementById(idPages).style.display = '';
		}
		objcTabla.style.display = '';
	}
	
	//Nomes mostrarem les 5 pagines anteriors i les 5 seguents en referencia de la pagina que tenimda
	//Capturem la coleccio que conte els TDs amb les pagines

	var taulaPagines = document.getElementById('pagines').rows.item(0).cells;
	//Calculem quines seran les pagines que es mostraran a partir de la pagina que hem de carregar
	var paginaInici;
	var paginaFinal;
	//Determinem la pagina inici
	if (numPagina <= 6) {
		paginaInici = 0;
		if (totalPages > 10)
			paginaFinal = paginaInici + 10;
	}
	else if (numPagina + 6 > totalPages) {
		paginaInici = (totalPages - 1) - 10;
	}
	else {
		paginaInici = numPagina - 6;
		paginaFinal = numPagina + 4;	
	}
	
	//Mostrem i amaguem les pagines que toca
	for (var i = 0; i <= totalPages - 1; i++) {
		if (i < paginaInici || i > paginaFinal) {
			//taulaPagines.item(i).style.setAttribute('display', 'none');			
			taulaPagines.item(i).style.display = 'none';
		}
		else {
			//taulaPagines.item(i).style.removeAttribute('display');
			taulaPagines.item(i).style.display = '';
		}
	}
	//Nomes s'ha de fer en el cas que el numero de pagines sigui major a 1
	if (totalPages > 1) {
		//Guardem en la variable global aquella pagina que acavem de carregar
		currentPage = numPagina;
		
		//Cridem a una funcio que actualitzara els onclicks dels TDs de anterior y siguiente ara que tenim en la variable global quin es el numero de pagina que tenim carregat
		refreshPreviousNext();
		
		//Mostrem el numero de la pagina que esta carregada en aquests moments com la activa
		activaNumPagina(currentPage);
	}

	ultimateRedimensiona();
	redimensiona('mainbusqueda');
	redimensiona('mainframe2');
	if (window.parent){	
		window.parent.redimensiona('mainframe2');
	 	//window.parent.redimensiona('mainframe');
		window.parent.ultimateRedimensiona();
		
	}
	if (window.parent.parent){
		//window.parent.parent.redimensiona('mainframe');
		window.parent.parent.ultimateRedimensiona();
	}
	window.scrollTo(0,0);
	return true;

}

/* Funcio que actualitza el onclick dels TD de 2anterior" i "siguiente" cada cop que carreguem una pagina del paginador*/
function refreshPreviousNext() {
	var objcTdAnterior = document.getElementById('idAnterior');
	var objcTdSeguent = document.getElementById('idSeguent');
	//Calculem quines seran la pagina anterior i quina sera la posterior a partir de la global "currentPage". Tenim en compte que si estem en la primera pagina, la anterior la definirem com la primera tambe; si estem en la ultima, la seguent la definirem com la ultima tambe.
	var anterior = (currentPage - 1 < 1)?1:currentPage - 1;
	var seguent = (currentPage + 1 > totalPages)?totalPages:currentPage + 1;
	//Sabent quines son la pagina i la anterior a mostrar, definim les funcions per carregar pàgines a traves dels butons (no dels enllassos)
	if (esIE) {		//IE
		objcTdAnterior.setAttribute('onclick', new Function("showPage(" + anterior + ");"));
		objcTdSeguent.setAttribute('onclick', new Function("showPage(" + seguent + ");"));
	} else {		//NS
		objcTdAnterior.setAttribute('onclick', 'showPage('+anterior+')');
		objcTdSeguent.setAttribute('onclick', 'showPage('+seguent+')');		
	}
}

/* Funcio que despres de mostrar una de les pagines de la paginacio, deixa el seu enllas corresponent marcat com actiu (nomes per efecte visual) */
function activaNumPagina(pagina) {
//	alert("La pagina a resaltar es: " + pagina);
	//Capturem la taula on tenim el TD amb el numero de registres i la taula de paginacio, i ens co.loquem en el td on tenim creada la taula amb els enllassos
	var tdTaula = document.getElementById(idPages).rows.item(0).cells.item(1);
	//Naveguem fins al enllas del TD que correspongui a la pagina que s'acaba de carregar i li clavem el focus
	if (esIE) {
		//IE
		tdTaula.childNodes.item(0).rows.item(0).cells.item(pagina - 1).childNodes.item(0).focus();
	} else	{	//NS		(REVISAR)
		tdTaula.childNodes.item(1).rows.item(0).cells.item(pagina - 1).childNodes.item(0).focus();
	}


}

/********************* FIN JS PAGINADOR ********************************/

var opened = "a";
function swapLetra(id){
	document.getElementById(opened).className = "letra_glosario";
	document.getElementById(id).className = "titulo_text_glosario";
	opened = id;
}

/***** CABECERA *****/
	
function cargar_cabecera(id){
	if(window.top.document.getElementById("frameCabecera")){
		if(id != "" && id != "@@Campo8@@"){
            window.top.loadUrl("/showFlash.php","frameCabecera","id=" + id,"");
			//window.top.document.getElementById("frameCabecera").src = "showFlash.php?id=" + id ;	
		}
		else{
             window.top.loadUrl("/showFlash.php","frameCabecera","id=313","");
			//window.top.document.getElementById("frameCabecera").src = "showFlash.php?id=313";
		}
	}
}

function openMenu(szIdVisible, szIdOcult){
	document.getElementById(szIdVisible).style.display = "";
	document.getElementById(szIdOcult).style.display = "none";
}

function cargadoc(url){
	document.getElementById('mainframe').src= url;
}

function cargadocV2(nueva,url){
	if( trim(nueva) == "0"){
		window.open(url);
	}
	else{
		cargadoc(url);
	}
}

function creaRelatedURL(szTieneHijos, typeHijos, id, plantilla,target){

	var szUrl = "/admin/web/gc_search.php?";
	if(typeHijos == "13"){
		if( plantilla != "0" && plantilla != ""){
			szUrl  = szUrl + "&tipo=3&entidad=" + typeHijos + "&plantilla=" + plantilla + "&Id=" + id;
		}	
		else{
			if(szTieneHijos == "true"){
				szUrl  = szUrl  + "tipo=3&entidad=" + typeHijos + "&plantilla=11&Id=" + id;
			}
			else{
				szUrl  = szUrl  + "tipo=3&entidad=" + typeHijos + "&Id=" + id;
			}
		}
	}
	else{
		szUrl  = szUrl  + "tipo=3&entidad=" + typeHijos + "&Id=" + id;
		szUrl  = szUrl  + "&contenttype=html"
	}
	
    if(target != null && target != ""){
        szUrl += "&target="+target;
    }
	return szUrl;
}

function creaURL(szTieneHijos, typeHijos, id, plantilla, target){
	var szUrl = "/admin/web/gc_search.php?";
	if(typeHijos == "13"){
		if( plantilla != "0" && plantilla != ""){
			szUrl  = szUrl + "&tipo=3&entidad=" + typeHijos + "&plantilla=" + plantilla + "&Id=" + id;
		}	
		else{
			if(szTieneHijos == "true"){
				szUrl  = szUrl  + "tipo=3&entidad=" + typeHijos + "&plantilla=11&Id=" + id;
			}
			else{
				szUrl  = szUrl  + "tipo=3&entidad=" + typeHijos + "&Id=" + id;
			}
		}
	}
	else{
		szUrl  = szUrl  + "tipo=3&entidad=" + typeHijos + "&Id=" + id;
		szUrl  = szUrl  + "&contenttype=html"
	}
    if(target == '0'){
         szUrl += "&count="+target;
    }else if(target != null && target != ""){
        szUrl += "&target="+target;
    }
	return szUrl;
}

function swapTexto(esconder, mostrar) {
	document.getElementById(esconder).style.display = "none";
	document.getElementById(mostrar).style.display = "block";
}
		

function googleMaps(){
	window.open("/aecoc/google/googleMaps.htm","AECOC","height=375,width=445,status=yes,toolbar=no,menubar=no,location=no");
}

function busqueda(){
	
	szUrl = "/aecoc/admin/web/gc_search.php?tipo=5&entidad=19&plantilla=27&subgrupo="+ document.getElementById('mainSecciones').value + "&searchtext="+ document.getElementById('search_colaboradores').value;
	var iframe = document.getElementById('busqueda_colaboradores');
	iframe.src = szUrl;
}

function construeixRuta(szId, arrayId, arrayTitulos, szTitulo){
	var szHtml = "";
	var classe = new Array();
	classe[0] = "mapa_seccion";
	classe[1] = "primera_subcarpeta";	
	classe[2] = "segunda_subcarpeta";
	classe[3] = "tercera_subcarpeta";
	
	for(i = 1; i < arrayId.length; i++){
		szHtml = szHtml + "<a href='" + arrayId[i] + "&plantilla=31'";
		if(i > 3){
			szHtml = szHtml + " class='" + classe[3] + "' target=\"mainframe\"> " + arrayTitulos[i] + " </a>";
		}
		else{
			szHtml = szHtml + " class='" + classe[i-1] + "' target=\"mainframe\"> " + arrayTitulos[i] +"/</a>";
		}
	}
	if(i > 3){
		szHtml = szHtml + "<span  class='" + classe[3] + "' >" + szTitulo + "</span>";
	}
	else{
		szHtml = szHtml + "<span  class='" + classe[i - 1] + "' >" + szTitulo + "</span>";
	}
	document.getElementById(szId).innerHTML= szHtml;
}

function changeSelector(oSubgrupo, subgrupo){
	var arr;
	if(document.getElementById('grupo')){
		var grupo = document.getElementById('mainGrupo').value
		if(trim(grupo) == "*" ){
			arr = subgrupo[0];
		}
		else{
			arr = subgrupo[grupo];
		}
	}
	if(oSubgrupo){
		
		oSubgrupo.values = arr;
		document.getElementById('mainSub').value = arr[0].split('|')[1];
		document.getElementById('idmainSub').value = arr[0].split('|')[0];
		oSubgrupo.escribeSelector();
	}
}

function canviaBusqueda(szUrl){
	if(document.getElementById('grupo')){
		var grupo = document.getElementById('mainGrupo').value
		if(trim(grupo) != "*" ){
			szUrl = szUrl + "&grupo=" + grupo; 
		}
	}
	if(document.getElementById('subgrupo')){
		var subgrupo = document.getElementById('mainSub').value
		if(trim(subgrupo) != "*" ){
			szUrl = szUrl + "&subgrupo=" + subgrupo;
		}
	}
	if(document.getElementById('con_el_texto')){
		var texto = document.getElementById('con_el_texto').value
		if(trim(texto) != "" ){
			szUrl = szUrl + "&searchtext=" + texto;
		}
	}
	document.getElementById('mainbusqueda').src = "/aecoc/admin/web/" + szUrl;
}
function canviaBusquedaOrga(szUrl){
	if(document.getElementById('grupo')){
		var grupo = document.getElementById('mainGrupo').value
		if(trim(grupo) != "*" ){
			szUrl = szUrl + "&grupo=" + grupo; 
		}
	}
	if(document.getElementById('subgrupo')){
		var subgrupo = document.getElementById('mainSub').value
		if(trim(subgrupo) != "*" ){
			szUrl = szUrl + "&subgrupo=" + subgrupo;
		}
	}
	if(document.getElementById('con_el_texto')){
		var texto = document.getElementById('con_el_texto').value
		if(trim(texto) != "" ){
			szUrl = szUrl + "&searchtext=" + texto;
		}
	}
	window.parent.document.getElementById('ruta').innerHTML = '<td colspan="2" class="mapa_seccion" style="padding-bottom:27px; padding-left:1px" >	<a class="mapa_seccion" href="/aecoc/admin/web/gc_search.php?tipo=3&entidad=13&plantilla=11&Id=52" target="mainframe">Sobre AECOC</a> <span class="primera_subcarpeta">/ <a class="primera_subcarpeta" href="/aecoc/admin/web/gc_search.php?entidad=13&tipo=3&plantilla=11&Id=97" target="mainframe">Organigrama </a></span><span class="segunda_subcarpeta">/ '+document.getElementById('idmainSub').value+'</span></td>';
	window.parent.document.getElementById('dept').innerHTML = document.getElementById('idmainSub').value;
	document.getElementById('mainbusqueda').src = "/aecoc/admin/web/" + szUrl;
}

function canviaBusquedaDates(szUrl){
	arrMeses = new Array("Enero","Febrero","Marzo","Abril","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
	if(document.getElementById('grupo')){
		var grupo = document.getElementById('mainGrupo').value
		if(trim(grupo) != "*" ){
			szUrl = szUrl + "&grupo=" + grupo; 
		}
	}
	if(document.getElementById('subgrupo')){
		var subgrupo = document.getElementById('mainSub').value
		if(trim(subgrupo) != "*" ){
			if(grupo == "*"){
				subgrupo = subgrupo.substring(1);
				if(trim(subgrupo) != "*" ){
					szUrl = szUrl + "&searchtext=" + arrMeses[subgrupo - 1];
					if(document.getElementById('con_el_texto')){
						var texto = document.getElementById('con_el_texto').value
						if(trim(texto) != "" ){
							szUrl = szUrl + "&searchtext2=" + texto;
						}
					}
				}
			}
			else{
				szUrl = szUrl + "&subgrupo=" + subgrupo;
				if(document.getElementById('con_el_texto')){
					var texto = document.getElementById('con_el_texto').value
					if(trim(texto) != "" ){
						szUrl = szUrl + "&searchtext=" + texto;
					}
				}
			}
		}
	} else {
//Modificacions Marc  coloquem el else per poder fer la busqueda per text encara que no hi hagi subgrup!!
		if(document.getElementById('con_el_texto')){
			var texto = document.getElementById('con_el_texto').value
			if(trim(texto) != "" ){
				szUrl = szUrl + "&searchtext=" + texto;
			}
		}
	}
	document.getElementById('mainbusqueda').src = "/aecoc/admin/web/" + szUrl;
}


function cargaBuscador(){
	
	if(document.getElementById('txt_buscador')){
		if(document.getElementById('mainframe')){
			var searchtext = document.getElementById('txt_buscador').value;
			if(trim(searchtext) != ""){
				var src = "admin/web/gc_search.php?&tipo=5&plantilla=76&contenttype=html&searchText=" + searchtext;
				document.getElementById('mainframe').src = src;
			}
		}
	}
}

function evalua_xx(){
	div = document.getElementById('textoLargo').outerHTML;
	alert(div);
	div = div.substring(div.indexOf(">") + 1,div.length);
	div = div.substring(0,div.indexOf("<"));
	//No hay texto corto
	if(trim(div) != ""){
		div = document.getElementById('textoCorto').outerHTML;
		div = div.substring(div.indexOf(">") + 1,div.length);
		div = div.substring(0,div.indexOf("<"));
		alert("hay largo " + div);
		if(trim(div) == ""){
			document.getElementById('leer_mas').style.display = "none"
			document.getElementById('minimizar').style.display = "none"
		}
	}
	else{
		div = document.getElementById('textoCorto').outerHTML;
		div = div.substring(div.indexOf(">") + 1,div.length);
		div = div.substring(0,div.indexOf("<"));
		alert("no hay largo "+div);
		if(trim(div) != ""){
			document.getElementById('leer_mas').style.display = "none"
			document.getElementById('minimizar').style.display = "none"
			document.getElementById('textoLargo').style.display = "none"
		}
	}

}


function stripTags (t) {
   if (t)
     while (t.match(/<.*>/)) t = t.replace(/<[^>]*>/, "");
     return t;
}
function stripTagsV2 (t) {
   if (t)
     while (t.match(/&.*;/)) t = t.replace(/&[^;]*;/, "");
     return t;
}

function Verificar(szTexto)
{
if (szTexto)
for(j=0;j<2;j++)
{
for(i=0;i<szTexto.length;i++)
{
if((szTexto.charCodeAt(i)==10) && (szTexto.charCodeAt(i+1)==13) || (szTexto.charCodeAt(i)==13) && (szTexto.charCodeAt(i+1)==10))
{
szTexto=szTexto.substring(0,i) + szTexto.substring(i+2,szTexto.length);
//alert(Texto);
}
//alert(Texto.charCodeAt(i));
}
}
return szTexto;
}



function evalua(szFlash){
     div = document.getElementById('textoLargo').innerHTML;
     div = stripTags(div);
     div = stripTagsV2(div);
	 div = Verificar(div);
     //Hay texto largo
     if(trim(div) != ""){
          div = document.getElementById('textoCorto').innerHTML;
          div = stripTags(div);
          div = stripTagsV2(div);
          div = Verificar(div);

          //No hay texto corto
          if(trim(div) != ""){
               document.getElementById('leer_mas').style.display = "block";
               document.getElementById('leer_mas').innerHTML = "<span onclick=\"swapTexto('textoCorto', 'textoLargo');ultimateRedimensiona();\" class='leer_mas'>leer más</span>";
               document.getElementById('minimizar').innerHTML = "<span class='leer_mas' onclick=\"swapTexto('textoLargo', 'textoCorto');ultimateRedimensiona();\">minimizar texto</span>";
          }
          //Solo hay texto largo
          else{
               document.getElementById('textoLargo').style.display = "block";
               document.getElementById('leer_mas').style.display = "none";
               document.getElementById('minimizar').style.display = "none";
               document.getElementById('textoCorto').style.display = "none";
          }
     }
     else{
          div = document.getElementById('textoCorto').innerHTML;
          div = stripTags(div);
          div = stripTagsV2(div);
          div = Verificar(div);
          //Solo hay texto corto

          if(trim(div) != ""){
               document.getElementById('leer_mas').style.display = "none";
               document.getElementById('minimizar').style.display = "none";
               document.getElementById('textoLargo').style.display = "none";
          }
          //No hay nada
          else{
               document.getElementById('leer_mas').style.display = "none";
               document.getElementById('minimizar').style.display = "none";
               document.getElementById('textoLargo').style.display = "none";
               document.getElementById('textoCorto').style.display = "none";
          }
     }
	//Canvi funcionalitat, ja no es necessita l'amplada d'aquests al cargar el flash
     /*if(szFlash){
	 	document.getElementById('textoCorto').style.width = "225px"
		document.getElementById('textoLargo').style.width = "225px"
	}*/
}


function ultimateRedimensiona(){

	altoBody = parseInt(this.document.body.scrollHeight, 10);
	if(window.parent){
		altoPadre = parseInt(window.parent.document.body.scrollHeight,10);
		if(altoBody > altoPadre || altoBody < altoPadre){
			total= window.parent.frames.length;
			for(a=0; a <total; a++){
				szName = window.parent.frames[a].name;
				if(szName.indexOf("main") >= 0 ){
					if(window.parent.document.getElementById(szName)){
							iframe = window.parent.document.getElementById(szName);
							iframe.style.height = (altoBody +"px");
					}
				}
			}
			window.top.redimensionaHome();
		}
	}
}

function redimensionaHome() {
	//alert(parseInt(document.documentElement.clientHeight,10));
	if (document.all){
		var arVersion = navigator.appVersion.split("MSIE");
		var version = parseFloat(arVersion[1]);
		if ((version >= 5.5) && (version < 7)){ 
		if (parseInt(document.documentElement.clientHeight,10) - parseInt(document.getElementById('mainframe').style.height,10) > 181){
			//cambiamos el frame central
			document.getElementById("mainframe").style.height = parseInt(document.documentElement.clientHeight,10) - 217 + "px";
		//cambiamos el frame de la derecha
		/*document.getElementById("framederecha").style.height = parseInt(document.documentElement.clientHeight,10) - 219 + "px";	*/
			}	
		}
		else{
			if (parseInt(document.documentElement.clientHeight,10) - parseInt(document.getElementById('mainframe').style.height,10) > 229){
			//cambiamos el frame central
			document.getElementById("mainframe").style.height = parseInt(document.documentElement.clientHeight,10) - 235 + "px";
			//cambiamos el frame de la derecha
			/*document.getElementById("framederecha").style.height = parseInt(document.documentElement.clientHeight,10) - 219 + "px";	*/
			}	
		}	
	}
	else{
		if (parseInt(document.documentElement.clientHeight,10) - parseInt(document.getElementById('mainframe').style.height,10) > 171){
		//cambiamos el frame central
		document.getElementById("mainframe").style.height = parseInt(document.documentElement.clientHeight,10) - 186 + "px";
		//cambiamos el frame de la derecha
		/*document.getElementById("framederecha").style.height = parseInt(document.documentElement.clientHeight,10) - 219 + "px";	*/
		}	
	}
	toTop();
}

function setTamanyDefecte(szId1){
	
	altoBody = parseInt(document.body.scrollHeight,10);
	if(document.getElementById(szId1)){
		if(document.getElementById(szId1).style.height < altoBody ){
			document.getElementById(szId1).style.height = altoBody + "px";
		}
	}
 }

function isFlash(szUrl){
	var tmp = szUrl.substring(szUrl.lastIndexOf(".") + 1 );
	if(tmp.toLowerCase() == "swf"){
		return true;
	}
	else{
		return false;
	}
}

function evaluaSinopsis(){
	szText = document.getElementById('sinopsis').outerHTML;
	szText = stripTags(szText);
    szText = stripTagsV2(szText);
    szText = Verificar(szText);
	if(trim(szText) == ""){
		document.getElementById('ocultaSinopsis').style.display = 'none';
	}
}

function swapDestacados(szId, szSpanId) {
	if(document.getElementById(szId).style.display == "none"){
		document.getElementById(szId).style.display = "block";
		document.getElementById(szSpanId).innerHTML = "[-]"
	}
	else{
		document.getElementById(szId).style.display = "none";
		document.getElementById(szSpanId).innerHTML = "[+]"
	}
	redimensiona('iframe_destacados');
	window.parent.redimensiona('framederecha');
}

function openDestacado(szTipo, szUrl){
	if(trim(szUrl) != ""){
		if(trim(szTipo) == "0"){
			window.top.document.getElementById('mainframe').src= szUrl;
		}
		else{
			szUrl = "http://" + szUrl;
			window.open(szUrl);
		}
	}
}

function verificaTxt(szText){
	szText = stripTags(szText);
    szText = stripTagsV2(szText);
    szText = Verificar(szText);
	return szText;
}

function evaluaDestacados(szIdDescCorta, szIdDescLarga, szIcono){
	
	szText = verificaTxt(document.getElementById(szIdDescCorta).outerHTML);
	if(trim(szText) == "" || trim(szText) == "[+]"){
		document.getElementById(szIdDescCorta).style.display = 'none';
		document.getElementById(szIcono).style.display = 'none';
		szText = verificaTxt(document.getElementById(szIdDescLarga).outerHTML);
		if(trim(szText) != ""){
			document.getElementById(szIdDescLarga).style.display = 'block';
		}
	}
	else{
		szText = verificaTxt(document.getElementById(szIdDescLarga).outerHTML);
		if(trim(szText) == ""){
			document.getElementById(szIcono).style.display = 'none';
		}
	}
}

function redimensionaDestacadosRelentizado(szId){
	var y = parseInt(document.body.scrollHeight,10);
	//alert(y);
	var i = 0;
	var j = 0;
	var redim =  100;
	if (parent)
	if (parent.document)
	if(parent.document.getElementById(szId)){
		while(i < y ){
			j = i * 2
			redim = redim + j
			setTimeout ("parent.document.getElementById('iframe_destacados').style.height = (" + i + " + 'px');", j); 
			i++;
		}
	}
}

function redimensiona(id){
	
	var y = parseInt(document.body.scrollHeight,10);
	
	if (id != 'busqueda'){
		if (parent)
		if (parent.document)
		if(parent.document.getElementById(id)){
			if(y > 200 ){
				parent.document.getElementById(id).style.height	= (y +"px");			
			}
		}
	}
	if (id == 'iframe_destacados'){
		if (parent)
		if (parent.document)
		if(parent.document.getElementById(id)){
			parent.document.getElementById(id).style.height	= (y +"px");		
		}
	}
	else{
		if(parent.document.getElementById(id)){
			parent.document.getElementById(id).style.height	= (y +"px");	
			if( y < 120){
				parent.document.getElementById(id).style.height = '300px';
			}		
		}
	}
	toTop();
}	

/***********************************GALERIA DE IMAGENES***********************************************/


var widthDMostra = 0;
var heightDMostra = 0;
var posx;
var posy;
function getMouseXY(e){
// captures the mouse position
posx = 0; 
posy = 0;
if (!e){var e = window.event;}
	if (e.pageX || e.pageY){
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY){
		posx = e.clientX;
		posy = e.clientY;
	}
} 

/***
*	mostrarImatge : fa que s'ensenyi la imatge i carrega la corresponent en el tag img, aquesta finestre emergent feta amb javascript esta 
* en el body de la pagina principal no es genera en el frame
*    	-url String: url de la imatge.
*
***/ 

function mostrarImatge(url,posx,posy){
	//inicialitzam la posicio en la pagina principal
	if( posx < 150 ) {
		this.posx = 210;
	} else if ( posx < 310 ) {
		this.posx = 365;
	} else if ( posx < 500 ) {
		this.posx = 520;
	}
	if( posy < 210 ) {
		this.posy = 348.5;
	} else if ( posy < 450 ) {
		this.posy = 560.5;
	} else if ( posx < 700 ) {
		this.posy = 772.5;
	}
	//fem que ss'amagui per si està encara visible
	tancarMostra();
	//coloquem tota la informacio de la imatge
	var img = document.getElementById('imageMostra');
	var imageNom = url.split("/")[1];
	img.setAttribute("alt",imageNom);
	img.setAttribute("title",imageNom);
	document.getElementById("handle").innerHTML = imageNom;
	img.setAttribute("src","admin/web/"+url);
	var widths = widthSize();
 	widths = (widths * 0.5) - (858 / 2);
	if ( widths < 0 ) {
		widths = 10;
	}
	// posicionem el tag div que conte la imatge a mostrar
	if(esIE){
		document.getElementById('divMostra').style.top = (this.posy) + "px";
		document.getElementById('divMostra').style.left = (this.posx + widths) + "px";
	} else { 
		document.getElementById('divMostra').style.top = (this.posy + 35) + "px";
		document.getElementById('divMostra').style.left = (this.posx + widths - 10 ) + "px";
	}
 	document.getElementById('divMostra').style.display = "";
	//crreem el tag per fer que el poguem desplaçar per la pantalla
	Drag.init(document.getElementById("handle"),document.getElementById("divMostra"));
	//fem que es fagi gran amb un set time
	agrandarImatge();


}

/***
*	agrandarImatge : fa una recursivitat per fer lael div al tamany que ensconvingui
****/
 

function agrandarImatge() {
	document.getElementById('divMostra').style.width = (widthDMostra + 10) + "px";
	document.getElementById('divMostra').style.height = (heightDMostra + 10) + "px";
	widthDMostra= (widthDMostra + 10);
	heightDMostra = (heightDMostra + 10);
	t=setTimeout("agrandarImatge()",25);
	if(widthDMostra >= 400) {
		widthDMostra = 400;
		heightDMostra = 450;
		document.getElementById('divMostra').style.width = (400) + "px";
		document.getElementById('divMostra').style.height = (450) + "px";
		clearTimeout(t);
		document.getElementById('divImatge').style.display = "";
	}

}


/****
* 	tancarMostra: fa que s'amagui la imatge i redimensiona el div
*
******/
function tancarMostra(){
 	
    if(document.getElementById('divMostra')){
        document.getElementById('divMostra').style.display = "none";
        document.getElementById('divMostra').style.width = "145px";
        document.getElementById('divMostra').style.height = "202px";    
    }
     
	widthDMostra = 145;
	heightDMostra = 202;
	if(document.getElementById('divImatge'))document.getElementById('divImatge').style.display = "none";
	if(document.getElementById('imageMostra')){
        var img = document.getElementById('imageMostra');
	    img.setAttribute("alt","");
	    img.setAttribute("title","");
	    img.setAttribute("src","");
    }
}

function getMes(oNum){
    try{
        
        oNum = parseInt(oNum, 10) - 1;
        if( oNum >= 0 && oNum <=12  ){
            mesos = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septienbre','Octubre','Noviembre','Diciembre');   
            return mesos[oNum];
        }
        else{
            return ""
        }
    } 
    catch(e){
        return ""
    }    
}

function obreDiv(szId,szLeer){
    
    if(document.getElementById(szId)){
      if(document.getElementById(szId).style.display == "none"){ 
          document.getElementById(szId).style.display = "";
          document.getElementById(szLeer).innerHTML = "[Cerrar]";
       }
       else{
          document.getElementById(szId).style.display = "none";
          document.getElementById(szLeer).innerHTML = "[leer más]";       
       }    
    }
}
function getFecha(oFecha){
    
    try{ 
        
        
        oDay = oFecha.substring(0,2);
        oDay = parseInt(oDay, 10);
        if(oDay != 'NaN' && oDay > 0 ){
            oMes = oFecha.substring(3,5); 
            oMes = getMes(oMes);
            if(trim(oMes) != ""){
                return oDay + " de " + oMes ;
            }
            else{
                return "";    
            }
        }
        else{
            return "";    
        }
    } 
    catch(e){
        return "";
    }       
}

function widthSize() {
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	  }
	  return myWidth;
}

/*function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function checkVersion()
{
  var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver > 6.0 ) 
		canvisIE6();
  }
}

function canvisIE6() {
	document.getElementByTagName

}*/



window.top.tancarMostra();




/************************************************************************************* 
* Nom:          loadUrl()
* Descripcio:   petició ajax per carregar codi hatml i scrips en un div       
* @Param:       addres--> url on volem fer la petició
                local--> id del div de destí
                params--> array o string amb les variables que volem oferir al servidor  
                functionAfter-->funció a carregarun cop feta l'accio
* @return:      res
***************************************************************************************/ 
function loadUrl(addres,local,params,functionAfter){
    $.ajax({
     type: "post",
     url: addres ,
     dataType: "text",
     data: params,
     complete: functionAfter,
     error: function(request,error) {
          if(error != "") {
           $("#"+local).html(request.responseText);
          }
      },
      success: function(request) {
          //alert(request);
          $("#"+local).html(request);
      } // End success
    });

}


var hijo_ruta="";
var hijo_titulo="";

function agregaRuta(arrayId, arrayTitulos, szTitulo){
    hijo_titulo = szTitulo;
    var szHtml = "";
    var classe = new Array();
    classe[0] = "font-family: Arial, Helvetica, sans-serif;text-align:left;font-size: 11px;font-weight: bold;padding-bottom:27px;padding-left:5px;text-decoration:none;color: black;";
    classe[1] = " font-family: Arial, Helvetica, sans-serif;font-size: 11px;color:#878889;font-weight: bold;text-decoration:none;";    
    classe[2] = "font-family: Arial, Helvetica, sans-serif;font-size: 11px;color:#393A73;font-weight: bold;text-decoration:none;";
    classe[3] = " font-family: Arial, Helvetica, sans-serif;font-size: 11px;color:#F16331;font-weight: bold;text-decoration:none;";
    
    for(i = 1; i < arrayId.length; i++){
        szHtml = szHtml + "<a href='/admin/web/" + arrayId[i] + "&plantilla=31'";
        if(i > 3){
            szHtml = szHtml + " style='" + classe[3] + "' target=\"mainframe\"> " + arrayTitulos[i] + " </a>";
        }
        else{
            szHtml = szHtml + " style='" + classe[i-1] + "' target=\"mainframe\"> " + arrayTitulos[i] +"/</a>";
        }
    }
    if(i > 3){
        szHtml = szHtml + "<span  style='" + classe[3] + "' >" + szTitulo + "</span>";
    }
    else{
        szHtml = szHtml + "<span  style='" + classe[i - 1] + "' >" + szTitulo + "</span>";
    }
    hijo_ruta = szHtml;
}

function agregaCabeceraHijo(){
    if(hijo_ruta != '' && hijo_ruta != ' ' && hijo_titulo != '' && hijo_ruta != ' ' ){
        var frameBody = $('#mainframe').contents().find('body');
        frameBody.prepend('<table border="0" cellpadding="0" cellspacing="0" width="500px" ><tr><td  id="ruta"  style="padding-bottom:27px; padding-left:1px" >'+hijo_ruta+'</td></tr>' 
                + '<tr><td  class="cabecera_hijos" style="width:100%;font-size: 22px;color:#F16331; ">'+hijo_titulo+'</td></tr>');
    }
}

