function changeOpac(opacity, id) 
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}   

//function fnTrapKP(btnName,divSearchSuggestionName)
//{
//	var btn = document.getElementById(btnName);
//	if (event.keyCode == 13)
//	{
//	    event.returnValue=false;
//	    event.cancelBubble = true;
//	    btn.click();
//	}
//}

function getStyle(el,styleProp)
{
	if (el.currentStyle)
		var y = el.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
	return y;
}

// Scale the image to the closest parent
//  Call: Scale(this) from event
function ScaleImageToParent(img)
{
    var Parent = img.parentElement;
    
    // Search for applicable parent to size to
    while(Parent != null)
    {
        // If table cell or div block...
        if(Parent.tagName == "TD" || Parent.tagName == "DIV")
        {
            // Check height
		    var height = 0;
		    if(isNaN(parseInt(Parent.style.height)) == false)
		        height = parseInt(Parent.style.height);
		    else if(isNaN(parseInt(Parent.height)) == false)
		        height = parseInt(Parent.height);
		    else if(isNaN(parseInt(getStyle(Parent, "height"))) == false)
		        height = parseInt(getStyle(Parent, "height"));
		        
		    if(height > 0 && parseInt(img.height) > height)
		        img.height = height;
		        
		    // Check width
		    var width = 0;
		    if(isNaN(parseInt(Parent.style.width)) == false)
		        width = parseInt(Parent.style.width);
		    else if(isNaN(parseInt(Parent.width)) == false)
		        width = parseInt(Parent.width);
		    else if(isNaN(parseInt(getStyle(Parent, "width"))) == false)
		        width = parseInt(getStyle(Parent, "width"));
		    		        
		    if(width > 0 && parseInt(img.width) > width)
		        img.width = width;
		        
		    // Leave
			break;
		}

		Parent = Parent.parentElement;
	}
}

function PopupImage(image){
  cuteLittleWindow = window.open('', "Image", "location=0,status=0,scrollbars=auto");
  cuteLittleWindow.document.write('<div style="position: absolute; width: 100%; height: 100%; z-index: 1; left:0px; top:0px"><table cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td align="center"><img id="IMG" onload="window.resizeTo(this.width+10,this.height+30);" src="'+image+'"></td></tr></table></div>');
}

