function ocultar_foto(){
	$('#fndlayer').fadeTo(500,0,function(){ $('#fndlayer').css({display : "none"}); });
	$('#layer').fadeTo(500,0,function(){ $('#layer').css({display : "none"}); });	
}

function ocultar_fnd_layer(){
	$('#fndlayer').fadeTo(500,0,function(){ $('#fndlayer').css({display : "none"}); });
	$('#layer').fadeTo(500,0,function(){ $('#layer').css({display : "none"}); });	
}

/************************** **************************************************************************************************/
// from : http://www.dynamicdrive.com/dynamicindex4/lightbox
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		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;
	if (self.innerHeight) {	// all except Explorer
		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;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/************************** **************************************************************************************************/


/*
function show_full_img(img, w, h){
//	ocultar_swf();
	
	$('#fndlayer').css({opacity : "0"});
	$('#fndlayer').css({display : "block"});
	$('#fndlayer').fadeTo(500,.8);
	
	$('#layer').width(w+40);
	$('#layer').css({width : (w+40)+"px"});
	document.getElementById('layer').style.width = (w+40)+"px";
	$('#layer').height(h+50);
	
	$('#layer').css({opacity : "0"});
	$('#layer').css({display : "block"});
	
	// por problemas con ie6 (q raro)
	var ancho_real = document.getElementById('layer').style.width.split('px')[0];
	
	var __left = ($(window).width() / 2) - ( ancho_real / 2);
	$('#layer').css({left : __left+"px"});
	var __top = getPageScroll();
	$('#layer').css({top : (__top[1]+50)+"px"});

	txt = '<br /><img onclick="ocultar_foto()" src="fotos/'+img+'" alt="" title="" /><br /><span onclick="ocultar_foto()" class="span_cerrar">Cerrar [X]</span>';
	
	$('#layer').html(txt);
	$('#layer').fadeTo(500,1);
	
}

*/

/*
function cargar_categorias_link(w, h, idlink, id){
//	ocultar_swf();
	if(id != 0)
		$('#fndlayer').height(__med[1]+360+380); 

	$('#fndlayer').css({opacity : "0"});
	$('#fndlayer').css({display : "block"});
	$('#fndlayer').fadeTo(500,.8);
	
	$('#layer').width(w+40);
	$('#layer').css({width : (w+40)+"px"});
	document.getElementById('layer').style.width = (w+40)+"px";
//	$('#layer').height(h+50); -------- ALTURA DINAMICA 
	
	$('#layer').css({opacity : "0"});
	$('#layer').css({display : "block"});
	
	// por problemas con ie6 (q raro)
	var ancho_real = document.getElementById('layer').style.width.split('px')[0];
	
	var __left = ($(window).width() / 2) - ( ancho_real / 2);
	$('#layer').css({left : __left+"px"});
	var __top = getPageScroll();
	$('#layer').css({top : (__top[1]+50)+"px"});

	$.ajax({ 
	  type: "POST", 
	  url: "paginas/principales/loadcontenidos.php",
	  data: "idlink="+idlink+"&id="+id,
	  success: function(txt){
			$('#layer').html(txt);
			$('#layer').fadeTo(500,1);
	  } 
	}); 
	
}
*/

function show_full_img(img, id){
	//ocultar_swf();
	
	$('#fndlayer').css({opacity : "0"});
	$('#fndlayer').css({display : "block"});
	$('#fndlayer').fadeTo(500,.8);
	
	$('#layer').css({opacity : "0"});
	$('#layer').css({display : "block"});
	var __left = ($(window).width() / 2) - ($('#layer').width() / 2);
	$('#layer').css({left : __left+"px"});
	var __top = getPageScroll();
	$('#layer').css({top : (__top[1]+20)+"px"});
				
		$.ajax({ 
		  type: "POST", 
		  url: "loadfullimg.php", 
		  data: "idg="+id+"&img="+img, 
		  success: function(txt){ 
				$('#layer').html(txt);
				$('#layer').fadeTo(500,1,function(){
					if(($.browser.msie)){ var add_w = 30; al_img += 15; }
					else{ var add_w = 0;}
					if(an_img < 250){
						an_img = 250;
					}
					al_img += 90;
					al_img += 43;
					an_img += add_w;
									
					al_old = al_img;
					an_old = an_img;
//					alert(an_img + ' -- ' + al_img);
					$('#div_foto_ppal_cargada').animate({width: an_img},'slow',function(){
						$('#div_foto_ppal_cargada').animate({height: al_img},'slow',function(){
							$('#foto_ppal_cargada').fadeIn('slow');
							$('#div_flechas_cargada').show();
						});
					});
				});
		  } 
		}); 
}

function load_next_prev(img){
	$.ajax({ 
	  type: "POST", 
	  url: "loadnextprev.php", 
	  data: "p_w="+an_img+"&p_h="+al_img+"&img="+img, 
	  success: function(txt){ 
			$('#layer').html(txt);
			if(($.browser.msie)){ var add_w = 30; al_img += 15;}
			else{ var add_w = 0;}
			if(an_img < 250){
				an_img = 250;
			}
			al_img += 90;
			al_img += 43;
			an_img += add_w;
			
			if(an_img == an_old) v_w = 1;
			else if(((an_img - an_old) > 0 ? an_img - an_old : an_old - an_img ) <= 30 ) v_w = 'fast';
			else v_w = 'slow';

			if(al_img == al_old) v_h = 1;
			else if(((al_img - al_old) > 0 ? al_img - al_old : al_old - al_img ) <= 30 ) v_h = 'fast';
			else v_h = 'slow';
			
			al_old = al_img; an_old = an_img;

			$('#div_foto_ppal_cargada').animate({width: an_img},v_w,function(){
				$('#div_foto_ppal_cargada').animate({height: al_img},v_h,function(){
					$('#foto_ppal_cargada').fadeIn('slow');
					$('#div_flechas_cargada').show();
				});
			});
	  } 
	}); 
}

function ver_prev(){
	if(indice_img_actual <= 0) indice_img_actual = _total;
	else indice_img_actual--;

	$('#foto_ppal_cargada').css({visibility:'hidden'});
	$('#div_flechas_cargada').css({visibility:'hidden'});
	
	load_next_prev(list_img[indice_img_actual]);
}

function ver_sigu(){
	if(indice_img_actual >= _total) indice_img_actual = 0;
	else indice_img_actual++;
	$('#foto_ppal_cargada').css({visibility:'hidden'});
	$('#div_flechas_cargada').css({visibility:'hidden'});
	
	load_next_prev(list_img[indice_img_actual]);
}
