 //<a class="thumbnail" target="_blank" href="http://{umbraco.library:Replace(data[@alias='external_link'], 'http://', '')}">
 //   <img src="http://open.thumbshots.org/image.aspx?url=http://{umbraco.library:Replace(data[@alias='external_link'], 'http://', '')}"  style="width:60px"/>
 //                 </a>
var arrFokusImages = new Array();
var arrQuickLinks = {};  
var quickLinkCmb = null;
var searchpage = '/inatsisartuthome/soeg.aspx';


$(document).ready(function()
{
  $('a.thumbLink').each(function () {
    $(this).html('<img src="http://open.thumbshots.org/image.aspx?url=' + $(this).attr('href') + '" height="40"/><span>' + $(this).text() + '</span>');
    //alert('<img src="http://open.thumbshots.org/image.aspx?url=' + $(this).attr('href') + '"/>');
    });
  
  
  if ( $("span.mailme").length ) {// variables, which will be replaced
    var at = / at /;
    var dot = / dot /g;
  
    // function, which replaces pre-made class
    $('span.mailme').each(function () {
      var addr = $(this).text().replace(at, '@').replace(dot, '.');
      $(this).after('<a href="mailto:' + addr + '">' + addr + '</a>');
      $(this).remove();
    });
  }


  $("#container").append('<div class="searchFieldIntra" id="searchIntra" style="z-index:102;text-align:left"><input type="hidden" id="quickLinksHidden" value=""/><input id="quickLinks"  value="'+searchPretext +'" style="float:left;z-index:101;position:absolute;"/></div>');
    //$("#header").append('<div class="searchFieldIntra" id="searchIntra"><input id="quickLinks"/></div>');
  try
  { 
    $("#searchIntra").corner("bottom 4px");
  }
  catch (eeee)
  {
  }
    
   $("#shadow").css("height", $("#maincontainer").height()).hide();
  
  $.get("/?alttemplate=" +(isIntranet ? "IntranetQuickLinks" : "internetQuickLinks"), function(datax) {
          arrQuickLinks.results= eval(datax);   
          arrQuickLinks.total =   arrQuickLinks.results.length;

          $('#quickLinks').autocomplete({delay:0, source: arrQuickLinks.results,
                focus: function( event, ui ) {
                  $( "#quickLinks" ).val( ui.item.label );
                  return false;
                },                                         
            select: function( event, ui ) {
          $( "#quickLinks" ).val( ui.item.label );
          $( "#quickLinksHidden" ).val( ui.item.id );
           window.location.href = ui.item.link ;
        
          return false;
          }});
          $( "#quickLinks").focus(function() {$(this).val('')});
    
          $('#quickLinks').blur( function() {dimpage();$(this).val(searchPretext)});
          $('#quickLinks').focus(
                  function() 
                  { 
               
                       dimpage();
                       $(document).keyup(function(e) {
                        // ESCAPE key pressed
                          if (e.keyCode == 27) {
                            $('#quickLinks').blur();
                          }
                         if(e.keyCode == 13){
                           //document.location.href="http://www.ina.gl";
                           //alert("x");
                           var findText = $('#quickLinks').val();
                           //alert(findText);
                           for(sindex in arrQuickLinks.results)
                           {
                             if (findText == arrQuickLinks.results[sindex].label)
                               return false;
                           }
                          
                           document.location.href="/inatsisartuthome/soeg.aspx?search="+findText+'&meta=SITE&year=ALL&slang=ALL';
                         }
                  });          
          });
                                             

      });
});









function isLesser(value1, value2) {return value1 < value2;} 

  function checkForEnter(tvent) {
  
   if (tvent.keyCode==13) {
        searchPerson();
    }
  }
  

  function freeTextSearch()
  { 
      alert($("#quickLinks_input").val());
 }
  
  function searchPerson()
  { //alert('/vaerktoejer/telefon-og-adresseliste-over-medlemmer-og-ansatte.aspx?search=' + $("#personSearch").val());
    window.location.href = 'vaerktoejer/telefon-og-adresseliste-over-medlemmer-og-ansatte.aspx?search=' + $("#personSearch").val();
  }
  
  function dimpage()
  {
    $("#shadow").toggle();
  }


  
  


  
  
