/******************************************************************
******function to toggle (display and hide) any element************
******************************************************************/
function ToggleDisplay(elementID, displayType)
{
	switch(displayType)
	{
		case 'display':
			if(document.getElementById(elementID).style.display=='none')
			{
				document.getElementById(elementID).style.display='block';
			}
			else
			{
				document.getElementById(elementID).style.display='none';
			}
			break;
		case 'visibility':
			if(document.getElementById(elementID).style.visibility=='hidden')
			{
				document.getElementById(elementID).style.visibility='visible';
			}
			else
			{
				document.getElementById(elementID).style.visibility='hidden';
			}
			break;
	}
}

/***************************************************************************************
//function called to create a modal pop-up window
//example:  var pop = new PopUp(); pop.popOut("some content goes here");
//@reload_page is bool to determine if to reload the page where the function is called
//@w & @h determine the width & height dimensions of the popup window
//@dim determines if dimensions are in "pix" or percents "%"
***************************************************************************************/
function PopUp(reload_page, w, h, dim) 
{ 
    this.square = null;
    this.overdiv = null;

    this.popOut = function(msgtxt) 
	{
        //filter:alpha(opacity=25);-moz-opacity:.25;opacity:.25;
        this.overdiv = document.createElement("div");
        this.overdiv.className = "overdiv";

        this.square = document.createElement("div");
        this.square.className = "square";
		this.square.style.height = h + dim;
		this.square.style.width = w + dim;
		this.square.style.marginLeft = -(w/2) + dim;
		this.square.style.marginTop = -(h/2) + dim;
        this.square.Code = this;
        var msg = document.createElement("div");
        msg.className = "msg";
        msg.innerHTML = msgtxt;
        this.square.appendChild(msg);
        
		var closebtn = document.createElement("button");
		closebtn.className = "btn_close";
        closebtn.onclick = function() 
		{
            this.parentNode.Code.popIn();
        }
        closebtn.innerHTML = "OK";
        this.square.appendChild(closebtn);

        document.body.appendChild(this.overdiv);
        document.body.appendChild(this.square);
    }
    this.popIn = function() 
	{
        if (this.square != null) 
		{
            document.body.removeChild(this.square);
            this.square = null;
        }
        if (this.overdiv != null) 
		{
        	document.body.removeChild(this.overdiv);
        	this.overdiv = null;
        }
		//reload the page?
		if(reload_page==true)
		{
			location.reload(true);
		}
    }
}