﻿function SetDisplay(Item) {	
	var item = document.getElementById(Item);
	if(item.style.display == '') {
		item.style.display = 'none';
	} else {
		item.style.display = '';
	}
}

function SwitchImage(Item, Image1, Image2) {
	var item = document.getElementById(Item);	
	if(item.src.indexOf(Image1) == -1) {
		item.src = "Images/" + Image1;		
	} else {
		item.src = "Images/" + Image2;
	}
}

function FlagPostPopup(PostID) {
	var pageWidth = document.body.offsetWidth;
	var pageHeight = document.body.offsetHeight;

	var flagPopup = document.getElementById("flagPopup");
	var flagForm = document.getElementById("flagForm");	
	
	flagPopup.style.display = "block";
	flagForm.style.display = "block";
	flagPopup.style.height = document.getElementById("pagewrapper").offsetHeight + "px";
	flagForm.style.left = ((pageWidth / 2) - (400/ 2)) + "px";
}


function DisplayModalPopup() {
	var pageWidth = document.body.offsetWidth;
	var pageHeight = document.body.offsetHeight;
	var wrapper = document.getElementById("modalPopupWrapper");
	var gray = document.getElementById('modalPopupGray');
	var popup = document.getElementById("modalPopup");

	// Fill even the scrollable area with gray	
	gray.style.height = document.getElementById("pagewrapper").offsetHeight + "px";
	
	// Put the popup in the correct place on the screen
	popup.style.marginLeft = "-" + (popup.style.width.replace("px","") / 2) + "px";		
	popup.style.marginTop = "-" + (popup.style.height.replace("px","") / 2) + "px";
		

	// Set focus
	if (wrapper.style.display == "none") {
		wrapper.style.display = "";
		gray.focus();
		
		document.body.onfocus = function() { gray.focus(); };
	} else {
		wrapper.style.display = "none";
		
		document.body.onfocus = function() { return true; };
	}
}