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_tl_xport_overview':
     location='/xport/overview.php';
     break;
     
  case 'id_tl_xport_download':
     location='/xport/download.php';
     break;
     
  case 'id_tl_xportpro_overview':
     location='/xportpro/overview.php';
     break;
     
  case 'id_tl_xportpro_purchase':
     location='/xportpro/purchase.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();
}

// preload images
Image1= new Image(5,10);
Image1.src = "/common/images/interior_top.png";

Image2 = new Image(5,10);
Image2.src = "/common/images/interior_bottom.png";

Image3 = new Image(10,5);
Image3.src = "/common/images/interior_right.png";

Image4 = new Image(10, 5);
Image4.src = "/common/images/interior_left.png";

Image5 = new Image(20,40);
Image5.src = "/common/images/toplink_right.png";

Image6 = new Image(20,40);
Image6.src = "/common/images/toplink_left.png";

Image7 = new Image(20,20);
Image7.src = "/common/images/interior_top_left.png";

Image8 = new Image(20,20);
Image8.src = "/common/images/interior_top_right.png";

Image9 = new Image(20,20);
Image9.src = "/common/images/interior_bottom_left.png";

Image10 = new Image(20,20);
Image10.src = "/common/images/interior_bottom_left.png";

Image11 = new Image(15,25);
Image11.src = "/common/images/grey_gradient.jpg";

Image12 = new Image(15,25);
Image12.src = "/common/images/red_gradient.jpg";

