function getbgframe()
{
  var ca = document.getElementById('coverall');

  if ( ca == null || ca == undefined )
  {
    ca = parent.document.getElementById('coverall');
  }

  return ca;
}

function getcontentbounds( root )
{
  var bounds = new Rectangle(0, 0, 0, 0);

  bounds.width  = root.document.body.scrollWidth;    
  bounds.height = root.document.body.scrollHeight;

  return bounds;
}

function getwindowbounds(root)
{
  var bounds = new Rectangle(0, 0, 0, 0);

  if (root.innerHeight) 
  {
      bounds.height = root.innerHeight;
      bounds.width  = root.innerWidth;
  } 
  else if ( root.document.documentElement &&
            root.document.documentElement.clientHeight) 
  {
      bounds.height = root.document.documentElement.clientHeight;
      bounds.width  = root.document.documentElement.clientWidth;
  } 
  else if (root.document.body) 
  {
      bounds.height = root.document.body.clientHeight;
      bounds.width  = root.document.body.clientWidth;
  }

  return bounds;
}

function refitbgframe()
{
  var bg = getbgframe();
  
  var cb;
  var vb;
  
  if ( isnested() )
  {
    cb = getcontentbounds(parent);
    vb = getwindowbounds(parent);
  }
  else
  {
    cb = getcontentbounds(self);
    vb = getwindowbounds(self);
  }
  
  bg.style.width = Math.max( cb.width, vb.width ) + 'px';
  bg.style.height = Math.max( cb.height, vb.height ) + 'px';
}

function isnested()
{
  var ca = document.getElementById( 'coverall' );
  
  return ca == null || ca == undefined;
}

function grayoutbg()
{
  var ca = getbgframe();
  
  refitbgframe();

  ca.style.display='block';
}

function ungrayoutbg()
{
  var ca = getbgframe();

  ca.style.display='none';
}


function getScroll(win)
{

    return [parent.pageXOffset,parent.pageYOffset];


}

function assertEmailControl( id )
{
  var obj = byID( id );

  if ( obj.value.trim().length < 1 || !assertEmail(obj.value.trim()) )
  {
    obj.style.borderColor = 'red';
    alert( "Please enter a valid Email." );
    return false;
  }
  else
  {
      obj.style.borderColor = null;
  }

  return true;
}

function assertEditControl( id, desc)
{
  var obj = byID( id );

  if ( obj.value.trim().length < 1 )
  {
    obj.style.borderColor = 'red';
    alert( "Please enter a value for '" + desc + "' before continuing." );
    return false;
  }
  else
  {
      obj.style.borderColor = null;
  }

  return true;
}

function doLogout()
{
  location.href='http://www.bizcard.com/logout.hd';
}
