function resizeDivTo(div,width){
  if(document.layers) { // NN4
   div.resizeTo(width,0);
  }
  // IE5+, Mozilla, Opera 7     
  else if(typeof div.style.width!="undefined"&& typeof div.style.width=="string"){
   div.style.width =width +'px';
  }
  else if(typeof div.style.pixelWidth!="undefined"){ // IE4, Opera 6
   div.style.pixelWidth  = width;
  }  
}

// function which adds generic listeners
function addHomeListeners()
{
	
}

var scaled = false;

// function for setting up the attractor dimensions

function scaleAttractor()
{
		
		width = getWindowWidth();

		width = width; // take into account for right hand scroll bar being present

		height = Math.round(width/(1100/278));
		
		setAttractorSize(width, height);	
}

function setScaled(val)
{
	scaled = val;
}

function getWindowWidth()
{
	dimensions = getVisibleSize();
	width = dimensions[0];
	return width;
}

function getVisibleSize()
{
	var dimensions = [0,0];
	
	if (typeof window.innerWidth != 'undefined') 
	{
		dimensions = [window.innerWidth, window.innerHeight];
	} 
	else if ((typeof document.documentElement != 'undefined') && (typeof document.documentElement.clientWidth != 'undefined') && (document.documentElement.clientWidth !=0)) 
	{
		dimensions = [document.documentElement.clientWidth,document.documentElement.clientHeight]
	} 
	else 
	{
		dimensions = [document.getElementsByTagName('body')[0].clientWidth,document.getElementsByTagName('body')[0].clientHeight ];
	}

	return dimensions;
}

function setAttractorSize(width, height)
{	
	str = navigator.appName.toUpperCase();
	
	// restrict size about 1100 pixels wide to avoid images scaling up
	if(width > 1100) 
	{
		width = 1100;
		height = 278;
	}
	
	if(width < 800) 
	{
		width = 800;
		height = 202;
	}
	
	// IE and newer browsers use the object tag
	attractorObject = getElement('attractor');
	if(attractorObject) 
	{
		attractorObject.width = width;
		attractorObject.height = height;
		
	}

	// Mozilla and older browsers use the embed tag.
	attractorEmbedElement = getElement('attractorEmbed');	
	if(attractorEmbedElement) 
	{
		attractorEmbedElement.width = width;
		attractorEmbedElement.height = height;
	}
	
	top_headerObject = getElement('top_header');
	if(top_headerObject) 
	{
		if (str.indexOf("EXPLORER") >= 0){
			resizeDivTo(top_headerObject,width);
		}else{
			bytefx.size$(top_headerObject, { width:width });
		}
	}
	top_master_containerObject = getElement('top_master_container');
	if(top_headerObject) 
	{
		if (str.indexOf("EXPLORER") >= 0){
			resizeDivTo(top_master_containerObject,width);
		}else{
			bytefx.size$(top_master_containerObject, { width:width });
		}
	}
	
	top_mainObject = getElement('top_main');
	if(top_mainObject) 
	{
		if (str.indexOf("EXPLORER") >= 0){
			resizeDivTo(top_mainObject,width-200);
		}else{
			bytefx.size$(top_mainObject, { width:width-200 });
		}
	}
	
}

// once the page has loaded add all of the appropriate events to it.
addEvent(window, 'load', scaleAttractor, false);
addEvent(window, 'resize',scaleAttractor, false);

