
//var myURL = 'http://localhost:8888/'; //'http://www.arji.edu.mx/arji/.html'
var myURL = 'http://www.arji.edu.mx/arji/'; //'http://localhost:8888/'

$(function(){
	$(document).ready(function(){

		getXML('getNoticias.php?id=-1','x=2',10,-1);

	});
});


function Filter(URL,Vars,nFuction,nFilter){
         switch (nFilter){
			    case 1:
										
				      break;
		 }
}

function getNoticias(xml){

	try{	
			var i=1;
			if ($("status",xml).text() == "2") { return};
				  $("noticia",xml).each(function(id) {
							  nota = $("noticia",xml).get(id);
							  nidcolumna = $("idcontenido",nota).text();

							  $('#imgNota'+i).attr({src:$("image",nota).text()});
							  $('#hRefNota'+i).attr({href:"javascript:getXML('getContenido.php?id="+nidcolumna+"','x=1',9,9);"});
							  $('#tituloNota'+i).html($("titulo",nota).text());
							  $('#detalleNota'+i).html($("sumario",nota).text());
												  
							  i++;
		
			});
				  
	} catch (e) {
		alert(e.description);
	}
		
}


function getContenido(xml,nMenu){
		 try{	
				//  $("#panelDerecho").html("");
				  var sHTML  = "";
					  sHTML += "<div id='divContenedor' class='ui-corner-all'>";
					  sHTML += "<p>";
		
				  var vBack  = "<div id='encabi' class='ui-corner-all' style='background:url(images/coreArji/menuBar1.gif) top no-repeat; width:567px; height:25px; margin-top:10px; margin-bottom:10px; margin-right:10px;'>";
					  vBack += "<a href='"+myURL+"index.html' class='backHome'></a>"
					  vBack += "</div>"

//alert(0);					  



				  var i = 1;
				  var nota;
				  var nidcolumna; 
				  var alto = 0;
				  if ($("status",xml).text() == "2") {$("#panelDerecho").html("No Hay Informaci&oacute;n "+vBack); return};
				  
					  $("contenido",xml).each(function(id) {
													   
								  nota = $("contenido",xml).get(id);
								  nidcolumna = $("idcontenido",nota).text(); 
								  sHTML += oMenuActivo;
								  if (nMenu==9 || nMenu==11) {
									  sHTML += "<div id='cuerpoNota' class=' ui-corner-top' style='margin-top:300px; @height:700px; @overflow-x:hidden; @overflow-y:scroll;''>";
								  }else{
									  
									  if ($("image",nota).text()!=''){
									  	 sHTML += "<div id='cuerpoNota' class=' ui-corner-top' style='@height:700px; @overflow-x:hidden; @overflow-y:scroll;'>";
									  }else{
									  	 sHTML += "<div id='cuerpoNota' class=' ui-corner-top' style='@height:1000px; @overflow-x:hidden; @overflow-y:scroll;'>";
									  }
								  }
								  sHTML += vBack;
								  if ($("titulo",nota).text()=='.'){
									  sHTML += "";
								  }else{
									  sHTML += "<h1>"+$("titulo",nota).text()+"</h1><br/>";
								  }
								  sHTML += "<p styly='text-align:center; margin-left:auto; margin-right:auto; margin-right:10px; @margin-right:40px; '>"+$("cuerpo",nota).text()+"</p>";
								  sHTML += vBack;
								  sHTML += "</div>";
								  vImage = $("image",nota).text();
								  alto = $("alto",nota).text();
								  i++;
			
					  });
					  sHTML += "</p>";
					  sHTML += "</div>";
					  
					  $("#panelDerecho").html(sHTML);

	
					  var k = $("#panelDerecho #divContenedor").height()+25;
//					  var k = $("#panelDerecho").height()+25;
		
					  paintpanelDerecho(k);
						
					  if (nMenu==9 || nMenu==11){
						  $("#panelDerecho #imgNoticia").css("background","url("+vImage+") top no-repeat");
					  }else{
						  $("#panelDerecho #imgNota").css("background","url("+vImage+") top no-repeat");
					  }
					  
					 //alert( $("#panelDerecho").html() );
					  
		
					 // if (nMenu==7 && nMenu==7){
						  tableHighlightRow();
					 // }
					  
//					  window.location.hash="anclaContenedora"; 			  
					  
					  //alert($("#panelDerecho").width());
					  
					  
						//alert(1);
		 } catch (e) {
		   alert(e.description);
		 }
	
}



function getXML(URL,Vars,nFunction,nMenu){
		 try{	
				  var xURL = URL
				  var x;
			  
				  if (nFunction != 10){
//alert(1);					  
					 x = paintMenu(nMenu);
//alert(x);					  
					 $("#panelDerecho").html(x);
//alert(3);					  
					 //paintpanelDerecho(0);
				  }
				 URL = xURL;
				//alert("php/"+URL+"&language="+language);
				  jQuery.ajax({
								url: "php/"+URL+"&language="+language,
								async:true,
								data:Vars,
								contentType: "text/xml; charset=iso_8859-1",
								dataType: "xml",
								global: true,
								ifModified: false,
								processData:true,
								error: function(objeto, quepaso, otroobj){
									   //alert("La comunicaicón ha fallado, intente de nuevo: "+quepaso+"; fallo provocado por: "+URL+"; "+Vars+"; "+" Linea del error: "+nFunction);
								},
								success: function(xml){
										 switch(nFunction){
												case 1: 
												case 2: 
												case 3: 
												case 4: 
												case 5: 
												case 6: 
												case 9: 
												case 11: 
													   //$.paintpanelDerecho(0);
													   getContenido(xml,nMenu);
													   break;
												case 10: 
													   //alert("hola");
													   getNoticias(xml);
													   break;
											 }
								},
								timeout: 120000,
								type: "GET"
				  });
				  
		 } catch (e) {
		   // alert(e.description);
		 }
	

}

function paintpanelDerecho(j){

try{	

		var k = j;
		if ( k>0 && k<1040){
		   $("#panelDerecho").height(1040);
		   $("#panelDerecho").css("@height","1100px");
		   //$("#noticias").css("@top","2000px");
		}else if (k==0) {
			   var sHTML = "<div id='imgNota' class='ui-corner-all'> ";			
                 //  sHTML += "           <img src='images/coreArji/preloader_next.gif' border='0'/>";
                  sHTML += "<p style='margin-top:100px; width:567px;'>Cargando datos, por favor, espere...</p>";
				sHTML += "</div>";
				if ($("#panelDerecho").length<=0){
					  alert("no existe panelDerecho");
				}
                $("#panelDerecho").html(sHTML);
				$("#panelDerecho #imgNota").css("background","url(images/coreArji/preloader_children.gif) no-repeat left top");
				x = $("#panelDerecho").html();
		}else{
			
			  $("#panelDerecho").height(k);
		}
} catch (e) {
	alert(e.description);
}


}



