////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// COPYRIGHT NOTICE /
// Copyright 2010 MLS EARTHview, LLC, All Rights Reserved. /
// /
// This software is the property of MLS EARTHview, LLC. and may NOT be /
// copied, reused, modified, backed up, executed, moved or ANYTHING else /
// without the express written consent of MLS EARTHview, LLC. /
//For more information contact: MLS EARTHview, LLC   254-449-7255 /
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


var ie = document.all?true:false;
var fullwd = 0;
var fullht = 0;
var bdywd = 0;
var bdyht = 0;

function centerPage(horiz, vert)
	{
	var mrgn = 30; // Desired minimum margin
	var crns = 12; // Approximate width of DIVs added by curvyCorners 
	var tabOffset = 20; // Desired offset from the right corner of the body frame

        var bodyDv = document.getElementById("bodyFrame");

	if (ie)
		{
		fullwd = document.body.clientWidth;
		fullht = document.body.clientHeight;
		}
	else
		{
		fullwd = window.innerWidth;
		fullht = window.innerHeight;
		}

	if (bodyDv.scrollWidth > 0 || bodyDv.offsetWidth > 0)
		{
		if (ie)
			{
			bdywd = bodyDv.scrollWidth;
			bdyht = bodyDv.scrollHeight;
			}
		else
			{
			bdywd = bodyDv.offsetWidth;
			bdyht = bodyDv.offsetHeight;
			}
		}
	else
		{
		bdywd = fullwd - (mrgn * 2) - (crns * 2);
		bdyht = fullht - (mrgn * 2) - (crns * 2);
		bodyDv.style.width = bdywd + "px"; 
		}

	lft = ((fullwd - bdywd) / 2);
	bodyDv.style.left = lft + "px"; 

	tp = mrgn + (crns * 2);
	bodyDv.style.top = tp + "px";



	// Draw tabs
	var tabWd = new Array();
	var tabHt = new Array();
	lastTab = tabArray.length - 1;

/*	i = 0;
	for (i; i <= lastTab; i++)
		{
		tID = tabArray[i];
		tab = document.getElementById(tID);
		if (tab.innerHTML.indexOf("Google Streetview") > 0)
			{
			if (!panoramaSet)
				{tabArray.splice(i, 1); lastTab = lastTab - 1;}
			}
		}
*/
	i = 0;
	for (i; i <= lastTab; i++)
		{
		tID = tabArray[i];
		tab = document.getElementById(tID);

		if (ie)
			{
			tabWd[i] = tab.scrollWidth;
			tabHt[i] = tab.scrollHeight;
			}
		else
			{
			tabWd[i] = tab.offsetWidth;
			tabHt[i] = tab.offsetHeight;
			}
		}

	lastTabLeft = lft + bdywd - tabWd[lastTab] - tabOffset;
	lastLeft = lastTabLeft;
	i = tabArray.length - 1;
	j = 0;
	for (i; i >= j; i--)
		{
		if (i == lastTab)
			{
			tabLeft = lastTabLeft;
			}
		else
			{
			if (ie)	{tabLeft = lastLeft - tabWd[i] - 2;} // Remove extra space added by IE
			else	{tabLeft = lastLeft - tabWd[i] + 1;}
			}

		if (ie)	{tabTop = tp - (tabHt[i] * 1.5) - 8;} // Remove extra space added by IE
		else	{tabTop = tp - (tabHt[i] * 1.5);}

		lastLeft = tabLeft;

		tID = tabArray[i];
		tab = document.getElementById(tID);
		tab.style.left = tabLeft + "px";
		tab.style.top  = tabTop + "px";
		}


	bodyDv.style.visibility = "visible";

	lastTab = tabArray.length - 1;
	i = 0;
	for (i; i <= lastTab; i++)
		{
		tID = tabArray[i];
		tab = document.getElementById(tID);
		tab.style.visibility = "visible";
		}
	}


function roundCrnrs()
	{
	bodyFrameSettings = 
	  {
	   tl: { radius: 12 },
	   tr: { radius: 12 },
	   bl: { radius: 12 },
	   br: { radius: 12 },
	   antiAlias: true,
	   autoPad: true
	  };

	var bodyFrameObj = new curvyCorners(bodyFrameSettings, "bodyFrameClass");
	bodyFrameObj.applyCornersToAll();


	bodyElmntSettings = 
	  {
	   tl: { radius: 12 },
	   tr: { radius: 12 },
	   bl: { radius: 12 },
	   br: { radius: 12 },
	   antiAlias: true,
	   autoPad: true
	  };

	var bodyElmntObj = new curvyCorners(bodyElmntSettings, "bodyElmntClass");
	bodyElmntObj.applyCornersToAll();


	tabSettings = 
	  {
	   tl: { radius: 8 },
	   tr: { radius: 8 },
	   bl: { radius: 8 },
	   br: { radius: 8 },
	   antiAlias: true,
	   autoPad:true
	  };

	 var tabCrnrsObj = new curvyCorners(tabSettings, "tabCrnrsClass");
	 tabCrnrsObj.applyCornersToAll();


	boxSettings = 
	  {
	   tl: { radius: 5 },
	   tr: { radius: 5 },
	   bl: { radius: 5 },
	   br: { radius: 5 },
	   antiAlias: true,
	   autoPad:true
	  };

	 var boxCrnrsObj = new curvyCorners(boxSettings, "boxCrnrsClass");
	 boxCrnrsObj.applyCornersToAll();
	}


