﻿function Username_Keypress(a,b){var c=document.getElementById(a);if(c.value.length<4){return}Ajax_PostUpdate('/User/CheckName',{username:c.value},b,'animation',0)}function User_ShowPassword(){$('#PasswordContainer').slideToggle(100);$('#ShowPassword').css('display','none')}function Invite_ShowPreview(){$('#SearchInvite #Preview').slideToggle(500);$('#SearchInvite a').css('display','none')}function TimelineEntryForm_KeyPress(){var a=$('#CharsLeft');var b=document.getElementById('PostContents');var c=$('#EntryState');var d=c.attr('u');if(b===null){return}var e=(140-b.value.length);if(e==0){e=0}else if(e==140){e='&nbsp;'}else if(e<0){e=0;b.value=b.value.substring(0,140)}var f=b.value;if(f.charAt(0)=='@'){var g=f.indexOf(' ');if(g!=-1&&g>1){var h=f.substring(1,g);if(d!=h){c.html(h+' antworten');c.attr('u',h)}}else if(d!=''){c.html('Was machst du gerade?');c.attr('u','')}}else{if(d!=''){c.html('Was machst du gerade?');c.attr('u','')}}a.html(e)}function TimelineEntry_Reply(a){var b=document.getElementById('PostContents');var c=b.value;if(c.charAt(0)=='@'){var d=c.indexOf(' ');if(d!=-1){c=c.substring(d+1)}c='@'+a+' '+c}else{c='@'+a+' '+c}b.value=c;TimelineEntryForm_KeyPress();if(b.setSelectionRange){b.focus();b.setSelectionRange(140,140)}else if(b.createTextRange){var e=b.createTextRange();e.collapse(true);e.moveEnd('character',140);e.moveStart('character',140);e.select()}}function TimelineEntry_Delete(b,c){if(confirm('Willst du diesen Eintrag wirklich löschen?')==false){return false}var d='/Notification/Delete/'+b+'/'+c+'/?hash='+(Math.floor(1000*Math.random()));var e=$('#Timeline');var f=$('#CharsLeft');f.html(Ajax_GetLoadingHtml());$.get(d,function(a){if(c=='ForeignProfile'){window.location.reload();return false}TimelineEntryForm_KeyPress();e.html(a);TimeLine_init()});return false}function TimelineEntryForm_Reset(){var a=document.getElementById('PostContents');var b=a.value;document.PostForm.reset();a.value=b}function TimelineEntryForm_ShowAddEmoticon(){$('#ImageOptions,#AudioOptions,#LinkOptions').css('display','none');var b=$('#EmoticonOptions').css('display','block');var c='/Notification/Emoticons';var d=500;var e=document.getElementById('PostContents');if(b.attr('loaded')!=undefined){return}b.html(Ajax_GetLoadingHtml());$.get(c,function(a){b.fadeOut(d,function(){b.attr('loaded','done').html(a).fadeIn(d);$("#EmoticonOptions img").hover(function(){$(this).toggleClass("active",true)},function(){$(this).toggleClass("active",false)}).click(function(){e.value+=this.alt;TimelineEntryForm_KeyPress()})})})}function TimelineEntryForm_ShowAddLink(){$('#ImageOptions,#AudioOptions,#EmoticonOptions').css('display','none');$('#LinkOptions').css('display','block');TimelineEntryForm_Reset()}function TimelineEntryForm_ShowAddImage(){$('#LinkOptions,#AudioOptions,#EmoticonOptions').css('display','none');$('#ImageOptions').css('display','block');TimelineEntryForm_Reset()}function TimelineEntryForm_ShowAddMp3(){$('#LinkOptions,#ImageOptions,#EmoticonOptions').css('display','none');$('#AudioOptions').css('display','block');TimelineEntryForm_Reset()}function TimelineEntry_Post(a){var b=document.getElementById('PostContents');if(b.value.length<=0){return false}var c=$('#CharsLeft');if($('#ImageOptions').css('display')=='block'){var d=document.getElementById('ImageFile').value;if(d.length>0){$('#PostMessage').html('Dein Bild wird hochgeladen, dies kann etwas dauern.');$('#PostMessage').css('display','block')}}else if($('#AudioOptions').css('display')=='block'){var e=document.getElementById('AudioTitle').value;var d=document.getElementById('AudioFile').value;if(d.length>0){if(e.length==0){$('#PostMessage').html('Bitte gebe einen Songtitel für dieses Mp3 ein.');$('#PostMessage').css('display','block');return false}$('#PostMessage').html('Dein Mp3 wird hochgeladen, dies kann etwas dauern.');$('#PostMessage').css('display','block')}}c.html(Ajax_GetLoadingHtml());return true}function TimelineEntry_PostFailed(){var a=$('#CharsLeft');a.html('&nbsp;');$('#PostMessage').css('display','block');document.getElementById('PostMessage').innerHTML=window.frames['PostTarget'].document.body.innerHTML}function TimelineEntry_PostComplete(){document.PostForm.reset();var a=$('#CharsLeft');a.html('&nbsp;');$('#PostMessage').css('display','none');document.getElementById('Timeline').innerHTML=window.frames['PostTarget'].document.body.innerHTML;TimeLine_init()}function MessageEntry_Send(b){var c=document.getElementById('PostContents');var d=document.getElementById('TargetUserID');if(d.value==0){alert('Um eine Nachricht zu senden musst du den User auswählen, an den du eine Nachricht schicken möchtest.');return false}if(c.value.length<=0){return false}var e=$('#MessagingForm');var f=$('#CharsLeft');var g=e.serialize();var h='/Message/Send';f.html(Ajax_GetLoadingHtml());$.post(h,g,function(a){f.html('&nbsp;');window.location='/Message/Sent'});c.value='';return false}function Profile_ChangeRelation(b){var c=$('#UserPanel');var d=$('#AjaxStatus');d.html(Ajax_GetLoadingHtml());$.get(b,function(a){c.html(a);Ajax_GetUpdateLoading('/Profile/SubscriptionButtons/?hash={1}','UserPanel','AjaxStatus')});return false}function Background_UploadBegin(a){var b=$('#'+a);b.css('display','block');b.html(Ajax_GetLoadingHtml())}function Background_UploadCompleted(a,b,c){var d=$('#'+a);var e=$('#'+b);d.css('display','none');document.location='/Profile/Settings/Design'}function Background_UploadFailed(a,b,c){var d=$('#'+a);var e=$('#'+b);d.html('&nbsp;');e.html(c)}function Avatar_UploadBegin(a){var b=$('#'+a);b.html(Ajax_GetLoadingHtml())}function Avatar_UploadCompleted(a){var b=$('#AvatarSettings #AvatarImage');var c=$('#AvatarUploadMessage');avatarImage=new Image(96,96);avatarImage.src=a;b.html(Image_GetHtml(avatarImage,'Avatar',96,96));c.html('&nbsp;')}function Avatar_UploadFailed(a){var b=$('#AvatarSettings #AvatarImage');var c=$('#AvatarUploadMessage');b.html('&nbsp;');c.html(a)}function Image_GetHtml(a,b,c,d){return'<img src="'+a.src+'" alt="'+b+'" width="'+c+'" height="'+d+'" />'}ajaxLoadingImage=new Image(16,16);ajaxLoadingImage.src="/Content/Images/ajax-loader.gif";function Ajax_GetLoadingHtml(){return Image_GetHtml(ajaxLoadingImage,'Loading...',16,16)}function Ajax_GetUpdateLoading(b,c,d){var e=$('#'+c);var f=$('#'+d);f.html(Ajax_GetLoadingHtml());$.get(b,function(a){f.html('&nbsp;');e.html(a)});return false}function Ajax_GetUpdate(b,c,d,e){var f=$('#'+c);if(d!='undefined'&&e!='undefined'){if(d=='hide'){f.hide(e)}else if(d=='fadeOut'){f.fadeOut(e)}else if(d=='fadeIn'){f.fadeIn(e)}else if(d=='slide'){f.slideToggle(e)}}$.get(b,function(a){f.html(a);if(d!='undefined'&&e!='undefined'){if(d=='hide'){f.show(e)}else if(d=='fadeOut'){f.fadeIn(e)}else if(d=='fadeIn'){f.fadeOut(e)}else if(d=='slide'){f.slideToggle(e)}}});return false}function Ajax_PostUpdate(b,c,d,e,f){var g=$('#'+d);if(e!='undefined'&&f!='undefined'){if(e=='hide'){g.hide(f)}else if(e=='fadeOut'){g.fadeOut(f)}else if(e=='fadeIn'){g.fadeIn(f)}else if(e=='slide'){g.slideToggle(f)}else if(e=='animation'){g.html(Ajax_GetLoadingHtml())}}$.post(b,c,function(a){g.html(a);if(e!='undefined'&&f!='undefined'){if(e=='hide'){g.show(f)}else if(e=='fadeOut'){g.fadeIn(f)}else if(e=='fadeIn'){g.fadeOut(f)}else if(e=='slide'){g.slideToggle(f)}}});return false}function Ajax_PostFormUpdateLoading(b,c,d,e){var f=$('#'+c);var g=$('#'+d);var h=$('#'+e);var i=f.serialize();h.html(Ajax_GetLoadingHtml());$.post(b,i,function(a){h.html('&nbsp;');g.html(a)});return false}function Ajax_PostFormUpdate(b,c,d,e,f){var g=$('#'+c);var h=$('#'+d);var i=g.serialize();if(e!='undefined'&&f!='undefined'){if(e=='hide'){h.hide(f)}else if(e=='fadeOut'){h.fadeOut(f)}else if(e=='fadeIn'){h.fadeIn(f)}else if(e=='slide'){h.slideToggle(f)}else if(e=='animation'){h.html(Ajax_GetLoadingHtml())}}$.post(b,i,function(a){h.html(a);if(e!='undefined'&&f!='undefined'){if(e=='hide'){h.show(f)}else if(e=='fadeOut'){h.fadeIn(f)}else if(e=='fadeIn'){h.fadeOut(f)}else if(e=='slide'){h.slideToggle(f)}}});return false}function Ajax_PostForm(b,c,d,e){var f=$('#'+c);var g=f.serialize();if(d!='undefined'&&e!='undefined'){if(d=='hide'){f.hide(e)}else if(d=='fadeOut'){f.fadeOut(e)}else if(d=='fadeIn'){f.fadeIn(e)}else if(d=='slide'){f.slideToggle(e)}}$.post(b,g,function(a){if(d!='undefined'&&e!='undefined'){if(d=='hide'){f.show(e)}else if(d=='fadeOut'){f.fadeIn(e)}else if(d=='fadeIn'){f.fadeOut(e)}else if(d=='slide'){f.slideToggle(e)}}});return false}function TimeLine_init(){$("div .ImgAttachment a").fancybox();$("div .YtAttachment a").fancybox({'hideOnContentClick':false,'frameHeight':355,'frameWidth':425})}function JQuery_init(){TimeLine_init();$("#ShowLogin").fancybox({'hideOnContentClick':false,'frameHeight':230,'frameWidth':295,'callbackOnShow':function(){$('#fancy_div input:first')[0].focus()}});$("a.ToolTip").hover(function(){ToolTip_show(this.href,this.id,this.name)},function(){$('#Bubble').remove()}).click(function(){return false});$("div.InfoTip,span.InfoTip,a.InfoTip").hover(function(){ToolTip_show('',this.id,this.title)},function(){$('#Bubble').remove()});if(typeof($.farbtastic)!='undefined'){var f=$.farbtastic('#ColorPicker');var p=$('#ColorPicker').css('display','none');var a;$('.colorwell').each(function(){f.linkTo(this);$(this).css('opacity','0.75')}).focus(function(){if(a){$(a).css('opacity',0.75).removeClass('colorwell-selected')}f.linkTo(this);p.css('display','block');$(a=this).css('opacity',1).addClass('colorwell-selected')})}$(".TimelineEntry").live("mouseover",function(){$(this).addClass('Hov')}).live("mouseout",function(){$(this).removeClass('Hov')})}function ToolTip_show(a,b,c){if(c==false){c="&nbsp;"}var d=document.documentElement;var w=self.innerWidth||(d&&d.clientWidth)||document.body.clientWidth;var e=w-getAbsoluteLeft(b);var f=a.replace(/^[^\?]+\??/,'');var g=parseQuery(f);var h=255;var i=g['ajax'];if(i!==undefined){$('#'+b).bind('click',function(){window.location=a.replace('?ajax='+i,'')})}var j='Right';var k=0;if(e>(h+64)){k=getElementWidth(b)}else{j='Left';k=-h}var l=getAbsoluteLeft(b)+k;var m=getAbsoluteTop(b)-32;var n="<div id='Bubble' style='left:"+l+"px;top:"+m+"px;' class='"+j+"'><div id='BubbleContent'><h4>"+c+"</h4><div id='BubbleInner'><div class='ToolTipLoad'></div></div></div><div id='BubbleClose'></div></div>";$("body").append(n);$('#Bubble').show();if(i!==undefined){$('#Bubble #BubbleContent #BubbleInner').load(i)}else{var o=$("#"+b).attr('contents');$('#Bubble #BubbleContent #BubbleInner').html(o)}}function getElementWidth(a){x=document.getElementById(a);return x.offsetWidth}function getAbsoluteLeft(a){o=document.getElementById(a);oLeft=o.offsetLeft;while(o.offsetParent!=null){oParent=o.offsetParent;oLeft+=oParent.offsetLeft;o=oParent}return oLeft}function getAbsoluteTop(a){o=document.getElementById(a);oTop=o.offsetTop;while(o.offsetParent!=null){oParent=o.offsetParent;oTop+=oParent.offsetTop;o=oParent}return oTop}function parseQuery(a){var b=new Object();if(!a){return b}var c=a.split(/[;&]/);for(var i=0;i<c.length;i++){var d=c[i].split('=');if(!d||d.length!=2){continue}var e=unescape(d[0]);var f=unescape(d[1]);f=f.replace(/\+/g,' ');b[e]=f}return b}function blockEvents(a){if(a.target){a.preventDefault()}else{a.returnValue=false}}$(document).ready(JQuery_init);
