TTLinks={

TTLinksId : 'theTTLinksId',

screenReader : true,
Mp3 : true,
readStory : true,
stop : true,
zoomIn : true,
zoomOut : true,
zoomReset : true,

screenReaderLinkId : 'screenReaderLink',
screenReaderLinkOn : 'Turn screen reader on',
screenReaderLinkOff : 'Turn screen reader off',

TTcontentId : false,

mp3Link : 'Save as MP3',
readMainStoryLink : 'Read main story',
stopLink : 'Stop reading',
zoomInLink : 'Zoom in',
zoomOutLink : 'Zoom out',
zoomResetLink : 'Reset zoom',

linkBgColor : '#000000',
linkColor : '#ffffff',

//updates link on page load
screenReaderLink : function()
{
 
  try
  {  
    loadedTTCookie = getCookies('loadedTT');
  
    el = document.getElementById(this.screenReaderLinkId);
    
    if(loadedTTCookie==2)
    {
      el.innerHTML=this.screenReaderLinkOff;
      el.title=this.screenReaderLinkOff;
    }
    else
    {
      el.innerHTML=this.screenReaderLinkOn;
      el.title=this.screenReaderLinkOn;
    }
  
  }
  catch(err)
  {
    setTimeout('TTLinks.screenReaderLink()', 200);
  }
  
},

//toggles screenreader and link
screenReaderToggle : function()
{
  ToggleOnOff();
  
  var el = document.getElementById(this.screenReaderLinkId);
   
  if(loadedTT==2)
  {
    el.innerHTML=this.screenReaderLinkOff;
    el.title=this.screenReaderLinkOff;
  }
  else
  {
    el.innerHTML=this.screenReaderLinkOn;
    el.title=this.screenReaderLinkOn;
  }
  
},

SaveTT2 : function() 
{ 
  document.TexticTalkSubmit.TextIn.value=seltxt; 
  document.TexticTalkSubmit.Down.value=DLconst; 
  document.TexticTalkSubmit.submit(); 
  document.TexticTalkSubmit.Down.value=0;
},

mp3ById : function()
{
  //dont find story
  setselecttext(1);
  
  //FF thinks seltxt is an object?
  seltxt+='';
  
  if(!seltxt)
  {
  
    elmp3 = document.getElementById(this.TTcontentId);
  
    curtext = elmp3.innerHTML; 
    
    //clear the last text read. 
    lasttext = ""; 
    //Read it. 
  
    seltxt = ReplaceTags(curtext);
  }
    
  this.SaveTT2();

},

saveMp3 : function()
{
  if(this.TTcontentId)
  {
    this.mp3ById();
  }
  else
  {
    SaveTT();
  }
},

readMainStory : function()
{ 
  
  if(this.TTcontentId)
  {
    el = document.getElementById(this.TTcontentId); 
      
    curtext= el.innerHTML;
       
  }
  else
  {
    FindStory();

    curtext= curel.innerHTML;
  
  }

  lasttext="";
  
  curtext= ReplaceTags(curtext);
  
  readit();
  
},

displayTTLinks : function()
{

  try
  {
  
    var TTel = document.getElementById(this.TTLinksId);
  
    var TTLinks='';
  
    //screenreader link
    TTLinks +=(this.screenReader)?'<a href="javascript:TTLinks.screenReaderToggle();" id="'+this.screenReaderLinkId+'" >'+this.screenReaderLinkOn+'</a>':'';
  
    //mp3 link
    TTLinks +=(this.Mp3)?'<a href="javascript:TTLinks.saveMp3();">'+this.mp3Link+'</a>':'';
  
    //read main story link
    TTLinks +=(this.readStory)?'<a href="javascript:TTLinks.readMainStory();">'+this.readMainStoryLink+'</a>':''; 
  
    TTLinks +=(this.stop)?'<a href="javascript:TTStopPlaying();">'+this.stopLink+'</a>':''; 

    TTLinks +=(this.zoomIn)?'<a href="javascript:zoomIn();">'+this.zoomInLink+'</a>':'';

    TTLinks +=(this.zoomOut)?'<a href="javascript:zoomOut();">'+this.zoomOutLink+'</a>':'';

    TTLinks +=(this.zoomReset)?'<a href="javascript:resetZoom();">'+this.zoomResetLink+'</a>':'';
    
    //stop onoff error
    TTLinks +='<span id="OnOff"></span>';
    
    TTel.innerHTML = TTLinks;
  
  }
  catch(e)
  {
    setTimeout('TTLinks.displayTTLinks()', 200);
  }
      
},

preserveLinkBackground : function()
{
  try
  {
    var el = document.getElementById(this.screenReaderLinkId);
  
    el.onmouseout = function()
    {
      el.style.backgroundColor=TTLinks.linkBgColor;
      el.style.color=TTLinks.linkColor;    
    }
  }
  catch(e)
  {
    setTimeout('TTLinks.preserveLinkBackground()', 200);    
  }
  
},


innit : function()
{

  TTLinks.displayTTLinks();

  TTLinks.screenReaderLink();

  TTLinks.preserveLinkBackground();

}

}


//id of links container
TTLinks.TTLinksId = 'theTTLinksId';
// display screen reader link - true/false
TTLinks.screenReader = true;
// display mp3 link - true/false
TTLinks.Mp3 = true;
// display read main story link - true/false
TTLinks.readStory = true;
// display stop link - true/false
TTLinks.stop = true;
// display zoom in - true/false
TTLinks.zoomIn = true;
// display zoom out - true/false
TTLinks.zoomOut = true;
// display zoom reset - true/false
TTLinks.zoomReset = true;
// id for screen reader link
TTLinks.screenReaderLinkId = 'screenReaderLink';
// screen reader link on text
TTLinks.screenReaderLinkOn =  '<img src="image/on.jpg" alt="turn talking text on" />';
// screen reader link off text
TTLinks.screenReaderLinkOff = '<img src="image/off.jpg" alt="turn talking text off" />';
// if using element with id for main story text, leave blank to use smart story finder - id/false
TTLinks.TTcontentId = 'TTcontent';
// mp3 link text
TTLinks.mp3Link = '<img src="image/mp3.jpg" alt="save content as MP3" />';
// main story link text
TTLinks.readMainStoryLink = '<img src="image/read.jpg" alt="Read main story" />';
// stop link text
TTLinks.stopLink = '<img src="image/stop.jpg" alt="stop reading" />';
// zoom in link text
TTLinks.zoomInLink = '<img src="image/zoom.jpg" alt="increase text size" />';
// zoom iout link text
TTLinks.zoomOutLink = '<img src="image/decrease.jpg" alt="decrease text size" />';
// resret zoom  link text
TTLinks.zoomResetLink = '<img src="image/reset.jpg" alt="Reset zoom" />';
//links background color - prevents stuck link highlight when turning screen reader off
TTLinks.linkBgColor = '#ffffff';
//links text color - prevents stuck link highlight when turniing screen reader off
TTLinks.linkColor = '#0033FF';


window.onload= TTLinks.innit;

TTLinks.innit();