var setTOImageOpeners = function() {
	setTimeout( setImageOpeners, 1000 );
}
var setImageOpeners = function() {
	for ( var i=0; i<_arImages.length; i++ ) {
		//Element.clonePosition( $('opener_'+_arImages[i]), $('image_'+_arImages[i]), {setWidth=false, setHeight=false} );
		//alert($('opener_'+_arImages[i]));
		$('opener_'+_arImages[i]).clonePosition( $('image_'+_arImages[i]));
		$('opener_'+_arImages[i]).style.display = 'block';
	}
}
var openImage = function( img, dir ) {
	//window.open('/showImage.cfm?file=' + img + '&dir=' + dir,'sightImage', 'width=100,height=100' );
	window.open('/showImage.cfm?file=' + img.file + '&dir=' + dir,'sightImage', 'width=100,height=100' );
}
var sizeImageWindow = function() {
	var w = $('imageImg').getWidth();	
	var h = $('imageImg').getHeight() + $('imageInfo').getHeight();
	window.ResizeToInner(w,h);
	window.focus();
}
function GetInnerSize () {
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return [x,y];
}

var ResizeToInner = function(w, h, x, y) {
	// make sure we have a final x/y value
	// pick one or the other windows value, not both
	if (x==undefined) x = window.screenLeft || window.screenX;
	if (y==undefined) y = window.screenTop || window.screenY;
	// for now, move the window to the top left
	// then resize to the maximum viewable dimension possible
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
	// now that we have set the browser to it's biggest possible size
	// get the inner dimensions.  the offset is the difference.
	var inner = GetInnerSize();
	var ox = screen.availWidth-inner[0];
	var oy = screen.availHeight-inner[1];
	// now that we have an offset value, size the browser
	// and position it
	window.resizeTo(w+ox, h+oy);
	window.moveTo(x,y);
}
