function setWindow( w, h ){
  isNav = (document.all) ? false : true;
  isIE = (document.all) ? true : false;
  
  if (isNav && !isIE)
    var widthWin = window.innerWidth;
    
  else if (isIE && !isNav)
    var widthWin = document.body.clientWidth;
    
  if (isNav && !isIE)
    var heightWin = window.innerHeight;
    
  else if (isIE && !isNav)
    var heightWin = document.body.clientHeight;
    

   
  var all = document.createElement('all');
  all.setAttribute('id','all');
  all.style.position = 'absolute';
  all.style.filter = 'alpha(opacity=60)';
  all.style.opacity = 0.6;
  all.style.left = 0;
  all.style.top = 0;
  all.style.height = heightWin + 'px';
  all.style.width = widthWin + 'px';
  all.style.background = '#000';
  
  
  var newdiv = document.createElement('tooltip');
  newdiv.setAttribute('id','tooltip');
  newdiv.style.height = h + 'px';
  newdiv.style.width = w + 'px';
  var left = Math.floor((widthWin - w) / 2 );
  var top = Math.floor((heightWin - h) / 2 );

  newdiv.style.top = top + 'px';
  newdiv.style.left = left + 'px';
  newdiv.innerHTML = '';
  
  document.body.appendChild(all);
  document.body.appendChild(newdiv);
  
  newdiv.className="tooltip"
  
  return newdiv;
}



function updateOpusObject( paragraph, page, zone ){

  newdiv = setWindow(700,700);
  
  
  var ajaxRequest;  // The variable that makes Ajax possible!
	
  try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
  } catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
  }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			newdiv.innerHTML = ajaxRequest.responseText;
		}
  }
  
  ajaxRequest.open("GET", "/ajax.php?interface=page/paragraphview.php&paragraph=" + paragraph + "&page=" + page + "&zone=" + zone, true);
  ajaxRequest.send(null); 
  
}







function loginOpus(){
  newdiv = setWindow(400,270);
  
  var ajaxRequest;  // The variable that makes Ajax possible!
	
  try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
  } catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
  }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			newdiv.innerHTML = ajaxRequest.responseText;
		}
  }
  
  ajaxRequest.open("GET", "/ajax.php?interface=login.php", true);
  ajaxRequest.send(null); 
  
}


function closeOpus(){
	isNav = (document.all) ? false : true;
  	isIE = (document.all) ? true : false;
  	
  	if(!isIE){
  		
		tooltip = document.getElementById('tooltip');
		all = document.getElementById('all');
  	}
  	
	document.body.removeChild(tooltip); 
  	document.body.removeChild(all); 
}
