/*  Default, version 0.0.2 003
 *  (c) 2007 Unknow Developers
 *
 *  For details, try your knowledge.
 *
 *--------------------------------------------------------------------------*/
if (!Prototype) throw('Need prototype...'); else
if (parseFloat(Prototype.Version.substr(0,3)) < 1.6) throw('Wrong version of prototype...');


/* Window */
Object.extend(window, {
	
	setResolution: function (element, minWidth, minHeight) {
		element = $(element);
		var minWidthBrowser, minHeightBrowser;

		if (element != null){
			// IE ou  FIREFOX
			if (Prototype.Browser.IE || Prototype.Browser.Gecko){
				minWidthBrowser = this.getDimensions().windowWidth;
				minHeightBrowser = this.getDimensions().windowHeight;
			}
			//alert()
	
			if (minWidthBrowser <= minWidth)
				element.width = minWidth;
			else
				element.width = '100%';
	
			if (minHeightBrowser <= minHeight)
				element.height = minHeight;
			else
				element.height = '100%';
		}
	},

	getDimensions: function () {
		var body = document.body,
			docElement = document.documentElement,
			xScroll, yScroll, windowWidth, windowHeight;

		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		}
		else if (body.scrollHeight > body.offsetHeight){ // all but Explorer Mac
			xScroll = body.scrollWidth;
			yScroll = body.scrollHeight;
		}
		else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = body.offsetWidth;
			yScroll = body.offsetHeight;
		}

		if (self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		}
		else if (docElement && docElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = docElement.clientWidth;
			windowHeight = docElement.clientHeight;
		}
		else if (body) { // other Explorers
			windowWidth = body.clientWidth;
			windowHeight = body.clientHeight;
		}

		// for small pages with total height less then height of the viewport
		if (yScroll < windowHeight)
			pageHeight = windowHeight;
		else
			pageHeight = yScroll;
	
		// for small pages with total width less then width of the viewport
		if (xScroll < windowWidth)
			pageWidth = windowWidth;
		else
			pageWidth = xScroll;

		return {
			pageWidth: pageWidth,
			pageHeight: pageHeight,
			windowWidth: windowWidth,
			windowHeight: windowHeight
		};
	}
});