function LimitInput(jsField, $CounterField, MaxNum) {
	if (jsField.value.length > MaxNum) {
		jsField.value = jsField.value.substring(0, MaxNum);
	} else {
		document.getElementById($CounterField).innerHTML = MaxNum - jsField.value.length;
	}
}
function pruffen(aa,user){
        if(aa.button){
            if (aa.button == 2){
                fileinput(user);
            }
        }
}
function prfnen(aa){
        if(aa.button){
            if (aa.button == 2){
                var Theinput = document.getElementById('userlist');
                var Indexe = Theinput.selectedIndex;
                var user = Theinput.options[Indexe].text;
                var OldText = $("#timelineinput").val();
                $("#timelineinput").val(OldText + user);
            }
        }
}
function pruffnen(){
    var Theinput = document.getElementById('userlist');
    var Indexe = Theinput.selectedIndex;
    var TheUSer = Theinput.options[Indexe].text;
    fileinput(TheUSer);
}
function fileinput(user){
        var OldText = $("#timelineinput").val();
        if(OldText == "Sag was!"){
            $("#timelineinput").val("/p " + user + ":");
            document.getElementById('timelineinput').focus();
            setTimeout("document.getElementById('timelineinput').focus();", 500);
            setTimeout("document.getElementById('timelineinput').focus();", 1000);
        }else{
            $("#timelineinput").val("/p " + user + ":" + OldText);
            document.getElementById('timelineinput').focus();
            setTimeout("document.getElementById('timelineinput').focus();", 500);
            setTimeout("document.getElementById('timelineinput').focus();", 1000);
        }
}
function openHide($id){
	if(document.getElementById($id).style.display == 'none'){
		document.getElementById($id).style.display = 'block';
	}
	else{
		document.getElementById($id).style.display = 'none';
	}
}
function showDiv($id){
	document.getElementById($id).style.display = 'block';
}
function _showDiv($id){
	document.getElementById($id).style.display = 'inline';
}
function hideDiv($id){
	document.getElementById($id).style.display = 'none';
}
function activatePlaceholders() {
var detect = navigator.userAgent.toLowerCase(); 
if (detect.indexOf("safari") > 0) return false;
var inputs = document.getElementsByTagName("input");
for (var i=0;i<inputs.length;i++) {
  if (inputs[i].getAttribute("type") == "text") {
   if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
    document.getElementsByTagName("input")[i].style.color = "#bbb";
    inputs[i].value = inputs[i].getAttribute("placeholder");
    inputs[i].onclick = function() {
     if (this.value == this.getAttribute("placeholder")) {
      this.style.color = "#333";
      this.value = "";
     }
     return false;
    }
    inputs[i].onblur = function() {
     if (this.value.length < 1) {
      this.style.color = "#bbb";
      this.value = this.getAttribute("placeholder");
     }
    }
   }
  }
}
}
function passwordChanged() {
	var strength = document.getElementById('strength');
	var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[^a-zA-Z_0-9]).*$", "g");
	var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
	var enoughRegex = new RegExp("(?=.{6,}).*", "g");
	var pwd = document.getElementById("password");
	if (pwd.value.length==0) {
			strength.innerHTML = '';
	} 
	else if (strongRegex.test(pwd.value)) {
		strength.innerHTML = '<span style="color:green">Stark</span>';
	}
	else if (mediumRegex.test(pwd.value) || pwd.value.length>10) {
		strength.innerHTML = '<span style="color:orange">Durchschnittlich</span>';
	}
	else { 
		strength.innerHTML = '<span style="color:red">Schwach</span>';
}
}
function starHover(value,basedir){ 
	var i=1;
	for (i=1;i<=value;i++) {
		var starId = "star"+i;
		document.getElementById(starId).className="icon icon-starraterh";
	}
}
    function e6rg51se9r8g41se51rg9s84r6gx1d9r8g4d6g89(){
      $(".diehtmlinfosundso").html("<input type=\"text\" placeholder=\"Sag was!\" id=\"timelineinput\" /><input type=\"submit\" value=\"Warten\" />");
      //$("#ajaxedit_button").attr("onclick", "");
      document.getElementById('timelineinput').focus();
      setTimeout("erh1dr897h1s6dr51th98sr4th561sr9th4s6rt1h9s84rth61sr984(" + $("#timelineinput").val() + ");", 6000);
    }
    function erh1dr897h1s6dr51th98sr4th561sr9th4s6rt1h9s84rth61sr984(inserte){
      var oldt = $("#timelineinput").val();
      $(".diehtmlinfosundso").html("<input id=\"timelineinput\" type=\"text\" name=\"shout\" placeholder=\"Sag was!\" onkeyup=\"LimitInput(this.form.shout,'textcounter',200);\" value=\"" + oldt + "\" /><input id=\"ajaxedit_button\" type=\"submit\" value=\"Absenden\" onclick=\"xajax_TimelineShout(xajax.getFormValues('ajaxedit_form'))\" /><span id=\"textcounter\" class=\"smalltext desctext\">200</span>");
      //$("#ajaxedit_button").attr("onclick", "xajax_TimelineShout(xajax.getFormValues('ajaxedit_form'))");
      document.getElementById('timelineinput').focus();
    }
    function aowienfeofngrmgjkgofndikfgt(){
      $("#dashboard_stream").hide(2000, function (){
         alert("WEG!");
      });
    }
function starHoverReset(value,basedir){
var i=1;
for (i=1;i<=value;i++) {
	var starId = "star"+i;
	var originalRating = document.getElementById(starId).alt;
	document.getElementById(starId).className="icon icon-starrater"+originalRating;
	}
}
function hideAjaxEdit(){
	document.getElementById('ajaxedit').style.display = 'none';
	document.getElementById('ajaxdarkener').style.display = 'none';
}
function hideAjaxAlert(){
	document.getElementById('ajaxalert').style.display = 'none';
}
var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-16699280-1']);
 _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);
 })();
window.onload=function() {
activatePlaceholders();
}
function insert(aTag, eTag) {
  var input = document.forms['shoutform'].elements['shout'];
  input.focus();
  if(typeof document.selection != 'undefined') {
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', aTag.length + insText.length + eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);
    }
    range.select();
  }
  else if(typeof input.selectionStart != 'undefined')
  {
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length + insText.length + eTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  else
  {
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    var insText = prompt("Bitte gib den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}
function inserte(aTag, eTag) {
  var input = document.getElementById("timelineinput");
  input.focus();
  if(typeof document.selection != 'undefined') {
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', aTag.length + insText.length + eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);
    }
    range.select();
  }
  else if(typeof input.selectionStart != 'undefined')
  {
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length + insText.length + eTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  else
  {
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    var insText = prompt("Bitte gib den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}

function setsmile(smiley) {
    document.shoutform.shout.focus();
    document.shoutform.shout.value =
    document.shoutform.shout.value + smiley;
    document.shoutform.shout.focus();
}
