var userList = new Array();
var lastUser;


function arrayShuffle(){
  var tmp, rand;
  for(var i =0; i < this.length; i++){
    rand = Math.floor(Math.random() * this.length);
    tmp = this[i]; 
    this[i] = this[rand]; 
    this[rand] =tmp;
  }
}


Array.prototype.shuffle =arrayShuffle;



function displayLogo(pos) {
  
  if (pos >= userList.length) {
    pos = 0;
  }
  if (lastUser) {
    $(lastUser).fadeOut("slow",function() {
      $(userList[pos]).fadeIn("slow", function() {
        lastUser = userList[pos];
        window.setTimeout("displayLogo("+(pos+1)+")",1500);
      });
    });
  } else {
    $(userList[pos]).fadeIn("slow", function() {
      lastUser = userList[pos];
      window.setTimeout("displayLogo("+(pos+1)+")",1500);
    });
  }
}

$(document).ready(function() {
  var pngImg = $('.overlay').eq(0).css("background-image");
  if (pngImg == "none") {
    $('.overlay').css({"background-color":"white","opacity":0.35});
  }
  $('.right-search-plz').click(function() { 
    if ($(this).val() == "PLZ") {
      $(this).val('');
    }
  });

if ($('ul#logoscroller').length > 0) {
$('ul#logoscroller').css({'height':'136px','overflow':'hidden'});
  $('ul#logoscroller li').each(function() {
    userList.push(this);
$(this).hide();
  });
  userList.shuffle();
  
  displayLogo(0);
}


$(".radius_search_form").submit(function() {
  var field =$(this).children("input[name='base']").eq(0);
  var val = $(field).val();
  if (val.length != 5 || isNaN(val)) {
  $(field).css('background-color','#E89E7E');
    if ($(this).children('.radius_search_error').length == 0) {
      $(this).append('<br clear="all" /><small class="radius_search_error">Bitte geben Sie eine gültige Postleitzahl an!</small><br clear="all" />');
      $(this).css('height','140px');
    }
    return false;
  }
});
$(".radius_search_form").children("input[name='base']").keydown(function() {
$(this).css('background-color','#FFFFFF');
});

  
    $("#share_unfolded").remove();
  $("#share").remove();
  
  
  $("#right").css({'marginTop' : 0, 'overflow' : 'visible'});

$("#right").prepend('<div id="share"><small>Teilen</small></div><br /><br />'); 
  
$("#share").bind('mouseenter', function() {
  $("#share").append('<div  id="share_unfolded"><div>Weitersagen/Lesezeichen</div></div>');
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://www.mister-wong.de/\" onclick=\"window.open('http://www.mister-wong.de/index.php?action=addurl&amp;bm_url='+encodeURIComponent(location.href)+'&amp;bm_notice=&amp;bm_description='+encodeURIComponent(document.title)+'&amp;bm_tags=');return false;\" title=\"Bookmark bei: Mr. Wong\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/wong_trans.gif\" alt=\"Bookmark bei: Mr. Wong\" name=\"wong\" border=\"0\" id=\"wong\" /> Mister Wong</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://www.linkarena.com/\" onclick=\"window.open('http://linkarena.com/bookmarks/addlink/?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)+'&amp;desc=&amp;tags=');return false;\" title=\"Bookmark bei: Linkarena\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/linkarena_trans.gif\" alt=\"Bookmark bei: Linkarena\" name=\"Linkarena\" border=\"0\" id=\"Linkarena\" />Linkarena</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://www.favoriten.de/\" onclick=\"window.open('http://www.favoriten.de/url-hinzufuegen.html?bm_url='+encodeURIComponent(location.href)+'&amp;bm_title='+encodeURIComponent(document.title));return false;\" title=\"Bookmark bei: Favoriten\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/favoriten_trans.gif\" alt=\"Bookmark bei: Favoriten\" name=\"Favoriten\" border=\"0\" id=\"Favoriten\" />Favoriten</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://www.folkd.com/\" onclick=\"window.open('http://www.folkd.com/submit/'+encodeURIComponent(location.href));return false;\" title=\"Bookmark bei: Folkd\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/folkd_trans.gif\" alt=\"Bookmark bei: Folkd\" name=\"Folkd\" border=\"0\" id=\"Folkd\" />Folkd</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://digg.com/\" onclick=\"window.open('http://digg.com/submit?url='+encodeURIComponent(location.href)+'&amp;bodytext=&amp;tags=&amp;title='+encodeURIComponent(document.title));return false;\" title=\"Bookmark bei: Digg\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/digg_trans.gif\" alt=\"Bookmark bei: Digg\" name=\"Digg\" border=\"0\" id=\"Digg\" />Digg</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://del.icio.us/\" onclick=\"window.open('http://del.icio.us/post?v=2&amp;url='+encodeURIComponent(location.href)+'&amp;notes=&amp;tags=&amp;title='+encodeURIComponent(document.title));return false;\" title=\"Bookmark bei: Del.icio.us\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/del_trans.gif\" alt=\"Bookmark bei: Del.icio.us\" name=\"Delicious\" border=\"0\" id=\"Delicious\" />del.icio.us</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://www.stumbleupon.com/\" onclick=\"window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title));return false;\" title=\"Bookmark bei: StumbleUpon\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/stumbleupon_trans.gif\" alt=\"Bookmark bei: StumbleUpon\" name=\"StumbleUpon\" border=\"0\" id=\"StumbleUpon\" />StumbleUpon</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://www.yahoo.com/\" onclick=\"window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+encodeURIComponent(document.title)+'&amp;d=&amp;tag=&amp;u='+encodeURIComponent(location.href));return false;\" title=\"Bookmark bei: Yahoo\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/yahoo_trans.gif\" alt=\"Bookmark bei: Yahoo\" name=\"Yahoo\" border=\"0\" id=\"Yahoo\" />Yahoo</a>");
  $("#share_unfolded").append("<a rel=\"nofollow\" style=\"text-decoration:none;\" href=\"http://www.google.com/\" onclick=\"window.open('http://www.google.com/bookmarks/mark?op=add&amp;hl=de&amp;bkmk='+encodeURIComponent(location.href)+'&amp;annotation=&amp;labels=&amp;title='+encodeURIComponent(document.title));return false;\" title=\"Bookmark bei: Google\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/google_trans.gif\" alt=\"Bookmark bei: Google\" name=\"Google\" border=\"0\" id=\"Google\" />Google</a>");
  $("#share_unfolded").append("<a style=\"margin-bottom:5px;text-decoration:none;\" rel=\"nofollow\" href=\"http://www.blinklist.com/\" onclick=\"window.open('http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Tag=&amp;Url='+encodeURIComponent(location.href)+'&amp;Title='+encodeURIComponent(document.title));return false;\" title=\"Bookmark bei: Blinklist\"> <img style=\"padding-bottom:1px;\" src=\"/real/user/images/social/blinklist_trans.gif\" alt=\"Bookmark bei: Blinklist\" name=\"Blinklist\" border=\"0\" id=\"Blinklist\" />Blinklist</a>");
  $("#share_unfolded").append("<br clear=\"all\" />");
});

$("#share").bind('mouseleave', function() {
    $("#share_unfolded").remove();
    });  
  
  
});







