//Course descriptionpopup

function visible_yes(popupid,e)
{
  var xpos = 100;
  var ypos = 100;

  if (document.all) //för IE
  {

    if ( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
    {
      theTop = document.body.scrollTop
      screenHeight = document.body.clientHeight;
	  theLeft = document.body.scrollLeft
      screenWidth = document.body.clientWidth;
	}
	
	else if (document.documentElement)
    {
      theTop = document.documentElement.scrollTop;
      screenHeight = document.documentElement.offsetHeight;
	  theLeft = document.documentElement.scrollLeft;
      screenWidth = document.documentElement.offsetWidth;
	}

    xpos = e.clientX + theLeft + 10;
    ypos = e.clientY + theTop + 10;

    if ((xpos - theLeft + document.getElementById(popupid).offsetWidth + 15) > screenWidth) //ifall popupen hamnar utanför bild till höger)
    {
      xpos = (xpos - document.getElementById(popupid).offsetWidth - 20);
    }

    if ((ypos - theTop + document.getElementById(popupid).offsetHeight + 15) > screenHeight) //ifall popupen hamnar utanför bild i botten)
    {
      ypos = (ypos - document.getElementById(popupid).offsetHeight - 20);
    }

  }
  else // för MOZILLA
  {
    xpos = e.clientX + pageXOffset + 10;
    ypos = e.clientY + pageYOffset + 10;

    if ((xpos - window.pageXOffset + document.getElementById(popupid).offsetWidth + 15) > window.innerWidth) //ifall popupen hamnar utanför bild till höger)
    {
      xpos = (xpos - document.getElementById(popupid).offsetWidth - 20);
    }

    if ((ypos - window.pageYOffset + document.getElementById(popupid).offsetHeight + 15) > window.innerHeight) //ifall popupen hamnar utanför bild i botten)
    {
      ypos = (ypos - document.getElementById(popupid).offsetHeight - 20);
    }
  }

  //flytta popupsen
  document.getElementById(popupid).style.left = xpos+"px";
  document.getElementById(popupid).style.top = ypos+"px";
  document.getElementById(popupid).style.visibility = 'visible';
}

function visible_no(popupid)
{
  document.getElementById(popupid).style.visibility = 'hidden';
  document.getElementById(popupid).style.left = '100px';
  document.getElementById(popupid).style.top = '100px';
}



//Fullscreen popup

//first some variables thats needed, pageWidth,pageHeight,windowWidth,windowHeight,scrollOffset

function showfullpop(fullpop) {

	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	
	var scrollOffset;

	if (self.pageYOffset) {
		scrollOffset = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		scrollOffset = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		scrollOffset = document.body.scrollTop;
	}

//then the move and show
	divheight = document.getElementById(fullpop).clientHeight;
	document.getElementById('shadow').style.height = pageHeight-110+'px';
	document.getElementById('shadow').style.visibility = 'visible';
	document.getElementById(fullpop).style.top = windowHeight/2+scrollOffset-divheight/2+'px';
	document.getElementById(fullpop).style.visibility = 'visible'; 
}

function closefullpop(fullpop) {
	document.getElementById('shadow').style.visibility = 'hidden'; 
	document.getElementById(fullpop).style.visibility = 'hidden'; 
}