function keypressHandler(e, theEle) 
{
    var evt = (e) ? e : ((event) ? event : null);
   //  var evt = e || window.event;

// backspace(8), tab(9), escape(27), pgUp(33/!), pgDown(34/"), end(35/#), home(36/$)
// left(37/%), up(38/&), right(39/'), down(40/(), insert(45/-), delete(46/.), f5 & t[new tab](116/t) 0..9 //(48..57)

	var controlKeys = /8|9|27|33|34|35|36|37|38|39|40|45|46|48|49|50|51|52|53|54|55|56|57|116/;
	var pressedKeyCode = evt.charCode || evt.keyCode; // ASCII value of character pressed
	var charcode = evt.charCode;
	var keycode = evt.keyCode;
	var character = String.fromCharCode(pressedKeyCode);

        if (keycode == 27 || charcode == 27)         // ESC character pressed
        {
                  theEle.style.display='none';
        }
        else if (keycode)
        {
// for more on key charcodes see demo at: http://www.w3.org/2002/09/tests/keys.html
         switch(keycode)
         {
            case 48 :                     // 0 digit pressed
                   checkClicked(search_bar);
                   start(); //toggle search bar
                  break;
            case 49 :                     // 1 digit pressed
                  document.location.href = document.mobiletv.d1.value;
                  break;
            case 50 :                      // 2 digit pressed
//                  window.alert(keycode);
                  document.location.href = document.mobiletv.d2.value;
                  break;
            case 51 :                      // 3 digit pressed
                  document.location.href = document.mobiletv.d3.value;
                  break;
            case 52 :                      // 4 digit pressed
                  document.location.href = document.mobiletv.d4.value;
                  break;
            case 53 :                      // 5 digit pressed
                  document.location.href = document.mobiletv.d5.value;
                  break;
            case 54 :                     // 6 digit pressed
                  document.location.href = document.mobiletv.d6.value;
                  break;
            case 55 :                      // 7 digit pressed
                  document.location.href = document.mobiletv.d7.value;
                  break;
            case 56 :                      // 8 digit pressed
                  document.location.href = document.mobiletv.d8.value;
                  break;
            case 57 :                     // 9 digit pressed
                  document.location.href = document.mobiletv.d9.value;
                  break;
            default:
                  return;
         } 
        }
        else
        {
// for more on key charcodes see demo at: http://www.w3.org/2002/09/tests/keys.html
         switch(charcode)
         {
            case 48 :                     // 0 digit pressed
                   checkClicked(search_bar);
                   start(); //toggle search bar
                  break;
            case 49 :                     // 1 digit pressed
                  document.location.href = document.mobiletv.d1.value;
                  break;
            case 50 :                      // 2 digit pressed
//                  window.alert(keycode);
                  document.location.href = document.mobiletv.d2.value;
                  break;
            case 51 :                      // 3 digit pressed
                  document.location.href = document.mobiletv.d3.value;
                  break;
            case 52 :                      // 4 digit pressed
                  document.location.href = document.mobiletv.d4.value;
                  break;
            case 53 :                      // 5 digit pressed
                  document.location.href = document.mobiletv.d5.value;
                  break;
            case 54 :                     // 6 digit pressed
                  document.location.href = document.mobiletv.d6.value;
                  break;
            case 55 :                      // 7 digit pressed
                  document.location.href = document.mobiletv.d7.value;
                  break;
            case 56 :                      // 8 digit pressed
                  document.location.href = document.mobiletv.d8.value;
                  break;
            case 57 :                     // 9 digit pressed
                  document.location.href = document.mobiletv.d9.value;
                  break;
            default:
                  return;
         } 
       }
       return (controlKeys.test(pressedKeyCode));
}	

function clearDefault(field, defaultText)
{
   if (field.value == defaultText)
       return field.value='';   
   else
	   return;  
}

function restoreDefault(field, defaultText)
{
   if (field.value == '' || field.value == defaultText)
       return field.value=defaultText;   
   else
	   return;  
}
function showBox(e,n,dnm,xoff,yoff)
{
	if(document.getElementById(dnm).style["display"] !="block") 
	{
		var tempid;
		for(i=1; i<infocount +1 ; i++)
		{
			tempid = "infobox"+i;
			hideDiv(tempid);
		}	 
		 var theTop;
		 if (navigator.userAgent.indexOf("MSIE")!=-1) 
			theTop =  document.body.scrollTop; 
		 else
			theTop = 0;
		if(!e) e = window.event;
		evt = new Evt(e);
		tempid = dnm+"_img";

		//document.getElementById(dnm).style.left=evt.x + xoff;
		//document.getElementById(dnm).style.top=evt.y + yoff + theTop;
		document.getElementById(dnm).style.left= findPosX(document.getElementById(tempid))-40;
		document.getElementById(dnm).style.top=findPosY(document.getElementById(tempid))-80;		
		if(n==1)
		{
			document.getElementById(dnm).style["display"]="block" ;
			document.getElementById(dnm).style["visibility"]="visible" ;
		}
		else
		{
			document.getElementById(dnm).style["display"]="none" ;
			document.getElementById(dnm).style["visibility"]="hidden" ;
		}
	}
}

    function checkClicked(theEle)
    {
        if (theEle.style.display=='')
        {
               theEle.style.display='none'; 
        }
        else
        {                
            theEle.style.display='';
        }               
    }
	
