/**
 * The WhiteLevelPage class
 * This is the representation of the browser and all his variables
 *
 * @package		WhiteLevel
 * @version		1.1.0
 * @autor		mathias puerro (mathias@whitelevel.ch)
 */
var WhiteLevelPage = {}
{
	/** Start with the WhiteLevelPage.Window part **/
	WhiteLevelPage.Window = {}
	/** Method to get the height of the window **/
	WhiteLevelPage.Window.Height = function() {
		return $(document).height();
		if( self.innerHeight ) return self.innerHeight;									// all except Explorer
		else if( document.documentElement && document.documentElement.clientHeight )
			return document.documentElement.clientHeight;								// Explorer 6 Strict Mode
		else if( document.body ) return document.body.clientHeight;						// other Explorers
	}
	/** Method to get the width of the window **/
	WhiteLevelPage.Window.Width = function() {
		if( self.innerHeight ) return self.innerWidth;									// all except Explorer
		else if( document.documentElement && document.documentElement.clientWidth )
			return document.documentElement.clientWidth;								// Explorer 6 Strict Mode
		else if( document.body ) return document.body.clientWidth;						// other Explorers
	}
	/** Set the new scroll position **/
	WhiteLevelPage.Window.ScrollTo = function( top, left ) { window.scrollBy( left, top ); }
	/** Start with the WhiteLevelPage.Window.Event part **/
	WhiteLevelPage.Window.Event = {}
	/** Add the onscroll event to the page **/
	WhiteLevelPage.Window.Event.OnScroll = function( func ) { window.onscroll = func; }
	/** Add the onload event to the page **/
	WhiteLevelPage.Window.Event.OnLoad = function( func ) { window.onload = func; }
	/** Add the onresize event to the page **/
	WhiteLevelPage.Window.Event.OnResize = function( func ) { window.onresize = func; }

	/** Start with the WhiteLevelPage.Body part **/
	WhiteLevelPage.Body = {}
	/** Method to get the height of the complete body **/
	WhiteLevelPage.Body.Height = function() {
		if( document.body.scrollHeight ) return document.body.scrollHeight;				// Explorer 6 Strict Mode
		else if( document.body.offsetHeight ) return document.body.offsetHeight;		// other Browsers
	}
	/** Method to get the width of the complete body **/
	WhiteLevelPage.Body.Width = function() {
		if( document.body.scrollWidth ) return document.body.scrollWidth;				// Explorer 6 Strict Mode
		else if( document.body.offsetWidth ) return document.body.offsetWidth;			// other Browsers
	}

	/** Start with the WhiteLevelPage.Body.Scroll part **/
	WhiteLevelPage.Body.Scroll = {}
	/** Method to read the top scroll position **/
	WhiteLevelPage.Body.Scroll.Top = function() { return $(window).scrollTop(); }
	/** Method to read the left scroll position **/
	WhiteLevelPage.Body.Scroll.Left = function() { return document.body.scrollLeft; }
	/** Method to show the scroll bar (if needed) **/
	WhiteLevelPage.Body.Scroll.Show = function() { document.body.style.overflow='auto'; }
	/** Method to hide the scroll bar **/
	WhiteLevelPage.Body.Scroll.Hide = function() { $( document.body ).css( 'overflow', 'hidden' ); }
	
	/** Start with the WhiteLevelPage.Browser part **/
	WhiteLevelPage.Browser = {}
	/** Method to check if the browser is msie6 **/
	WhiteLevelPage.Browser.IE6 = function() { return ( $.browser.msie && parseFloat( $.browser.version )<7 ) ? true : false; }
}

/**
 * The WhiteLevelImage class
 * This is the representation of an image
 *
 * @package		WhiteLevel
 * @version		1.0
 * @autor		mathias puerro (mathias@whitelevel.ch)
 */
function WhiteLevelImage( image ) {
	var _image = new Image();
	_image.src = image;
	var _width = null;
	var _height = null;
	
	/** Method to set/get the source of this image **/
	this.getSource = function() { return _image.src; }
	
	/** Method to set/get the width of this image **/
	this.setWidth = function( width ) { _image.width = width; }
	this.getWidth = function() { return _image.width; }
	
	/** Method to set/get the height of this image **/
	this.setHeight = function( height ) { _image.height = height; }
	this.getHeight = function() { return _image.height; }
	
	/** Method to get the image **/
	this.getImage = function() { return '<img src="' + this.getSource() + '" height="' + this.getHeight() + '" width="' + this.getWidth() + '" />'; }
	
	/** Method to (pre)load this image **/
	this.load = function( callback ) {
		/*if( this.isLoaded() ) { callback; }
		else { setTimeout( load( callback ), 50 ); }*/
		//else { setTimeout( callback, 50 ); }
		//else { $.get( this.getSource(), callback ); }
		$.get( this.getSource(), callback );
	}
	/** Method to check if this image is loaded or not **/
	this.isLoaded = function() { return _image.complete; }
}

