
function abrir(imagen,titulo)
 {
 /*var img = new Image();
 img.src = imagen;
 win=window.open('','','width='+img.width+',height='+img.height+',scrollbars=no,resizable=1,toolbar=0');
 win.document.write ('<html>\n');
 win.document.write (' <head>\n');
 win.document.write (' <title>'+titulo+'</title>\n');
 win.document.write (' </head>\n');
 win.document.write (' <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">\n');
 win.document.write (' <img src="' + imagen + '" height='+img.height+' width='+img.width+'>\n');
 win.document.write (' </body>\n');
 win.document.write ('</html>\n');*/
	
	//obtenemos el div donde se incrustara la imagen
	m_i = document.getElementById('marco_imagen');
	
	//Limpiamos el div por si tiene una imagen
	m_i.innerHTML="" ;
	
	m_i.innerHTML='<img width="710px" src="' + imagen + '"/>';
}


gallery = function() {

/* show first image and information */
showTime=7000;
timer=0;
absLeft=0;
picCount=0;
total = jQuery('.thumb img').length;
$totalImgs = jQuery('.thumb img');
jQuery('#imageNumber').html('Image 1 of ' + total + ' images' );

thumbWidth = 0;
for (x=0; x<total; x++) {
thumbWidth = thumbWidth + jQuery($totalImgs[x]).outerWidth();
}
thumbWidth += 5;
jQuery('#innerContainer')	.css({ width: thumbWidth + 'px'});
jQuery('#innerContainer img').css({ display: 'inline'});

firstStr = jQuery('.thumb');
showStr = firstStr.html();
showDiv(showStr)


jQuery('#slideLeft')			.hover(function(e){
jQuery('#innerContainer')	.stop();
jQuery('#innerContainer')	.animate({"left": "0px"}, 5000 , "swing")
},function(){
jQuery('#innerContainer')	.stop();
});

jQuery('#slideRight')			.hover(function(e){
posLeft = jQuery('#thumbnails')	.offset().left;
absLeft = e.pageX - posLeft;
hiddenBit = thumbWidth - jQuery('#thumbnails').width() ;
jQuery('#innerContainer')		.stop();
jQuery('#innerContainer')		.animate({"left": -hiddenBit + "px"}, 5000 , "swing")
},function(){
jQuery('#innerContainer')		.stop();
});



/* monitor mouse clicks */
jQuery('.thumb').click(function(){
htmlStr = jQuery(this).html();
currentLarge = jQuery(this).attr('class').split(' ').slice(-1);
if ("p"+(total) == currentLarge) {
jQuery('#clickRight').css("backgroundImage", "url(blank.gif)")
				.attr("alt", "")
				.attr("title", "");
}
else {
jQuery('#clickRight').css("backgroundImage", "url(next.gif)")
				.attr("alt", "Next")
				.attr("title", "Next");
}
if ("p1" == currentLarge) {
jQuery('#clickLeft')	.css("backgroundImage", "url(blank.gif)")
				.attr("alt", "")
				.attr("title", "");
}
else {
jQuery('#clickLeft').css("backgroundImage", "url(previous.gif)")
				.attr("alt", "Previous")
				.attr("title", "Prevous");
}

/* swap images and information */
	jQuery('#fullSize')	.fadeOut(600, function(){showDiv(htmlStr)});
});

/* show image and information */
function showDiv (htmlStr) {
	jQuery('#fullSize')		.html(htmlStr)
						.fadeIn(600);
	currentLarge = jQuery('#fullSize img').attr('class');
	currentLarge = currentLarge.substr(1,3);
	jQuery('#imageNumber').html('Image ' + currentLarge + ' of ' + total + ' images' );
}


jQuery('#clickRight').click(function(){
currentLarge = jQuery('#fullSize img').attr('class');
if ("p"+(total-1) == currentLarge) {
jQuery$('#clickRight')	.css("backgroundImage", "url(blank.gif)")
					.attr("alt", "")
					.attr("title", "");
}
if ("p" + total != currentLarge) {
jQuery('#clickLeft')	.css("backgroundImage", "url(previous.gif)")
				.attr("alt", "Previous")
				.attr("title", "Previous");
htmlStr = jQuery('#innerContainer li.'+currentLarge).next('li').html();
jQuery('#fullSize')	.fadeOut(600, function(){showDiv(htmlStr)});
}
});

jQuery('#clickLeft')	.click(function(){
currentLarge = jQuery('#fullSize img').attr('class');
if ("p2" == currentLarge) {
jQuery('#clickLeft')	.css("backgroundImage", "url(blank.gif)")
				.attr("alt", "")
				.attr("title", "");
}
if ("p1" != currentLarge) {
jQuery('#clickRight')	.css("backgroundImage", "url(next.gif)")
					.attr("alt", "Next")
					.attr("title", "Next");
htmlStr = jQuery('#innerContainer li.'+currentLarge).prev('li').html();
jQuery('#fullSize')	.fadeOut(600, function(){showDiv(htmlStr)});
}
});


jQuery('#autoPlay')	.toggle(function(){
jQuery('#autoPlay')	.css("backgroundImage", "url(stop.gif)")
				.attr("alt", "Stop")
				.attr("title", "Stop");
autoPlay()
},function(){
clearTimeout(timer);
jQuery('#autoPlay')	.css("backgroundImage", "url(play.gif)")
				.attr("alt", "Play")
				.attr("title", "Play");
 });


}

function autoPlay () {
currentLarge = jQuery('#fullSize img').attr('class');
if ("p"+(total-1) == currentLarge) {
jQuery('#clickRight')	.css("backgroundImage", "url(blank.gif)")
					.attr("alt", "")
					.attr("title", "");
}
if ("p" + total != currentLarge) {
jQuery('#clickLeft')		.css("backgroundImage", "url(previous.gif)")
					.attr("alt", "Previous")
					.attr("title", "Previous");
htmlStr = jQuery('#innerContainer li.'+currentLarge).next('li').html();
jQuery('#fullSize')		.fadeOut(600, function(){playDiv(htmlStr)});
}
if ("p"+(total) == currentLarge) {
jQuery('#clickLeft')		.css("backgroundImage", "url(blank.gif)")
					.attr("alt", "")
					.attr("title", "");
jQuery('#clickRight')	.css("backgroundImage", "url(next.gif)")
					.attr("alt", "Next")
					.attr("title", "Next");
htmlStr = jQuery('#innerContainer li.p1').html();
jQuery('#fullSize')		.fadeOut(600, function(){playDiv(htmlStr)});
}
timer = setTimeout ("autoPlay()", showTime);
}


function playDiv (htmlStr) {
jQuery('#fullSize')		.html(htmlStr)
					.fadeIn(600);
currentLarge = jQuery('#fullSize img').attr('class');
currentLarge = currentLarge.substr(1,3);
jQuery('#imageNumber').html('Image ' + currentLarge + ' of ' + total + ' images' );
}

/* ]]> */
