// JavaScript Document

function getXMLHttpRequest()
{
   var Versiones = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp","Microsoft.XMLHttp"];
	 var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp","Microsoft.XMLHttp"]; 
   if (window.XMLHttpRequest){
      return new XMLHttpRequest();
   }
   else if(window.ActiveXObject){
      for(var i = 0; i < aVersions.length; i++){
         try{
            var oXmlHttp = new ActiveXObject(aVersions[i]);
            return oXmlHttp;
         }
         catch(error){
      
         }
      }
   }
}
 
function paginaPublic(pag)
{
	var xmlhttp = getXMLHttpRequest();
		
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 4) 
		{
			document.getElementById("listaPublic").innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open("POST", "wp-content/themes/Qwilm!/paginaPublic.php", true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	xmlhttp.send("pagActual="+pag);
	
}

function controlFeed()
{
	form = document.fPublic;
	
	if((form.nombre.value != "")&&(form.email.value != "")&&(form.titulo.value != "")&&(form.archivo.value != "")&&(form.contenido.value != "")&&(form.enlace.value != ""))
	{
		form.submit();
	}
}

var actHeightLista = 0;

function publish()
{
	toHeight = document.getElementById("listaPublic").clientHeight;
	actHeight = document.getElementById("formulario").clientHeight;

	if(toHeight == 0)
	{
		toHeight = document.getElementById("listaPublic").offsetHeight;
		actHeight = document.getElementById("formulario").offsetHeight;
	}

	actHeightLista = toHeight;

	minHeight = 461;
	
	
	if(toHeight > minHeight)
	{
		open_height = toHeight+"px";
		$("#formulario").animate({"height": open_height}, {duration: "fast" });
	}
	
	if(toHeight < minHeight)
	{
		open_height = minHeight+"px";
		
		$("#formulario").animate({"height": open_height}, {duration: "fast" });
		$("#listaPublic").animate({"height": open_height}, {duration: "fast" });
	}
	
}

function closePublish()
{
	open_height = actHeightLista+"px";
	
	$("#formulario").animate({"height": "0px"}, {duration: "fast" });
	$("#listaPublic").animate({"height": open_height}, {duration: "fast" });
	
}

function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}