// this file gets client computer properties

//  This code creates HTML5 elements.  It is implemented on scourcing
document.createElement( 'header' );
document.createElement( 'hgroup' );
document.createElement( 'nav' );
document.createElement( 'section' );
document.createElement( 'article' );
document.createElement( 'footer' );
document.createElement( 'aside' );

//  This code determines the browser width and height. It is implemented on scourcing
var bwsrWidth = 0, bwsrHght = 0;
function getBwsrDim()
{
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
		bwsrWidth = window.innerWidth;
		bwsrHght = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		bwsrWidth = document.documentElement.clientWidth;
		bwsrHght = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		bwsrWidth = document.body.clientWidth;
		bwsrHght = document.body.clientHeight;
	}
	console.log( 'bwsrDim: ' + bwsrWidth + ' x ' + bwsrHght );
}

// takes an image and an array of div dimensions and calculates the width and height of the image that will fit and center it in the div
function calcImg(img, imgDim, divDim)
{
	imgDim[2] = imgDim[4];
	imgDim[3] = imgDim[5];
	
	if ( ( imgDim[2] / divDim[2] ) < ( imgDim[3] / divDim[3] ) && ( imgDim[2] >= divDim[2] )  )
	{
		imgDim[3] = imgDim[3] * ( divDim[2] / imgDim[2] );
		imgDim[2] = divDim[2];
		img[0] = -( imgDim[2] - divDim[2] ) / 2;
		img[1] = -( imgDim[3] - divDim[3] );
		console.log( '&1' );
	}
	else if ( ( imgDim[2] / divDim[2] ) > ( imgDim[3] / divDim[3] ) && ( imgDim[3] >= divDim[3] )  )
	{
		imgDim[2] = imgDim[2] * ( divDim[3] / imgDim[3] );
		imgDim[3] = divDim[3];
		img[0] = -( imgDim[2] - divDim[2] ) / 2;
		img[1] = -( imgDim[3] - divDim[3] );
		console.log( '&2' );
	}	
}


