/*
	Copyright David Trewern Design         :: www.dtdesign.com ::
	Unauthorised modification / use is a criminal offence, and
	will be prosecuted to the fullest extent permitted by law.
	All Rights Reserved
*/

NAVarr = new Array("home", "about", "technology", "appcasestudies", "products", "newsevents", "careers", "resources", "contactus", "dtdcog");
if (document.images) {
	for (var NAVitem in NAVarr) { 
		 for (var NAVicount=0; NAVicount < 2; NAVicount++) { 
				eval("b" + NAVarr[NAVitem] + NAVicount + " = new Image()");
				eval("b" + NAVarr[NAVitem] + NAVicount + ".src = 'assets/swap_" + NAVarr[NAVitem] + "_" + NAVicount + ".gif'");
		 } 
	} 
}

function BturnOn(imageName) {
	if (document.images) { document [imageName].src = eval("b" +imageName + "1.src");   }
}

function BturnOff(imageName) {
	if (document.images) { document [imageName].src = eval("b" + imageName + "0.src");   }
}

function imgPopup(path) {
	if (path) {
		window.open("utils_imagepopup.aspx?path=" + path, "popup", "width=400, height=300, toolbar=no, status=no, scrollbars=yes, resizable=yes");
	}
}




//new ypSlideOutMenu("name", "direction(down/up/right/left)", left, top, width, height);
var about = new ypSlideOutMenu("about", "down", -1000, 104, 150, 200);
var technology = new ypSlideOutMenu("technology", "down", -1000, 104, 150, 200);
var products = new ypSlideOutMenu("products", "down", -1000, 104, 150, 200);
var resources = new ypSlideOutMenu("resources", "down", -1000, 104, 150, 200);

about.onactivate = function() { repositionMenu(about, -302); }
technology.onactivate = function() { repositionMenu(technology, -246); }
products.onactivate = function() { repositionMenu(products, -9); }
resources.onactivate = function() { repositionMenu(resources, 188); }

function repositionMenu(menu, offset) {
	var newLeft = getWindowWidth() / 2 + offset;

	menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
}

function getWindowWidth() {
	var windowWidth = window.innerWidth ? window.innerWidth : document.body.offsetWidth;

	var agt=navigator.userAgent.toLowerCase();

	var browserPlatform = (agt.indexOf("windows")>-1 ? "win" : "") + (agt.indexOf("mac")>-1 ? "mac" : "")
	var browserType = (agt.indexOf("msie")>-1 ? "ie" : "") +
		(agt.indexOf("netscape")>-1 ? "ns" : "") +
		(agt.indexOf("firefox")>-1 ? "ff" : "")

	if (browserType == "ns") windowWidth += 4;
	if (browserType == "ff") windowWidth += 18;
	if (browserPlatform == "mac" && browserType == "ie") windowWidth += 18;

	if (windowWidth < 722) windowWidth = 722;

	return windowWidth;
}