//	MB general functions - CLK version
//	Overrides the ../../js/general.js file to support TreeMenu.
//	Syzygy Ltd 20/05/2002
//	Requires:	n/a
//	Language:	Javascript
//	$Date: 2002/08/01 09:45:59 $
//	$Revision: 1.3 $


function remoteWindow(URL, width, height) {
	_popupWin(URL, "imageWin", width, height);
}

function overviewWindow(URL, width, height) {
	_popupWin(URL, "overWin", width, height);
}

function galleryWindow(URL, width, height) {
	_popupWin(URL, "gallWin", width, height);
}

function flashWindow(URL, width, height) {
	_popupWin(URL, "flashWin", width, height);
}

//generic popup window
function _popupWin(URL, winName, width, height, winProperties) {
	var agent=navigator.userAgent.toLowerCase();
	var dimensions = "width=" + width + ",height=" + height;
	winProperties = winProperties || "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";
	remote = window.open(URL, winName, winProperties +','+ dimensions);
	if (remote.opener == null) {
		remote.opener = self;
	}
	if(agent.indexOf("msie 3") == -1) {
		remote.focus();
	}
}

function scrollWindow(URL, width, height) {
	_scrollWin(URL, "scrollWin", width, height);
}

//generic popup window which scrolls
function _scrollWin(URL, winName, width, height, winProperties) {
	var agent=navigator.userAgent.toLowerCase();
	var dimensions = "width=" + width + ",height=" + height;
	winProperties = winProperties || "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0";
	remote = window.open(URL, winName, winProperties +','+ dimensions);
	if (remote.opener == null) {
		remote.opener = self;
	}
	if(agent.indexOf("msie 3") == -1) {
		remote.focus();
	}
}

// <mark> SIMPLE ROLLOVERS - not clear where used, candidate for removal?
function INITimages() {
	if(!document.images) { return false }
	swop_on = new Array(arguments.length);
	swop_off = new Array(arguments.length);
	for (var i=0; i<arguments.length; i++) {
		swop_on[arguments[i]] = new Image();
		swop_off[arguments[i]] = new Image();
		swop_on[arguments[i]].src = IMAGEDIR+arguments[i]+'_on.'+ IMAGETYPE;
		swop_off[arguments[i]].src = IMAGEDIR+arguments[i]+'_off.'+IMAGETYPE;
	}
	return true;
}

function rollover(imgName,imgName2) {
	if (document.images) {
		document[imgName].src = swop_on[imgName].src;
		if (imgName2) document[imgName2].src = swop_on[imgName2].src;
	}
}
function rollout(imgName,imgName2) {
	if (document.images) {
		document[imgName].src = swop_off[imgName].src;
		if (imgName2) document[imgName2].src = swop_off[imgName2].src;
	}
}
//Gallery Screensaver - button stays selected when clicked on.
function clickOn(imgName,imgName2) {
	if (document.images) {
			document[imgName].src = swop_on[imgName].src;
			document[imgName2].src = swop_off[imgName2].src;
	}
}
// </mark>

// changeNav not used with TreeMenu, use doCallBack
function changeNav() {}

// called in contentFrame BODY onload, causes navigation to show context
function doCallBack(callBackID) {
	if(parent.navFrame && parent.navFrame.menu && parent.navFrame.menu.doCallBack) {
		parent.navFrame.menu.doCallBack(trimModelID(callBackID));
	}
}
// parse "model_data/000000,111111/px" to "model_data/000000/px"
function trimModelID(callbackID) {
	var id = callbackID.split("/");
	for(var i=0; i<id.length; i++) {
		if(id[i].indexOf(",")) id[i] = id[i].split(",")[0];
	}
	return id.join("/");
}

// RANDOM HOMEPAGE DISPLAY
// not used in CLK
homeImg = setHomeImg();
function setHomeImg() {
	var homeImg = new Array;
	homeImg[1] = "/pc/gfx/home_vaneo_1.jpg";
	homeImg[2] = "/pc/gfx/home_vaneo_2.jpg";
	homeImg[3] = "/pc/gfx/home_vaneo_3.jpg";
	homeImg[4] = "/pc/gfx/home_vaneo_4.jpg";
	var rand1 = Math.round( (homeImg.length-1) * Math.random()) +1;
	return homeImg[rand1];
}

// eof
