function wau_wibiya_obj(){this.api_port="wib";this.version="1.53";this.sitekey="";this.scheme="http";this.port="";this.interval=20000;this.log_int=120000;this.timeout=0;this.num_ups=0;this.auto_en="f";this.timer;this.date;this.init_time;this.title="";this.browser="";this.platform="";this.ref="";this.unique="t";this.s_eng="";this.s_ter="";this.scaling_intervals=[20000,30000,60000];this.scaling_up_skips=[12,0,0];this.scaling_index=0;this.scaling_en=true;this.init=function(a){this.sitekey=a;if(this.sitekey==""||this.sitekey.length<4||this.sitekey.length>26){return}this.get_params();if(this.key_is_pro()){this.timer_init();this.send_wid_request()}else{this.send_wid_request()}};this.get_params=function(){this.set_time();if(document.location.href.substr(0,5)=="https"){this.scheme="https";this.port=":4444"}if(document.title){this.title=this.trim_string(document.title)}if(document.referrer){this.ref=document.referrer}this.search_parse(this.ref);this.parse_ua(navigator.userAgent);this.check_unique()};this.key_is_pro=function(){if(this.sitekey.length==4){return true}else{return false}};this.send_wid_request=function(){var c="/";if(this.key_is_pro()){if(this.timeout_exceeded()){this.timer_stop();return}if(this.num_ups%(this.log_int/this.interval)==0){c="/"+this.wid_args(true);if(this.scaling_en&&(this.num_ups>=this.scaling_up_skips[this.scaling_index])){this.set_next_scaling_int();this.timer_mod(this.interval)}}else{c="/"+this.wid_args(false)}}else{c="/"+this.title}var b=document.getElementsByTagName("head")[0];var a=document.createElement("script");a.type="text/javascript";a.src=this.scheme+"://whos.amung.us"+this.port+"/api/query/wibiya/"+this.sitekey+c;a.id="wau_wib_scr_"+this.num_ups;b.appendChild(a);this.num_ups++};this.wid_args=function(c){var g;var f;if(c){var d="f";if(this.num_ups==0){d="t"}g="?t="+encodeURIComponent(this.title)+"&r="+encodeURIComponent(this.ref)+"&s="+encodeURIComponent(this.s_ter)+"&p="+encodeURIComponent(this.s_eng)+"&o="+encodeURIComponent(this.platform)+"&b="+encodeURIComponent(this.browser)+"&u="+this.unique+"&f="+d+"&";f="t"}else{g="?";f="f"}var e="f";if(this.scaling_en){e="t"}var a=new Date();var b=g+"z="+this.api_port+"&v="+this.version+"&a="+this.auto_en+"&l="+f+"&num="+this.num_ups+"&int="+(this.interval/1000)+"&sca="+e+"&ts="+parseInt(a.getTime()/1000);return b};this.check_unique=function(){var a=this.sitekey+"_unique_user";var f=a+"=";var g=document.cookie.split(";");for(var j=0;j<g.length;j++){var k=g[j];while(k.charAt(0)==" "){k=k.substring(1,k.length)}if(k.indexOf(f)==0){if(k.substring(f.length,k.length)==1){this.unique="f"}}}if(this.unique=="t"){var e=new Date();e.setUTCDate((new Date((new Date(e.getYear(),e.getMonth()+1,1))-1)).getDate());e.setUTCHours(23);e.setUTCMinutes(59);e.setUTCSeconds(59);var b="; expires="+e.toUTCString();var h=window.location.hostname;var d=/[a-z0-9\-]+\.[a-z]{2,3}\.[a-z]{2}$/i;var l=/[a-z0-9\-]+\.[a-z]{2,4}$/i;if(h.match(d)){h=h.match(d)}else{if(h.match(l)){h=h.match(l)}}document.cookie=a+"=1"+b+"; path=/; domain="+h}};this.search_parse=function(a){var b=null;b=/https?:\/\/[^\/]*images\.google\.(.*)prev=\/images%3Fq%3D(.*)%26hl%3D/i.exec(a);if(b!=null&&b[2]!=null){this.s_eng="gi-"+this.google_country(a);this.s_ter=unescape(b[2]).replace(/\+/g," ");return}b=/https?:\/\/[^\/]*\.google\.(.*)\/cse/i.exec(a);if(b!=null){this.s_eng="gc-"+this.google_country(a);this.s_ter=this.query_val("q",a).replace(/\+/g," ");return}b=/https?:\/\/[^\/]*((images|video|maps|news|blogsearch)\.google)\./i.exec(a);if(b==null){b=/https?:\/\/[^\/]*((images|video|local|maps)(\.search)?\.yahoo)\./i.exec(a)}if(b==null){b=/https?:\/\/[^\/]*(google|search\.yahoo|search\.msn|search\.live|msnlive|ask|lycos|aol|hotbot|bing|technorati|digg|delicious|del\.icio|facebook)\./i.exec(a)}if(b==null||b[1]==null){return}this.s_eng=b[1];switch(this.s_eng){case"images.google":this.s_eng="gi-"+this.google_country(a);this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"video.google":this.s_eng="gv-"+this.google_country(a);this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"maps.google":this.s_eng="gm-"+this.google_country(a);this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"news.google":this.s_eng="gn-"+this.google_country(a);this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"blogsearch.google":this.s_eng="gb-"+this.google_country(a);this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"google":this.s_eng="go-"+this.google_country(a);this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"search.yahoo":this.s_eng="ya-"+this.yahoo_country(a);this.s_ter=this.query_val("p",a).replace(/\+/g," ");break;case"images.search.yahoo":this.s_eng="yi-"+this.yahoo_country(a);this.s_ter=this.query_val("p",a).replace(/\+/g," ");break;case"video.search.yahoo":this.s_eng="yv-"+this.yahoo_country(a);this.s_ter=this.query_val("p",a).replace(/\+/g," ");break;case"local.yahoo":this.s_eng="yl-"+this.yahoo_country(a);this.s_ter=this.query_val("p",a).replace(/\+/g," ");if(this.s_ter==null){this.s_ter=this.query_val("stx",a).replace(/\+/g," ")}break;case"maps.search.yahoo":this.s_eng="ym-"+this.yahoo_country(a);this.s_ter=this.query_val("p",a).replace(/\+/g," ");break;case"ask":this.s_eng="as";this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"bing":this.s_eng="bi";this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"live":case"msnlive":case"search.msn":this.s_eng="ms";this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"aol":this.s_eng="ao";this.s_ter=this.query_val("query",a).replace(/\+/g," ");break;case"lycos":this.s_eng="ly";this.s_ter=this.query_val("query",a).replace(/\+/g," ");break;case"hotbot":this.s_eng="hb";this.s_ter=this.query_val("query",a).replace(/\+/g," ");break;case"technorati":this.s_eng="tc";this.s_ter=this.query_val("q",a).replace(/\+/g," ");break;case"digg":this.s_eng="dg";this.s_ter=this.query_val("s",a).replace(/\+/g," ");break;case"delicious":case"dl.icio":this.s_eng="dl";this.s_ter=this.query_val("p",a).replace(/\+/g," ");break;case"facebook":this.s_eng="fb";this.s_ter=this.query_val("q",a).replace(/\+/g," ");break}};this.query_val=function(b,d){b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c=new RegExp("[\\?&]"+b+"=([^&#]*)");var a=c.exec(d);if(a!=null){return a[1]}else{return""}};this.google_country=function(a){var b=/https?:\/\/[^\/]*google\.(co\.|com\.)?([a-z]{2,3})/i.exec(a);if(b[2]=="com"){return"us"}else{return b[2]}};this.yahoo_country=function(a){var b=/https?:\/\/([a-z]{2}\.)?([\.a-z]+)?\.yahoo\./i.exec(a);if(b==null){return"us"}else{return b[1].replace(".","")}};this.parse_ua=function(c){var a="";var b="";c=c.toLowerCase();if(c.indexOf("windows nt 5.1")>=0){a="xp"}else{if(c.indexOf("windows nt 6.0")>=0){a="vi"}else{if(c.indexOf("mac os x")>=0){a="ox"}else{if(c.indexOf("windows nt 6.1")>=0){a="w7"}else{if(c.indexOf("windows nt 5.0")>=0){a="w2"}else{if(c.indexOf("windows nt 5.2")>=0){a="w3"}else{if(c.indexOf("windows")>=0){a="wn"}else{if(c.indexOf("linux")>=0){a="lx"}else{if(/(unix|bsd)/i.exec(c)!=null){a="ux"}else{if(c.indexOf("iphone")>=0){a="ip"}else{if(c.indexOf("blackberry")>=0){a="bb"}else{if(c.indexOf("nokia")>=0){a="nk"}else{if(c.indexOf("ipod")>=0){a="io"}else{if(/(midp|mobile|j2me|symbian)/i.exec(c)!=null){a="mo"}else{a="un"}}}}}}}}}}}}}}if(c.indexOf("firefox")>=0){b="ff"}else{if(c.indexOf("msie")>=0){b="ie"}else{if(c.indexOf("chrome")>=0){b="ch"}else{if(c.indexOf("safari")>=0){b="sf"}else{if(c.indexOf("opera")>=0){b="op"}else{if(/(bot|crawl|spider)/i.exec(c)!=null){b="bt";if(a=="un"){a="bt"}}else{if(/(blackberry|nokia|midp|mobile|j2me|symbian)/i.exec(c)!=null){b="mo";if(a=="un"){a="mo"}}else{b="un"}}}}}}}this.platform=a;this.browser=b};this.rem_resp=function(){try{var a=document.getElementById(this.last_script_id());a.parentNode.removeChild(a)}catch(b){}};this.last_script_id=function(){return"wau_wib_scr_"+(this.num_ups-1)};this.timer_init=function(){this.auto_en="t";try{clearInterval(this.timer)}catch(a){}this.timer=setInterval(function(){wau_wib_request()},this.interval)};this.timer_mod=function(a){this.interval=a;this.timer_init()};this.timer_stop=function(){this.auto_en="f";try{clearInterval(this.timer)}catch(a){}};this.set_next_scaling_int=function(){if((this.scaling_index+1)>(this.scaling_intervals.length-1)){this.scaling_index=this.scaling_intervals.length-1}else{this.scaling_index=this.scaling_index+1}this.interval=this.scaling_intervals[this.scaling_index]};this.disable_scaling=function(a){this.scaling_en=false;this.timer_mod(a)};this.disable_scaling_no_mod=function(){this.scaling_en=false};this.enable_scaling=function(a){this.scaling_en=true;if(a<0){this.scaling_index=0}else{if(a>(this.scaling_intervals.length-1)){this.scaling_index=(this.scaling_intervals.length-1)}else{this.scaling_index=a}}this.timer_mod(this.scaling_intervals[this.scaling_index])};this.enable_scaling_no_mod=function(){this.scaling_en=true};this.timeout_mins=function(a){this.timeout=Math.abs(a*60)};this.timeout_now_mins=function(a){this.set_time();this.timeout=Math.abs(a*60)};this.set_time=function(){var a=new Date();this.init_time=parseInt(a.getTime()/1000)};this.timeout_exceeded=function(){var a=new Date();var b=parseInt(a.getTime()/1000);if((this.timeout!=0)&&((b-this.init_time)>this.timeout)){return true}else{return false}};this.trim_string=function(a){return a.replace(/^\s+|\s+$/g,"").substr(0,80)}};

var wau_wib_obj = new wau_wibiya_obj();     //create WAU object for Wibiya toolbar
var wau_wib_request = function() {          //required global namespace wrapper
    wau_wib_obj.send_wid_request();
};
