

//-------------------------------------------------------------------
//	Función que trata el tag <a></a> para redimensionar la ventana
//-------------------------------------------------------------------

function TratamientoTagA(){
	var obj=document.getElementsByTagName("a");
	for(i=0;i<obj.length;i++){
		if (obj[i].getAttribute("target") == '_self' || obj[i].getAttribute("target") == '') 
			obj[i].onclick = Resize;
	}
}		

//-------------------------------------------------------------------
//	Función redimensión del iframe
//-------------------------------------------------------------------

function Resize() {
	var oFrame = eval("parent.document.all.ifrContenido");
	oFrame.style.height = screen.availHeight - 225;

}

//-------------------------------------------------------------------
//	Función tratamiento tag <image>
//-------------------------------------------------------------------	
	
function TratamientoTagImg(Width,Height){		
	var iWidth, iHeight
	var dimensiones, dimAux
	var objImg=document.getElementsByTagName("img");
	var Indice_Img	
	
	for(i=0;i<objImg.length;i++){
		Indice_Img = objImg.item(i);
		if (Indice_Img.getAttribute("src") != null) 
		{
			if (Indice_Img.getAttribute("src").indexOf("aspVerArchivoBinary")!= -1 )
			{
				iWidth = Indice_Img.getAttribute("Width");
				iHeight = Indice_Img.getAttribute("Height");		
				dimension = ValidarSize(iWidth,iHeight,Width,Height);
				dimAux = dimension.split("¬");
				Indice_Img.style.width=dimAux[0];
				Indice_Img.style.height=dimAux[1];												
			}
		}
	}
}	

function TratamientoTagImgProporcionado(){	
//sacanos las dimensiones reales de la imagen, y las maximas, y proporcionamos, cambiando 
//solo el ancho con el maximo si el ancho pasa del maximo
	var iWidth, iHeight
	var dimensiones, dimAux
	var objImg=document.getElementsByTagName("img");
	var Indice_Img
		
	for(i=0;i<objImg.length;i++)
	{
		Indice_Img = objImg.item(i);
		if (Indice_Img.getAttribute("name") != null)
		{
			if (Indice_Img.getAttribute("name").indexOf("BBDD")!= -1 )
			{
				iWidth = Indice_Img.getAttribute("Width");
				iHeight = Indice_Img.getAttribute("Height");	
						
				MiWidth = Indice_Img.getAttribute("MiWidth");
				MiHeight = Indice_Img.getAttribute("MiHeight");
					
				dimension = ProporcionarAlto(iWidth,iHeight,MiWidth,MiHeight);
				dimAux = dimension.split("¬");
					
				Indice_Img.style.width=dimAux[0];
				Indice_Img.style.height=dimAux[1];	
			}	
				
		}		
	}	
}	
			
//-------------------------------------------------------------------
//	Función que redimiensiona el alto de la imagen 
//-------------------------------------------------------------------			

function  ProporcionarAlto(iWidth,iHeight,MiWidth,MiHeight){
	var blnRedimensiona; 
	
					
	
	//Inicializmos redimensionar a false
	blnRedimensiona = false;
			
	//Validamos los tamaños de la imagen insertada para proceder a redimensionar
	if (iWidth > MiWidth) {
		blnRedimensiona = true;
		}
	
			
	//Si la imagen introducida no está redimensionada modificaremos su altura y anchura
	if (blnRedimensiona){
		iHeight=parseInt(iHeight*MiWidth/iWidth);
		iWidth=MiWidth;
	}
	
	return iWidth+"¬"+iHeight;
}



			
//-------------------------------------------------------------------
//	Función que valida el tamaño de la imagen y la redimensiona
//-------------------------------------------------------------------			

function  ValidarSize(iWidth,iHeight,Width,Height){
	var blnRedimensiona 
	var RestaWidth, RestaHeight	
					
	//Inicializamos variables a 0 para la resta
	RestaWidth = 0
	RestaHeight = 0
	//Inicializmos redimensionar a false
	blnRedimensiona = false
			
	//Validamos los tamaños de la imagen insertada para proceder a redimensionar
	if (iWidth > Width) {
		blnRedimensiona = true
		//RestaWidth = iWidth - Width
		RestaWidth = iWidth / Width
	}
	if (iHeight > Height){
		blnRedimensiona = true
		//RestaHeight = iHeight -Height
		RestaHeight = iHeight / Height
	}
			
	//Si la imagen introducida no está redimensionada modificaremos su altura y anchura
	if (blnRedimensiona){
		if (RestaWidth > RestaHeight) Height = parseInt(iHeight/RestaWidth)
		if (RestaWidth == RestaHeight) Height = parseInt(iHeight/RestaWidth)
		if (RestaWidth < RestaHeight) Width =parseInt(iWidth/RestaHeight)

	}else{
		if (!blnRedimensiona){
			Height = iHeight
			Width = iWidth 
		}
	}
	return Width+"¬"+Height
}

