function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}// JavaScript Document


/* Muestro detalle noticia seleccionada en pagina inicial */
function GetInicio() { 
				xmlHttp=GetXmlHttpObject();
				xmlHttp.open("GET", "index.php?Flag=1", true); 
				xmlHttp.onreadystatechange=function()	{ 
					if (xmlHttp.readyState==4) { 
						main.innerHTML=xmlHttp.responseText; 
					}			
				}
				xmlHttp.send(null); 
		}


function GetCampo(GetFlag,IdFoto) { 
				Campo=GetXmlHttpObject();
				Campo.open("GET", "bilder.php?Ac=7&GetFlag="+GetFlag+"&IdFoto="+IdFoto, true); 
				Campo.onreadystatechange=function()	{ 
					if (Campo.readyState==4) { 
						CampoText.innerHTML=Campo.responseText; 
					}			
				}
				Campo.send(null); 
		}

/* MOstrar Listado Galeria  */
	function GetGaleria(IdGal) { 
				Galeria=GetXmlHttpObject();
				Galeria.open("GET", "index.php?Flag=2&IdGal="+IdGal, true); 
				Galeria.onreadystatechange=function()	{ 
					if (Galeria.readyState==4) { 
						ShowGaleria.innerHTML=Galeria.responseText; 
					}			
				}
				Galeria.send(null); 
		}	
		
	function GetInfo(IdMenu) { 
				Info=GetXmlHttpObject();
				Info.open("GET", "index.php?Flag=3&IdMenu="+IdMenu, true); 
				Info.onreadystatechange=function()	{ 
					if (Info.readyState==4) { 
						ShowGaleria.innerHTML=Info.responseText; 
					}			
				}
				Info.send(null); 
		}
	
	function GetPagGaleria(Flag,pagina) { 
				PagGaleria=GetXmlHttpObject();
				PagGaleria.open("GET", "index.php?Flag="+Flag+"&pagina="+pagina, true); 
				PagGaleria.onreadystatechange=function()	{ 
					if (PagGaleria.readyState==4) { 
						noticias.innerHTML=PagGaleria.responseText; 
					}			
				}
				PagGaleria.send(null); 
		}
		
	function GetFotos(IdGal) { 
				detFotos=GetXmlHttpObject();
				detFotos.open("GET", "index.php?Flag=13&IdGal="+IdGal, true); 
				detFotos.onreadystatechange=function()	{ 
					if (detFotos.readyState==4) { 
						Fotos.innerHTML=detFotos.responseText; 
					}			
				}
				detFotos.send(null); 
		}
		
		function GetFormValor(GetFlag,IdFoto,Tipo) { 
				Valor=GetXmlHttpObject();
				Valor.open("GET", "bilder.php?Ac=7&IdFoto="+IdFoto+"&Tipo="+Tipo+"&GetFlag="+GetFlag, true); 
				Valor.onreadystatechange=function()	{ 
					if (Valor.readyState==4) { 
						FormValor.innerHTML=Valor.responseText; 
					}			
				}
				Valor.send(null); 
		}
		
		function GetFormMenu(GetFlag,IdMenu,Tipo) { 
				Menu=GetXmlHttpObject();
				Menu.open("GET", "addmenu.php?Ac=3&IdMenu="+IdMenu+"&Tipo="+Tipo+"&GetFlag="+GetFlag, true); 
				Menu.onreadystatechange=function()	{ 
					if (Menu.readyState==4) { 
						FormMenu.innerHTML=Menu.responseText; 
					}			
				}
				Menu.send(null); 
		}
		
		function ShowDiv(id){
			if($(id).style.display=='none'){
				$(id).style.display='';
			}else{
				$(id).style.display='none';
			}
		}
		
		function ShowImg(IdFoto){
			Img=GetXmlHttpObject();
			Img.open("GET", "index.php?Flag=4&IdFoto="+IdFoto, true); 
			Img.onreadystatechange=function()	{ 
				if (Img.readyState==4) { 
					Foto.innerHTML=Img.responseText; 
				}			
			}
			Img.send(null); 
	
		}


		

/* MOstrar Resultado Buscador  */
	function showHint(str){
		if (str.length==0)  { 
			noticias.innerHTML="";
			return;
		}
		Busk=GetXmlHttpObject()
		if (Busk==null)  {
			alert ("Your browser does not support AJAX!");
			return;
		} 
		var url="index.php";
		url=url+"?busk="+str;
		url=url+"&Flag=15";
		url=url+"&sid="+Math.random();
		Busk.onreadystatechange=stateChanged;
		Busk.open("GET",url,true);
		Busk.send(null);
	}

	function stateChanged() { 
		if (Busk.readyState==4){ 
			noticias.innerHTML=Busk.responseText;
		}
	}



/* Validar Maximo 300 caracteres */
	function maximo(campo,limite){
		if(campo.value.length>=limite){
			campo.value=campo.value.substring(0,limite);
 		}
	}


/* Ventana */
function ventanaG(URL,ancho,alto) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=auto,location=0,statusbar=0,menubar=0,resizable=0,width='+ ancho +',height='+ alto +',left = 400,top = 100');");
}


