//search highlight
  jQuery.fn.extend({
    highlight: function(search, insensitive, hls_class){
      var regex = new RegExp("(<[^>]*>)|(\\b"+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1") +")", insensitive ? "ig" : "g");
      return this.html(this.html().replace(regex, function(a, b, c){
        return (a.charAt(0) == "<") ? a : "<strong class=\""+ hls_class +"\">" + c + "</strong>";
      }));
    }
  });
  jQuery(document).ready(function($){
    if(typeof(hls_query) != 'undefined'){
      $("#content").highlight(hls_query, 1, "hls");
    }
  });
  
  
//felder leeren
 function leeren() { if(document.getElementById("author_twitter").value == "Twitternick (optional)") document.getElementById("author_twitter").value = ""; if(document.getElementById("url").value == "URL (optional)") document.getElementById("url").value = ""; } 

//google analytics
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1308271-3']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  
  //gfc load



    var SITE_ID = '13245251370327830191';
    var viewer, ownerFriends, activities;
    google.friendconnect.container.setParentUrl('/api/' /* location of rpc_relay.html and canvas.html */);
    google.friendconnect.container.loadOpenSocialApi({ 
            site: SITE_ID,
            onload: function() { initAllData(); }});

    function initAllData() {
      var params = {};
      params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] =
        [opensocial.Person.Field.ID,opensocial.Person.Field.NAME,opensocial.Person.Field.THUMBNAIL_URL,opensocial.Person.Field.PROFILE_URL];
      var req = opensocial.newDataRequest();
      req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');
      req.add(req.newFetchPeopleRequest(
        new opensocial.IdSpec({'userId' : 'OWNER', 'groupId' : 'FRIENDS'}), params), 
        'ownerFriends');
      req.add(req.newFetchActivitiesRequest(new opensocial.IdSpec({'userId' : 'OWNER', 'groupId' : 'FRIENDS'})), 'activities');
      req.send(setupData);
    };

    function setupData(data) {
      ownerFriends = data.get('ownerFriends').getData().asArray();
      var html = "";
      for (var i = 0; i < ownerFriends.length && i < 8; i++) {
        var person = ownerFriends[i];
        html += "<a title='" + person.getField("displayName") + "' href='" + person.getField("profileUrl") + "'>";
        html += "<img width='32' style='padding-right:1px; padding-left:1px;' height='32' class='memberPhoto' src='" + person.getField("thumbnailUrl")  + "'/>";
        html += "</a>&nbsp;";
      };

      document.getElementById('members').innerHTML = html;
	  
      viewer = data.get('viewer').getData();
      if (viewer) {
        document.getElementById('memberstate').innerHTML = 
        '';  
/*         viewer.getField("displayName") + '!' ;*/
      } else {
        document.getElementById('memberstate').innerHTML = 
        '';
      }
	  
      viewer = data.get('viewer').getData();
      if (viewer) {
        document.getElementById('profile').innerHTML = 
        //'<img width="50" height="50" style="padding-right: 2px;" align="left" src="' + viewer.getField("thumbnailUrl")  + '">' +
//        'Hi ' +  viewer.getField("displayName") + 
          '<b>' +  viewer.getField("displayName") +
          '</b>' + 			
//        '. Du bist bereits Google-Abonnent. ' +
		  '&nbsp;(<a href="#" onclick="google.friendconnect.requestSignOut(); return false;">Logout</a>)';
//        '&nbsp;<a style="font-size:8px;" href="#" onclick="google.friendconnect.requestSignOut(); return false;">Logout</a>';
        //'<a href="#" onclick="google.friendconnect.requestSettings(); return false;">Einstellungen</a><br>' +
        //'<a href="#" onclick="google.friendconnect.requestInvite(); return false;">Einladen</a><br>';
      } else {
//        google.friendconnect.renderSignInButton({ 'id': 'profile1','style':'text','text':'Mit Google lesen'});
        google.friendconnect.renderSignInButton({ 'id': 'profile1' });
      }


    };
