function getWidthAndHeight() {

   //alert("'" + this.name + "' is " + this.width + " by " + this.height + " pixels in size.");
   
	//var imgW = document.getElementById("ImageWName")
	//if(this.width >300 ) {
	//	this.image.style.width = 300;
   // }
   // else
	//	this.image.style.width = this.width;
			
	var imgW = document.getElementsByName("PictureWidth")[0];	
	if(this.width >=this.height)
	{
		if(this.width > imgW.value) 
		{		
			this.image.style.width = imgW.value;
			this.image.style.height = this.height * imgW.value / this.width ;
			//	alert(this.image.style.width);
		}		
	}
	else
	{
		if(this.height > imgW.value)
		{
			this.image.style.width = this.width * imgW.value / this.height ;
			this.image.style.height = imgW.value;			
		}
	}
  
    this.image.style.display = "";   
    return true;
}
function loadFailure() {
    //alert("'" + this.name + "' failed to load.");
    return true;
}

function LoadImages() {
	
	var images = document.getElementsByTagName("img");
	for(var i =0; i<images.length; i++){
		var imagesname = document.getElementsByName("PICR")[i];
					if(imagesname)
					{
					imagesname.style.display = "none";
					}	
	}
	
	for(var i =0; i<images.length; i++) {
		var image = images[i];
		var toResize = false;			
		if(image.attributes && image.attributes.getNamedItem("resize") && image.attributes.getNamedItem("resize").value == "true") {
			toResize = true;
		}
		if(toResize) {
			
			var myImage = new Image();
						
			myImage.image = image;			
			myImage.onload = getWidthAndHeight;
			//alert(getWidthAndHeight);
			myImage.onerror = loadFailure;
			//myImage.scr = "http://localhost/Amber/Design/DesktopLayouts/Amber/images/logo.gif";
			myImage.src = image.src;
		}
	}
}

window.onload = function(){LoadImages();}
