var mikekipling = {baseURL:"http://www.mikekiplingstockphotos.co.uk/ci",viewport : {width:0, height:0 }, get : {}, wait : {}};

mikekipling.get.viewportdimensions = function () 
{
	if (typeof window.innerWidth !== 'undefined')
	{
	  mikekipling.viewport.width = window.innerWidth; mikekipling.viewport.height = window.innerHeight;
	}
	else if (typeof (document.documentElement) !== 'undefined' && typeof (document.documentElement.clientWidth) !== 'undefined' && document.documentElement.clientWidth !== 0)
	{
		mikekipling.viewport.width = document.documentElement.clientWidth; mikekipling.viewport.height = document.documentElement.clientHeight;
	}
	return mikekipling.viewport;
};

mikekipling.centrify = function (o)
{
	var vp = mikekipling.get.viewportdimensions();
	o.left = (vp.width/2) - (o.width/2);
	o.top = (vp.height/2) - (o.height/2); 
	return (o);
};


mikekipling.wait.loading = function ()
{
	var vp = mikekipling.get.viewportdimensions();
	var container = mikekipling.centrify({height : 50, width: 50, left: 0, top: 0});
	var html = "";

 	if (! document.getElementById("spinner"))
	{
		html = "<div id='spinner' style='width:"+vp.width+"px; height:"+vp.height+"px; background-color: white;'>";
		html += "<div style='position: absolute; z-index: 500; width:100px; height:100px; top:"+container.top+"px; left:"+container.left+"px; color: white; font-size:40px;'>";
		html += "<img style='width:50px; height:50px;' src='"+mikekipling.baseURL+"/loading.gif'/>";
		html += "</div>";		
		html += "</div>";		
		$("body").css("overflow","hidden").append(html);	
	}
};
