var excludeCookie='noCookie';(function($){$.trackWoopra=function(woop_options){var script;var src='http://static.woopra.com/js/woopra.v2.js';function init_woopra(){if(woop_options&&woop_options.cookie&&typeof(CookieHandler)=='undefined'){debug('Please initialize webtoolkit.cookies.js to handle cookie functionality');}else if(woop_options&&woop_options.cookie){var Cookie=new CookieHandler();excludeCookie=Cookie.getCookie(woop_options.cookie);if(excludeCookie==null)
excludeCookie='noCookie';}
if(woopraTracker!=undefined){if(woop_options&&woop_options.domain){woopraTracker.setDomain(woop_options.domain);debug('Woopra domain set: '+woop_options.domain);}
if(woop_options&&woop_options.url&&woop_options.title){woopraTracker.track(woop_options.url,woop_options.title);debug('Woopra loaded with url = '+woop_options.url+', title = '+woop_options.title);}
else if(woop_options&&woop_options.url&&woop_options.title&&woop_options.cookie){woopraTracker.track(woop_options.url,woop_options.title);debug('Woopra loaded with url = '+woop_options.url+', title = '+woop_options.title+', exclude cookie = '+woop_options.cookie);}
else if(woop_options&&woop_options.cookie&&excludeCookie!='noCookie'){woopraTracker.track();debug('Woopra loaded with exclude cookie = '+woop_options.cookie);}
else{woopraTracker.track();debug('Woopra loaded');}}
else{throw"woopraTracker is undefined";}}
load_woopra=function(){$.ajax({type:"GET",url:src,success:function(){init_woopra();},dataType:"script",cache:true});}
load_woopra();}
$.woopraEvent=function(title,woop_options){if(woopraTracker=='undefined'){debug('FATAL: woopraTracker is not defined');}
else if(excludeCookie=='noCookie'){var w_event=new WoopraEvent(title);$.each(woop_options,function(i,val){w_event.addProperty(i,val);});w_event.fire();}};$.fn.trackEvent=function(woop_options){return this.each(function(){var element=$(this);var parent=$(element).parent();if(element.hasClass('w_tracked')){return false;}
else{element.addClass('w_tracked');}
if(woop_options){var woop_settings=$.extend({},$.fn.trackEvent.defaults,woop_options);var title=evaluate(element,woop_settings.title);var event_name=evaluate(element,woop_settings.event_name);var options={};$.each(woop_options,function(i,val){options[i]=evaluate(element,val);});}
var message='';$.each(options,function(i,val){message+=i+' : '+val+', ';});debug('Monitoring '+message);element.bind(event_name+'.track',function(){var index=$(parent).find('> *').index(this);var skip=woop_settings.skip_internal&&(element[0].hostname==location.hostname);if(!skip){var title=evaluate($(parent).children().eq(index),woop_settings.title);options={}
$.each(woop_options,function(i,val){options[i]=evaluate($(parent).children().eq(index),val);});$.woopraEvent(title,options);if(excludeCookie=='noCookie'){debug('Tracked '+message);}
else{debug('Tracking '+message+' skipped due to exclude cookie');}}else{if(excludeCookie=='noCookie'){debug('Skipped '+message);}
else{debug('Skipped '+message+' due to exclude cookie');}}
return true;});});function evaluate(element,text_or_function){if(typeof text_or_function=='function'){text_or_function=text_or_function(element);}
return text_or_function;};};function debug(message){if(typeof console!='undefined'&&typeof console.debug!='undefined'&&$.fn.trackEvent.defaults.debug){console.debug(message);}};$.fn.trackEvent.defaults={title:function(element){return(element[0].hostname==location.hostname)?'internal':'external';},skip_internal:false,event_name:'click',debug:true};})(jQuery);