//<![CDATA[
App.env.siteId = "90047076";
App.env.contextPath = "/ms"; 
App.env.assetsPath = "/ms/assets/";
App.env.jwrPath = "/ms/gzip_N764571896/assets/";
App.env.yuiPath = "/ms/assets/lib/yui/2.8.0r4/build/";
App.env.logoutUrl = "/ms/admin/login.html;jsessionid=AC1FE1F6A7F1D981CD9A756F66B972AF";
App.env.mediaContextPath = ""; 
App.env.localize = {
AJAX_LOADING: "A carregar",
AJAX_SUCCESS: "Sucesso",
GLOBAL_ERROR_TITLE: "Ocorreu um erro",
REFRESH_PAGE: 'Efectue &quot;Actualizar&quot; &agrave; p&aacute;gina',
CONFIRM_TITLE: "Customiza&ccedil;&atilde;o do tema",
CONFIRM_TXT: "Seu tema foi modificado. Voc&ecirc; deseja salvar as altera&ccedil;&otilde;es?",
GLOBAL_OK: "Sim",
GLOBAL_CANCEL: "Cancelar",
GLOBAL_NO: "N&atilde;o"
};
App.ready(function() {
App.checkSplashScreen({ contentDiv: "splashPageDiv", strategy: "cookie", siteId: "90047076" }); 
});
//]]>


// WebTrends SmartSource Data Collector Tag
// Version: 8.6.2     
// Tag Builder Version: 3.0
// Created: 2/9/2010 3:58:53 PM

