
var origHeight, origWidth;
var coll = "";
var styleObj = "";
var isMac, isPC;
if (navigator.platform.indexOf('Mac') != -1) {
	isMac = true;
} else {
	isPC = true;
}

if (document.layers) {
	origWidth = innerWidth;
	origHeight = innerHeight;
} else if (document.all) {
	coll = "all.";
	//styleObj = ".style";
} else if (document.getElementById) {
	coll = "getElementById('";
	//styleObj = "').style";
	styleObj = "')";
}

function fixLayer(lname) {
	var fixedLayer;
	if (document.layers) {
		fixedLayer = "document." + lname;
	} else if (document.all) {
		fixedLayer = "document.all." + lname;
	} else if (document.getElementById) {
		fixedLayer = "document.getElementById('" + lname + "')";
	}
	return fixedLayer;
}

function fixLayerLong(lname) {
	var fixedLayer;
	
	if (document.layers) {
		//alert("document." + lname);
		fixedLayer = eval("document." + lname);
	} else {
		//alert("document." + coll + lname + styleObj);
		fixedLayer = eval("document." + coll + lname + styleObj);
	}
	return fixedLayer;
}


function writeToLayer(layerName,layerText) {
  layerObj = fixLayerLong(layerName);
	
  if (document.layers) {
    with (layerObj) {
      document.write(layerText);
      document.close();
    }
  } else if (document.all) {
    layerObj.innerHTML = layerText;
  } else if (document.getElementById) {
    layerObj.innerHTML = layerText;
  }
}

function ShowNav (thisLayer, thisNav) { 

	if(menuReadyState) { 
		
		//find image object 
		//imgObj = document.images["b"+imgNum];
		thisObj = eval(fixLayer(thisLayer));
		
		//find position of image 
		xPos = getRealLeft(thisObj); 
		yPos = getRealTop(thisObj); 

		//activate menu with returned co-ordinates 
		activateMenu(thisNav,xPos,91); 

	} 

} 

function swap(image, over) {
	deactivateMenus();
	if (over) {
		document.images[image].src = document.images[image].src.replace(/_off/gi, '_on');
	} else {
		document.images[image].src = document.images[image].src.replace(/_on/gi, '_off');
	}
}

function swap2(image, image2, over) {
	deactivateMenus();
	if (over) {
		document.images[image].src = document.images[image].src.replace(/_off/gi, '_on');
		document.images[image2].src = document.images[image2].src.replace(/_off/gi, '_on');
	} else {
		document.images[image].src = document.images[image].src.replace(/_on/gi, '_off');
		document.images[image2].src = document.images[image2].src.replace(/_on/gi, '_off');
	}
}

function preload() {
	args = preload.arguments;
	var preloaded = new Array();
	for (i=0;i<args.length;i++) {
		preloaded[i] = new Image();
		preloaded[i].src = args[i];
	}
}

function swapImg(thisImg, arrIndex) {
	document.images[thisImg].src = installImages[arrIndex].src;
	writeInstallDownload(arrIndex);
	writeInstallLocation(arrIndex);
	imgIndex = arrIndex;
};

function nextImg(thisImg) {
	//alert("imgIndex = " + imgIndex);
	if (imgIndex == (installImages.length -1)) {
		imgIndex = 0;
		swapImg(thisImg, imgIndex++);
	} else {
		swapImg(thisImg, ++imgIndex);
	}
};

function prevImg(thisImg) {
	if (imgIndex == 0) {
		imgIndex = installImages.length-1;
		swapImg(thisImg, imgIndex--);
	} else {
		swapImg(thisImg, --imgIndex);
	}
};

function writeInstallDownload(thisIndex) {
	thisLayer = "downloadDiv";
	thisString = '<a href="' + installImages[thisIndex].highResPath + '">Hi Res</a>&nbsp;&nbsp;&nbsp;<a href="' + installImages[thisIndex].lowResPath + '">Low Res</a>'
	writeToLayer(thisLayer, thisString);
}

function writeInstallLocation(thisIndex) {
	thisLayer = "locationDiv";
	thisString = installImages[thisIndex].lbl;
	writeToLayer(thisLayer, thisString);
}
