function showPopUp(strID)
{
    var objDiv = document.getElementById(strID);
    objDiv.style.display = "block";
}
function hidePopUp(strID)
{
    var objDiv = document.getElementById(strID);
    objDiv.style.display = "none";
}

function popCal(id, e)
{
    var x = 200;
    var y = 200;    
    if (e != null)
    {
        x = e.screenX;
        y = e.screenY;
    }
    else
    {
        x = (getScreenSize("W") / 2) - 100;
        y = (getScreenSize("H") / 2) - 100;
    }
    
	link = window.open("/webCal.aspx?id=" + id,"Cal","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=200,height=168,left=" + x + ",top=" + y + ",alwaysRaised=1");
	link.focus();
}

function popBulkUpload()
{
    link = window.open("/datamanager/bulk.aspx","Bulk","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=550,height=600,alwaysRaised=1");
    if(link) link.focus();
}
function popRFPHistory()
{
    link = window.open("/datamanager/RFPSummary.aspx","History","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=850,height=700,alwaysRaised=1");
    if(link) link.focus();
}

function popTokenListing(e) {


	link = window.open("/datamanager/token-listing.aspx","TokenListing","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=550,height=650,left=200,top=200,alwaysRaised=1");
	link.focus();
}

function popRFPProposal(id) {

    // first check to see if the proposal id is not <new>.
    if (id == "<new>")
    {
        alert("Please save the RFP before previewing the layout.");
    }
    else
    {
	    link = window.open("/energy-center/rfp/proposal.aspx?id=" + id,"RFPProposal","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=650,left=200,top=200,alwaysRaised=1");
    	link.focus();
    }
}

function popUsages(id) {

    // first check to see if the proposal id is not <new>.
    if (id == "<new>")
    {
        alert("Please save the Usages before previewing the layout.");
    }
    else
    {
	    link = window.open("/energy-center/rfp/usages.aspx?id=" + id,"RFPProposal","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=650,left=200,top=200,alwaysRaised=1");
    	link.focus();
    }
}

var curECPopUpID = "";
function showECSneakPeak(id, e)
{
    // first hide the current one, if it's showing
    hideECSneakPeak(curECPopUpID);
    
    // now show this first one.
    divPopUp = GetElement(id);
    if (divPopUp != null)
    {
        // set the current popup to this element
        curECPopUpID = id;
        
        // display the popup in a position close to the mouse coords.
        divPopUp.style.display = "block";
        divPopUp.style.top = getMouseCoords(e, "Y") + "px";
        divPopUp.style.left = getMouseCoords(e, "X") + "px";
    }
}

function hideECSneakPeak(id)
{
    divPopUp = GetElement(id);
    
    if (divPopUp != null)
        divPopUp.style.display = "none";
}

function chkFilterDates(strStart, strEnd)
{
    var msg = "";
   
}

function getScreenSize(type) {
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }

    if (type == "W")
        return myWidth;
    else
        return myHeight;
}

function GenerateGetElement()
{
	if (document.getElementById) return function(id) { return document.getElementById(id); }
	else if (document.all) return function(id) { return document.all[id]; }
	else if (document.layers) return function(id) { document.layers[id]; }
}

function getMouseCoords(e, axis) {
	var x = 0;
	var y = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		x = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		y = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	
	if (axis == "Y") return y;
	if (axis == "X") return x;
}

function setDelayedPopUp(iTimeInSeconds)
{
    window.setTimeout("showTimeoutWarning()", iTimeInSeconds*1000);
}

function showTimeoutWarning()
{
    GetElement("delta_timeout_popup").style.display = "block";
}

function hideTimeoutWarning()
{
    GetElement("delta_timeout_popup").style.display = "none";
}

function showTimeoutNotification()
{
    GetElement("timeout_happened_wrapper").style.display = "block";
}

function hideTimeoutNotification()
{
    GetElement("timeout_happened_wrapper").style.display = "none";
}
var ShowConfirmExit = true;
function BackButtonclick()
{
    window.onbeforeunload = confirmExit;
}
function confirmExit()
{
if (ShowConfirmExit)
    return "You have attempted to leave this page.  If you have made any changes to the fields without clicking the Submit button, your changes will be lost.  Are you sure you want to exit this page?";
}


var GetElement;
GetElement = GenerateGetElement();
