// ------ site javascript ----


main_email_addr = 'service@jdss.org.uk';


// ---------------------------


new_win_params = 'width=' + ( screen.width ) + ', height=' + ( screen.height ) + ', toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes';


// ---------------------------


function put_email_link()	/* 1st optional arg is text to display, second is css class */
{
  var argv = arguments;
  var argc = arguments.length;

  var theText = ( arguments.length > 0 ) ? arguments[0] : 'email';
  var css_class = ( arguments.length > 1 ) ? arguments[1] : '';

  document.write( "<a href='mailto:" + main_email_addr + "' class='" + css_class + "' title='Contact via email'>" + theText + "</a>" );
}


// ---------------------------


function log_out()
{
  if( confirm( "Log Out Now?" ) ) {
    self.location.href = document.URL + "?log_out=1";
  }
}


// ---------------------------


function close_win( win )
{
  if( win && !win.closed ) win.close();
}


// ---------------------------


function setFocus( field_id )
{
  document.getElementById( field_id ).focus();
}


// ---------------------------


function setCookie( c_name, value, expiredays )
{
  var exdate = new Date();
  exdate.setDate( exdate.getDate() + expiredays );
  document.cookie = c_name + "=" + escape( value ) + ( ( expiredays==null ) ? "" : ";expires=" + exdate.toUTCString() ) ;
}

function getCookie( c_name )
{
  if( document.cookie.length > 0 ) {
    c_start = document.cookie.indexOf( c_name + "=" );
    if( c_start != -1 ) {
      c_start = c_start + c_name.length + 1;
      c_end = document.cookie.indexOf( ";", c_start );
      if( c_end == -1 ) {
        c_end = document.cookie.length;
      }
      return unescape( document.cookie.substring( c_start, c_end ) );
    }
  }
  return "";
}


// ---------------------------


function not_yet() {
  alert( 'Sorry, this is not yet functioning' );
}


