﻿function killerrors()
{
   return true;
}
window.onerror = killerrors;
 function saveselection()
{
   if (document.getElementById('sw')) document.cookie = 'sw=' + escape(document.getElementById('sw').value);
}

function readcookie(sname)
{
   var c = document.cookie;
   if (c.length < 0) return false;
   var b = c.indexOf(sname + '=');
   if (b == - 1) return false;
   var d = c.indexOf(';', b);
   if (d == - 1) d = c.length;
   return unescape(c.substring(b + sname.length + 1, d));
}

function readselection()
{
   if (document.getElementById('sw'))
   {
      c = readcookie('sw');
      if (c) document.getElementById('sw').value = c;
   }
   
}

function OnSearchSubmit()
{
   var b_return = true;
   if (document.getElementById('sw'))
   {
      for(var i = 0; i < document.getElementById('sw').value.length; i ++ )
      {
         if (document.getElementById('sw').value.charAt(i) != " ")
         {
            lh = "SearchResult.aspx?sw=" + encodeURIComponent(document.getElementById('sw').value); 
            b_return = false;
            break;
         }
      }
   }
   if (b_return) return;
   saveselection();
   window.open(lh, "_self");
}

function GoogleSearch() 
{ 
    window.open("http://www.google.com/search?q=" + document.getElementById('txtSearch').value + "&ie=ISO-8859-1&hl=en&btnG=Google+Search&meta="); 
}

function SiteSearch() 
{ 	

//	document.getElementById('mainForm').action='SearchResult.aspx?SearchText=' + document.getElementById('txtSearch').value; 
//	document.getElementById('mainForm').submit(); 		 
}

function TextKeyDown(e) 
{
    var keynum;
    if(window.event) // IE
    {
        keynum = e.keyCode;
    }                    
    else if(e.which) // Netscape/Firefox/Opera 
    {
        keynum = e.which;;
    }
    if (keynum == 13)
    {
        OnSearchSubmit();    
    }                
}