function expand(id) {
  var elem = document.getElementById(id);
  if (elem) {
    var interior = document.getElementById('id_interior');
    if (elem.style.display != 'none') {
      var width = interior.style.width;
      interior.style.width = '200px'; // mozilla hack
      interior.style.visibility='hidden';
      elem.style.display = 'none';
      interior.style.width = width;
      interior.style.visibility='visible';
    } else {
      var width = interior.style.width;
      interior.style.visibility='hidden';
      interior.style.width = '200px'; // mozilla hack
      elem.style.display = '';
      interior.style.width = width;
      interior.style.visibility='visible';
    }
  }
}

function get_cookie( name )
{
  var all_cookies = document.cookie;
  var pos = all_cookies.indexOf(name);
  if (pos >= 0) {
    if (pos != 1) {
      var start = pos + name.length + 1;
      var end = all_cookies.indexOf(";", start);
      if (end == -1) {
        end = all_cookies.length;
      }
      var value = all_cookies.substring(start, end);
      return unescape(value);
    }
  }

  return "";
}

function delete_cookie( cookie_name )
{
    var d = new Date();
    document.cookie = cookie_name + "=mitcheljh;expires=" + d.toGMTString() + ";path=/" + ";";

}

function open_external_link( lnk )
{
  var width = screen.availWidth - 100;
  var height = screen.availHeight - 100;
  var new_wnd = window.open( lnk, 'new_wnd', 'height=' + height + ',width=' + width + ',scrollbars,resizable', true );
  new_wnd.moveTo(50,50);
  new_wnd.focus();
}


function on_toplink_btn_mousedown( btn_id )
{
    switch( btn_id )
  {
  case 'id_tl_home':
      document.location='/index.php';
    break;

  case 'id_tcl_overview':
     location='/tree_container_library/overview.php';
     break;

  case 'id_tcl_download':
     location='/tree_container_library/download.php';
     break;

  case 'id_tl_latest_news':
     location='/latest_news.php';
     break;

  case 'id_tl_xportpro_download':
     location='/xportpro/download.php';
     break;
  }
}

function on_footer_btn_mousedown( btn_id )
{
    switch( btn_id )
  {
  case 'id_tl_about_us':
      document.location='/about_us/overview.php';
    break;

  case 'id_tl_terms_of_use':
     location='/about_us/terms_of_use.php';
     break;

  case 'id_tl_privacy_policy':
     location='/about_us/your_privacy.php';
     break;

  case 'id_tl_contact_us':
     location='/about_us/contact_us.php';
     break;
    }

}


function set_content_height()
{
  var height = Math.max( document.getElementById('id_div_content').offsetHeight, window.screen.availHeight * 4/5 ) + 'px';
  document.body.style.height = height;
}

function open_help_file( src_file )
{
  var help_wnd = window.open( src_file, 'rounding_wnd', 'height=400,width=400,scrollbars', true );
  help_wnd.focus();
}

var img_wnd;  // global var
function open_thumbnail( src_img )
{
  img_wnd = window.open( "/main/php/generic_image_wnd.php?image=" + src_img, 'thumbnail_img',  'height=20 width=30', true );
  img_wnd.focus();
}

