// JavaScript Document

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;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';

	if (window.pageYOffset) {
		scrollPosition = window.pageYOffset;    
	}
	else if (document.documentElement.scrollTop) {
		scrollPosition = document.documentElement.scrollTop;  
	}
	else {
		scrollPosition = document.body.scrollTop;
	}


	//alert(screen.width);
	//alert(viewportheight);
	
	

	var popUpDiv = document.getElementById(popUpDivVar);	
	divHeight = popUpDiv.offsetHeight;
	//divHeight = popUpDiv.style.height;
	offset = (divHeight > viewportheight) ? 0 : ((viewportheight/2) - (divHeight/2));
	//alert("position = "+scrollPosition+"\nblanket_height = "+blanket_height+"\nviewportheight = "+viewportheight+"\ndivHeight = "+divHeight+"\noffset = "+offset);

	//popUpDiv_height=blanket_height/2-72;//150 is half popup's height
	//popUpDiv_height=scrollPosition+250;//150 is half popup's height
	popUpDiv_top=Math.round(scrollPosition+offset);//150 is half popup's height

	popUpDiv.style.top = popUpDiv_top + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerWidth;
	} else {
		viewportwidth = document.documentElement.clientWidth;
	}
	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;
		}
	}

	if (window.pageXOffset) {
		scrollPosition = window.pageXOffset;    
	}
	else if (document.documentElement.scrollTop) {
		scrollPosition = document.documentElement.scrollLeft;  
	}
	else {
		scrollPosition = document.body.scrollLeft;
	}

	var popUpDiv = document.getElementById(popUpDivVar);	
	divWidth = popUpDiv.offsetWidth;
	//divWidth = popUpDiv.style.Width;
	offset = (divWidth > viewportwidth) ? 0 : ((viewportwidth/2) - (divWidth/2));
	//alert("position = "+scrollPosition+"\nwindow_width = "+window_width+"\nviewportwidth = "+viewportwidth+"\ndivWidth = "+divWidth+"\noffset = "+offset);

	//popUpDiv_width=blanket_width/2-72;//150 is half popup's width
	//popUpDiv_width=scrollPosition+250;//150 is half popup's width
	popUpDiv_width=scrollPosition+offset;//150 is half popup's width


	window_width=window_width/2-303;//150 is half popup's width
	//popUpDiv.style.left = window_width + 'px';
	popUpDiv.style.left = popUpDiv_width + 'px';

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

	return false;
}