function getObject(objectName)
{	
  var objItem;
  
  if (document.all)
    objItem = document.all[objectName];
  else
  {
    objItem = document.getElementById(objectName);
    if (objItem==null)
      objItem= document.getElementsByName(objectName)[0];
    if (document.getElementsByName(objectName).length>1)
      objItem=document.getElementsByName(objectName);	
  }
  if(objItem == null) return false;
  return objItem;
}

function getName (object)
{
  return (object.name) ? object.name : object.id;
}


function popup(newURL, newName, newFeatures, orgName) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null) // if something went wrong
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}



function get_fullscreen()
{
	var fs = new Object;
	
	fullscreen_obj = getObject("fullscreen");
	content_obj = getObject("content");
	//Setup max and min widths
	
	fs.max_w = 1008;
	fs.min_w = 784;
	fs.differential_w = 0;
	
	fs.full_w = fullscreen_obj.offsetWidth;
	
	if(fs.full_w > fs.max_w)
	{
		fs.use_w = fs.max_w;
		fs.differential_w = fs.full_w - fs.max_w;
	}
	else
	{
		fs.use_w = fs.full_w;
	}
	
	if(fs.full_w < fs.min_w)
	{
		fs.use_w = fs.min_w;
		fs.differential_w = fs.full_w - fs.min_w;
	}
	
	content_obj.style.width = fs.use_w;
	
	content_h = content_obj.offsetTop + content_obj.offsetHeight + 50;

	fs.screen_h = fullscreen_obj.offsetHeight;
	fs.full_h = Math.max(fullscreen_obj.offsetHeight, content_h);
	fs.content_h = content_h;

	//alert("fs.full_w = " + fs.full_w + "\nfs.use_w = " + fs.use_w + "\nfs.differential_w = " + fs.differential_w);
	
	return fs;
}

function setup()
{
	body_obj = getObject("myBody");
	blackbar_obj = getObject("blackbar");
	topbar_obj = getObject("topbar");
	leftbar_obj = getObject("leftbar");
	rightbar_obj = getObject("rightbar");
	credit_container_obj = getObject("credit_container");
	topright_corner_obj = getObject("topright_corner");
	content_obj = getObject("content");
	
	fs = get_fullscreen();
	
	//alert(topright_toolbox_container_obj.style.posRight);
	
	blackbar_obj.style.width = fs.differential_w >= 0 ? fs.differential_w : 0;
	topbar_obj.style.width = fs.use_w - 5;
	rightbar_obj.style.right = fs.differential_w;
	topright_corner_obj.style.right = fs.differential_w;

	content_obj.style.width = fs.use_w - rightbar_obj.offsetWidth - content_obj.offsetLeft - 20;
	
	leftbar_obj.style.height = fs.full_h;
	rightbar_obj.style.height = fs.full_h;
	blackbar_obj.style.height = fs.full_h;
	
	//alert("fs.full_h: " + fs.full_h)
	
	if(credit_container_obj)
	{
		credit_container_obj.style.visibility = "visible";
		//credit_container_obj.style.posTop = fs.full_h - (credit_container_obj.offsetHeight + 20);
		credit_container_obj.style.top = fs.full_h - (credit_container_obj.offsetHeight + 20);
	}
	//alert("credit_container.style.top: " + credit_container.style.top)
	
	center_top_elements(fs);
	
	if(body_obj) body_obj.style.visibility = "visible";

}

function center_top_elements(fs)
{
	logo_fresnel_obj = getObject("logo_fresnel");
	menu_container_obj = getObject("menu_container");
	
	logo_fresnel_obj.style.posLeft = (fs.use_w - logo_fresnel_obj.offsetWidth) / 2;
	menu_container_obj.style.posLeft = (fs.use_w - menu_container_obj.offsetWidth) / 2;
}
