﻿/*
  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.Carpathian = function() {}
PH.Carpathian.toggleHistory = function(aNode) {
  for(var i=0;i<aNode.parentNode.childNodes.length;i++) {
    var oNode = aNode.parentNode.childNodes[i];
    if(oNode.nodeName.toLowerCase() == 'ul') {
      if(oNode.style.display == "none") {
          oNode.style.display = "block";
      } else {
          oNode.style.display = "none";
      }
    }
  }
};

PH.Carpathian.setHeader = function(value) {
  var oImage = document.getElementById('image')
  oImage.style.backgroundImage = 'url(/header/head' + value + '.gif)';
};
PH.Carpathian.showFlash = function(flashUrl) {
  if(FlashDetect.installed) {
      var oImage = document.getElementById('image');
      var sHTML = '<embed src="' + flashUrl + '" width="830" height="220" wmode="transparent" quality="high" loop="false" play="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
      oImage.innerHTML = sHTML;
  }
};

PH.Carpathian.setMapPosition = function(id, x, y) {
  document.getElementById(id + '_oX').value = x;
  document.getElementById(id + '_oY').value = y;
};
