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) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
              viewportwidth = window.innerWidth;
	} else {
		viewportheight = document.documentElement.clientHeight;
              viewportwidth = document.documentElement.clientWidth;
	}

	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
		blanket_width = viewportwidth;

	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
			blanket_width = document.body.parentNode.clientWidth;
		} else {
			blanket_height = document.body.parentNode.scrollHeight-4;
			blanket_width = document.body.parentNode.scrollWidth-21;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
       blanket.style.width = blanket_width + 'px';

	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-150;
	popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') { 
	  viewportheight = window.innerHeight;
         viewportwidth = window.innerWidth;
       } else { 
         viewportheight = document.documentElement.clientHeight;
         viewportwidth = document.documentElement.clientWidth;
       }

       if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
	  window_height = viewportheight;
	  window_width = viewportwidth;
	} else {
         if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
	    window_height = document.body.parentNode.clientHeight;
	    window_width = document.body.parentNode.clientWidth;
	  } else {
	    window_height = document.body.parentNode.scrollHeight-4;
	    window_width = document.body.parentNode.scrollWidth-21;
	  }
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=(window_width/2)-(parseInt(popUpDiv.style.width)/2);
       window_height=(window_height/2)-(parseInt(popUpDiv.style.height)/2);
	popUpDiv.style.left = window_width + 'px';
       popUpDiv.style.top =  window_height + 'px';
}

function popup(windowname) {
	blanket_size(windowname);
       window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}
