﻿var addthis_config={addthis_pub:"quodis",services_exclude:'backflip,ballhype,email,fark,faves,diigo,kaboodle,kirtsy,linkagogo,live,netvouz,nujij,hatena,meneme,plaxo,print,segnalo,spurl,simpy,stylehive,thisnext,twitter,yardbarker'}
var default_search="AhmetxAksoy";var ToriQueue=new Array(0);var currentQueueIndex=0;ToriTypes=new Array(5)
ToriTypes[0]=["XL",10000,5000];ToriTypes[1]=["L",15000,10000];ToriTypes[2]=["M",20000,15000];ToriTypes[3]=["S",25000,20000];ToriTypes[4]=["XS",30000,25000];CloudTypes=new Array(3)
CloudTypes[0]=["L",35000,8000];CloudTypes[1]=["M",40000,20000];CloudTypes[2]=["S",45000,30000];$(document).ready(function(){$('a[rel*=facebox]').facebox();function pageload(hash){if(hash){fetchFeed('search.twitter.com/search','callback=?&rpp=40&',hash);}else{fetchFeed('search.twitter.com/search','callback=?&rpp=40&',default_search);}}
$.historyInit(pageload);$("form:first").submit(function(){var hash=$("#search").val();$.historyLoad(hash);return false;});spawnTori();for(i=0;i<CloudTypes.length;++i){moveCloud(CloudTypes[i][0],CloudTypes[i][1],CloudTypes[i][2]);}
$("#search").keyup(function(){$("#sendBttn").removeClass("error");$("#sendBttn").addClass("standby");});});function moveCloud(id,speed,initialspeed){if(parseInt($("#cloud"+id).css("left"))==100){$("#cloud"+id).css("left","-220px");thisspeed=speed;}else{thisspeed=initialspeed;}
$("#cloud"+id).animate({left:"100%"},thisspeed,"linear");setTimeout("moveCloud('"+id+"', "+speed+")",thisspeed+100);}
function chat_string_create_urls(input){return input
.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim,'<a href="$&" class="my_link" target="_blank">$&</a>')
.replace(/([^\/])(www[\S]+(\b|$))/gim,'$1<a href="http://$2" class="my_link" target="_blank">$2</a>')
.replace(/(^|\s)@(\w+)/g,'$1<a href="http://twitter.com/$2" class="my_link" target="_blank">@$2</a>')
.replace(/(^|\s)#(\S+)/g,'$1<a href="http://search.twitter.com/search?q=%23$2" class="my_link" target="_blank">#$2</a>');}
$('.toriWrapper')
.livequery(function(){var previousZ;var newSpeed;$(this)
.hover(function(){if($(this).find('.tweet').is(':hidden')){previousLeft=parseInt($(this).css('left'));screenWidth=$(document).width();$(this).stop();previousZ=$(this).css('z-index');previousSpeed=parseInt($(this).attr('speed'));newSpeed=parseInt((previousLeft/(screenWidth+150))*previousSpeed);$(this).css('z-index','100');$(this).find('.tweet').show('fast');$(this).stop();}},function(){if($(this).find('.tweet').is(':visible')){$(this).find('.tweet').hide('fast');$(this).animate({left:'-150px'},newSpeed,'linear',function(){$(this).hide();$(this).remove();$(this).empty();}).css('z-index',previousZ);}});$(this).click(function(){});});function spawnTori(){if((ToriQueue.length>=currentQueueIndex)&&(ToriQueue[currentQueueIndex]!=undefined)){currentToriText=chat_string_create_urls(ToriQueue[currentQueueIndex][0]);currentToriTwittID=ToriQueue[currentQueueIndex][1];currentTorifrom_user=ToriQueue[currentQueueIndex][2];currentToricreated_at=ToriQueue[currentQueueIndex][3];currentToriDivID=Math.floor(Math.random()*1000000);currentToriType=Math.floor(5*Math.random());currentToriSpeed=ToriTypes[currentToriType][2]+(Math.floor((ToriTypes[currentToriType][1]-ToriTypes[currentToriType][2])*Math.random()))
torihtml='\
			<div id="'+currentToriDivID+'" class="toriWrapper tori'+ToriTypes[currentToriType][0]+'Wrapper" speed="'+currentToriSpeed+'">\
				<div class="toriBouncer">\
					<a href="javascript:void(0);"><img src="assets/img/layout/tori'+ToriTypes[currentToriType][0]+'.png"></a>\
					<div class="tweet">\
						<h2><strong><a href="http://twitter.com/'+currentTorifrom_user+'" title="'+currentTorifrom_user+'" target="_blank">'+currentTorifrom_user+'</a></strong> tarafından <i><a class="timeago" href="http://twitter.com/'+currentTorifrom_user+'/statuses/'+currentToriTwittID+'" target="_blank"><abbr title="'+currentToricreated_at+'">'+jQuery.timeago(currentToricreated_at.substring(4))+'</abbr></a></i></h2>\
						<p>'+currentToriText+'</p>\
					</div>\
				</div>\
			</div>';$('#content').append(torihtml);startHim('#'+currentToriDivID,currentToriSpeed);bounceHim('#'+currentToriDivID);currentQueueIndex++;}else{currentQueueIndex=0;}
setTimeout("spawnTori()",2000+parseInt(Math.random()*2000));}
function startHim(id,speed){randomHeight=25-parseInt(Math.random()*50);$(id).css('left',$(document).width()+'px');$(id+" .toriBouncer").css('margin-top',randomHeight+'px');$(id).animate({left:"-150px"},speed,"linear",function(){$(this).hide();$(this).remove();$(this).empty();});}
function bounceHim(id){$(id+" .toriBouncer").animate({marginTop:"-=4px"},450).animate({marginTop:"+=4px"},300);if($(id).is(':visible')){setTimeout("bounceHim('"+id+"')",parseInt(Math.random()*1750));}}
function fetchFeed(type,parameters,torisQuery){$("#sendBttn").removeClass("error");$("#sendBttn").addClass("loading");$("#search").val(decodeURIComponent(torisQuery.replace(/\+/g," ")));if($.safari=='false'){torisQuery=encodeURIComponent(torisQuery);}
$.getJSON('http://'+type+'.json?'+parameters+'q='+torisQuery,function(data){$.each(data,function(i,tweets){if(tweets.length!=undefined)
if(tweets.length>0){if(tweets[0]){if(tweets[0].created_at!=undefined){if(tweets[0].text!=undefined){ToriQueue.length=0;currentQueueIndex=0;for(i=0;i<tweets.length;i++){if(tweets[i].text!='')
ToriQueue[ToriQueue.length]=[tweets[i].text,tweets[i].id,tweets[i].from_user,tweets[i].created_at];};$("#sendBttn").removeClass("loading");$("#sendBttn").addClass("standby");}}}}else{$("#sendBttn").removeClass("loading");$("#sendBttn").addClass("error");}});});}
