﻿



//will make the target element the same height as the copy from element + or - the offset   
//use 0 for the offset if you want them to be the exact same height
function MakeSameHeight(TargetID, CompareID, offset)
{
	var TargetHeight = GetElementHeight(TargetID)
	var CopyHeight = GetElementHeight(CompareID)
	if (TargetHeight && CopyHeight)
	{
		//only change the target height if it is smaller than the copy height
		if ( (TargetHeight + offset) < CopyHeight)
		{
			SetElementHeight(TargetID, CopyHeight + offset);
		}
	}
}

//this function will make the target elemtents be as tall as the tallest one of them
function MakeSameHeightAsTallest (ElementID1, ElementID2)
{
	var HeightElement1 = GetElementHeight(ElementID1)
	var HeightElement2 = GetElementHeight(ElementID2)
	if (HeightElement1 && HeightElement2)
	{
		if (HeightElement2 > HeightElement1)
		{
			MakeSameHeight(ElementID1, ElementID2, 0);
		}
		else
		{
			MakeSameHeight(ElementID2, ElementID1, 0);
		}
	}
}

//this function will make the target elemtents be as tall as the compare if the compare is taller
function MakeSameHeightIfTaller (TargetID, CompareID)
{
	var TargetHeight = GetElementHeight(TargetID)
	var CompareHeight = GetElementHeight(CompareID)
	if (TargetHeight && CompareHeight)
	{
		if (TargetHeight < CompareHeight)
		{
			MakeSameHeight(TargetID, CompareID, 0);
		}
		
	}
}

//this function will make the target elemtents be as tall as the compare if the compare is taller
function MakeSameHeightIfTaller2 (TargetID, CompareHeight)
{
	
	var TargetHeight = GetElementHeight(TargetID)
	
	if (TargetHeight && CompareHeight)
	{
		if (TargetHeight < CompareHeight)
		{
			SetElementHeight(TargetID, CompareHeight);
		}
		
	}
}

//set the height in pixels
function SetElementHeight(ElementID, height)
{
	var e = document.getElementById(ElementID)
	if (e)
	{
		e.style.height = height + 'px';
	}
}


//get the height in pixels
function GetElementHeight(ElementID)
{
	var e = document.getElementById(ElementID)
	if (e)
	{
		return e.offsetHeight;
	}
	else
	{
		return false;
	}
}

function scrolltobottom()
{
	dh=document.body.scrollHeight
	ch=document.body.clientHeight
	if(dh>ch)
	{
		moveme=dh-ch
		window.scrollTo(0,moveme)
	}
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

