﻿
// JScript File
//Change  topnav bullet images on mouseover and mouseout
function imagechange(id)
{
    var imgpath=id.style.backgroundImage;
        imgpath=imgpath.split('/');
     var img=imgpath[imgpath.length-1];
     img=img.split(')');       
    if(img[0]=='green-arrow.gif'|| img[0]=='')
        id.style.backgroundImage='url(./images/white-arrow.gif)';
    else
        id.style.backgroundImage='url(./images/green-arrow.gif)';    
        
}
/////////////////////////////////////////////
function search()
{

    if(trim(document.ff.p.value) == "")
    {
        alert("Kindly enter the keyword you want to search");
        return;
    }
   
    var len=trim(document.ff.p.value);
    if(len.length < 2)
    {
          alert("Your keyword should contain a minimum of 2 letters");
          return;
    }
    
        document.ff.action = "search_key.aspx";
        document.ff.method = "post";
        document.ff.submit();
    
  }
  
  function entSearch(a)
  {
 
    if(a.keyCode==13)
    {
         
            if(trim(document.ff.p.value) == "")
            {
                alert("Kindly enter the keyword you want to search");
                return false;
            }
            var len=trim(document.ff.p.value);
            
            if(len.length < 2)
            {
                alert("Your keyword should contain a minimum of 2 letters");
                return false;
            }
            
            document.ff.action = "search_key.aspx";
            document.ff.method = "post";
            document.ff.submit();
      }
     
 }
   
function trim(str)
{
  var str1=str.replace(/\S/g,"|");
  var i=str1.indexOf("|")-1;
  var j=str1.lastIndexOf("|")+1;
  var trimStr=str.substring(0,i).replace(/\s/g,"") + str.substring(i+1,j)
  trimStr = trimStr + str.substring(j).replace(/\s/g,"");
  return trimStr;
}

