ourimagewidth = 0;
ourimageheight = 0;
originalWidth = 0;
originalHeight = 0;
doublepudding = 430;

function _getsizefromDB(widthDB, heightDB){
	
	//alert(thisImg);
	
	originalWidth = widthDB;
	originalHeight = heightDB;
	
	getWindowWidth();
	
	getWindowHeight();
	
	outratio = widthDB/heightDB;
	
	ourimagewidth = stagewidth - doublepudding;
	
	if(ourimagewidth > originalWidth){
		ourimagewidth = originalWidth;
		ourimageheight = originalHeight;
	}
		 	
	ourimageheight = ourimagewidth/widthDB*heightDB;
	
	if(ourimageheight > (stageheight-150)){
		ourimageheight = stageheight-150;
		ourimagewidth = ourimageheight/heightDB*widthDB;
	}
	
	//alert(ourimagewidth);
	

		 
}

function _getsizefromDB_resize(widthDB, heightDB){
	
	//alert();
	
	getWindowWidth();
	
	getWindowHeight();
	
	outratio = widthDB/heightDB;
	
	ourimagewidth = stagewidth - doublepudding;
	
	if(ourimagewidth > originalWidth){
		ourimagewidth = originalWidth;
		ourimageheight = originalHeight;
	}
		 	
	ourimageheight = ourimagewidth/widthDB*heightDB;
	
	if(ourimageheight > (stageheight-150)){
		ourimageheight = stageheight-150;
		ourimagewidth = ourimageheight/heightDB*widthDB;
	}
	
	//alert(ourimagewidth);
		 
}

function getWindowWidth() {
  stagewidth = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
 
function getWindowHeight() {
  stageheight = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}


onresize = function(){
	
	_getsizefromDB_resize(ourimagewidth, ourimageheight);
	
	if(document.getElementById('lightbox-image')){
	document.getElementById('lightbox-image').style.width = ourimagewidth + "px";
	document.getElementById('lightbox-image').style.height = ourimageheight + "px";
	if(document.getElementById('lightbox-container-image-box')){
		document.getElementById('lightbox-container-image-box').style.width = ourimagewidth + "px";
		}
	}
	
}

function showrealresize(){
	
	_getsizefromDB_resize(ourimagewidth, ourimageheight);
	
	if(document.getElementById('lightbox-image')){
	document.getElementById('lightbox-image').style.width = ourimagewidth + "px";
	document.getElementById('lightbox-image').style.height = ourimageheight + "px";
	}
	
}
