// JavaScript Document

// Función de carga de contenido HTML Dinámico

function loadContent(file,admin)
{
	if (admin == 0)
	{
	document.getElementById('calback').style.display = 'none';
	document.getElementById('content').style.display = 'block';
	document.getElementById("content").style.visibility = 'hidden';
	}
	
	if (file == "adminnoticias.html")
	{
		var xmlHttp1 = newXMLHttpRequest();
		
		xmlHttp1.open("GET", '../cleanimage.php', true);
		
		xmlHttp1.send(null);
	}
	
	var xmlHttp = newXMLHttpRequest();
	
  	// Conexión con el servidor
	if (admin == 1)
		xmlHttp.open("GET", '../admin/' + file, true);
	else if (admin == 0)
		xmlHttp.open("GET", '../' + file, true);
  	
	// función de recepción del código HTML
  	
	xmlHttp.onreadystatechange = function() 
	{
		if (xmlHttp.readyState == 4) 
		{
			if (xmlHttp.status == 200) 
			{
				document.getElementById('content').innerHTML = xmlHttp.responseText;
				if (file == "adminnoticias.html")
				{
					getnewsid();
				}
				if (file == "registropub.html")
				{
					Recaptcha.create("6Ld6QgUAAAAAAMGXBhTXjodfhI-6tE7jRPXV5wR1","recap", {theme: "white",lang: "es", callback: Recaptcha.focus_response_field});
				}
				if (file == "adminsecciones.html")
				{
					tinyMCE.init({
					// General options
					mode : 'textareas',
					languages : 'es',
					theme : "advanced",
					height: '400px',
					width: '800px',
					// Theme options
	theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true
					});
					getsections("s");
					getsections("ss");
					getimagesmain();
				
				}
				var myFx = new Fx.Style('content', 'opacity',{duration: 350}).start(0,1);
			}
		}
	}

  	// No se envía nada al servidor
  	xmlHttp.send(null);
}

function newXMLHttpRequest() 
{
	var xmlreq = false;
	if (window.XMLHttpRequest) 
	{
		xmlreq = new XMLHttpRequest();
	} 
	else 
		if (window.ActiveXObject) 
		{
    		// prueba ActiveX
			try 
			{	 
				xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e1) 
			{ 
				// método alternativo 
				try 
				{
					xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e2) 
				{
				 // ambos métodos fallan 
				} 
			}
 		}
   	return xmlreq;
}
