// JavaScript Document

//------------------------------------------------------------------------------
// GLOBAL VARIABLES
//------------------------------------------------------------------------------

// Major and Minor versions, and required revision of Flash required
var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 0;

AC_FL_RunContent = 0;


//------------------------------------------------------------------------------
// GLOBAL FUNCTIONS - apply to more than one page in the site
//------------------------------------------------------------------------------

// Initialize the page:
// hide the content
// set the main margins
// load main images seen throughout the site
// show the content
function init() {
	setMainMargins(); 
	preloadMainImages();
}


// Set the top margin on the page to 20 if there is room, or between 0 and 20 if there is
// less than 20px available after the allocated 650px.
function setMainMargins() {
	var topMargin = document.documentElement.clientHeight - 650;
	if (topMargin > 20) topMargin = 20;
	if (topMargin < 0) topMargin = 0;
	var myMargin = topMargin + "px";
	document.getElementById("mybody").style.marginTop = myMargin;
}


// Function that preloads all images in the document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


// Explicitly preload the images used in css background-image properties
// (used in all pages)
function preloadMainImages() {
	image1 = new Image(303, 607);
	image1.src = "images/leftbg.jpg";

	image2 = new Image(564, 607);
	image2.src = "images/midbg.jpg";

	image3 = new Image(66, 607);
	image3.src = "images/rightbg.jpg";

	image4 = new Image(186, 15);
	image4.src = "images/client_access_link.jpg";

	image5 = new Image(154, 15);
	image5.src = "images/employees_link.jpg";

	image6 = new Image(90, 17);
	image6.src = "images/credits_link.jpg";
	
	image7 = new Image(11, 15);
	image7.src = "images/pipe.jpg";
	
	image8 = new Image(110, 20);
	image8.src = "images/phone.jpg";
	
	image9 = new Image(179, 17);
	image9.src = "images/copyright.jpg";
}


// Adds an event listener to the given object.
// Note that this function is written such that browser sniffing is not required;
// it will determine if attachEvent for IE should be used, or W3C's addEventListener.
function addEvent(obj, type, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(type, fn, false);
	} else if (obj.attachEvent) {
		obj["e" + type + fn] = fn;
		obj[type + fn] = function() { obj["e" + type + fn]( window.event ); }
		obj.attachEvent("on" + type, obj[type + fn]);
	}
}


// Removes an event listener from the given object.
// Note that this function is written such that browser sniffing is not required;
// it will determine if Event for IE should be used, or W3C's addEventListener.
function removeEvent(obj, type, fn) {
	if (obj.removeEventListener)
		obj.removeEventListener(type, fn, false);
	else if (obj.detachEvent)
		return obj.detachEvent("on" + type, fn);
}


// Set the image src for the given id
//
function setImageForId(id, newImage) {
	document.images[id].src = newImage;
}