﻿
var sLogoImageID;

function ShowLOGO(targetSrc, targetImageID){
//debugger;
    sLogoImageID = targetImageID;
	var targetPic = targetSrc;
	aIamge = null;
	aImage = new Image();
	aImage.src=targetPic;
	WaitLogo(aImage);
}


function WaitLogo(aImage){
	if(aImage.complete){
		SetLogo(aImage);
	}else{
		setTimeout("WaitLogo(aImage);",1000);
	}
}

function SetLogo(aImage){
    var intMaxWidth;
    var intMaxHeight;
    intMaxWidth = 250;
    intMaxHeight = 80
    intMaxScale = intMaxHeight / intMaxWidth;

	if(!aImage.complete){
		WaitLogo(aImage);
	}
	
	intWidth = aImage.width;
	intHeight = aImage.height;
	intImageScale = intHeight / intWidth;
	if ( intWidth < intMaxWidth && intHeight < intMaxHeight )
	{
	    //do nothing
	}
	else if ( intImageScale > intMaxScale )
	{
	    document.getElementById(sLogoImageID).height = intMaxHeight;
	}
	else
	{
	    document.getElementById(sLogoImageID).width = intMaxWidth;
	}
	
	document.getElementById(sLogoImageID).src = aImage.src;
}




//---------------------------------------------------------------------------------

function AdjImageSize2(aImage, targetImageID, iWidth, iHeight){
    var intMaxWidth;
    var intMaxHeight;
    intMaxWidth = iWidth;
    intMaxHeight = iHeight;
    intMaxScale = intMaxHeight / intMaxWidth;

	if(!aImage.complete || document.getElementById(targetImageID).src == aImage.src){
		return;
	}
	
	intWidth = aImage.width;
	intHeight = aImage.height;
	intImageScale = intHeight / intWidth;
	if ( intWidth < intMaxWidth && intHeight < intMaxHeight )
	{
	    //do nothing
	}
	else if ( intImageScale > intMaxScale )
	{
	    document.getElementById(targetImageID).height = intMaxHeight;
	}
	else
	{
	    document.getElementById(targetImageID).width = intMaxWidth;
	}
	
	document.getElementById(targetImageID).src = aImage.src;
	document.getElementById(targetImageID).style.display = "block";
}


function AdjImageSize(aImage, targetImageID, iWidth, iHeight){
    var intMaxWidth;
    var intMaxHeight;
    intMaxWidth = iWidth;
    intMaxHeight = iHeight;
    intMaxScale = intMaxHeight / intMaxWidth;

	if(!aImage.complete || document.getElementById("LOADED_" + targetImageID).value == "Y"){
		return;
	}
	
	intWidth = aImage.width;
	intHeight = aImage.height;
	intImageScale = intHeight / intWidth;
	if ( intWidth < intMaxWidth && intHeight < intMaxHeight )
	{
	    //do nothing
	}
	else if ( intImageScale > intMaxScale )
	{
	    document.getElementById(targetImageID).height = intMaxHeight;
	}
	else
	{
	    document.getElementById(targetImageID).width = intMaxWidth;
	}
	
	//document.getElementById(targetImageID).src = aImage.src;
	document.getElementById(targetImageID).style.display = "block";
	document.getElementById("LOADED_" + targetImageID).value = "Y";
}

