/*
  Copyright 2007 Paperheads, All Rights Reserved.
  http://www.paperheads.co.uk
*/

if(typeof(Type) !== 'undefined') {
  Type.registerNamespace("PH");
}
else {
  PH = function() {}
}


PH.CheckSearch = function(e, sSearchUrl, searchID) {
  var charCode;
  if(window.event) { 
    charCode = e.keyCode;
  } else if(e.which) {
    charCode = e.which;
  }
  
  if (charCode==13) {
    PH.Search(sSearchUrl, searchID);
    return false;
  } else {
    return true;
  }
}

PH.Search = function(sSearchUrl, searchID) {
  var sTerms = "";
  var sSearchTerms = $get(searchID).value;
  
  if(sSearchTerms == 'Search the site...') {
    sSearchTerms = '';
  }
 
  for (i=0;i<sSearchTerms.length;i++) {
    if (sSearchTerms.charAt(i) == " ") {
      sTerms += "+";
     } else {
      sTerms += sSearchTerms.charAt(i);
    }
  }

  sSearchUrl += "?terms=";
  sSearchUrl += escape(sTerms);
  
  window.location.href = sSearchUrl
}

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

PH.ECI = function() {}

PH.ECI.NewsScroll = function() {
  var oElement = document.getElementById('newsscroll');
  if(oElement) {
    var iTop = 0;
    if(oElement.style.top) {
      iTop = parseInt(oElement.style.top);
    }

    iTop -= 1;
    if((iTop * -1) > (oElement.offsetHeight / 2)) iTop = -11;
    
    oElement.style.top = iTop + 'px';
    
    PH.ECI.iTimeout = setTimeout('PH.ECI.NewsScroll();', 60);
  }
}

PH.ECI.NewsOver = function() {
  clearTimeout(PH.ECI.iTimeout);
}

PH.ECI.NewsStart = function() {
    PH.ECI.iTimeout = setTimeout('PH.ECI.NewsScroll();', 100);
}