function rshadow(elem, pngPathName, dimensions)
{
  size =  pngPathName.substr(pngPathName.length - 2) + 'px';
  nsize = '-' + size;
  $elem = $(elem);

  // add corners
  if (dimensions[0][0] > 0) {
    $elem.append($('<img/>')
      .attr( {'src' : (dimensions[0].length > 3 ? dimensions[0][3] : pngPathName) + '_topleft.png', 'alt' : '' })
      .css({'position' : 'absolute', 'height' : dimensions[0][2] + 'px', 'left' : -dimensions[0][1] + 'px', 'top' : -dimensions[0][2] + 'px' }))
  }
  if (dimensions[2][0] > 0) {
    $elem.append($('<img/>')
      .attr( {'src' : (dimensions[2].length > 3 ? dimensions[2][3] : pngPathName) + '_topRight.png', 'alt' : '' })
      .css({'position' : 'absolute', 'right' : -dimensions[2][1] + 'px', 'top' : -dimensions[2][2] + 'px' }))
  }
  if (dimensions[4][0] > 0) {
    $elem.append($('<img/>')
      .attr( {'src' : (dimensions[4].length > 3 ? dimensions[4][3] : pngPathName) + '_bottomRight.png', 'alt' : '' })
      .css({'position' : 'absolute', 'height' : dimensions[4][2] + 'px', 'right' : -dimensions[4][1] + 'px', 'bottom' : -dimensions[4][2] + 'px' }))
  }
  if (dimensions[6][0] > 0) {
    $elem.append($('<img/>')
      .attr( {'src' : (dimensions[6].length > 3 ? dimensions[6][3] : pngPathName) + '_bottomLeft.png', 'alt' : '' })
      .css({'position' : 'absolute', 'left' : -dimensions[6][1] + 'px', 'bottom' : -dimensions[6][2] + 'px' }))
  }

  // add sides
  if (dimensions[1][0] > 0) {
    $elem.append($('<div></div>')
      .css({'position' : 'absolute', 'top' : -dimensions[1][1] + 'px', 'left' : '0px', 'height' : dimensions[1][0] + 'px', 'width' : '100%', 'background' : 'url(' + (dimensions[1].length > 3 ? dimensions[1][3] : pngPathName) + '_top.png) repeat-x'}))
  }
  if (dimensions[3][0] > 0) {
    $elem.append($('<div></div>')
      .css({'position' : 'absolute', 'top' : '0px', 'right' : -dimensions[3][1] + 'px', 'width' : dimensions[3][0] + 'px', 'height' : '100%', 'background' : 'url(' + (dimensions[3].length > 3 ? dimensions[3][3] : pngPathName) + '_right.png) repeat-y'}))
  }
  if (dimensions[5][0] > 0) {
    $elem.append($('<div></div>')
      .css({'position' : 'absolute', 'bottom' : -dimensions[5][1] + 'px', 'left' : '0px', 'height' : dimensions[5][0] + 'px', 'width' : '100%', 'background' : 'url(' + (dimensions[5].length > 3 ? dimensions[5][3] : pngPathName) + '_bottom.png) repeat-x'}))
  }
  if (dimensions[7][0] > 0) {
    $elem.append($('<div></div>')
      .css({'position' : 'absolute', 'top' : '0px', 'left' : -dimensions[7][1] + 'px', 'width' : dimensions[7][0] + 'px', 'height' : '100%', 'background' : 'url(' + (dimensions[7].length > 3 ? dimensions[7][3] : pngPathName) + '_left.png) repeat-y'}))
  }

  // add margins
  if (dimensions[1][0] > 0) {
    $elem.css('margin-top', function(index, value) { return parseInt(value) + dimensions[1][2] - 12 + 'px'; })
  }
  if (dimensions[3][0] > 0) {
    $elem.css('margin-right', function(index, value) { return parseInt(value) + dimensions[3][2] + 'px'; })
  }
  if (dimensions[5][0] > 0) {
    $elem.css('margin-bottom', function(index, value) { return parseInt(value) + dimensions[5][2] + 'px'; });
  }
  if (dimensions[7][0] > 0) {
    $elem.css('margin-left', function(index, value) { return parseInt(value) + dimensions[7][2] + 'px'; })
  }

}


