lEnabled=false
lEnabledTimer=false
lEnabledStore=false

function Generic(tcLink)
{
   lEnabled=true
   defaultStatus="Waiting for "+lcHttp+"/DataEntrySpanIt.aspx?Session="+tcLink+"..."
   document.getElementById("IFrameGeneric").src="DataEntrySpanIt.aspx?Session="+tcLink
}

function GenericOnActivate()
{
   loIFrame=document.getElementById("IFrameGeneric")

   // If the page has finished loading
   if (typeof lcHttp != "undefined")
   {

      if (lcHttp != "about:blank")
      {
         // defaultStatus="Waiting for "+lcHttp+"/"+loIFrame.src+"..."
      }

   }

}

function GenericOnLoad()
{

   if (lEnabled)
   {
      lEnabled=false
      lcDiv=document.getElementById("Generic")

      if (document.getElementById("IFrameGeneric").contentWindow.document)
      {
         lcIFrame=document.getElementById("IFrameGeneric").contentWindow.document.body.innerHTML
      }

      lcDiv.innerHTML=lcIFrame

      // If we have some javascript
      if (document.getElementById("IFrameGeneric").contentWindow.document.getElementById("LXJavascript"))
      {
         lcIFrame=document.getElementById("IFrameGeneric").contentWindow.document.getElementById("LXJavascript").innerHTML
         ss=document.createElement('script')
         lcIFrame=lcIFrame.replace(RegExp("LX@@","g"),"\n")
         ss.text=lcIFrame
         lcDiv.appendChild(ss)
      }

      // If we have to set the focus on a field
      if (document.getElementById("IFrameGeneric").contentWindow.document.getElementById("LXFocus"))
      {
         lcField=document.getElementById("IFrameGeneric").contentWindow.document.getElementById("LXFocus").innerHTML
         document.getElementById(lcField).focus()
      }

      defaultStatus="Done"
   }

}

// This is the timer that will be called every minute
function Timer()
{

   if (lEnabledTimer)
   {
      return
   }

   // If we have a next event or a photo one
   if (document.getElementById("NextEvent") || document.getElementById("PhotoOne"))
   {
      lEnabledTimer=true
      GenericTimer("766D44367A416533334B633D20766358304364686D67377953357534374B6F6E7367673D3D")
      setTimeout("Timer()",60000)
   }
}

function GenericTimer(tcLink)
{
   defaultStatus="Waiting for "+lcHttp+"/DataEntrySpanIt.aspx?Session="+tcLink+"..."
   document.getElementById("IFrameGenericTimer").src="DataEntrySpanIt.aspx?Session="+tcLink
}

function GenericTimerOnLoad()
{

   if (lEnabledTimer)
   {
      lEnabledTimer=false

      if (document.getElementById("IFrameGenericTimer").contentWindow.document)
      {
         loIFrame=document.getElementById("IFrameGenericTimer").contentWindow.document

         // Just in case
         if (document.getElementById("NextEvent"))
         {
            loDiv=document.getElementById("NextEvent")

            // If we have a next event
            if (loIFrame.getElementById("NextEvent"))
            {
               loIFrameDiv=loIFrame.getElementById("NextEvent")
               loDiv.innerHTML=loIFrameDiv.innerHTML
            }

         }

         // Just in case
         if (document.getElementById("PhotoOne"))
         {
            loDiv=document.getElementById("PhotoOne")

            // If we have a next event
            if (loIFrame.getElementById("PhotoOne"))
            {
               loIFrameDiv=loIFrame.getElementById("PhotoOne")
               loDiv.innerHTML=loIFrameDiv.innerHTML
            }

         }

      }

      defaultStatus="Done"
   }

}

function GenericStore(tcLink)
{
   lEnabledStore=true
   defaultStatus="Waiting for "+lcHttp+"/DataEntrySpanIt.aspx?Session="+tcLink+"..."
   document.getElementById("IFrameGenericStore").src="DataEntrySpanIt.aspx?Session="+tcLink
}

function GenericStoreOnLoad()
{

   if (lEnabledStore)
   {
      lEnabledStore=false

      if (document.getElementById("IFrameGenericStore").contentWindow.document)
      {
         loIFrame=document.getElementById("IFrameGenericStore").contentWindow.document

         // Just in case
         if (document.getElementById("GenericStore"))
         {
            loDiv=document.getElementById("GenericStore")

            // If we have a return
            if (loIFrame.getElementById("LXReturn"))
            {
               loIFrameDiv=loIFrame.getElementById("LXReturn")
               loDiv.innerHTML=loIFrameDiv.innerHTML
            }

            // If we have some javascript
            if (loIFrame.getElementById("LXJavascript"))
            {
               loIFrameDiv=loIFrame.getElementById("LXJavascript")
               lcIFrame=loIFrameDiv.innerHTML
               ss=document.createElement('script')
               lcIFrame=lcIFrame.replace(RegExp("LX@@","g"),"\n")
               ss.text=lcIFrame
               loDiv.appendChild(ss)
            }

         }

      }

      defaultStatus="Done"
   }

}