function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  ventana=window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	ventana.focus();
}


function cargar(imagenes) {
	if(!imagenes) 
		return; 

	var image = new Image;
	image.src = imagenes;
}

function carga_thumb(image) {
	if(!image)
		return;

	var new_image = new Image(); 	
	new_image.src = "/imagenesdin/" + image;

	carga_imagen(new_image, true);
	return;
}

function carga_imagen(image, from_thumb) {
	if(!image) 
		return;

	var image_name = archivo(image);
	var image_position = posicion_img(image_name, images);
	var thumbnail;

	if(from_thumb) {
		document.getElementById("main_image").src = "/imagenesdin/" + image_name;
		thumbnail = document.getElementById("thumb" + image_position);	
		
	} 
	else if(image_position > images.length - 2) {
		thumbnail = document.getElementById("thumb0");	
		
		image.src = "/imagenesdin/" + images[0];	
	} 

else {
		thumbnail = document.getElementById("thumb" + eval(image_position+1));	
		image.src = "/imagenesdin/" + images[image_position + 1];
		cargar(images[image_position + 2]);	
	}
}

function archivo(image) {
	var position = image.src.indexOf("9/foto");
	if(position<0)
	{
		position = image.src.indexOf("foto");
	}
	return image.src.substring(position, image.src.length);	
}
function posicion_img(nombre, array) {
	for(var i = 0; i < array.length; i++) {
		if(array[i] == nombre) 
			return i;
	}
}