//###############################################################################
// minsize(), v1.0.001 2008-04-15
//
// Author:	Scott Park (scott@firefallpro.com)
//
// minsize -- Defines the minimum size of an element for IE 6 or less
//
//	Description: boolean minsize(string id,int width,int height)
//		Accepts the id of an element as the first argument. Accepts the minimum
//		width followed by the minimum height as the second and third argument.
//
//	Notes: This function should only be conditionally called for IE 6 or less,
//		otherwise use CSS to define min-width & min-height. The function must be
//		called after the element is available, or during the onload event.
//
//	Return Values: Returns a boolean true on success or false on failure.
//###############################################################################

function minsize(id,w,h) {
	var element;

	// Validate Input
	if (!id || !w || !h) {
		alert("minsize(): Missing input.");
		return false;
	}

	if (!document.getElementById(id)) {
		alert("minsize(): Can't find element with the ID of \""+id+"\".");
		return false;
	} else {
		element = document.getElementById(id);
	}

	// IE6 detection found at http://www.thefutureoftheweb.com/blog/detect-ie6-in-javascript
	// updated to use <= instead of <, since IE6 updated to using version 5.7
	var IE6 = false /*@cc_on || @_jscript_version <= 5.7 @*/;

	if (IE6) {
		// Width
		if (element.style.width != "100%") element.style.width = "100%";
		if (element.offsetWidth < w) element.style.width = w+"px";

		// Height
		if (element.style.height != "100%") element.style.height = "100%";
		if (element.offsetHeight < h) element.style.height = h+"px";

		// Check When Window Resizes
		window.onresize = function() {
			// Width
			if (element.style.width != "100%") element.style.width = "100%";
			if (element.offsetWidth < w) element.style.width = w+"px";

			// Height
			if (element.style.height != "100%") element.style.height = "100%";
			if (element.offsetHeight < h) element.style.height = h+"px";
		}
	}
	//safari hackery
	else if(/WebKit/i.test(navigator.userAgent)) {
		function forceH() {
			element.style.height = (element.offsetHeight < h) ? h+"px" : "100%";
		}

		forceH();
		window.onresize = forceH;
	}
	//mozilla, etc.
	else {
		element.style.minWidth = w+"px";
		element.style.minHeight = h+"px";
	}

	return true;
}
