﻿// ----------------------------------------------------------------------------------------------------------------------------------
// PROGRAM
// PAGE            custom.js
// AUTHOR          Venkata 
// LANGAUGE        JavaScript
// PURPOSE         Customer JavaScript functions
//
// REVISION HISTORY
// Date			Progammer	Purpose 
// ----------	--------	--------------------------------------------------------------------------------------------
// 27/10/2009	Venkata	    Initial write
// 26/05/2011   Santosht    Added CheckInFocus and CheckOuFocus function
//---------------------------------------------------------------------------------------------->

    function checkInFocus() 
    {
        var objsearchText = document.getElementById('ctl00_txtSearchText');
        if ((objsearchText.value == 'Search')) 
        {
            objsearchText.value="";
        }        
    }
    function checkOutFocus() 
    {
        var objsearchText = document.getElementById('ctl00_txtSearchText');
        if ((objsearchText.value == '')) 
        {
            objsearchText.value="Search";
        }       
    }
    function checkKeycode(e) 
    {
        var keycode;
        if (window.event) // IE
            keycode = e.keyCode;
        else if (e.which) // Netscape/Firefox/Opera
            keycode = e.which;
        if (keycode == 13)
        {           
            CallSearch();
        }
    }

    //document.onkeydown = checkKeycode;

    function CallSearch() 
    {

        var objsearchText = document.getElementById('ctl00_txtSearchText');
        var searchText;

        if ((objsearchText != null)) 
        {
            searchText = objsearchText.value;
            searchText = searchText.replace(/>/gi, " >");
            searchText = searchText.replace(/</gi, "< ");
            objsearchText.value = searchText;
        }
        //This cookie is used for the backbutton to work in search on postback
        //This cookie must be cleared to prevent old search results from displayed
        document.cookie = 'postbackcookie=';
        
        window.location = "/SearchResult.aspx?searchtext=" + searchText.replace('alert', '').replace('confirm', '') + "";
        //window.location = "SearchResult.aspx?searchtext=" + searchText.replace('alert', '').replace('confirm', '') + "&folderid=0&searchfor=all&orderby=id&orderdirection=ascending";
        //window.top.mainFrame.bottomFrame.document.location.href="SearchPage.aspx?searchtext=" + searchText.replace('alert','').replace('confirm','') + "&folderid=0&searchfor=all&orderby=id&orderdirection=ascending";
        //Load the page with the websearch server control in the bottom frame using Javascript
        //Set websearch properties using querystring parameters
        //Properties set here- search text,Orderby, FolderId, and SearchFor
        //SearchFor can be a value from all/html/documents/images/multimedia/discussionForum
        //Orderby can be one of these - editor,id,rank,title,datecreated,datemodified
        //OrderDirection can be ascending or descending
    }
    
//    $(document).ready(function() { 
//          var OldBaseURL= $('#ctl00_OldBaseURL').val();
//          var NewBaseURL= $('#ctl00_NewBaseURL').val(); 
//          var count=0;    
//          if(OldBaseURL != "0" && NewBaseURL !="0")
//          {  
//              var oldURL = OldBaseURL.split(',');                     
//              while (count < oldURL.length) 
//              {                
//                $("a[href^='"+ oldURL[count] +"']")        
//                .each(function()
//                   {                                                          
//                      this.href = this.href.replace(oldURL[count],NewBaseURL);
//                        
//                   });
//                 count+=1;
//               }
//           }                           
//        });
//    
//    
