/*Mostrar ocultar elemento por Id*/

function displayNoneBlock(id)
{
	var elemento=document.getElementById(id);
	
	if(elemento.style.display == 'none')
		elemento.style.display = 'block';
	else
		elemento.style.display = 'none';
}


//ajax para formulario de etiquetado por listado
function nuevoAjax(){
	var xmlHttp=false;
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
		xmlHttp = false;
		}
	}
	
	if (!xmlHttp && typeof XMLHttpRequest!='undefined') {
		xmlHttp = new XMLHttpRequest();
	}

	return xmlHttp;
}


//mostramos el formulario individual de meter etiquetas
function formEtiquetasListado(idcontent){
	var contenedor;
	contenedor = document.getElementById('EtiquetasListado'+idcontent);
	ajax=nuevoAjax();
	ajax.open("GET", "/modules/addListado.php?objectId="+idcontent+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}


function formEtiquetasListadoSend(opcion, objectId, tag, idi){
	var contenedor;
	//alert(tag);
	contenedor = document.getElementById('EtiquetasListado'+objectId);
	ajax=nuevoAjax();
	ajax.open("GET", "/modules/addListado.php?opcion="+opcion+"&objectId="+objectId+"&tag"+objectId+"="+tag+"&idi="+idi+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}


function formEtiquetasListadoHide(objectId){
	var contenedor;
	//alert(tag);
	contenedor = document.getElementById('EtiquetasListado'+objectId);
	ajax=nuevoAjax();
	ajax.open("GET", "/modules/empty.php",true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}


function tagDelete(idcont, tag, del, idi){
	var contenedor;
	//alert(tag);
	contenedor = document.getElementById('tagsListado'+idcont);
	ajax=nuevoAjax();
	ajax.open("GET", "/modules/tagsListados.php?objectId="+idcont+"&tag="+tag+"&del="+del+"&idi="+idi+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}

function tagReload(idcont, idi){
	var contenedor;
	//alert(tag);
	contenedor = document.getElementById('tagsListado'+idcont);
	ajax=nuevoAjax();
	ajax.open("GET", "/modules/tagsListados.php?objectId="+idcont+"&idi="+idi+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}

function cacheClear(id, web, path, query, pbname, tag){
	var contenedor;
	alert(id, web, path, query, pbname, tag);
	contenedor = document.getElementById('resultadoClearCache');
	ajax=nuevoAjax();
	ajax.open("GET", "/modules/tagsListados.php?id="+id+"&web="+web+"&path="+path+"&query="+query+"&pbname="+pbname+"&tag="+tag+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}

function addCaption(id, idi){
	var contenedor;
	contenedor = document.getElementById('SUBTITULOS');
	ajax=nuevoAjax();
	//ajax.open("GET", "/_include/addCaptions.php?nocache=" + Math.random(),true);
	ajax.open("GET", "/_include/showCaptions.php?idi="+idi+"&id="+id+"&action=insert&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}

function deleteCaption(id, idCaption, idi){
	var contenedor;
	contenedor = document.getElementById('SUBTITULOS');
	ajax=nuevoAjax();
	ajax.open("GET", "/_include/showCaptions.php?idi="+idi+"&id="+id+"&idCaption="+idCaption+"&action=delete&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}

function showCaptions(id, idi){
	var contenedor;
	contenedor = document.getElementById('SUBTITULOS');
	ajax=nuevoAjax();
	ajax.open("GET", "/_include/showCaptions.php?idi="+idi+"&id="+id+"&nocache=" + Math.random(),true);
	ajax.onreadystatechange=function() {
	if (ajax.readyState==4) {
	contenedor.innerHTML = ajax.responseText;
	}
	}
	ajax.send(null)
}

function wait(msecs)
{
	var start = new Date().getTime();
	var cur = start;
	while(cur - start < msecs)
	{
		cur = new Date().getTime();
	} 
} 
