function mostrar(w,h,img){
	document.getElementById("mostrar-foto").style.display="block";
	document.getElementById("mostrar-foto").style.width=w+"px";
	document.getElementById("mostrar-foto").style.height=h+"px";
	document.getElementById("mostrar-foto").style.left=((640-w)/2)+"px";
	document.getElementById("img-box").innerHTML="<img src=\"_img_resize/"+w+"/"+img+".jpg\" />";

}
function cerrar(){
	document.getElementById("mostrar-foto").style.display="none";

}

function eliminar_foto(x){
	if (confirm("Seguro queres eliminar la foto seleccionada?")){
	  location.href=("mis_fotos.php?del="+x);
	 }
}



function votar(foto_id){
	popuper(300,154);
	load("popup",url_base+"votar.php?foto_id="+foto_id);
}

function enviar(foto_id){
	popuper(460,272)
	load("popup",url_base+"enviar.php?foto_id="+foto_id);

}


function mostrar(divid){
	if(document.getElementById(divid).style.display=="block"){
		document.getElementById(divid).style.display="none";
	}else{
		document.getElementById(divid).style.display="block";
	}
}

function popuper(ancho,alto){
	if(document.getElementById("capa").style.display=="block"){
		document.getElementById("capa").style.display="none";
		document.getElementById("popup").style.display="none";
		document.getElementById("popup").innerHTML="";
	}else{
		var arr_pagesize=getPageSize();
		var arr_pagescroll=getPageScroll();
		var top=arr_pagescroll[1]+150;
		var left=(arr_pagesize[0]-ancho)/2;
		document.getElementById("popup").style.top=top+"px";
		document.getElementById("popup").style.left=left+"px";
		document.getElementById("popup").style.width=ancho+"px";
		document.getElementById("popup").style.height=alto+"px";
		document.getElementById("capa").style.height=arr_pagesize[1]+"px";
		
		document.getElementById("capa").style.display="block";
		document.getElementById("popup").style.display="block";
		
	}
}

var divid="";
function load(caja,url) {
	divid=caja;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	  alert ("Su navegador no soporta AJAX!");
	  return;
	 } 
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
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;
}

function stateChanged() {
	if (xmlHttp.readyState==4){document.getElementById(divid).innerHTML=xmlHttp.responseText;}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}







// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
