// Event handler, subscribes the init() funtion to the onLoad event of the page
Event.observe(window, 'load', init, false);

var ie = false;
var mozilla = false;
var isAdmin = false;

/* First function to be called by all pages on load
*/
function init(){
    //alert('main.init()');
    checkBrowser();
    do_onResize();
    // if the page has an annotation sidebar, load the Annotations for the current page (see Annotation.js)
    if($('sidebarBoxAnnotations')) {
        transcriptInit();
        loadAnnotations(); 
    }
    // if tha page is the upload page, initialize required js (see upload.js)
    if($('upload')) {
        uploadInit();
    }
    Event.observe(window, 'resize', do_onResize, false);
}

/* Resizes the transcript DIV of a page to "fill" the rest of the page
    IE and Firefox handle this in very different ways, so plain CSS was not possible, we have to do it programmatically.
*/
function do_onResize() {
    //alert('main.do_onResize()');
	if(ie) {
		//y = document.body.clientHeight - 95;
		x = document.body.offsetWidth - 380;
		if (document.getElementById('interlinear')) {
		document.getElementById('interlinear').style.width = x;
		//document.getElementById('interlinear').style.height = '700px';
		}
	}
	else {
		screenY = window.innerHeight-105;
		//screenX = window.innerWidth;
		if (document.getElementById('interlinear')) {
		document.getElementById('interlinear').style.width = 'auto'; // fills the remaining space in firefox
		document.getElementById('interlinear').style.height = screenY + 'px'; // is set based on window height
		}
	} 
}


/* Check if it is Mozilla or IE
*/
function checkBrowser(){
	if (document.implementation && document.implementation.createDocument){
		mozilla = true;
	}
	else if (window.ActiveXObject)
	{
		ie = true;
	}
}
