/************************************************ 
*Archivo que incluya las funciones necesarias para AJAX
*************************************************/

function getSubCategories()
{
	if(!document.getElementById ) return; 
	var f = document.getElementById("form_categorias");
	if(f != '')
	{
		cat_selected = f.elements["categoria"].value;
		divResultado = document.getElementById('div_subcategory');
		//alert(cat_selected);
		ajax=objetoAjax();
		var url = "http://"+window.location.host+"/includes/ajax_subcategories.php?cat_selected="+cat_selected
		if(window.location.host == "localhost")
		{
			var url = "http://"+window.location.host+"/zonanew/includes/ajax_subcategories.php?cat_selected="+cat_selected
		}
		ajax.open("GET", url, true)
		ajax.onreadystatechange=function() 
		{
			if (ajax.readyState==4) 
			{
				
				divResultado.innerHTML = ajax.responseText
				divResultado.style.display = 'block';
			}
			else
			{
				divResultado.innerHTML = ajax.responseText
				divResultado.style.display = 'block';
			}
		}
		//ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send('cat_selected='+cat_selected);		
	}
}

function leerMas(news_id)
{
	jQuery.noConflict();
	var id = news_id
	if(id != '')
	{
		divResultado = document.getElementById('hidden_novedades');
		//alert(id);
		ajax=objetoAjax();
		var url = "http://"+window.location.host+"/includes/ajax_selectnoticia.php?id_noticia="+id
		if(window.location.host == "localhost")
		{
			var url = "http://"+window.location.host+"/zonanew/includes/ajax_selectnoticia.php?id_noticia="+id
		
		}
		ajax.open("GET", url, true)
		ajax.onreadystatechange=function() 
		{
			if (ajax.readyState==4) 
			{
				Effect.toggle('novedades', 'blind')
				divResultado.innerHTML = ajax.responseText
				divResultado.style.display = 'block';
			}
			else
			{
				divResultado.style.display = 'none';
			}
		}
		//ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send('id_noticia='+id);		
	}

}

function leerMenos()
{
	Effect.toggle('hidden_novedades', 'appear')
	Effect.toggle('novedades', 'blind')
	
}

function habilitarCat(cat_id, hacer, user)
{
		
		var cat_id = cat_id
		if(hacer == 1)
		{
			var hacer = 'garantizar'
		}
		else
		{
			var hacer = 'remover';
		}
		var user = user
		
		divResultado = document.getElementById(''+cat_id+'');
		ajax=objetoAjax();
		var url = "http://"+window.location.host+"/includes/ajax_permissions.php?cat_id="+cat_id+"&perform="+hacer+"&user_id="+user
		if(window.location.host == "localhost")
		{
			var url = "http://"+window.location.host+"/zonanew/includes/ajax_permissions.php?cat_id="+cat_id+"&perform="+hacer+"&user_id="+user
		
		}
		ajax.open("GET", url, true)
		ajax.onreadystatechange=function() 
		{
			if (ajax.readyState==4) 
			{
				divResultado.innerHTML = ajax.responseText
			}
		}
		//ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("cat_id="+cat_id+"&perform="+hacer+"&user_id="+user);
}


function mostrarCalendario()
{

	Effect.toggle('hidden_calendar', 'appear')
	/*$("hidden_calendar").style.display = 'block';*/
}

function objetoAjax(){
	//alert(document.form1.grupo.value);
var obj;
if(window.XMLHttpRequest) { // no es IE
	obj = new XMLHttpRequest();
} else { // Es IE o no tiene el objeto
	try {
		obj = new ActiveXObject("Microsoft.XMLHTTP");
		}
	catch (e) {
		alert('El navegador utilizado no está soportado');
	}
}
return obj;
}
