﻿/***********************************************************************************************************************
 * File Name    : GoogleSearch.js
 * Date Created : 06/30/2007
 * Author       : Nishit Pandey 
 * Purpose      : This file has Javascript code required for Implementing Google Search
  * ---------------------------------------------------------------------------------------------------------------------
 * Revision history
 * ---------------------------------------------------------------------------------------------------------------------
 *  Author       Date       Description
 *----------------------------------------------------------------------------------------------------------------------
 * 
 **********************************************************************************************************************/
function sendtoSearch(m_ResultType,eResultType,m_strRegisterUrl,m_strRedirectUrl,strNavigateUrl,m_strDomain,rd_myDomain,windowheight,windowwidth,searchtext,strDeleteConfirmationMessage)
{
var strsearchstring = document.getElementById(searchtext).value;
var strsearchstringformated = strsearchstring.replace(/#/g,"%23") ;
   if(IsBlank(searchtext,strDeleteConfirmationMessage)==true)
   {
    if(m_ResultType == eResultType && m_strRegisterUrl != "" && m_strRedirectUrl != "")
     {
         if(document.getElementById(rd_myDomain).checked==true)
        {
          window.location = strNavigateUrl+"?q="+ strsearchstringformated +"&sa=Search&sitesearch="+ m_strDomain +"&client="+ document.getElementById('client').value +"&forid="+document.getElementById('forid').value+"&ie="+document.getElementById('ie').value+"&oe="+document.getElementById('oe').value+"&safe="+document.getElementById('safe').value+"&cof="+document.getElementById('cof').value+"&hl="+document.getElementById('hl').value;
        }
         else
         {
          window.location = strNavigateUrl+"?q="+ strsearchstringformated +"&sa=Search&sitesearch=&client="+ document.getElementById('client').value +"&forid="+document.getElementById('forid').value+"&ie="+document.getElementById('ie').value+"&oe="+document.getElementById('oe').value+"&safe="+document.getElementById('safe').value+"&cof="+document.getElementById('cof').value+"&hl="+document.getElementById('hl').value;
         }
      }
   else
     {
      if(document.getElementById(rd_myDomain).checked==true)
       {
       window.open("http://www.google.com/custom?&q="+ strsearchstringformated +"&sa=Search&sitesearch="+ m_strDomain +"&client="+ document.getElementById('client').value +"&forid="+document.getElementById('forid').value+"&ie="+document.getElementById('ie').value+"&oe="+document.getElementById('oe').value+"&safe="+document.getElementById('safe').value+"&cof="+document.getElementById('cof').value+"&hl="+document.getElementById('hl').value,'SearchResult',"width="+windowwidth+",height="+windowheight+",scrollbars=yes,resizable=yes");
       }
      else
      {
       window.open("http://www.google.com/custom?&q="+ strsearchstringformated +"&sa=Search&sitesearch=&client="+ document.getElementById('client').value +"&forid="+document.getElementById('forid').value+"&ie="+document.getElementById('ie').value+"&oe="+document.getElementById('oe').value+"&safe="+document.getElementById('safe').value+"&cof="+document.getElementById('cof').value+"&hl="+document.getElementById('hl').value,'SearchResult',"width="+windowwidth+",height="+windowheight+",scrollbars=yes,resizable=yes");
      }
  }
}
}
function IsBlank(searchtext,strDeleteConfirmationMessage)
{
var strTrim = trim(document.getElementById(searchtext).value);
    if(strTrim=="")
    {
       alert(strDeleteConfirmationMessage);
        return false;
    }
    else
    {
       return true;
    }    
}
function trim(str)
{
return str.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');

}