function WebTrends(){
	var that=this;
	// begin: user modifiable
	this.dcsid="";
	this.domain="statse.webtrendslive.com";
	this.timezone=0;
	this.fpcdom="";
	this.enabled=true;
	this.i18n=false;
	this.fpc="WT_FPC";
	this.paidsearchparams="gclid";
	// end: user modifiable
	this.DCS={};
	this.WT={};
	this.DCSext={};
	this.images=[];
	this.index=0;
	this.exre=(function(){return(window.RegExp?new RegExp("dcs(uri)|(ref)|(aut)|(met)|(sta)|(sip)|(pro)|(byt)|(dat)|(p3p)|(cfg)|(redirect)|(cip)","i"):"");})();
	this.re=(function(){return(window.RegExp?(that.i18n?{"%25":/\%/g}:{"%09":/\t/g,"%20":/ /g,"%23":/\#/g,"%26":/\&/g,"%2B":/\+/g,"%3F":/\?/g,"%5C":/\\/g,"%22":/\"/g,"%7F":/\x7F/g,"%A0":/\xA0/g}):"");})();
}
WebTrends.prototype.dcsGetId=function(){
	if (this.enabled&&(document.cookie.indexOf(this.fpc+"=")==-1)&&(document.cookie.indexOf("WTLOPTOUT=")==-1)){
		document.write("<scr"+"ipt type='text/javascript' src='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+this.domain+"/"+this.dcsid+"/wtid.js"+"'><\/scr"+"ipt>");
	}
}
WebTrends.prototype.dcsGetCookie=function(name){
	var cookies=document.cookie.split("; ");
	var cmatch=[];
	var idx=0;
	var i=0;
	var namelen=name.length;
	var clen=cookies.length;
	for (i=0;i<clen;i++){
		var c=cookies[i];
		if ((c.substring(0,namelen+1))==(name+"=")){
			cmatch[idx++]=c;
		}
	}
	var cmatchCount=cmatch.length;
	if (cmatchCount>0){
		idx=0;
		if ((cmatchCount>1)&&(name==this.fpc)){
			var dLatest=new Date(0);
			for (i=0;i<cmatchCount;i++){
				var lv=parseInt(this.dcsGetCrumb(cmatch[i],"lv"));
				var dLst=new Date(lv);
				if (dLst>dLatest){
					dLatest.setTime(dLst.getTime());
					idx=i;
				}
			}
		}
		return unescape(cmatch[idx].substring(namelen+1));
	}
	else{
		return null;
	}
}
WebTrends.prototype.dcsGetCrumb=function(cval,crumb,sep){
	var aCookie=cval.split(sep||":");
	for (var i=0;i<aCookie.length;i++){
		var aCrumb=aCookie[i].split("=");
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
WebTrends.prototype.dcsGetIdCrumb=function(cval,crumb){
	var id=cval.substring(0,cval.indexOf(":lv="));
	var aCrumb=id.split("=");
	for (var i=0;i<aCrumb.length;i++){
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
WebTrends.prototype.dcsIsFpcSet=function(name,id,lv,ss){
	var c=this.dcsGetCookie(name);
	if (c){
		return ((id==this.dcsGetIdCrumb(c,"id"))&&(lv==this.dcsGetCrumb(c,"lv"))&&(ss==this.dcsGetCrumb(c,"ss")))?0:3;
	}
	return 2;
}
WebTrends.prototype.dcsFPC=function(){
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var WT=this.WT;
	var name=this.fpc;
	var dCur=new Date();
	var adj=(dCur.getTimezoneOffset()*60000)+(this.timezone*3600000);
	dCur.setTime(dCur.getTime()+adj);
	var dExp=new Date(dCur.getTime()+315360000000);
	var dSes=new Date(dCur.getTime());
	WT.co_f=WT.vtid=WT.vtvs=WT.vt_f=WT.vt_f_a=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
	if (document.cookie.indexOf(name+"=")==-1){
		if ((typeof(gWtId)!="undefined")&&(gWtId!="")){
			WT.co_f=gWtId;
		}
		else if ((typeof(gTempWtId)!="undefined")&&(gTempWtId!="")){
			WT.co_f=gTempWtId;
			WT.vt_f="1";
		}
		else{
			WT.co_f="2";
			var curt=dCur.getTime().toString();
			for (var i=2;i<=(32-curt.length);i++){
				WT.co_f+=Math.floor(Math.random()*16.0).toString(16);
			}
			WT.co_f+=curt;
			WT.vt_f="1";
		}
		if (typeof(gWtAccountRollup)=="undefined"){
			WT.vt_f_a="1";
		}
		WT.vt_f_s=WT.vt_f_d="1";
		WT.vt_f_tlh=WT.vt_f_tlv="0";
	}
	else{
		var c=this.dcsGetCookie(name);
		var id=this.dcsGetIdCrumb(c,"id");
		var lv=parseInt(this.dcsGetCrumb(c,"lv"));
		var ss=parseInt(this.dcsGetCrumb(c,"ss"));
		if ((id==null)||(id=="null")||isNaN(lv)||isNaN(ss)){
			return;
		}
		WT.co_f=id;
		var dLst=new Date(lv);
		WT.vt_f_tlh=Math.floor((dLst.getTime()-adj)/1000);
		dSes.setTime(ss);
		if ((dCur.getTime()>(dLst.getTime()+1800000))||(dCur.getTime()>(dSes.getTime()+28800000))){
			WT.vt_f_tlv=Math.floor((dSes.getTime()-adj)/1000);
			dSes.setTime(dCur.getTime());
			WT.vt_f_s="1";
		}
		if ((dCur.getDay()!=dLst.getDay())||(dCur.getMonth()!=dLst.getMonth())||(dCur.getYear()!=dLst.getYear())){
			WT.vt_f_d="1";
		}
	}
	WT.co_f=escape(WT.co_f);
	WT.vtid=(typeof(this.vtid)=="undefined")?WT.co_f:(this.vtid||"");
	WT.vtvs=(dSes.getTime()-adj).toString();
	var expiry="; expires="+dExp.toGMTString();
	var cur=dCur.getTime().toString();
	var ses=dSes.getTime().toString();
	document.cookie=name+"="+"id="+WT.co_f+":lv="+cur+":ss="+ses+expiry+"; path=/"+(((this.fpcdom!=""))?("; domain="+this.fpcdom):(""));
	var rc=this.dcsIsFpcSet(name,WT.co_f,cur,ses);
	if (rc!=0){
		WT.co_f=WT.vtvs=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
		if (typeof(this.vtid)=="undefined"){
			WT.vtid="";
		}
		WT.vt_f=WT.vt_f_a=rc;
    }
}

//Modified dcsMultiTrack function to pause non IE browsers before sending hit
//Designed for TagBuilder v2, v3 tags
//M.Orr Jan 2010	
WebTrends.prototype.dcsMultiTrack=function(){
	var args=dcsMultiTrack.arguments?dcsMultiTrack.arguments:arguments;
	if (args.length%2==0){
		this.dcsSetProps(args);
		var dCurrent=new Date();
		this.DCS.dcsdat=dCurrent.getTime();
		this.dcsFPC();
		this.dcsTag();
	}
	if (navigator.appName != "Microsoft Internet Explorer"){
	dcsPause(250);
	}	
}



//New dcsMultiTrack function to avoid sending the visitorid for impressions on websearch
//M.Cuyt 2010
WebTrends.prototype.dcsMultiTrackWebSearch=function(){
	var args=dcsMultiTrackWebSearch.arguments?dcsMultiTrackWebSearch.arguments:arguments;
	if (args.length%2==0){
		this.dcsSetProps(args);
		var dCurrent=new Date();
		this.DCS.dcsdat=dCurrent.getTime();
		this.dcsFPC();
		this.WT.co_f='2';
		this.dcsTag();
	}	
}


//New dcsMultiTrack function for measuring impressions with multiple calls to dcsMultiTrack without having to use Firefox fix with pause
//M.Cuyt 2011
WebTrends.prototype.dcsMultiTrackImpressions=function(){
	var args=dcsMultiTrackImpressions.arguments?dcsMultiTrackImpressions.arguments:arguments;
	if (args.length%2==0){
		this.dcsSetProps(args);
		var dCurrent=new Date();
		this.DCS.dcsdat=dCurrent.getTime();
		this.dcsFPC();
		this.dcsTag();
	}	
}

function dcsPause(ms){
	var start = new Date();
	var now = new Date();
	while(now.getTime() - start.getTime() < ms)
	{
		now = new Date();
	}
}


WebTrends.prototype.dcsCleanUp=function(){
	this.DCS={};
	this.WT={};
	this.DCSext={};
	if (arguments.length%2==0){
		this.dcsSetProps(arguments);
	}
}
WebTrends.prototype.dcsSetProps=function(args){
	for (var i=0;i<args.length;i+=2){
		if (args[i].indexOf('WT.')==0){
			this.WT[args[i].substring(3)]=args[i+1];
		}
		else if (args[i].indexOf('DCS.')==0){
			this.DCS[args[i].substring(4)]=args[i+1];
		}
		else if (args[i].indexOf('DCSext.')==0){
			this.DCSext[args[i].substring(7)]=args[i+1];
		}
	}
}
WebTrends.prototype.dcsAdv=function(){
	this.dcsFPC();
}
WebTrends.prototype.dcsVar=function(){
	var dCurrent=new Date();
	var WT=this.WT;
	var DCS=this.DCS;
	WT.tz=parseInt(dCurrent.getTimezoneOffset()/60*-1)||"0";
	WT.bh=dCurrent.getHours()||"0";
	WT.ul=navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
	if (typeof(screen)=="object"){
		WT.cd=navigator.appName=="Netscape"?screen.pixelDepth:screen.colorDepth;
		WT.sr=screen.width+"x"+screen.height;
	}
	if (typeof(navigator.javaEnabled())=="boolean"){
		WT.jo=navigator.javaEnabled()?"Yes":"No";
	}
	if (document.title){
		if (window.RegExp){
			var tire=new RegExp("^"+window.location.protocol+"//"+window.location.hostname+"\\s-\\s");
			WT.ti=document.title.replace(tire,"");
		}
		else{
			WT.ti=document.title;
		}
	}
	WT.js="Yes";
	WT.jv=(function(){
		var agt=navigator.userAgent.toLowerCase();
		var major=parseInt(navigator.appVersion);
		var mac=(agt.indexOf("mac")!=-1);
		var ff=(agt.indexOf("firefox")!=-1);
		var ff0=(agt.indexOf("firefox/0.")!=-1);
		var ff10=(agt.indexOf("firefox/1.0")!=-1);
		var ff15=(agt.indexOf("firefox/1.5")!=-1);
		var ff20=(agt.indexOf("firefox/2.0")!=-1);
		var ff3up=(ff&&!ff0&&!ff10&!ff15&!ff20);
		var nn=(!ff&&(agt.indexOf("mozilla")!=-1)&&(agt.indexOf("compatible")==-1));
		var nn4=(nn&&(major==4));
		var nn6up=(nn&&(major>=5));
		var ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));
		var ie4=(ie&&(major==4)&&(agt.indexOf("msie 4")!=-1));
		var ie5up=(ie&&!ie4);
		var op=(agt.indexOf("opera")!=-1);
		var op5=(agt.indexOf("opera 5")!=-1||agt.indexOf("opera/5")!=-1);
		var op6=(agt.indexOf("opera 6")!=-1||agt.indexOf("opera/6")!=-1);
		var op7up=(op&&!op5&&!op6);
		var jv="1.1";
		if (ff3up){
			jv="1.8";
		}
		else if (ff20){
			jv="1.7";
		}
		else if (ff15){
			jv="1.6";
		}
		else if (ff0||ff10||nn6up||op7up){
			jv="1.5";
		}
		else if ((mac&&ie5up)||op6){
			jv="1.4";
		}
		else if (ie5up||nn4||op5){
			jv="1.3";
		}
		else if (ie4){
			jv="1.2";
		}
		return jv;
	})();
	WT.ct="unknown";
	if (document.body&&document.body.addBehavior){
		try{
			document.body.addBehavior("#default#clientCaps");
			WT.ct=document.body.connectionType||"unknown";
			document.body.addBehavior("#default#homePage");
			WT.hp=document.body.isHomePage(location.href)?"1":"0";
		}
		catch(e){
		}
	}
	if (document.all){
		WT.bs=document.body?document.body.offsetWidth+"x"+document.body.offsetHeight:"unknown";
	}
	else{
		WT.bs=window.innerWidth+"x"+window.innerHeight;
	}
	WT.fv=(function(){
		var i,flash;
		if (window.ActiveXObject){
			for(i=10;i>0;i--){
				try{
					flash=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
					return i+".0";
				}
				catch(e){
				}
			}
		}
		else if (navigator.plugins&&navigator.plugins.length){
			for (i=0;i<navigator.plugins.length;i++){
				if (navigator.plugins[i].name.indexOf('Shockwave Flash')!=-1){
					return navigator.plugins[i].description.split(" ")[2];
				}
			}
		}
		return "Not enabled";
	})();
	WT.slv=(function(){
		var slv="Not enabled";
		try{     
			if (navigator.userAgent.indexOf('MSIE')!=-1){
				var sli = new ActiveXObject('AgControl.AgControl');
				if (sli){
					slv="Unknown";
				}
			}
			else if (navigator.plugins["Silverlight Plug-In"]){
				slv="Unknown";
			}
		}
		catch(e){
		}
		if (slv!="Not enabled"){
			var i,j,v;
			if ((typeof(Silverlight)=="object")&&(typeof(Silverlight.isInstalled)=="function")){
				for(i=3;i>0;i--){
					for (j=9;j>=0;j--){
						v=i+"."+j;
						if (Silverlight.isInstalled(v)){
							slv=v;
							break;
						}
					}
					if (slv==v){
						break;
					}
				}
			}
		}
		return slv;
	})();
	if (this.i18n){
		if (typeof(document.defaultCharset)=="string"){
			WT.le=document.defaultCharset;
		} 
		else if (typeof(document.characterSet)=="string"){
			WT.le=document.characterSet;
		}
		else{
			WT.le="unknown";
		}
	}
	WT.tv="8.6.2";
//	WT.sp="@@SPLITVALUE@@";
	WT.dl="0";
	WT.ssl=(window.location.protocol.indexOf('https:')==0)?"1":"0";
	DCS.dcsdat=dCurrent.getTime();
	DCS.dcssip=window.location.hostname;
	DCS.dcsuri=window.location.pathname;
	WT.es=DCS.dcssip+DCS.dcsuri;
	if (window.location.search){
		DCS.dcsqry=window.location.search;
	}
	if (DCS.dcsqry){
		var dcsqry=DCS.dcsqry.toLowerCase();
		var params=this.paidsearchparams.length?this.paidsearchparams.toLowerCase().split(","):[];
		for (var i=0;i<params.length;i++){
			if (dcsqry.indexOf(params[i]+"=")!=-1){
				WT.srch="1";
				break;
			}
		}
	}
	if ((window.document.referrer!="")&&(window.document.referrer!="-")){
		if (!(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)<4)){
			DCS.dcsref=window.document.referrer;
		}
	}
}
WebTrends.prototype.dcsEscape=function(S, REL){
	if (REL!=""){
		S=S.toString();
		for (var R in REL){
 			if (REL[R] instanceof RegExp){
				S=S.replace(REL[R],R);
 			}
		}
		return S;
	}
	else{
		return escape(S);
	}
}
WebTrends.prototype.dcsA=function(N,V){
	if (this.i18n&&(this.exre!="")&&!this.exre.test(N)){
		if (N=="dcsqry"){
			var newV="";
			var params=V.substring(1).split("&");
			for (var i=0;i<params.length;i++){
				var pair=params[i];
				var pos=pair.indexOf("=");
				if (pos!=-1){
					var key=pair.substring(0,pos);
					var val=pair.substring(pos+1);
					if (i!=0){
						newV+="&";
					}
					newV+=key+"="+this.dcsEncode(val);
				}
			}
			V=V.substring(0,1)+newV;
		}
		else{
			V=this.dcsEncode(V);
		}
	}
	return "&"+N+"="+this.dcsEscape(V, this.re);
}
WebTrends.prototype.dcsEncode=function(S){
	return (typeof(encodeURIComponent)=="function")?encodeURIComponent(S):escape(S);
}
WebTrends.prototype.dcsCreateImage=function(dcsSrc){
	if (document.images){
		this.images[this.index]=new Image();
		this.images[this.index].src=dcsSrc;
		this.index++;
	}
	else{
		document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="'+dcsSrc+'">');
	}
}
WebTrends.prototype.dcsMeta=function(){
	var elems;
	if (document.all){
		elems=document.all.tags("meta");
	}
	else if (document.documentElement){
		elems=document.getElementsByTagName("meta");
	}
	if (typeof(elems)!="undefined"){
		var length=elems.length;
		for (var i=0;i<length;i++){
			var name=elems.item(i).name;
			var content=elems.item(i).content;
			var equiv=elems.item(i).httpEquiv;
			if (name.length>0){
				if (name.toUpperCase().indexOf("WT.")==0){
					this.WT[name.substring(3)]=content;
				}
				else if (name.toUpperCase().indexOf("DCSEXT.")==0){
					this.DCSext[name.substring(7)]=content;
				}
				else if (name.toUpperCase().indexOf("DCS.")==0){
					this.DCS[name.substring(4)]=content;
				}
			}
		}
	}
}
WebTrends.prototype.dcsTag=function(){
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var WT=this.WT;
	var DCS=this.DCS;
	var DCSext=this.DCSext;
	var i18n=this.i18n;
	var P="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+this.domain+(this.dcsid==""?'':'/'+this.dcsid)+"/dcs.gif?";
	if (i18n){
		WT.dep="";
	}
	for (var N in DCS){
 		if (DCS[N]&&(typeof DCS[N]!="function")){
			P+=this.dcsA(N,DCS[N]);
		}
	}
	var keys=["co_f","vtid","vtvs","vt_f_tlv"];
	for (var i=0;i<keys.length;i++){
		var key=keys[i];
		if (WT[key]){
			P+=this.dcsA("WT."+key,WT[key]);
			delete WT[key];
		}
	}
	for (N in WT){
		if (WT[N]&&(typeof WT[N]!="function")){
			P+=this.dcsA("WT."+N,WT[N]);
		}
	}
	for (N in DCSext){
		if (DCSext[N]&&(typeof DCSext[N]!="function")){
			if (i18n){
				WT.dep=(WT.dep.length==0)?N:(WT.dep+";"+N);
			}
			P+=this.dcsA(N,DCSext[N]);
		}
	}
	if (i18n&&(WT.dep.length>0)){
		P+=this.dcsA("WT.dep",WT.dep);
	}
	if (P.length>2048&&navigator.userAgent.indexOf('MSIE')>=0){
		P=P.substring(0,2040)+"&WT.tu=1";
	}
	this.dcsCreateImage(P);
	this.WT.ad="";
}
WebTrends.prototype.dcsDebug=function(){
	var t=this;
	var i=t.images[0].src;
	var q=i.indexOf("?");
	var r=i.substring(0,q).split("/");
	var m="<b>Protocol</b><br><code>"+r[0]+"<br></code>";
	m+="<b>Domain</b><br><code>"+r[2]+"<br></code>";
	m+="<b>Path</b><br><code>/"+r[3]+"/"+r[4]+"<br></code>";
	m+="<b>Query Params</b><code>"+i.substring(q+1).replace(/\&/g,"<br>")+"</code>";
	m+="<br><b>Cookies</b><br><code>"+document.cookie.replace(/\;/g,"<br>")+"</code>";
	if (t.w&&!t.w.closed){
		t.w.close();
	}
	t.w=window.open("","dcsDebug","width=500,height=650,scrollbars=yes,resizable=yes");
	t.w.document.write(m);
	t.w.focus();
}
WebTrends.prototype.dcsCollect=function(){
    if (this.enabled){
        this.dcsVar();
        this.dcsMeta();
        this.dcsAdv();
        this.dcsTag();
    }
}


//New dcsCollect function to add _mainreq=1 parameter only for pageviews and not for clicks
//M.Cuyt/S.Winter 2010 / This function from orignal webtrends javascript was added to this modified version which has the dcsCollectPageWebSearch - BP Jan26-2010
WebTrends.prototype.dcsCollectPage=function(){  
    if (this.enabled){  
  this.DCSext._mainreq=1; 
  this.dcsVar();
  this.dcsMeta();
  this.dcsAdv();
  this.dcsTag();
  delete this.DCSext._mainreq; 
    }
}

//New dcsCollect function to avoid pageviews being sent on a syndicated web search page (but still allow parameters to be set to measure clicks)
//M.Cuyt 2010
WebTrends.prototype.dcsCollectPageWebSearch=function(){	
    if (this.enabled){	
	this.dcsVar();
	this.dcsMeta();
	this.dcsAdv();
	//this.dcsTag();
    }
}

function dcsMultiTrack(){
	if (typeof(_tag)!="undefined"){
		return(_tag.dcsMultiTrack());
	}
}

//New dcsMultiTrack function to avoid sending the visitorid for impressions on websearch
//M.Cuyt 2010
function dcsMultiTrackWebSearch(){
	if (typeof(_tag)!="undefined"){
		return(_tag.dcsMultiTrackWebSearch());
	}
}


//New dcsMultiTrack function for measuring impressions with multiple calls to dcsMultiTrack without having to use Firefox fix with pause
//M.Cuyt 2010
function dcsMultiTrackImpressions(){
	if (typeof(_tag)!="undefined"){
		return(_tag.dcsMultiTrackImpressions());
	}
}


function dcsDebug(){
	if (typeof(_tag)!="undefined"){
		return(_tag.dcsDebug());
	}
}

Function.prototype.wt = function(obj){
	var method=this;
	var temp=function(){
		return method.apply(obj,arguments);
	};
	return temp;
}
/**
 * Simple Wrapper class around a Webtrends instance 
 * This is used to simplify the call to the Webtrends event API
 * 
 */

/**
 * Inject a Webtrends instance into the constructor
 * Set the list of value that must be deleted for every request 
 */

function WebtrendsEventDelegator(webtrends, events){
	
	this.webtrends = webtrends;
	this.events = events; 
	this.DCSextToClean = ['linktype','eventtype', 'eventvalue', 'linkplace','linkvalue', 'show_jobId', '_mainreq', 'message_info', 'user_userid', 'user_name'];
	this.LINK_TYPE = 'DCSext.linktype';
	this.EVENT_TYPE = 'DCSext.eventtype';
	this.EVENT_VALUE = 'DCSext.eventvalue';
	this.MAIN_REQ = 'DCSext._mainreq';
	this.LINK_PLACE = 'DCSext.linkplace';
	this.USER_ACTION = 'DCSext.useraction';
	this.LINK_VALUE = 'DCSext.linkvalue';
	this.SHOW_JOBID = 'DCSext.show_jobId';		
	this.MESSAGE_INFO = 'DCSext.message_info';
	this.USER_ID = 'DCSext.user_userid';
	this.USER_NAME = 'DCSext.user_name';
	this.videoData = {};
	this.videoProgression = [0, 0.25, 0.5, 0.75, 0.85, 0.9, 0.95, 1];	
}


/**
 * This is usually triggered from a link click event
 * In this case we must parse the args it contain the event and a maybe link value
 * 
 */
WebtrendsEventDelegator.prototype.clickEvent = function(stringParameters){
	
	parameters = stringParameters.split(',');
	if(parameters.length > 0){
		this.simpleEvent.apply(this, parameters);
	}		
};

/**
 * this the most commonly way to send a event
 * note that the linkvalue parameter is optional 
 * 
 */

WebtrendsEventDelegator.prototype.simpleEvent = function(event, linkvalue){	
	this.dynamicEvent(event, this.LINK_VALUE, linkvalue !== undefined ? linkvalue: '');
};



/**
 * This event is only used when the review is sended
 */
WebtrendsEventDelegator.prototype.reviewEvent= function(eventData, userData){
	
	
	if (eventData && eventData.value.length > 0) 
	{ 
		var eventDataAr = eventData.value.split(",");
		var userDataAr = userData && userData.value.length > 0 ? userData.value.split(',') : ['', ''];
		if(userDataAr.length < 2){
			userDataAr = ['', ''];
		}
		if(eventDataAr.length >= 2){
			if(eventDataAr.length == 2){
				this.dynamicEvent(eventDataAr[0], this.LINK_VALUE, eventDataAr[1], this.USER_ID, userDataAr[0], this.USER_NAME, userDataAr[1]);
			}
			else{
				this.dynamicEvent(eventDataAr[0], this.LINK_VALUE, eventDataAr[1], this.MESSAGE_INFO, eventDataAr[2], this.USER_ID, userDataAr[0], this.USER_NAME, userDataAr[1]);
			}
		}
	} 	
};


/**
 * This event is only used for the coupon this use a custom parameter couponid
 */
WebtrendsEventDelegator.prototype.couponEvent = function(event, linkvalue, couponid){
	this.dynamicEvent(event, this.LINK_VALUE, this.getLastPartOfLink(linkvalue), this.SHOW_JOBID, couponid);
};

/**
 * This is called from the different type of image gallery
 */

WebtrendsEventDelegator.prototype.galleryEvent = function(event, linkvalue) {

	this.simpleEvent(event, this.getLastPartOfLink(linkvalue));     
};

WebtrendsEventDelegator.prototype.getLastPartOfLink = function(linkvalue){
	return linkvalue.substring(linkvalue.lastIndexOf("/") + 1, linkvalue.length);
};


/**
 * Send a Webtrends event with list of parameter represented as a string
 * This is the lowest level method that can be called from the API
 * The first argument should always be the event type
 * all the subsequent are in the form key value pair 
 */
WebtrendsEventDelegator.prototype.dynamicEvent = function(){
	
	if(arguments.length > 0){			
		var event = arguments[0];
		if(this.hasEvent(event)){		
			var parameters = this.getEventData(event);
			for(var i = 1; i < arguments.length; i++){
				parameters.push(arguments[i]);
			}			
			this.cleanUpEventAndSend.apply(this, parameters);					
		}
	}		
};

WebtrendsEventDelegator.prototype.hasEvent = function(event){
	return this.events.hasOwnProperty(event);
};

/**
 * Clean up the not persistent object
 * Send a Webtrends event with predefined parameter to this is used by most of the events  
 */
WebtrendsEventDelegator.prototype.cleanUpEventAndSend = function(){	
	if (this.webtrends.dcsMultiTrack !== "undefined"){
		this.cleanUp();				
		this.webtrends.dcsMultiTrack.apply(this.webtrends, arguments);
	}			
};

/**
 * Clean up the non persistent object in DCSext
 */
WebtrendsEventDelegator.prototype.cleanUp = function(){
	var DCSext  = this.webtrends.DCSext; 
	for (index in this.DCSextToClean){
		prop = this.DCSextToClean[index];  
		if(DCSext.hasOwnProperty(prop)){
			delete DCSext[prop]; 
		}
	}
};

/**
 * Get the webtrends data for this specific event
 * 
 */
WebtrendsEventDelegator.prototype.getEventData = function(event){
	var result = [];	
	result[0] = this.LINK_TYPE;
	result[1] = this.events[event].label;
	result[2] = this.LINK_PLACE;
	result[3] = this.events[event].position;			
	return result;	
};

/**
 * Video tagging
 */

WebtrendsEventDelegator.prototype.sendVideoProgressionEvent = function(videoId, progression){		
	this.cleanUpEventAndSend(this.EVENT_TYPE, "video " + progression + "% watched", this.EVENT_VALUE, this.flvVideoId(videoId), this.MAIN_REQ, 2, this.SHOW_JOBID, videoId);
};

WebtrendsEventDelegator.prototype.sendPlayEvent = function(videoId){		
	this.cleanUpEventAndSend(this.LINK_TYPE, "play video", this.LINK_VALUE, this.flvVideoId(videoId), this.SHOW_JOBID, videoId);
};

WebtrendsEventDelegator.prototype.sendPauseEvent = function(videoId){		
	this.cleanUpEventAndSend(this.LINK_TYPE, "pause video", this.LINK_VALUE, this.flvVideoId(videoId), this.SHOW_JOBID, videoId);
};


WebtrendsEventDelegator.prototype.flvVideoId = function(videoId){
	return videoId + ".flv";
};

WebtrendsEventDelegator.prototype.playTracker = function (obj) 
{  	
	var videoId = obj.id.split("_")[1];
	if(obj.state){
		this.sendPlayEvent(videoId);
	}
	else{
		this.sendPauseEvent(videoId);
	}		
};

WebtrendsEventDelegator.prototype.seekTracker = function (obj) 
{		
	var ids = obj.id.split("_");
	var moduleId = ids[2];	
	var duration = obj.duration;
	var videoData = this.getVideoData(moduleId, duration);
	var videoProgression = videoData.videoProgression; 
	var lastPosition = videoData.lastPosition;
	var position = Math.round(obj.position);
	//we can send an event if we have found a match in videoProgression and the position is superior than the last position
	if(position > lastPosition && videoProgression[position]){   
		this.videoData[moduleId].lastPosition = position;
		var videoId = ids[1];
		this.sendVideoProgressionEvent(videoId, videoProgression[position]);
	}
	else if(position < lastPosition){
		videoData.lastPosition = 0;
	}
};

WebtrendsEventDelegator.prototype.getVideoData  = function (moduleId, duration){	
	if(!this.videoData[moduleId]){
		this.videoData[moduleId] = {};
		this.videoData[moduleId].videoProgression = {};
		this.videoData[moduleId].lastPosition = 0;
		var videoProgression = this.videoData[moduleId].videoProgression;	
		for(var k = 0; k <  this.videoProgression.length; k++){
			videoProgression[Math.floor(duration * this.videoProgression[k])] = Math.floor(this.videoProgression[k] * 100);   
		}
		this.videoData[moduleId].lastPosition = 0;
	}		
	return this.videoData[moduleId];
};

WebtrendsEventDelegator.prototype.JWPlayerReady = function(obj){
	var player = document.getElementById(obj.id);	
    player.addControllerListener("PLAY", "App.webtrendsEventDelegator.playTracker");
    //player.addModelListener("TIME", "App.webtrendsEventDelegator.seekTracker");
};


//<![CDATA[
var TruvoMap;
App.ready( loadOtherLocationsMap );
function loadOtherLocationsMap() {
var oConfig = {
dashboardSize: "Normal", /* size of controls: Normal, Small, and Tiny */
editable: false,
isListing: true, /* is this a listing map? */
// define user defined map styles (write from Java)
//user: null,
// define pins (markers) array or single item is ok (write from Java)
markers: [
{ latLong: [41.4419555664062,-8.29560661315917],
icon: '<div class="bingIcon">1</div>',
listingId: 55400,
isCurrent: true,
title: "<span>SEDE</span><br\/>",
description: '<span>253 423 940<\/span>' },
{ latLong: [41.44799127,-8.29351527],
icon: '<div class="bingIcon">2</div>',
listingId: 55401,
isCurrent: true,
title: "<span>Guimar&atilde;es 2</span><br\/>",
description: '<span>253 419 240<\/span>' },
{ latLong: [41.4408244,-8.29502049],
icon: '<div class="bingIcon">3</div>',
listingId: 55402,
isCurrent: true,
title: "<span>Guimar&atilde;es 3</span><br\/>",
description: '<span>253 416 919<\/span>' },
{ latLong: [41.3650894165039,-8.19950103759765],
icon: '<div class="bingIcon">4</div>',
listingId: 55403,
isCurrent: true,
title: "<span>Felgueiras</span><br\/>",
description: '<span>255 331 301<\/span>' },
{ latLong: [41.5764198303222,-8.27069091796875],
icon: '<div class="bingIcon">5</div>',
listingId: 55404,
isCurrent: true,
title: "<span>P&oacute;voa de Lanhoso</span><br\/>",
description: '<span>253 631 398<\/span>' },
{ latLong: [41.64934024,-8.43559447],
icon: '<div class="bingIcon">6</div>',
listingId: 55405,
isCurrent: true,
title: "<span>Vila Verde</span><br\/>",
description: '<span>253 311 422<\/span>' },
{ latLong: [41.534236,-8.61621713],
icon: '<div class="bingIcon">7</div>',
listingId: 55406,
isCurrent: true,
title: "<span>Barcelos 1</span><br\/>",
description: '<span>253 816 940<\/span>' },
{ latLong: [41.53092052,-8.62061921],
icon: '<div class="bingIcon">8</div>',
listingId: 55407,
isCurrent: true,
title: "<span>Barcelos 2</span><br\/>",
description: '<span>253 811 707<\/span>' },
{ latLong: [41.53163839,-8.6166819],
icon: '<div class="bingIcon">9</div>',
listingId: 55408,
isCurrent: true,
title: "<span>Barcelos 3</span><br\/>",
description: '<span>253 818 403<\/span>' },
{ latLong: [41.5481758117676,-8.42122459411621],
icon: '<div class="bingIcon">10</div>',
listingId: 55409,
isCurrent: true,
title: "<span>Braga 1</span><br\/>",
description: '<span>253 278 048<\/span><br\/>' },
{ latLong: [41.54688196,-8.42035185],
icon: '<div class="bingIcon">11</div>',
listingId: 55410,
isCurrent: true,
title: "<span>Braga 2</span><br\/>",
description: '<span>253 088 590<\/span>' },
{ latLong: [41.23639727,-8.61469198],
icon: '<div class="bingIcon">12</div>',
listingId: 55411,
isCurrent: true,
title: "<span>Maia</span><br\/>",
description: '<span>229 446 760<\/span>' },
{ latLong: [41.15024603,-8.60784704],
icon: '<div class="bingIcon">13</div>',
listingId: 55412,
isCurrent: true,
title: "<span>Porto</span><br\/>",
description: '<span>222 039 394<\/span>' },
{ latLong: [41.00851984,-8.6406096],
icon: '<div class="bingIcon">14</div>',
listingId: 55413,
isCurrent: true,
title: "<span>Espinho</span><br\/>",
description: '<span>227 311 190<\/span>' },
{ latLong: [41.2089233398437,-8.33411884307861],
icon: '<div class="bingIcon">15</div>',
listingId: 55414,
isCurrent: true,
title: "<span>Paredes</span><br\/>",
description: '<span>255 782 812<\/span>' },
{ latLong: [41.34163991,-8.47470292],
icon: '<div class="bingIcon">16</div>',
listingId: 55415,
isCurrent: true,
title: "<span>Santo Tirso</span><br\/>",
description: '<span>252 859 373<\/span>' }
]
};
App.Ui.BingMap.prototype.BING_MAP_KEY = "";
TruvoMap = new App.Ui.BingMap("listingBingMap",oConfig);
}
function showInfo(id) { 
App.webtrendsEventDelegator.simpleEvent("showOnMap");
TruvoMap.showInfo(id);
}
//]]> 

//<![CDATA[ 
var getKeys = function(obj) {
var keys = [];
for(var key in obj){
keys.push(key);
}
return keys;
};
var headingId2fastDocumentVoSet = {"EHR":[{"customerId":"27548621","feedDocId":"PT_2669422_4__16","heading":"EHR|Padarias","itemCode":"SV","location":"Santo Tirso","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4780-554 SANTO TIRSO","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__1","heading":"EHR|Padarias","itemCode":"SV","location":"Azurém","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4800 GUIMARÃES","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__4","heading":"EHR|Padarias","itemCode":"SV","location":"Felgueiras","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4610-124 FELGUEIRAS","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__2","heading":"EHR|Padarias","itemCode":"SV","location":"Azurém","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4800-019 GUIMARÃES","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__14","heading":"EHR|Padarias","itemCode":"SV","location":"Espinho","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4500-257 ESPINHO","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__8","heading":"EHR|Padarias","itemCode":"SV","location":"Barcelos","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4750-265 BARCELOS","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__15","heading":"EHR|Padarias","itemCode":"SV","location":"Paredes","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4580-135 PAREDES","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__10","heading":"EHR|Padarias","itemCode":"SV","location":"Braga","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4710-251 BRAGA","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__5","heading":"EHR|Padarias","itemCode":"SV","location":"Póvoa de Lanhoso-Nossa Senhora do Amparo","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4830-517 PÓVOA DE LANHOSO","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__12","heading":"EHR|Padarias","itemCode":"SV","location":"Maia","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4470-334 MAIA","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__9","heading":"EHR|Padarias","itemCode":"SV","location":"Barcelos","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4750-333 BARCELOS","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__7","heading":"EHR|Padarias","itemCode":"SV","location":"Barcelos","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4750-279 BARCELOS","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__13","heading":"EHR|Padarias","itemCode":"SV","location":"Porto","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4000-219 PORTO","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__11","heading":"EHR|Padarias","itemCode":"SV","location":"Braga","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4710-250 BRAGA","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__3","heading":"EHR|Padarias","itemCode":"SV","location":"Guimarães","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4810-452 GUIMARÃES","productId":"S"},{"customerId":"27548621","feedDocId":"PT_2669422_4__6","heading":"EHR|Padarias","itemCode":"SV","location":"Vila Verde","name":"Padarias e Pastelarias Cristo Rei","postalCode":"4730-728 VILA VERDE","productId":"S"}]};
var headingIds = getKeys(headingId2fastDocumentVoSet);
var headingId = headingIds[Math.floor(Math.random() * headingIds.length)];
var fastDocuments = headingId2fastDocumentVoSet[headingId];
var fastDocument = fastDocuments[Math.floor(Math.random() * fastDocuments.length)]; 
var _tag = new WebTrends();
_tag.dcsid='dcsx4mkob10000cprbzf8uf1r_7c4n';
_tag.domain='statse.webtrendslive.com';
_tag.fpcdom='.cristorei.pai.pt';
_tag.dcsGetId(); 
//]]>

//<![CDATA[
_tag.DCSext.show_heading = fastDocument.heading;
_tag.DCSext.show_itemCode = fastDocument.itemCode;
_tag.DCSext.show_listingId = fastDocument.feedDocId; 
_tag.DCSext.show_location = fastDocument.location;
_tag.DCSext.show_name = fastDocument.name;
_tag.DCSext.show_postalcode = fastDocument.postalCode;
_tag.DCSext.show_productId = fastDocument.productId;
_tag.DCSext.show_subscriberId = fastDocument.customerId;
_tag.DCSext.show_mysiteID = '90047076';
_tag.DCSext.site_language = 'pt_PT';
_tag.DCSext.site_type = 'YELLOW';
_tag.DCSext.page = 'MySite|Other locations';
_tag.DCSext.pagename = 'Other locations'; 
App.webtrendsEventDelegator = new WebtrendsEventDelegator(_tag, {"send2Friend":{"label":"email page","position":"top","useraction":"user action"},"contactUsA":{"label":"email address","position":"top right","useraction":"potential contact"},"printCoupon":{"label":"print coupon","position":"","useraction":"user action"},"selectPhoto":{"label":"select photo","position":"viewer","useraction":"user action"},"reviewSuccess":{"label":"review form send","position":"review","useraction":"user action"},"mailToCompanyB":{"label":"email address","position":"bottom","useraction":"potential contact"},"viewCompanySiteMap":{"label":"website","position":"flyout","useraction":"user action"},"freeCallA":{"label":"free call","position":"top","useraction":"potential contact"},"showOnMap":{"label":"show on map","position":"","useraction":"user action"},"viewBanner":{"label":"banner","position":"","useraction":"user action"},"mail2CompanySuccess":{"label":"email form send","position":"","useraction":"lead"},"freeCallB":{"label":"free call","position":"bottom","useraction":"potential contact"},"send2FriendSuccess":{"label":"friend form send","position":"","useraction":"user action"},"viewCompanySiteB":{"label":"website","position":"bottom","useraction":"potential contact"},"contactUsB":{"label":"email address","position":"bottom right","useraction":"potential contact"},"reviewLocations":{"label":"show all locations","position":"review","useraction":"user action"},"freeTextLink":{"label":"free text link","position":"","useraction":"user action"},"viewCompanySiteA":{"label":"website","position":"top","useraction":"potential contact"},"reviewAll":{"label":"show all reviews","position":"review","useraction":"user action"},"viewCoupon":{"label":"browse coupon","position":"","useraction":"user action"},"reviewAbuse":{"label":"report abuse","position":"review","useraction":"user action"},"viewDocument":{"label":"document","position":"link","useraction":"user action"},"share":{"label":"share","position":"top","useraction":"user action"},"mail2CompanyError":{"label":"email form send errors","position":"","useraction":"user action"},"add2TomTom":{"label":"add to tom tom","position":"top","useraction":"user action"},"reviewError":{"label":"review form send errors","position":"review","useraction":"user action"},"enlargeCarousel":{"label":"enlarge photo","position":"carousel","useraction":"user action"},"browsePhoto":{"label":"browse photo","position":"viewer popup","useraction":"user action"},"enlargePhoto":{"label":"enlarge photo","position":"viewer","useraction":"user action"},"viewDocumentThumbnail":{"label":"document","position":"thumbnail","useraction":"user action"},"mailToCompanyA":{"label":"email address","position":"top","useraction":"potential contact"},"reviewAbuseSend":{"label":"abuse form send","position":"review","useraction":"user action"},"reviewMore":{"label":"show more review","position":"review","useraction":"user action"},"showOnMapA":{"label":"view map","position":"right","useraction":"user action"},"send2FriendError":{"label":"friend form send errors","position":"","useraction":"user action"},"reviewTop":{"label":"add review","position":"review top","useraction":"user action"},"bookIt":{"label":"book it","position":"","useraction":"potential contact"},"reviewBottom":{"label":"add review","position":"review bottom","useraction":"user action"},"review":{"label":"add review","position":"top","useraction":"user action"},"send2Outlook":{"label":"add to outlook","position":"top","useraction":"user action"}}); 
_tag.dcsCollectPage(); 
//]]> 
