;jQuery.twittersearch={build:function(options){var defaults={amount:3,replies:false}
var options=jQuery.extend(defaults,options);var object=this;if(!jQuery(object).data('query')){jQuery(object).data('query',jQuery(object).attr('title'));jQuery(object).attr('title','');}
if(!jQuery(object).data('lang')){jQuery(object).data('lang',jQuery(object).attr('lang'));jQuery(object).attr('lang','');}
if(!options.replies){var rpp=(options.amount*5);}else{var rpp=options.amount;}
if($(object).length){$(object).html('<li>Tweets worden geladen, een ogenblik...</li>');get_tweets(encodeURIComponent(jQuery(object).data('query')),"all","");}
function get_tweets(query,lang,accountinfo){if(query.length>1900){var query1=query.substr(0,1900);var finding_or=true;max=0;while(finding_or&&max<30){if(query1.substr(query1.length-5)=="%20OR"){query1=query1.substr(0,query1.length-5);var query2=query.substr(query1.length+8);finding_or=false;}else{query1=query1.substr(0,query1.length-1);max++;}}
var url1="http://search.twitter.com/search.json?q="+query1+"&lang="+lang+"&rpp="+rpp+"&callback=?";jQuery.getJSON(url1,function(json){var results1=json;var url2="http://search.twitter.com/search.json?q="+query2+"&lang="+lang+"&rpp="+rpp+"&callback=?";jQuery.getJSON(url2,function(json){var results2=json;var results={'results':[]};var counter1=0;var counter2=0;for(var i=0;i<(results1.results.length+results2.results.length);i++){if(results1.results.length>counter1+1&&results2.results.length>counter2+1){var item1=results1.results[counter1];var time1=new Date(Date.parse(item1.created_at));time1=time1.getTime();var item2=results2.results[counter2];var time2=new Date(Date.parse(item2.created_at));time2=time2.getTime();if(time1<time2){results.results[results.results.length]=item2;counter2++;}else{results.results[results.results.length]=item1;counter1++;}}else if(results1.results.length<=counter1+1&&results2.results.length>counter2+1){results.results[results.results.length]=results2.results[counter2];counter2++;}else if(results2.results.length<=counter2+1&&results1.results.length>counter1+1){results.results[results.results.length]=results1.results[counter1];counter1++;}else{break;}}
place_tweets(results,accountinfo);});});}else{var url="http://search.twitter.com/search.json?q="+query+"&lang="+lang+"&rpp="+rpp+"&callback=?";jQuery.getJSON(url,function(json){place_tweets(json,accountinfo);});}}
function place_tweets(json,accountinfo){var zebra_style='even';var item_counter=0;var tweets_html='';jQuery(json.results).each(function(index){if(item_counter<options.amount&&((options.replies&&this.to_user_id!=null)||(!options.replies&&this.to_user_id==null))){if(zebra_style=='odd'){zebra_style='even';}else{zebra_style='odd';}
if(accountinfo[this.from_user.toLowerCase()]){var account_name=accountinfo[this.from_user.toLowerCase()].fullname;if(accountinfo[this.from_user.toLowerCase()].id_image>0){var account_image='/data/thumb/abc_media_image/'+accountinfo[this.from_user.toLowerCase()].id_image+'/w60_cropped.jpg';}else{var account_image=this.profile_image_url;}}else{var account_name=this.from_user;var account_image=this.profile_image_url;}
var thedate=new Date(Date.parse(this.created_at));var curr_min=thedate.getMinutes();curr_min=curr_min+"";if(curr_min.length==1){curr_min="0"+curr_min;}
var thedatestr=thedate.getHours()+':'+curr_min;tweets_html+='<li id="tw'+this.id+'" class="'+zebra_style+'"><a href="http://www.twitter.com/'+this.from_user+'" class="image" target="_blank"><img src="'+account_image+'" alt="" /></a><div class="tweet"><a href="http://www.twitter.com/'+this.from_user+'" class="tweet_name" target="_blank">'+account_name+'</a> <span class="tweet_text">'+this.text.linkify().linktwitteruser().linktwittertag()+'</span> <span class="tweet_date">'+thedatestr+'</span></div></li>';item_counter++;}});$(object).html(tweets_html);}
return this;}};jQuery.fn.extend({twittersearch:jQuery.twittersearch.build});jQuery(function(){jQuery("ul.twittersearch-3").twittersearch({amount:3});jQuery("ul.twittersearch-50").twittersearch({amount:50});});jQuery.twittersearch2={build:function(options){var defaults={amount:3,replies:false}
var options=jQuery.extend(defaults,options);var object=this;if(!jQuery(object).data('query')){jQuery(object).data('query',jQuery(object).attr('title'));jQuery(object).attr('title','');}
if(!jQuery(object).data('lang')){jQuery(object).data('lang',jQuery(object).attr('lang'));jQuery(object).attr('lang','');}
if(!options.replies){var rpp=(options.amount*5);}else{var rpp=options.amount;}
if($(object).length){$(object).html('<li>Tweets worden geladen, een ogenblik...</li>');get_tweets(encodeURIComponent(jQuery(object).data('query')),"all","");}
function get_tweets(query,lang,accountinfo){if(query.length>1900){var query1=query.substr(0,1900);var finding_or=true;max=0;while(finding_or&&max<30){if(query1.substr(query1.length-5)=="%20OR"){query1=query1.substr(0,query1.length-5);var query2=query.substr(query1.length+8);finding_or=false;}else{query1=query1.substr(0,query1.length-1);max++;}}
var url1="http://search.twitter.com/search.json?q="+query1+"&lang="+lang+"&rpp="+rpp+"&callback=?";jQuery.getJSON(url1,function(json){var results1=json;var url2="http://search.twitter.com/search.json?q="+query2+"&lang="+lang+"&rpp="+rpp+"&callback=?";jQuery.getJSON(url2,function(json){var results2=json;var results={'results':[]};var counter1=0;var counter2=0;for(var i=0;i<(results1.results.length+results2.results.length);i++){if(results1.results.length>counter1+1&&results2.results.length>counter2+1){var item1=results1.results[counter1];var time1=new Date(Date.parse(item1.created_at));time1=time1.getTime();var item2=results2.results[counter2];var time2=new Date(Date.parse(item2.created_at));time2=time2.getTime();if(time1<time2){results.results[results.results.length]=item2;counter2++;}else{results.results[results.results.length]=item1;counter1++;}}else if(results1.results.length<=counter1+1&&results2.results.length>counter2+1){results.results[results.results.length]=results2.results[counter2];counter2++;}else if(results2.results.length<=counter2+1&&results1.results.length>counter1+1){results.results[results.results.length]=results1.results[counter1];counter1++;}else{break;}}
place_tweets(results,accountinfo);});});}else{var url="http://search.twitter.com/search.json?q="+query+"&lang="+lang+"&rpp="+rpp+"&callback=?";jQuery.getJSON(url,function(json){place_tweets(json,accountinfo);});}}
function place_tweets(json,accountinfo){var zebra_style='even';var item_counter=0;var tweets_html='';jQuery(json.results).each(function(index){if(item_counter<options.amount&&((options.replies&&this.to_user_id!=null)||(!options.replies&&this.to_user_id==null))){if(zebra_style=='odd'){zebra_style='even';}else{zebra_style='odd';}
if(accountinfo[this.from_user.toLowerCase()]){var account_name=accountinfo[this.from_user.toLowerCase()].fullname;if(accountinfo[this.from_user.toLowerCase()].id_image>0){var account_image='/data/thumb/abc_media_image/'+accountinfo[this.from_user.toLowerCase()].id_image+'/w60_cropped.jpg';}else{var account_image=this.profile_image_url;}}else{var account_name=this.from_user;var account_image=this.profile_image_url;}
var thedate=new Date(Date.parse(this.created_at));var curr_min=thedate.getMinutes();curr_min=curr_min+"";if(curr_min.length==1){curr_min="0"+curr_min;}
var thedatestr=thedate.getHours()+':'+curr_min;tweets_html+='<li id="tw'+this.id+'" class="'+zebra_style+'"><a href="http://www.twitter.com/'+this.from_user+'" class="image" target="_blank"><img src="'+account_image+'" alt="" /></a><div class="tweet"><a href="http://www.twitter.com/'+this.from_user+'" class="tweet_name" target="_blank">'+account_name+'</a> <span class="tweet_text">'+this.text.linkify().linktwitteruser().linktwittertag()+'</span> <span class="tweet_date">'+thedatestr+'</span></div></li>';item_counter++;}});$(object).html(tweets_html);}
return this;}};jQuery.fn.extend({twittersearch2:jQuery.twittersearch2.build});jQuery(function(){jQuery("ul.twittersearch2-3").twittersearch2({amount:3});jQuery("ul.twittersearch2-50").twittersearch2({amount:50});});String.prototype.linkify=function(){return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g,function(m){return'<a href="'+m+'" target="_blank">'+m+'</a>';});};String.prototype.linktwitteruser=function(){return this.replace(/@([a-zA-Z0-9_]*)/g,'@<a href="http://twitter.com/$1" target="_blank">$1</a>');};String.prototype.linktwittertag=function(){return this.replace(/#([a-zA-Z0-9_]*)/g,'#<a href="http://search.twitter.com/search?q=%23$1" target="_blank">$1</a>');};;var total_teaser_items;var item_width;var current_teaser_item;var fadeouttimer;var player;$(document).ready(function(){total_teaser_items=$("#home_teaser_progress_items>a").length;current_teaser_item=0;item_width=Math.floor((619/total_teaser_items-1));var tag=document.createElement('script');tag.src="http://www.youtube.com/player_api";var firstScriptTag=document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);$(".home_teaser_item").hide();$("#home_teaser_progress_items>a").each(function(){$(this).css("width",item_width+"px");});$("#home_teaser_progress_items>a").mouseover(function(){var id=$(this).attr("itemid");if(id!=current_teaser_item){show_progress_item(id,false);$("#home_teaser_progress_bar").stop(true);}});$("#home_teaser_progress_items>a").mousemove(function(e){if(e.offsetX||e.layerX){var d=e.offsetX||e.layerX;d=$("#home_teaser_progress_items>a").eq(current_teaser_item).position().left+d;$("#home_teaser_progress_bar").width(d);}});$("#home_teaser_cnt").mouseenter(hometeaser_mouseover);$("#home_teaser_cnt").mouseleave(hometeaser_mouseout);$("#home_teaser_progress_bar").width(0);show_progress_item(0,true);});function hometeaser_mouseout(e){$("#home_teaser .home_teaser_intro").fadeOut(200);show_progress_item(current_teaser_item,true);}
function hometeaser_mouseover(e){$("#home_teaser").find(".home_teaser_intro").fadeIn(200);$("#home_teaser_progress_bar").stop(true);}
function show_progress_item(item,play){if(item>=total_teaser_items){item=0;}
if($(".home_teaser_item").eq(item).length==0||$("#home_teaser_progress_items>a").eq(item).length==0){return;}
$("#home_teaser_progress_bar").stop(true);var itempos=$("#home_teaser_progress_items>a").eq(item).position();var curitemwidth=$("#home_teaser_progress_items>a").eq(item).width();var posstart=itempos.left;var posend=itempos.left+curitemwidth+1;if(item!=current_teaser_item){$("#player").hide().html("");$(".home_teaser_item").hide();$(".home_teaser_item").eq(item).fadeIn(200);$("#home_teaser_progress_bar").width(posstart);}
else{$(".home_teaser_item").eq(item).show();}
if(play=true){var anitime=Math.round((1-(($("#home_teaser_progress_bar").width()-item*item_width)/item_width))*5000);$("#home_teaser_progress_bar").animate({width:posend+"px"},anitime,"linear",function(){setTimeout("show_progress_item("+(item+1)+",true)",10);});}
current_teaser_item=item;}
