// JavaScript Document
function addEvent( obj, type, fn ){  // the add event function
	if (obj.addEventListener) obj.addEventListener( type, fn, false );
	else if (obj.attachEvent) {
	  obj["e"+type+fn] = fn;
	  obj[type+fn] = function() {
		obj["e"+type+fn]( window.event );
	  };
	  obj.attachEvent( "on"+type, obj[type+fn] );
	}
}
//open popup window
var myWindow;
function openCenteredWindow(url, width, height) {
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + 
        ",status,resizable,left=" + left + ",top=" + top + 
        ",screenX=" + left + ",screenY=" + top + ", status=no";
    myWindow = window.open(url, "DigitalCopiers", windowFeatures);
}
//open normal window
function openCenteredNormal(url, width, height) {
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + 
        ",status,resizable,left=" + left + ",top=" + top + 
        ",screenX=" + left + ",screenY=" + top + ", status=yes, menubar=yes, scrollbars=yes";
    myWindow = window.open(url, "DigitalCopiers", windowFeatures);
}
// add to favorites
function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}
//////////////////////////////////////
//products tab handling
//////////////////////////////////////
var msTabs = new Array();
msTabs.push('Workgroups');
msTabs.push('Department');
msTabs.push('Production');
msTabs.push('Color');

function initTabs() {
	for(key in msTabs) {		
		curTab = document.getElementById('ms'+msTabs[key]);
		curLink = document.getElementById('l'+msTabs[key]);
		if(curTab != null && msTabs[key] == "Workgroups") {
			curTab.style.display = 'block';
			curLink.className = 'active';
			break;
		}
		else {
			curTab.style.display = 'none';
			break;
		}
	}
}
function showTab(tab, linkOver) {
	for(key in msTabs) {		
		curTab = document.getElementById('ms'+msTabs[key]);
		curLink = document.getElementById('l'+msTabs[key]);
		if(curTab != null) {
			curTab.style.display = 'none';
			curLink.className = '';
		}
	}
	curTab = document.getElementById(tab);
	curTab.style.display = 'block';
	linkOver.className = 'active';
}
addEvent(window, 'load', initTabs);