jQuery(document).ready(function(){

  /*
  jQuery('#navigation > ul').corner({bl: false, br: false});
  jQuery('#footer').corner({tl: false, tr: false});
*/
	
	



  /*jQuery(".contact_field_holder").hide();
  jQuery(".show_profile").click(function(){
      var info = jQuery(this).parent().children('.contact_field_holder');
      
      jQuery(info).toggle(500);
      if(jQuery(this).hasClass('ss_bullet_arrow_down')){
          jQuery(this).removeClass('ss_bullet_arrow_down').addClass('ss_bullet_arrow_up').html('Hide Contact Information');
      }
      else {
          jQuery(this).removeClass('ss_bullet_arrow_up').addClass('ss_bullet_arrow_down').html('Show Contact Information');
      }
  })
*/
  var counter = 0;
  jQuery('li.linkslist_link').each(function(){
      var rlink = this;
      
        if(jQuery(rlink).children('div.link_description').html() != ''){
            counter++;
            jQuery(rlink).children('a').after(jQuery('<a title="Information" href="#link_description_'+counter+'" rel="#link_description_'+counter+'"><span style="padding-bottom: 4px; padding-top:-4px;" class="ss_sprite ss_information"></span></a>').cluetip({local:true, cursor: 'pointer', sticky: true,  positionBy: 'bottomTop', cluetipClass: 'jtip', closePosition: 'title'}));
            jQuery(rlink).children('div.link_description').attr("id","link_description_"+counter).css('display','none');
            
        }
        
  });
  counter = 0;
  jQuery('p.contact_description').each(function(){
      var rlink = this;

        if(jQuery(rlink).parent('div').html() != ''){
            counter++;
            jQuery(rlink).parent('div').children('h4.name').css('display','inline').after(jQuery('<a class="contact_info" title="Information" href="#link_description_'+counter+'" rel="#link_description_'+counter+'"><span style="padding-bottom: 4px; padding-top:-4px;" class="ss_sprite ss_information"></span></a>').cluetip({local:true, cursor: 'pointer', sticky: true,  positionBy: 'bottomTop', cluetipClass: 'jtip', closePosition: 'title'}));
            jQuery(rlink).attr("id","link_description_"+counter).css('display','none');

        }

  });

/*
var path = window.location.pathname;

var strings = path.split('/');

jQuery('#mainContent .inner').append('<div id="suggestions"><h3>Maybe you are looking for the following:  &nbsp; <span id="ajax-loader"><img src="https://portal.lib.ohio-state.edu/carmenlibrarylink/images/ajax-loader.gif"/></span></h3><div/></div>');
var already = new Array();
for (i in strings){
    if(strings[i].length > 3){
        var strings2 = strings[i].split('-');
        for(var j in strings2){
            if(strings2[j].length > 3){
                var results = jQuery.ajax({
                async: false,
                dataType: "json",
                url: '/find/searchJSON/'+strings2[j]
             });
             results = eval(results.responseText)
             for(var k in results){
                for(var x in already){
                    if(already[x] == results[k].url){
                        var alr = true;
                        continue;
                    }
                }
                if(!alr){
                    already.push(results[k].url);
                    jQuery('#suggestions div').prepend('<p><a href="'+results[k].url+'">'+results[k].text+'</a></p>');
                }
             }
            break;
            }
        }
    }
}
  jQuery('#ajax-loader').hide();
*/

var suggestTimer;
var cached_results = [];

    jQuery(".section").addClass("current");

    jQuery("ul.sf-menu").superfish({
        pathClass:  'current',
        delay: 1000,
        autoArrows:  false,                           // disable generation of arrow mark-up
        dropShadows: false
    });


    jQuery('#suggest_search_input').focus(function(){
       $(this).addClass('googleCustomSearchFocus');
    }).blur(function(){
        if($(this).val() == ''){
            $(this).removeClass('googleCustomSearchFocus');
        }
    })/*.keyup(function(){
        if($(this).val() != ''){
            clearTimeout(suggestTimer);
            suggestTimer = setTimeout(getSuggestions, 1000, $(this).val());
        }
    })*/;
 /*
        function getSuggestions(text){
            var data = null;
            if(cached_results[text] != undefined){
                console.log('data was cached');
                data = cached_results[text];
            }
            else{
                var results = jQuery.ajax({
                    async: false,
                    dataType: "json",
                    url: '/find/searchJSON/'+text
                });
                var js = eval(results.responseText);
                 var websiteSearch = [{
                    text: 'Search website for '+text,
                    url: 'http://library.osu.edu/google_cse_results.php?cx=011200135891268286236%3Av3ccjn1huqy&cof=FORID%3A9&ie=UTF-8&q='+text+'&sa=Search#1016'
                 }];
                 js = websiteSearch.concat(js);
                 cached_results[text] = js;
                 data = cached_results[text];
            }
            console.log(data);
            suggestData = data;
           jQuery('#suggest_search_input').jsonSuggest(data, {maxResults: 10, onSelect:callback});
            
        }*/
        
   jQuery('#suggest_search_input').jsonSuggest(


	function (text, wildCard, caseSensitive, notCharacter) {
      if(cached_results[text] != undefined){
        return cached_results[text];
    }

		var results = jQuery.ajax({
        async: false,
        dataType: "json",
        url: '/find/searchJSON/'+text
     });


     var js = eval(results.responseText);
     var websiteSearch = [{
        text: 'Search website for '+text,
        url: 'http://library.osu.edu/google_cse_results.php?cx=011200135891268286236%3Av3ccjn1huqy&cof=FORID%3A9&ie=UTF-8&q='+text+'&sa=Search#1016'
     }];
     js = websiteSearch.concat(js);
     cached_results[text] = js;
     return cached_results[text];

	}, {ajaxResults:true,minCharacters:2, onSelect:callback});
    
    

 
     
  
    function callback(item){
        window.location.href  = item.url;
    }

    jQuery('a#global-books-link').attr('href','#global-books-search');
    jQuery('a#global-articles-link').attr('href','#global-articles-search');
    jQuery('a#global-journals-link').attr('href','#global-journals-search');
    jQuery('a#global-website-link').attr('href','#global-website-search');

    jQuery('#globalSearch > ul').tabs();

});
