function preloadImages(preFix, sTart, fInish, pAth) {
	if (document.images) {
		for (var i=sTart; i<=fInish; i++) {
			//preload on images
			newImage = preFix + i + "on = new Image()";
			loCation = pAth + preFix + i + "on.gif";
			newImageSRC = preFix + i + "on.src = \"" + loCation + "\"";
			eval(newImage);
			eval(newImageSRC);

			//preload off images
			newImage = preFix + i + "off = new Image()";
			loCation = pAth + preFix + i + "off.gif";
			newImageSRC = preFix + i + "off.src = \"" + loCation + "\"";
			eval(newImage);
			eval(newImageSRC);
		};
	};
};

function change(Name,OnOff) {
	if (document.images) {
		document [Name].src = eval(Name + OnOff + ".src");
	};
};

preloadImages('nav',1,4,'images/home/mainnav/');


Menu.highlightMenu = function (ntevent, ev, tag) {
	tag.src = 'images/home/mainnav/' + tag.name + 'on.gif';
	return true;
}
Menu.flattenMenu = function (ntevent, ev, tag) {
	tag.src = 'images/home/mainnav/' + tag.name + 'off.gif';
	return true;
}

Menu.highlightItem = function (ntevent, ev, tag) {
	tag.className = 'hover';
	return true;
}
Menu.flattenItem = function (ntevent, ev, tag) {
	tag.className = '';
	return true;
}

CaseStudy = new Object();
CaseStudy.popup = function (ntevent, ev, tag) {
	popWindow(tag.href, '700', '600');
	return false;
}

function init() {
	var event = Events.get('ul#mainmenu li', 'onmouseover');
	event.bind(Menu.expand);
	
	event = Events.get('body', 'onclick');
	event.bind(Menu.collapseAll);
	
	event = Events.get('ul#mainmenu img', 'onmouseover');
	event.bind(Menu.highlightMenu);
	
	event = Events.get('ul#mainmenu img', 'onmouseout');
	event.bind(Menu.flattenMenu);
	
	event = Events.get('ul#mainmenu li li', 'onmouseover');
	event.bind(Menu.highlightItem);
	
	event = Events.get('ul#mainmenu li li', 'onmouseout');
	event.bind(Menu.flattenItem);
	
	event = Events.get('#casestudies a:not(.nopopup)', 'onclick');
	event.bind(CaseStudy.popup);

	event = Events.get('#casestudy a', 'onclick');
	event.bind(CaseStudy.popup);
	
	event = Events.get('div.casestudy a', 'onclick');
	event.bind(CaseStudy.popup);
	
	event = Events.get('body.clientsuccesses #content li a', 'onclick');
	event.bind(CaseStudy.popup);
	
	event = Events.get('div#secondcolumn.clientlist li a', 'onclick');
	event.bind(CaseStudy.popup);
}

init();



function popWindow(popURL, height, width) {
	theWindow=window.open( popURL, "theWindow", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + width + ",height=" + height + "");
	theWindow.opener=self;
	setTimeout("theWindow.focus();",200);
};
function popWindowScroll(popURL, height, width) {
	theWindow=window.open( popURL, "theWindow", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + width + ",height=" + height + "");
	theWindow.opener=self;
	setTimeout("theWindow.focus();",200);
};