function applyCornerShadows(group)
{
  if (group == 'index') {
    rshadow('#id_banner', '/common/images/shadow/header', [ [25,25,25], [25,25,15], [25,25,25], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#id_toplink', '/common/images/shadow/toplink25', [ [0,0,0], [0,0,0], [0,0,0], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#services', '/root/content/images/shadow/topFold', [[0,0,0], [0,0,0], [0,0,0], [13,11,-1], [25,9,8], [0,0,0], [25,8,8], [11,8,-1]]);
    rshadow('#id_interior', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/green'], [0,0,0], [25,8,8,'/common/images/shadow/green'], [11,9,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#wts', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/maroon'], [0,0,0], [25,8,8,'/common/images/shadow/maroon'], [11,9,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#id_footer', '/common/images/shadow/bottomLink', [ [0,0,0], [0,0,0], [0,0,0], [25,25,15, '/common/images/shadow/toplink25'], [25,25,25], [25,25,15], [25,25,25], [25,25,15, '/common/images/shadow/toplink25']]);
  } else if (group == 'general') {
    rshadow('#id_banner', '/common/images/shadow/header', [ [25,25,25], [25,25,15], [25,25,25], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#id_toplink', '/common/images/shadow/toplink25', [ [0,0,0], [0,0,0], [0,0,0], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#id_interior', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/green'], [0,0,0], [25,8,8,'/common/images/shadow/green'], [11,9,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#wts', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/maroon'], [0,0,0], [25,8,8,'/common/images/shadow/maroon'], [11,8,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#id_footer', '/common/images/shadow/bottomLink', [ [0,0,0], [0,0,0], [0,0,0], [25,25, 15, '/common/images/shadow/toplink25'], [25,25,25], [25,25,15], [25,25,25], [25,25,15, '/common/images/shadow/toplink25']]);
  } else if (group == 'tcl') {
    rshadow('#id_banner', '/common/images/shadow/header', [ [25,25,25], [25,25,15], [25,25,25], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#id_toplink', '/common/images/shadow/toplink25', [ [0,0,0], [0,0,0], [0,0,0], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#tcl_header', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/tree_container_library/images/shadow/tcl'], [0,0,0], [25,8,8,'/tree_container_library/images/shadow/tcl'], [11,9,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#id_interior', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/green'], [0,0,0], [25,8,8,'/common/images/shadow/green'], [11,9,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#wts', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/maroon'], [0,0,0], [25,8,8,'/common/images/shadow/maroon'], [11,8,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#id_footer', '/common/images/shadow/bottomLink', [ [0,0,0], [0,0,0], [0,0,0], [25,25, 15, '/common/images/shadow/toplink25'], [25,25,25], [25,25,15], [25,25,25], [25,25,15, '/common/images/shadow/toplink25']]);
  } else if (group == 'xport') {
    rshadow('#id_banner', '/common/images/shadow/header', [ [25,25,25], [25,25,15], [25,25,25], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#id_toplink', '/common/images/shadow/toplink25', [ [0,0,0], [0,0,0], [0,0,0], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#id_interior', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/green'], [0,0,0], [25,8,8,'/common/images/shadow/green'], [11,9,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#wts', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/maroon'], [0,0,0], [25,8,8,'/common/images/shadow/maroon'], [11,8,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#id_footer', '/common/images/shadow/bottomLink', [ [0,0,0], [0,0,0], [0,0,0], [25,25, 15, '/common/images/shadow/toplink25'], [25,25,25], [25,25,15], [25,25,25], [25,25,15, '/common/images/shadow/toplink25']]);
  } else if (group == 'services') {
    rshadow('#id_banner', '/common/images/shadow/header', [ [25,25,25], [25,25,15], [25,25,25], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#id_toplink', '/common/images/shadow/toplink25', [ [0,0,0], [0,0,0], [0,0,0], [25,25,15], [25,25,8,'/common/images/shadow/maroon'], [0,0,0], [25,25,8,'/common/images/shadow/maroon'], [25,25,15]]);
    rshadow('#services_top_pane', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [13,11,-1,'/root/content/images/shadow/topFold'], [25,9,8,'/common/images/shadow/green'], [0,0,0], [25,8,8,'/common/images/shadow/green'], [11,10,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#id_interior', '/root/content/images/shadow/wts', [[0,0,0], [0,0,0], [0,0,0], [11,8,-2,'/root/content/images/shadow/topFold'], [25,8,8,'/common/images/shadow/green'], [0,0,0], [25,8,8,'/common/images/shadow/green'], [11,9,-1,'/root/content/images/shadow/topFold']]);
    rshadow('#id_footer', '/common/images/shadow/bottomLink', [ [0,0,0], [0,0,0], [0,0,0], [25,25,15, '/common/images/shadow/toplink25'], [25,25,25], [25,25,15], [25,25,25], [25,25,15, '/common/images/shadow/toplink25']]);
  }
}
