/**
 * Open a Word document in Microsoft Word and not 
 * in the browser. Use an ActiveX object to create
 * a new instance of Word and open it.
 *
 * If browser is not IE, just pass the URL of the
 * Word document.
 *
 * @param  string url   Full URL of the word document
 * @return bool
 */

function startWord(url) {

	if (document.all) {
		
		var myWord = '';
		var isIE = true;

		try {
			myWord = new ActiveXObject("Word.Application");	
		}
		catch (e) {
			isIE = false;
		}
		
		if (isIE) {
		
			if (myWord != null) {
				myWord.Visible = true;
				myWord.Documents.Open(url);
				myWord.Activate();
				//myWord.PrintOut();
				//myWord.Quit();
				//myWord = '';
				return true;
			}
		}
	}

	location.href = url;
}

/**
 *  Open a centered popup window, and focus the window.
 *
 * @param  string url          URL of page
 * @param  string window_name  Name of the window
 * @param  int	  width        Width of the window
 * @param  int    height       Height of the window
 *
 */
function openWindow(url, window_name, width, height) {
	if (isNaN(width))
		width = 500;
	if (isNaN(height))
		height = 400;

	var win_left = (screen.width - width) / 2;
	var win_top = (screen.height - height) / 2;

	win_attr = 'menubar=yes,scrollbars=yes,resizable=yes';
	win_attr += ',width='+width+',height='+height+',top='+win_top+',left='+win_left;

	win = window.open(url, window_name, win_attr);

	if (parseInt(navigator.appVersion) >= 4)
		win.window.focus();

	return false;
}


function checkActiveX() {
	var browser=navigator.appName;

	if (document.all && browser == 'Microsoft Internet Explorer') {
		
		var myWord = '';
		var isIE = true;

		try {
			myWord = new ActiveXObject("Word.Application");	
		}
		catch (e) {
			isIE = false;
		}
		
		myWord.Quit();
		
		if (isIE == false) {
			var box = document.getElementById('NoActiveX');
			box.style.display = 'block';
		}
	}
}