/** Must include cookie.js before this file
  * to initialise value of "greeting".
  * Otherwise initialise it here....
  *
  * Added class=title to <a> tags. Different hover behaviour,
  * see mastyle1.css
  */

var browser = navigator.appName;
/* These not used any more (?)
var w = screen.width;
var colour = document.bgColor;
var orig_colour = "#CCFFFF";
var new_colour = "#003300";
var colour2 = "#CCCCCC";
var bg = document.background;
*/


/** GET PAGENAME ------------------------------------------------------------------
  * What you will get is the filename of the page, without the .html on the end.
  *
  * This is used to decide which page/s to exclude from the default stylesheet
  * (mastyle1) - presently the microsites page which has its own stylesheet.
  *
  */
  var strings = new Array();
  strings = document.location.pathname.split("/");
//  alert(strings);
  strings = strings[strings.length-1].split(".");
  strings = strings[0].split("\\");
  var pagename = strings[strings.length-1];
  var folder = strings[strings.length-2];

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

// "greeting" is set up in cookie.js

// regexp any filename with *sites* in it. sites page has its own stylesheet.
var excludefromss = /^sites|^chat/;
// Case sensitive...
var page_title = /Welcome|WOMAD/;


if(browser == "Microsoft Internet Explorer")
{
  document.write('<META http-equiv="Page-Enter" CONTENT="RevealTrans(Duration=1,Transition=6)">');

    // FRONT PAGE OF SITE
//    if(document.title == "Welcome to serlin.co.uk")
    if(page_title.test(document.title))
    {
      document.write('<div id="top-title"><h2>'+greeting+'</h2></div><P>&nbsp;</P>');
   		document.write('<link rel="stylesheet" href="ss/mastyle1.css">');
   		status=greeting;
    }
    // REST OF SITE
    else
    {
     /** Testing document.location.pathname instead of pagename here
         creates havoc with the stylesheet!
       */
      // If there's no legacy stylesheet...
	    if(!excludefromss.test(pagename))
    		document.write('<link rel="stylesheet" href="../ss/mastyle1.css">');

      // IF PAGE IS LOCATED IN ROOT FOLDER
      // open DIV
      if(this.section  && this.section == "root")
      {
        document.write('<div id="top"><h3><a href="index.html" class="title">serlin.co.uk</a> - ');
      }
    // PAGE IS ONE FOLDER DEEP eg /work
    else
    {
      document.write('<div id="top"><h3><a href="../" class="title">serlin.co.uk</a> - ');
    }
    // IF PAGE IS NOT THE INDEX PAGE
    if(this.section && this.section != "root")
    {
      /** It may be linked on from the [folder]_index page.
        * Now that I'm using an .htaccess file we can just go
        * back to this folder - net result is fewer 404's since the
        * page we are on might have a number of referers within the
        * site (due to ssi include method).
        */
  	  document.write('<a class="title" href="./">');
  	  document.write(this.section + '</a> - ');

		// ...or it may be linked on again, from the one above.
		if(this.subsection)
		{
		  document.write('<a class="title" href="');
		  document.write(this.subsection.toLowerCase() + '.html">');
		  document.write(this.subsection + '</a> - ');
		}

		    // Write the page title if there is one
		    if(document.title)document.write(document.title);
     }

     // IF PAGE IS THE INDEX OR ROOT FILE
     else if(document.title)document.write(document.title);
     // close DIV
     document.write('</h3></div><P>&nbsp;</P>');

    if(document.title)status = "www.serlin.co.uk - " + document.title;

   }
}




// ----- NETSCAPE: FIREFOX?! -----------------------------------------------------
else
{
  document.write('<link rel="stylesheet" href="../ss/mastyle1.css">');
  if(document.title == "Welcome")
  {
    document.write('<h2>'+greeting+'</h2><hr>');
  }
  else
  {
    document.write('<h3><a class="title" href="../index.html" class="title">serlin.co.uk</a> - ');
    if(this.section && this.section != "root")
    {
	    document.write('<a class="title" href="' + this.section + '_index.html">');
	    document.write(this.section + '</a> - ');

  	  if(this.subsection)
		   {
    	   document.write('<a class="title" href="' + this.subsection.toLowerCase() + '.html">');
    	   document.write(this.subsection + '</a> - ');
    	 }

      if(document.title)document.write(document.title);
    }
    else if(document.title)document.write(document.title);
    document.write('</h3>');
  }
}



  