var theImg, wMax, hMax, wFinal, hFinal;

function ZoomOut() {
	var NewWidth, NewHeight;
	
	NewWidth = theImg.width - 10;
	if (NewWidth >= wFinal) {
		theImg.width = NewWidth;
	} else {
		theImg.width = wFinal;
	}
	
	NewHeight = theImg.height - 10;
	if (NewHeight >= hFinal) {
		theImg.height = NewHeight;
	} else {
		theImg.height = hFinal;
	}
	
	if (theImg.width > wFinal || theImg.height > hFinal) {
		setTimeout('ZoomOut()', 10);
	}
}

function ZoomIn() {
	var NewWidth, NewHeight;
	
	NewWidth = theImg.width + 10;
	if (NewWidth <= wMax) {
		theImg.width = NewWidth;
	} else {
		theImg.width = wMax;
	}
	
	NewHeight = theImg.height + 10;
	if (NewHeight <= hMax) {
		theImg.height = NewHeight;
	} else {
		theImg.height = hMax;
	}
	
	if (theImg.width < wMax || theImg.height < hMax) {
		setTimeout('ZoomIn()', 10);
	} else {
		ZoomOut();
	}
}

function ZoomImg(idImg, widthMax, heightMax, widthFinal, heightFinal) {
	// get the img object
	theImg = MM_findObj(idImg);
	theImg.width = 1;
	theImg.height = 1;
	// Make the parameters global vars
	wMax = widthMax;
	hMax = heightMax;
	wFinal = widthFinal;
	hFinal = heightFinal;
	// Start the zooming
	ZoomIn();
}

function ZoomOut2() {
	var NewWidth, NewHeight;
	
	NewWidth = theImg.width - 10;
	if (NewWidth >= wFinal) {
		theImg.width = NewWidth;
	} else {
		theImg.width = wFinal;
	}
	
	NewHeight = theImg.height - 10;
	if (NewHeight >= hFinal) {
		theImg.height = NewHeight;
	} else {
		theImg.height = hFinal;
	}
	
	if (theImg.width > wFinal || theImg.height > hFinal) {
		setTimeout('ZoomOut2()', theDelay);
	}
	
	if (theImg.height == hFinal && theImg.width == wFinal && OnDone != '')
		eval(OnDone);
	
}

function ZoomIn2() {
	var NewWidth, NewHeight;
	
	NewWidth = theImg.width + 10;
	if (NewWidth <= wMax) {
		theImg.width = NewWidth;
	} else {
		theImg.width = wMax;
	}
	
	NewHeight = theImg.height + 10;
	if (NewHeight <= hMax) {
		theImg.height = NewHeight;
	} else {
		theImg.height = hMax;
	}
	
	if (theImg.width < wMax || theImg.height < hMax) {
		setTimeout('ZoomIn2()', theDelay);
	} else {
		ZoomOut2();
	}
	
	if (theImg.height == hFinal && theImg.width == wFinal)
		eval(OnDone);
	
}

function ZoomImg2(idImg, delay, widthStart, heightStart, widthMax, heightMax, widthFinal, heightFinal, Done) {
	// Make the parameters global vars
	theDelay = delay;
	wMax = widthMax;
	hMax = heightMax;
	wFinal = widthFinal;
	hFinal = heightFinal;
	// get the img object
	theImg = MM_findObj(idImg);
	theImg.width = widthStart;
	theImg.height = heightStart;
	theImg.style.display = '';
	OnDone = Done;
	// Start the zooming
	ZoomIn2();
}

var ToggleNotice = function(idNotice, CollapsedHeight, ExpandedHeight){
	var objNotice = document.getElementById(idNotice);
	var NoticeHeight;
	
	if (objNotice) {
		NoticeHeight = parseInt(objNotice.style.height);
		if (NoticeHeight > CollapsedHeight) {
			objNotice.scrollTop = 0;
			objNotice.style.height = CollapsedHeight + 'px';
			objNotice.style.overflow = 'hidden';
		} else {
			objNotice.style.height = ExpandedHeight + 'px';
			objNotice.style.overflow = 'auto';
		}
	}
}

var ItemDetailWindowOnHide = function(){
	// Destroy the window
	ColdFusion.Window.destroy('ItemDetailWindow', true);
}

// Handle a click on an Edit order button/link
var ItemDetail = function(EquipID){
	ColdFusion.Window.create('ItemDetailWindow', 'Equipment Detail - NLEQ ID ' + EquipID, 
		'item_detail.cfm?equip_id=' + EquipID,
		{x:100,y:100,height:750,width:750,modal:true,closable:true,
		draggable:true,resizable:true,center:true,initshow:true,
		refreshonshow:true,bodystyle:'color:#000000; background-color:#b8c7e6; padding: 5px;'});
	document.getElementById('ItemDetailWindow_title').className = 'cfWindowTitleBar';
	ColdFusion.Window.onHide('ItemDetailWindow', ItemDetailWindowOnHide);
}


