﻿/////// YAHOO
//var YahooSearch = new SearchEngine({name:"Yahoo", desc:"Yahoo Web Search",imageUrl:"Images/new/yahoo.gif"});
//YahooSearch.yahooSearches = {};
//YahooSearch.yahooCallbacks = {};
//YahooSearch.SearchFunc = function(term, id, offset, opts)
//{
//  var search = YahooSearch.yahooSearches[id] || {id: id, total:0, required: searchResultsToShow, offset:offset, term:term, options:opts};
//  YahooSearch.yahooSearches = {};
//  YahooSearch.yahooSearches[id] = search;

//  if (search.options.searchType=="web")
//  {
//    var url = 'http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=keIChznV34GJf03Uj6O3C_XWbpAOjEoqZExGlIDZE0ukywtt0zlsYp4DQmBqxI3px9tyJlA1F5OuXg--&output=json&callback=YahooSearch.yahooCallbacks['+id+']&results='+searchResultsToShow+'&query=' + term;
//    if (offset)
//      url +="&start="+String(offset+1);
//    if (search.options.lang && this.languages && this.languages[search.options.lang])
//      url+=("&language="+this.languages[search.options.lang]);
//    if (search.options.country && this.countries && this.countries[search.options.country])
//      url+=("&country="+this.countries[search.options.country]);
//      
//    YahooSearch.yahooCallbacks[id] = function(response) { YahooSearch.ProcessYahooSearchResults(response,id);}
//  }
//  else if (search.options.searchType=="image")
//  {
//    var url = 'http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=keIChznV34GJf03Uj6O3C_XWbpAOjEoqZExGlIDZE0ukywtt0zlsYp4DQmBqxI3px9tyJlA1F5OuXg--&output=json&callback=YahooSearch.yahooCallbacks['+id+']&results='+searchResultsToShow+'&query=' + term;
//    if (search.options.adult_ok)
//      url+=("&adult_ok=1");
//    if (search.options.colorOnly)
//      url+=("&coloration=color");
//    else if (search.options.blackWhiteOnly)
//      url+=("&coloration=bw");
//    if (search.options.format) //bmp, gif, jpeg, png, or any (default)
//      url+=("&format="+search.options.format);
//    if (offset)
//      url +="&start="+String(offset+1);
//    YahooSearch.yahooCallbacks[id] = function(response) { YahooSearch.ProcessYahooSearchResults(response,id);}
//  }
// 
//  addScript(url,'YahooSearch_'+id);
//}
//YahooSearch.ProcessYahooSearchResults = function(response,id)
//{
//  //Cleanups
//  YahooSearch.yahooCallbacks[id] = null;
//  //$("YahooSearch_"+id).remove.delay(0);
//  
//  var search = YahooSearch.yahooSearches[id];    
//  var ret = [];
//  if (response.Error)
//  {
//    notifyEngineResults("Yahoo", id, ret, false, false);
//    return;
//  }
//  if (search.offset==0)
//  {
//    notifyEngineResultsEstimation("Yahoo",id,response.ResultSet.totalResultsAvailable);
//  } 
//  var resultsArr = response.ResultSet.Result;
//  for (var i=0,j=resultsArr.length;i<j;i++)
//  {
//    if (search.options.searchType=="web")
//    {
//      ret.push(
//      {
//        rank : i,
//        title: resultsArr[i].Title,
//        description: resultsArr[i].Summary,
//        url: "http://"+resultsArr[i].DisplayUrl
//      });
//    } else if (search.options.searchType=="image")
//    {
//      ret.push(
//      {
//        Url: resultsArr[i].ReferrerUrl,
//        ClickUrl : resultsArr[i].ClickUrl,
//        FileFormat : resultsArr[i].FileFormat,
//        FileSize : resultsArr[i].FileSize,
//        Height : resultsArr[i].Height,
//        Width : resultsArr[i].Width,
//        Summary: resultsArr[i].Summary,
//        Title : resultsArr[i].Title,
//        ThumbnailUrl: resultsArr[i].Thumbnail.Url,
//        ThumbnailHeight: resultsArr[i].Thumbnail.Height,
//        ThumbnailWidth: resultsArr[i].Thumbnail.Width        
//      });
//    }
//  }
//  var firstResponse = response.ResultSet.firstResultPosition;
//  var lastResponse = firstResponse + response.ResultSet.Result.length - 1;
//  var hasMore = lastResponse < response.ResultSet.totalResultsAvailable;
//  
//  if (!hasMore || ret.length == searchResultsToShow)
//  {
//    notifyEngineResults("Yahoo", id, ret, search.offset, hasMore);
//    YahooSearch.yahooSearches = {};
//  } 
//  //if need to search more: doYahooSearch(null,id,response.ResultSet.moreUrl);
//}

//YahooSearch.CreateSearch = function(term, id, options)
//{
//  var srch = new Search(this, term, id, options);
//  srch.InternalGetPage = function (pageNumber, pageReadyCallback, notifyEstimatesCallback)
//  {
//    YahooSearch.SearchFunc(this.term, this.id, (pageNumber-1)*searchResultsToShow, options);
//  }
//  return srch;
//}
//YahooSearch.Register();
