function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


var myimages = new Array();
function preloadimages() {
    for (i = 0; i < preloadimages.arguments.length; i++) {
        //alert(preloadimages.arguments[i]);
        myimages[i] = new Image();
        myimages[i].src = preloadimages.arguments[i];
    }
}


function preloadMenuImg()
{
    preloadimages('../img/menu/catalogue_roll.gif','../img/menu/case_studies_roll.gif','../img/menu/news_roll.gif','../img/menu/orange_arrow.gif','../img/menu/services_support_roll.gif','../img/menu/who_we_are_roll.gif','../img/menu/black_arrow.gif');
}


function insertStylesheet()
{
    if (isNS4)
	{
		var css_filename = "stylesheet_ns4.css";
	}
	else
	{
		var css_filename = "stylesheet.css";
	}
	document.writeln("<link rel=\"stylesheet\" href=\"../css/" + css_filename + "\" type=\"text/css\">");
}


function displayCenteredPopup(url, winName, winWidth, winHeight, features)
{
	var winTop = (screen.height - winHeight) / 2;
	var winLeft = (screen.width - winWidth) / 2;
	
	window.open(url, winName, features + ',width=' + winWidth + ',height=' + winHeight + ',top=' + winTop + ', left=' + winLeft);
}


function sGetLayerWidth(sLayerName)
{
	if (isNS4)
	{
		oLayer = document.layers[sLayerName];
		iLayerWidth = oLayer.clip.width;
	}
	else if (isNS)
	{
		oLayer = document.getElementById(sLayerName);
		iLayerWidth = oLayer.offsetWidth;
	}
	else
	{
		oLayer = document.all(sLayerName);
		iLayerWidth = oLayer.offsetWidth;
	}
	return iLayerWidth;
}


function sGetLayerHeight(sLayerName)
{
	if (isNS4)
	{
		oLayer = document.layers[sLayerName];
		iLayerHeight = oLayer.clip.height;
	}
	else if (isNS)
	{
		oLayer = document.getElementById(sLayerName);
		iLayerHeight = oLayer.offsetHeight;
	}
	else
	{
		oLayer = document.all(sLayerName);
		iLayerHeight = oLayer.offsetHeight;
	}
	return iLayerHeight;
}


function resizeWindow(iLayerWidth, iLayerHeight) 
{
	if (isNS4)
	{
		wndHorizontalMargins = 0;
		wndVerticalMargins = 0;
		isScrollbar = 0;
		scrollbarWidth = 17;
		maxWndWidth = screen.availWidth - 30;
		maxWndHeight = screen.availHeight - 60;
		
		elm = document.myDiv;
		
		if (iLayerWidth > maxWndWidth)
		{
			iLayerWidth = maxWndWidth;
		}
		
		if (iLayerHeight > maxWndHeight)
		{
			iLayerHeight = maxWndHeight;
			isScrollbar = 1;
		}
		
		wndWidth = iLayerWidth + wndHorizontalMargins;
		if (isScrollbar)
		{
			wndWidth += scrollbarWidth;
		}
		
		wndHeight = iLayerHeight + wndVerticalMargins;
	}
	else if (isNS)
	{
		wndHorizontalMargins = 18;
		wndVerticalMargins = 28;
		isScrollbar = 0;
		scrollbarWidth = 15;
		maxWndWidth = screen.availWidth - 30;
		maxWndHeight = screen.availHeight - 30;
				
		wndWidth = iLayerWidth + wndHorizontalMargins;
		if (wndWidth > maxWndWidth)
		{
			wndWidth = maxWndWidth;
		}
		
		wndHeight = iLayerHeight + wndVerticalMargins;
		if (wndHeight > maxWndHeight)
		{
			wndHeight = maxWndHeight;
			isScrollbar = 1;
		}
		
		if (isScrollbar)
		{
			wndWidth += scrollbarWidth;
		}
		
		window.resizeTo(wndWidth, wndHeight);
	}
	else
	{
		wndHorizontalMargins = 0;
		wndVerticalMargins = 32;
		scrollbarWidth = 17;
		maxWndWidth = screen.availWidth - 30;
		maxWndHeight = screen.availHeight - 60;
		
		if(iLayerWidth > maxWndWidth)
		{
			iLayerWidth = maxWndWidth;
		}
		
		if(iLayerHeight > maxWndHeight)
		{
			iLayerHeight = maxWndHeight;
		}
		
		wndWidth = iLayerWidth + wndHorizontalMargins + scrollbarWidth;
		wndHeight = iLayerHeight + wndVerticalMargins;
	}
	
	window.resizeTo(wndWidth, wndHeight);
}


function moveWindow(wndWidth, wndHeight) {
	iLeft = (screen.availWidth - wndWidth) / 2;
	iTop = (screen.availHeight - wndHeight) / 2;
	
	self.moveTo(iLeft, iTop);
	self.focus();
}


function init_popup_consumables()
{
	iLayerWidth = sGetLayerWidth("myDiv");
	iLayerHeight = sGetLayerHeight("myDiv");

 	resizeWindow(iLayerWidth, iLayerHeight);
	
 	countdown = 0.5;
 	timer = setTimeout("moveWindow(wndWidth, wndHeight)", countdown * 1000);
}


function swapImage(imgName, imgSrc)
{
	document.images[imgName].src = imgSrc;
}


function centered_popup(url, name, width, height, options)
{
	
	var top = (screen.height - height) / 2;
	var left = (screen.width - width) / 2;
	window.open(url, name, options + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',screenX=' + left + ',screenY=' + top);
}


function popupPrint(printPage)
{
	var url = '../popup/popup_print.php?print=1&print_page=' + printPage;
	var name = 'print';
	var width = 580;
	var height = 400;
	var options = 'toolbar=1,resizable=1,scrollbars=1,menubar=1';
	
	centered_popup(url, name, width, height, options);
}