///////////////////////////////////////////////////
// called by onload event
function setUp()
{
  //topNavHighligh()
  //leftNavHighlight()
  scrollerSetUp()
}

var strCurrentSection = "" // used to disable top-nav rollover
var strCurrentSubSection = "" // used to sisable side navigation
var blnScrollerToggle = true // scroller toggle

///////////////////////////////////////////////////
// sets up the homepage scroller
function scrollerSetUp()
{
  if (document.getElementById)
  {
    if (document.getElementById("add"))
    {
      rotateImage()
    }
    if (document.getElementById("stopper"))
    {
      document.getElementById("stopper").innerHTML = "<a href='javascript:toggleScroller()'>stop scroller</a>"
    }
  }
}

var boolImageToggle = true
function rotateImage()
{
  if (boolImageToggle)
  {
    document.getElementById("add").src="/images/hp_main_image_right.jpg"
    document.getElementById("add").alt="SPECIALISTS IN SERVER CONSOLIDATION"
    boolImageToggle = false
  }
  else
  {
    document.getElementById("add").src="/images/hp_main_image_right_2.jpg"
    document.getElementById("add").alt="LEADERS IN THIN CLIENT IMPLEMENTATION AND SUPPORT"
    boolImageToggle = true
  }
  setTimeout ("rotateImage()" , 5000)
}

///////////////////////////////////////////////////
// drives the homepage scroller
function toggleScroller()
{
  if (blnScrollerToggle)
  {
    blnScrollerToggle = false
    news.stop()
    document.getElementById("stopper").innerHTML = "<a href='javascript:toggleScroller()'>start scroller</a>"
  }
  else
  {
    blnScrollerToggle = true
    news.start()
    document.getElementById("stopper").innerHTML = "<a href='javascript:toggleScroller()'>stop scroller</a>"
  }
}


///////////////////////////////////////////////////
// highlights top naviagtion if in that section
function topNavHighligh()
{
  if (document.getElementById)
  {
    if (document.getElementById("homepage"))
    {
       // homepage
       document.getElementById("home").src = "/images/top_nav_txt_home_1.gif"
       strCurrentSection = "home"
    }
    else
    {
      var arrSections = new Array()
      arrSections[0] = "who-we-are"
      arrSections[1] = "what-we-do"
      arrSections[2] = "case-studies"
      arrSections[3] = "demo"
      arrSections[4] = "contact-us"
      var strHref = new String (document.location.href)
      
      for (i=0;i<arrSections.length;i++)
      {
         if (strHref.indexOf("/" + arrSections[i] + "/") != -1)
         {
            var strImageSrc = new String ( document.getElementById(arrSections[i]).src )
            var strImagePrefix = strImageSrc.substring(0 , strImageSrc.lastIndexOf("_") + 1)
            var strImageSuffex = strImageSrc.substring(strImageSrc.lastIndexOf("_")+1,strImageSrc.lastIndexOf("."))
            var strImageExtension = strImageSrc.substring(strImageSrc.lastIndexOf("."),strImageSrc.length)
            document.getElementById(arrSections[i]).src = strImagePrefix + "1" + strImageExtension
            strCurrentSection = arrSections[i]
         }
      }
    }
  }
}

