/* -----------------------------------------------
Title: Menu de Noticies Ajax
Author: Albert Serra
w. http://www.aplicacionsweb.com/
----------------------------------------------- */

	var request;
	var dest;
	
function canviar_border(colorins) {
  objdiv = document.getElementById("menu_noticies_esquerra");
  objdiv.style.borderRight = "1px solid " + colorins;
  return true;
}


  
function processStateChange(){
	if (request.readyState == 4){
		contentDiv = document.getElementById(dest);
		if (request.status == 200){
			response = request.responseText;
			contentDiv.innerHTML = response;
		} else {
			contentDiv.innerHTML = "Error: Status "+request.status;
		}
	}
}


function loadHTML(URL, destination){
	dest = destination;
	if (window.XMLHttpRequest){
		request = new XMLHttpRequest();
		request.onreadystatechange = processStateChange;
		request.open("GET", URL, true);
		request.send(null);
	} else if (window.ActiveXObject) {
		request = new ActiveXObject("Microsoft.XMLHTTP");
		if (request) {
			request.onreadystatechange = processStateChange;
			request.open("GET", URL, true);
			request.send();
		}
	}
}

function seleccionar(boto) {
	boto.style.backgroundColor = "#E0E7D1";
	boto.style.border = "1px solid #89B524";
	boto.style.borderBottom = "1px solid #E0E7D1";
	boto.style.color = "#000000";
}

function canvi_select_poblacio(slt) {
  	poblacio = slt.options[slt.selectedIndex].value;
  	loadHTML('noticies/poblacions.php?poblacio='+poblacio,'noticiagran');
}
function canvi_select_categoria(slt) {
	categoria = slt.options[slt.selectedIndex].value;
	loadHTML('noticies/categories.php?categoria='+categoria,'noticiagran');
}
  
