function checkEnter(e)
{
  if (e.keyCode == 13) doSearch();
}

function doSearch()
{
  var t = document.getElementById('txtSearch');
  var s = t.value;
  if (s == '') t.value = 'please type something';
  else 
  {
    var searchDiv = document.getElementById('searchDiv');
    searchDiv.innerHTML = "Searching, please wait...";
    document.location = "SearchVideos?q=" + encodeURIComponent(s);
  }
  return false;
}

function openBlog()
{
  return HandleClick("YTBlog", "YoutubeRepeaterBlog", "http://youtuberepeater.blogspot.com/2009/11/how-youtuberepeater-started.html");
}
function openPower101()
{
  return HandleClick("YTPower", "Power101", "http://www.Power101.com");
}
function openPhotos()
{
  return HandleClick("YTPhotos", "DepositPhotos", "http://submit.depositphotos.com?ref=1006969");
}
function openTwit()
{
  return HandleClick("YTTwit", "YoutubeRepeaterTwit", "http://twitter.com/YoutubeRepeater");
}
function openDental()
{
  return HandleClick("YTDental", "DrPetrova", "http://www.DrPetrova.com");
}
// return FALSE on success (so that regular click doesn't proceed)
function HandleClick(s,t,u)
{
  var RR1 = createHttpPost();
  if (RR1 != null)
  {
    RR1.onreadystatechange = function() 
    {
    }
    RR1.send('ref='+s);
  }
  try
  {
    var new_wnd = window.open(u, t, "menubar=1,toolbar=1,location=1,scrollbars=1,status=1,directories=1,resizable=1");
    new_wnd.focus();
    return false;
  }
  catch (err)
  {
    return true;
  }
}
function createHttpPost()    
{
  var req = null;
  try 
  {
    if (window.XMLHttpRequest) req = new XMLHttpRequest();
    else if (window.ActiveXObject) req = new ActiveXObject("Microsoft.XMLHTTP");
    var url = 'http://' + document.location.host + '/YoutubeRepeater_TEST/RefClick';
    req.open('POST', url, true);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  }
  catch (err) { req = null; }
  return req;
}