///////////////////////////////////////////////////
// highlights leftnav in "What we do" section
function leftNavHighlight()
{
  if (document.getElementById)
  {
    var strHref = new String (document.location.href)
    if (strHref.indexOf("/projectservices/what-we-do/") != -1)
    {
      // to add new link add image ID to this array
      var arrSubSections = new Array()
      arrSubSections[0] = "thin-client-computing"
      arrSubSections[1] = "corporate-internet"
      arrSubSections[2] = "insite-managed-services"
      arrSubSections[3] = "secure-application-deployment"
      arrSubSections[4] = "mail-migration"  
      arrSubSections[5] = "real-time-disaster-recovery"  
      arrSubSections[6] = "vpn-solutions"  
      arrSubSections[7] = "server-consolidation"  
      
      for (i=0;i<arrSubSections.length;i++)
      {
         if (strHref.indexOf(arrSubSections[i]) != -1)
         {
            var strImageSrc = new String ( document.getElementById(arrSubSections[i]).src )
            var strImagePrefix = strImageSrc.substring(0 , strImageSrc.lastIndexOf("_") + 1)
            var strImageSuffex = strImageSrc.substring(strImageSrc.lastIndexOf("_")+1,strImageSrc.lastIndexOf("."))
            var strImageExtension = strImageSrc.substring(strImageSrc.lastIndexOf("."),strImageSrc.length)
            document.getElementById(arrSubSections[i]).src = strImagePrefix + "1" + strImageExtension
            strCurrentSubSection = arrSubSections[i]
         }
      }
    }
    
    if (strHref.indexOf("/case-studies/") != -1)
    {
      // to add new link add image ID to this array
      var arrSubSections = new Array()
      arrSubSections[0] = "moat"
      arrSubSections[1] = "citrix"
      arrSubSections[2] = "shepway"
      arrSubSections[3] = "group"      
      for (i=0;i<arrSubSections.length;i++)
      {
         if (strHref.indexOf(arrSubSections[i]) != -1)
         {
            var strImageSrc = new String ( document.getElementById(arrSubSections[i]).src )
            var strImagePrefix = strImageSrc.substring(0 , strImageSrc.lastIndexOf("_") + 1)
            var strImageSuffex = strImageSrc.substring(strImageSrc.lastIndexOf("_")+1,strImageSrc.lastIndexOf("."))
            var strImageExtension = strImageSrc.substring(strImageSrc.lastIndexOf("."),strImageSrc.length)
            document.getElementById(arrSubSections[i]).src = strImagePrefix + "1" + strImageExtension
            strCurrentSubSection = arrSubSections[i]
         }
      }
    }
  }
}


///////////////////////////////////////////////////
// drives rollovers
// requires images to have name suffex _0 for off state, _1 for on state
// oImage - image object
// blnAction - 1:roll-on , 0:roll-off
function rollover(oImage , blnAction)
{
  if (document.getElementById)
  {
    var strSectionID = oImage.id
    if (strSectionID != strCurrentSection && strSectionID != strCurrentSubSection )
    {
      var strImageSrc = new String (oImage.src)
      var strImagePrefix = strImageSrc.substring(0 , strImageSrc.lastIndexOf("_") + 1)
      var strImageSuffex = strImageSrc.substring(strImageSrc.lastIndexOf("_")+1,strImageSrc.lastIndexOf("."))
      var strImageExtension = strImageSrc.substring(strImageSrc.lastIndexOf("."),strImageSrc.length)
      if ( strImageSuffex=="0" )
      {
        oImage.src = strImagePrefix + "1" + strImageExtension
      }
      else
      {
        oImage.src = strImagePrefix + "0" + strImageExtension
      }
    }
  }
}

///////////////////////////////////////////////////
// validate the form on the demo page
// oForm - form object
// returns true or false
function validateEmailForm(oForm)
{
  var strErrorMessage=""
  if (oForm.name.value == "")
  {
    strErrorMessage += "your name" + "\n"
  }
  if (oForm.email.value == "")
  {
    strErrorMessage += "your email address" + "\n"
  }
  else if (oForm.email.value.indexOf("@") == -1 || oForm.email.value.indexOf(".") == -1)
  {
    strErrorMessage += "a valid email address" + "\n"
  }
  var blnValidForm = true
  if (strErrorMessage != "")
  {
    blnValidForm = false
    strErrorMessage = "There is an error with the form!" + "\n" + "Please enter :" + "\n\n" + strErrorMessage
    alert (strErrorMessage)
  }
  return (blnValidForm)
}


///////////////////////////////////////////
// open popup window in what we do
// oLink - a href object
function openWindow_wwd(oLink)
{
  var strUrl = oLink.href
	this.window.name = "home";
  if (document.all)
  {
	  popupWin = window.open(strUrl, "popup", 'resizable=no,scrollbars=no,menubar=no,location=no,toolbar=no,status=no,width=690,height=308')
  }
  else
  {
	  popupWin = window.open(strUrl, "popup", 'resizable=no,scrollbars=yes,menubar=no,location=no,toolbar=no,status=no,width=705,height=308')
  }
  popupWin.focus()
}

///////////////////////////////////////////
// open popup window in what we do
// oLink - a href object
function openCaseStudy_wwd(oLink)
{
  var strUrl = oLink.href
	this.window.name = "home";
  if (document.all)
  {
	  popupWin = window.open(strUrl, "popup", 'resizable=no,scrollbars=yes,menubar=no,location=no,toolbar=no,status=no,width=706,height=408')
  }
  else
  {
	  popupWin = window.open(strUrl, "popup", 'resizable=no,scrollbars=yes,menubar=no,location=no,toolbar=no,status=no,width=706,height=408')
  }
  popupWin.focus()
}
