function objetoAjax(){
	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;
}
/*function selector2(id,campo,tabla){
	window.open(urlbase+"includes/extras/index2.php?campo="+campo+"&tabla="+tabla+"&id="+id,"multi_explorer","width=955,height=600,menubar=no,status=yes,resizable=yes");
}

function selector3(session_id){
	window.open(urlbase+"includes/extras/extplorer/index.php","multi_explorer","width=800,height=600,scrollbars=1,menubar=1,status=no,resizable=yes");
}

function selector4(id, campo ,tabla){
	window.open(urlbase+"includes/extras/index3.php?id=" + id + "&campo=" + campo + "&tabla=" + tabla,"multi_explorer","width=695,height=400,menubar=no,scrollbars=1,status=no,resizable=yes");
}

function selector5(id1,id2,fld1,fld2,capa,tipo){
	window.open(urlbase+"includes/extras/index4.php?id1="+id1+"&id2="+id2+"&fld1="+fld1+"&fld2="+fld2+"&capa="+capa+"&tipo="+tipo,"multi_explorer","width=620,height=400,menubar=no,scrollbars=1,status=yes,resizable=no");
}

function selector6(cod){
	window.open(urlbase+"includes/extras/index5.php?id="+cod,"multi_explorer","width=440,height=180,menubar=no,scrollbars=1,status=no,resizable=no");
}
*/

function cambio_idioma(idioma){
	divResultado = document.getElementById('dummy2');
	ajax=objetoAjax();
	ajax.open("POST",  urlbase+'includes/idioma.php', true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText;
			window.location.href = window.location.href;
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("idioma=" + idioma);
}
function cerrar_session(){
	divResultado = document.getElementById('dummy2');
	ajax=objetoAjax();
	ajax.open("POST",  urlbase+'includes/cerrar.php', true);
	ajax.onreadystatechange=function() {
		if(ajax.readyState==4){
			divResultado.innerHTML = ajax.responseText;
			window.location.href = window.location.href;
		}
	}
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("");
}
function abrir(){
	window.open(urlbase+"0/cuentas/configuracion","config01","top=0,left=0,width=800,height=500,scrollbars=NO,location=NO,menubar=NO,resizable=YES");
}
function calificar(e,n,a){
	var error = 0;
	if((e == 1 && document.getElementById('Publicacion_email').value.length == 0)||(n == 1 && document.getElementById('Publicacion_nombre').value.length == 0)||(a == 1 && document.getElementById('Publicacion_apellido').value.length == 0)){
		error = 1;
	}
	if(error == 0){
		divResultado = document.getElementById('encuestaz');
		ajax=objetoAjax();
		ajax.open("POST",  urlbase+'0/encuestas/calificar/', true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				divResultado.innerHTML = ajax.responseText;
			}
		}
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send("publicacion="+document.getElementById('idPublicacion').value+"&valor="+document.getElementById('radioEncuesta').value+"&email="+document.getElementById('Publicacion_email').value+"&nombre="+document.getElementById('Publicacion_nombre').value+"&apellido="+document.getElementById('Publicacion_apellido').value);
	}
	else{
		alert('Datos incompletos');
	}
}

function descargar(a){
	ventana_secundaria = window.open(urlbase+"includes/down_inc.php?p=" + a ,"Charge","width=100,height=100,top=90,left=90,menubar=no,statusbar=yes");
	setTimeout("ventana_secundaria.close();", 2000);
}
function preview_c(id,pref){
	if(document.getElementById(pref+'_'+id).style.display == '') document.getElementById(pref+'_'+id).style.display = 'none';
	else document.getElementById(pref+'_'+id).style.display = '';
}
