// JavaScript Document
function swap(image, over) {
	if (over) {
		document.images[image].src = document.images[image].src.replace(/_off/gi, '_over');
	} else {
		document.images[image].src = document.images[image].src.replace(/_over/gi, '_off');
	}
}

function swap2(image, src) {
	document.images[image].src = src;
}
   
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];
	}
}

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 showDefault() {
	return false;
}

function popDocument(fileName, lang){
	var size = "toolbar=no,location=no,directories=no,"+
				"status=no,menubar=yes,scrollbars=yes,"+
				"resizable=yes,width=780,height=550";
	path = '../docs/' + lang.toLowerCase() + '/' + fileName;
	top.docWindow = window.open(path, 'docWindow', size);
}

function popImage(fileName, width, height){
	var size = "toolbar=no,location=no,directories=no,"+
				"status=no,menubar=yes,scrollbars=yes,"+
				"resizable=yes,width="+ width +",height="+ height +"";
	path = '../img/' + fileName;
	top.docWindow = window.open(path, 'docWindow', size);
}

function popTut(fileName, width, height){
	var size = "toolbar=no,location=no,directories=no,"+
				"status=no,menubar=no,scrollbars=auto,"+
				"resizable=yes,width="+width+",height="+height+"";
	path = 'vrs_tutorials/' + fileName;
	top.docWindow = window.open(path, 'docWindow', size);
}