(function() {

	var jQ = typeof jQuery == 'function';
	
	var box
	var colors = { 'white': '#FFFFFF', 'black': '#000000', 'grey': '#cccccc', 'none': null }
	
	
	function init(  )						
	{
		var c = ( settings.shape != "rounded" ) ? ( ( colors[ settings.color ] != null ) ? colors[ settings.color ] : settings.color ) : null
		var insert = 		'<div id=\"' + settings.name + '\" ' 
							+	( ( settings.classname != null )
							?	'class=\"' + name + '\" '
							:	'style=\"position:absolute; left:0px; top:0px; z-index:10 ' 
								+ 	( ( c != null)
								?	'; background-color:' + c
								:	'' ) ) 
							+	'\">'
							+	'</div>'
								
		this.append( $( insert ) )
		
		box = this.find( '#' +settings.name )
		
		setDimensions.call( this )
		
		if( settings.shape == "rounded" ) 
		{
			settings.name = "rounded"
			box.ikRoundedCorners( settings )
		}
		
		return box
	}

	function setDimensions()						
	{
		box.css(
			{ 
				width		: ( !settings.destination ) ? ( pageDim( 0 ) * settings.scale[ 0 ] ) : parseInt( settings.destination[ 2 ] ), 
				height	: ( !settings.destination ) ?  pageDim( 1 ) * settings.scale[ 1 ] : parseInt( settings.destination[ 3 ] )
			} );
		return box
	}

	function pageDim( dim )						
	{
		return ( ( dim == 0 ) 
				  ? ( ( !jQuery.support.leadingWhitespace ) ? document.body.clientWidth : window.innerWidth ) 
				  : ( ( !jQuery.support.leadingWhitespace ) ? document.body.clientHeight : window.innerHeight ) )
	}
	
	//$( window ).resize( function ()											
	//{   
	//	setDimensions();   
	//});   
	
/*	function build( options )						
	{
		alert()
	}*/
	

	if (jQ)												
	{
	
		jQuery.fn.ikBox = function( options ) 
		{
  			settings = jQuery.extend(
			{
				name:				"straight",
				classname:		null,
				scale:		 		[ 1, 1 ],
				size:		 			null,
     			shape: 				"straight",				// 		rounded
     			color: 				"white",					// 		black, hex
				opacity:				1,
     			global:		 		true
  			}, 
			options);
			
/*			jQuery.box = {
				build : build.call( this, options )
			};			*/

			init.call( this )
			
		
			return this
		};

	}

})();

