/* sidebar needs to be the same size as maincontent if maincontent is bigger*/
var originalSidebarHeight;

window.onload=function()
{	
	var sidebarDiv = this.getObject("sidebar");

	if(sidebarDiv.offsetHeight){
		originalSidebarHeight = sidebarDiv.offsetHeight;
    }
    else if(sidebarDiv.style.pixelHeight){
        originalSidebarHeight = sidebarDiv.style.pixelHeight;
    }

	
    layoutPage();
}

window.onresize=function()
{
	layoutPage();
}
window.onscroll=function()
{
	layoutPage();
}

function layoutPage()
{
	var maincontentDivHeight = 0;
	var sidebarDivHeight = 0;
	
	var maincontentDiv = this.getObject("mainContent");
	var sidebarDiv = this.getObject("sidebar");
	
	if(sidebarDiv != null && maincontentDiv != null)
	{
	
		if(maincontentDiv.offsetHeight){
            maincontentDivHeight = maincontentDiv.offsetHeight;
        }
        else if(maincontentDiv.style.pixelHeight){
            maincontentDivHeight = maincontentDiv.style.pixelHeight;
        }
        
        if(sidebarDiv.offsetHeight){
			sidebarDivHeight = sidebarDiv.offsetHeight;
        }
        else if(sidebarDiv.style.pixelHeight){
            sidebarDivHeight = sidebarDiv.style.pixelHeight;
        }
		
		if(maincontentDivHeight > originalSidebarHeight)
		{
			sidebarDiv.style.height = maincontentDivHeight + "px";
			
			if (sidebarDiv.offsetHeight > maincontentDivHeight)
			{
				sidebarDiv.style.height = (maincontentDivHeight - (sidebarDiv.offsetHeight - maincontentDivHeight)) + 'px';
			}
			
		}
		
	}
	
}

function getObject(id)
{
  if (document.getElementById)
  {
  	return document.getElementById(id);
  }
  else if (document.all)
  {
	return document.all[id];
  }
  else if (document.layers)
  {
	   if (document.layers[id])
	   {
	   	return document.layers[id];
	   }	
  }
}

function HideBadLogin(messageID)
{
	if(document.getElementById(messageID) != null)
	{
		document.getElementById(messageID).style.display = 'none';
	}
}

function SubmitForm(buttonID, e)
{

    var key;

    if(window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

	if (key == 13)
	{
		__doPostBack(buttonID,'');
	}  
}