// JavaScript Document



//Preload and Rollover Image for Main Menu

function newImage(arg) {

	if (document.images) {

		rslt = new Image();

		rslt.src = arg;

		return rslt;

	}

}



function changeImages() {

	if (document.images && (preloadFlag == true)) {

		for (var i=0; i<changeImages.arguments.length; i+=2) {

			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];

		}

	}

}



var preloadFlag = false;

function preloadImages() {

	if (document.images) {

		mainMenu_Home_over = newImage("images/mainMenu-Home-over.gif");

		mainMenu_AboutUs_mainMenu_Home_over = newImage("images/mainMenu-AboutUs-over.gif");

		mainMenu_MajorProjects_mainMenu_Home_over = newImage("images/mainMenu-MajorProjects-over.gif");

		mainMenu_Employment_mainMenu_Home_over = newImage("images/mainMenu-Employment-over.gif");

		mainMenu_Services_mainMenu_Home_over = newImage("images/mainMenu-Services-over.gif");
		
		mainMenu_Search_mainMenu_Home_over = newImage("images/mainMenu-Search-over.gif");

		mainMenu_Tipping_mainMenu_Home_over = newImage("images/mainMenu-Tipping-over.gif");

		preloadFlag = true;

	}

}





// Homepage Side Rotate

var theRotateImages = new Array()

theRotateImages[0] = 'images/rotating/hpRotate01.jpg'
theRotateImages[1] = 'images/rotating/hpRotate02.jpg'
theRotateImages[2] = 'images/rotating/hpRotate06.jpg'
theRotateImages[3] = 'images/rotating/hpRotate07.jpg'
theRotateImages[4] = 'images/rotating/hpRotate08.jpg'
theRotateImages[5] = 'images/rotating/hpRotate09.jpg'
theRotateImages[6] = 'images/rotating/hpRotate10.jpg'
theRotateImages[7] = 'images/rotating/hpRotate11.jpg'
theRotateImages[8] = 'images/rotating/hpRotate12.jpg'
theRotateImages[9] = 'images/rotating/hpRotate13.jpg'
//theRotateImages[10] = 'images/rotating/hpRotate03.jpg'
//theRotateImages[11] = 'images/rotating/hpRotate04.jpg'
//theRotateImages[12] = 'images/rotating/hpRotate05.jpg' 

var j = 0
var p = theRotateImages.length;


var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theRotateImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));

function showRotatingImage(){
document.write('<img src="'+theRotateImages[whichImage]+'" border="0">');
}

// Homepage Interactive Rotate

var theInteractiveImages = new Array()

theInteractiveImages[0] = 'images/rotating/interactiveMap01.jpg'
theInteractiveImages[1] = 'images/rotating/interactiveMap02.jpg'
theInteractiveImages[2] = 'images/rotating/interactiveMap03.jpg'
theInteractiveImages[3] = 'images/rotating/interactiveMap04.jpg'
theInteractiveImages[4] = 'images/rotating/interactiveMap05.jpg'

var j = 0
var p = theInteractiveImages.length;


var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theInteractiveImages[i]
}

var whichImageInteractive = Math.round(Math.random()*(p-1));

function showInteractiveImage(){
document.write('<img src="'+theInteractiveImages[whichImageInteractive]+'" border="0">');
}

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["servicesOffered", "overview", "contactUs", "currentNews"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller