/* <img src="img/fot/fot_004.jpg" style="cursor:pointer;" onMouseUp="CCGimg(this,ancho,alto);" alt="Pulse sobre la imagen para ampliarla" /> */
/* Si no se ponen las dimensiones se cogen las de defecto */

function CCGimg(archivoObj,posV,ancho,alto){
	archivo = CCGimgBig(archivoObj)

	myTop = 340	    //altura desde la parte superior de la página
	myCenter = 0  //desplazamiento respecto al centro, puede ser negativo -150 pe
	defaultW = 500 //tamaño por defecto de la imagen si no se dice nada
	defaultH = 400
	
	if (alto == undefined)  { alto = defaultH; }
	if (ancho == undefined) { ancho = defaultW; }
	if (posV == undefined)  { posV = myTop; }

	xWidth ('CCGimg',ancho + 30)
	xHeight ('CCGimg',alto + 35)
	xWidth ('CCGimgContent',ancho)
	xHeight ('CCGimgContent',alto)
	//xWidth ('CCGimgContentimg',ancho)
	//xHeight ('CCGimgContentimg',alto)
	xWidth ('cerrarCCGimg',ancho)
	
	//xInnerHtml('CCGimgContentimg','<img src="' + archivo + '" style="border:0px;margin-top:-100px;" />')	
	xBackground('CCGimgContent',null,archivo)
		
	pos_left = parseInt((xClientWidth()-ancho+3)/2) + myCenter
	

	//pos_top = xScrollTop() + parseInt((xClientHeight()-alto-300)/2)
	pos_top = posV - parseInt(alto / 2)
	//alert (pos_top)
	
	//if (pos_top>150) pos_top = 150
	if (pos_top < 20) pos_top = 20
	
	xMoveTo('CCGimg',pos_left,pos_top)
	setTimeout("xShow('CCGimg')",50)
}

function CCGimgBig (mi_imagen) {
	//pone _big al final delnombre del archivo
	imageSrc  = mi_imagen.src;
	imagePath = imageSrc.substring(0,imageSrc.lastIndexOf('/'));
	imageName = imageSrc.substring(imageSrc.lastIndexOf('/')+1,imageSrc.length);
	imageOnlyName = imageName.substring(0,imageName.lastIndexOf('.'));
	
	//elimina los underscores del final
	imageOnlyName = stripTrailing(imageOnlyName,'_');
	
	return (imagePath + '/' + imageOnlyName + '_big.jpg');
}

function CCGimgClose(){	xHide('CCGimg'); }


function stripLeading(string,chr) {
   var finished = false;
   for (var i = 0; i < string.length && !finished; i++)
       if (string.substring(i,i+1) != chr) finished = true;
   if (finished) return string.substring(i-1); else return string;
}

function stripTrailing(string,chr) {
   var finished = false;
   for (var i = string.length - 1; i > -1 && !finished; i--)
       if (string.substring(i,i+1) != chr) finished = true;
   if (finished) return string.substring(0,i+2); else return string;
}

function stripLeadingTrailing(string,chr) {
    return stripTrailing(stripLeading(string,chr),chr)
}

