req = new Array();

function confirmar_url(url,texto)
{
	if (confirm (texto)) {self.location=url;}
}

function url_self()
{
	var text;
	
	text=location.href;
	var array_text=text.split("?");
    return array_text[0];
}

function openZoom(url,w,h)
{
  var str="height="+h+",width="+w+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no";
  window.open(url,"_blank",str);
}


function getAjax(url, valores, elemento, cargando) {
	 
	 //alert(valores);
	 
	 try {
     req[elemento] = new XMLHttpRequest(); /* e.g. Firefox */
     } catch(e) {
       try {
       req[elemento] = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
       } catch (e) {
         try {
         req[elemento] = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
         } catch (E) {
          req[elemento] = false;
         } 
       } 
     }
	
	 document.getElementById(cargando).style.visibility="visible";
     errorTxt = "Ocurrio un error";
     
     req[elemento].open("POST",url,true);
     req[elemento].onreadystatechange = function() {respuestaContenido(elemento, errorTxt, cargando);};
     req[elemento].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     req[elemento].send(valores);
}

  
function respuestaContenido(elemento, errorTxt, cargando) {
   var output = '';
   var codigo_pre = new Array();
   var codigo = new Array();
   
   if(req[elemento].readyState == 4) {
   	  if(req[elemento].status == 200) {
         output = req[elemento].responseText;
         document.getElementById(cargando).style.visibility="hidden";
		 document.getElementById(elemento).innerHTML=output;
		 try { 
			 codigo_pre = req[elemento].responseText.split('<!-- JSX');	 
		 	 if(typeof(codigo_pre[1])!='undefined') codigo = codigo_pre[1].split('-->');		
			 if(typeof(codigo[0])!='undefined') eval(codigo[0]);
		 } catch (e) { } 
      }
   }
}

function desplegables(id, nivel1, nivel2, nivel3, nivel4, nivel5) {
	
	if (id != 'null') location.href="index.php?opcion=33&id_cat="+id+"&nivel1="+nivel1+"&nivel2="+nivel2+"&nivel3="+nivel3+"&nivel4="+nivel4+"&nivel5="+nivel5;
}

function renombrar_galeria(id, galeria, nombre) {
	getAjax('modules/fotografos/gal_fotos_ajax.php', 'opcion=cname&galeria='+galeria+'&nombre='+nombre, id, 'load_'+id);
}

function cambiar_comentario_foto(id, foto, comentario) {
	getAjax('modules/fotografos/gal_fotos_ajax.php', 'opcion=ccom&id='+foto+'&comentario='+comentario, id, 'load_'+id);
}

function borrar_foto(id, foto, galeria, nodo) {
	if(confirm('Seguro que quieres borrar esta foto ?')) getAjax('modules/fotografos/gal_fotos_ajax.php', 'opcion=cdel&id='+foto+'&galeria='+galeria+'&nodo='+nodo, id, 'load_'+id);
}
