function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
  blanket_height = getWindowHeight();
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	//popUpDiv_height=blanket_height/2-170;//170 is half popup's height
	//popUpDiv.style.top = popUpDiv_height + 'px';

  var ScrollTop = document.body.scrollTop;
  if (ScrollTop == 0) {
    if (window.pageYOffset) {
      ScrollTop = window.pageYOffset;
    } else {
      ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }
  }
  popUpDiv_height=ScrollTop+200;
  popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-170;//170 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	//window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

function getWindowHeight() {       
  var xScroll, yScroll;

  if (window.innerHeight && window.scrollMaxY) {	
  	xScroll = window.innerWidth + window.scrollMaxX;
  	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
  	if(document.documentElement.clientWidth){
  		windowWidth = document.documentElement.clientWidth; 
  	} else {
  		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 = xScroll;		
  } else {
  	pageWidth = windowWidth;
  }
  
  return pageHeight;
}
