function gEI(i){return document.getElementById(i)}
function gPC(el,name){while(el !=null && el.parentNode != null && !CN(el,name)){el=el.parentNode;}if(el !=null && el.parentNode != null)return el;else return false;}
function gEC(el,class_name,tag_name){var all_obj,ret_obj=new Array(),j=0;if(tag_name==null||tag_name=="")tag_name="div";all_obj=el.getElementsByTagName(tag_name);for(i=0;i<all_obj.length;i++){  if(CN(all_obj[i],class_name)){   ret_obj[j]=all_obj[i];   j++;}}if(ret_obj.length>0)return ret_obj; else return false;}
function CN(el,name){var i,list;if(el.className){list=el.className.split(" ");for(i=0;i<list.length;i++)if(list[i]==name)return true}return false}
function rCN(el,name,c){var i,j,curList,newList;if(el.className=="")return;newList=new Array();curList=el.className.split(" ");j=0;for(i=0; i < curList.length;i++)if(curList[i]!=name)newList[i-j]=curList[i];else j++;if(c!=1)el.className=newList.join(" ");else return newList.join(" ")}
function aCN(el,name){if((el.className=="")||(el.className==" "))el.className=name;else el.className += " "+name}
function gP(el){if(el.offsetParent){var x=0;var y=0;while(el){x += el.offsetLeft;y += el.offsetTop;el=el.offsetParent}return [x,y]}else return [el.x, el.y]}
function addCSSRule(selector,style){var css=selector+'{'+style+'}';document.write('<style type="text/css">'+css+'</style>');}
function aV(el, type, fce){if(el.addEventListener){el.addEventListener(type, fce, false);return true;}else if(el.attachEvent){var r=el.attachEvent('on'+type, fce);return r;}else return false;}
function rV(el, type, fce) {if (el.removeEventListener){el.removeEventListener(type, fce, false);return true;}else if(el.detachEvent){var r = el.detachEvent('on'+type, fce);return r;}else return false;}
function gE(e){return(window.event && window.event.srcElement)?window.event.srcElement:(e && e.target)?e.target:false}
function gM(e){var e=e||window.event;var d=(document.documentElement&&document.documentElement.scrollTop!=null)?document.documentElement:document.body;return {x:(e.pageX||e.clientX+d.scrollLeft),y:(e.pageY||e.clientY+d.scrollTop)}}
function gS(o,prop){if(self.getComputedStyle)return eval('self.getComputedStyle(o,null).'+prop);if(o.currentStyle)return eval('o.currentStyle.'+prop)}
function gW() {if (window.innerWidth) return {'x':window.innerWidth-20,'y':window.innerHeight-15};else if (document.documentElement.clientHeight) {return {'x':document.documentElement.clientWidth,'y':document.documentElement.clientHeight};}else if (document.body.clientWidth) {return {'x':document.body.clientWidth,'y':document.body.clientHeight}}}
function gSr(){var t=(document.documentElement.scrollTop)?document.documentElement.scrollTop:document.body.scrollTop;var l=(document.documentElement.scrollLeft)?document.documentElement.scrollLeft:document.body.scrollLeft;return {'x':l,'y':t}}

function Flash(){this.movie="";this.img="";this.width="";this.height="";this.alt="";this.bgcolor="transparent";this.ver=7;this.link="";this.tracker="";this.ie=((navigator.userAgent.toLowerCase().indexOf("opera")==-1)&&navigator.appName=="Microsoft Internet Explorer")?true:false;this.className="";this.id="";this.urlparam="url";this.target="_blank";this.install=false;this.flashvars=null}
Flash.prototype.iF=function(i){if(!this.ie)return true;try{var a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);return true}catch(e){return false}}
Flash.prototype.write=function(m,w,h,a,b){var o=this.HTML(m,w,h,a,b);document.write(o)}
Flash.prototype.param=function(n,v){return '<param name="'+n+'" value="'+v+'" />';}
Flash.prototype.writeBanner=function(i,w,h,l,t,b){this.preBanner(i,null,w,h,l,t,b);var lnk=(this.link==null||this.link=="")?false:true;this.movie=this.img.slice(0,this.img.lastIndexOf('.'))+".swf"+((lnk)?"?"+this.urlparam+"="+escape(this.link):"");this.write();}
Flash.prototype.writeBannerAlt=function(i,m,w,h,l,t,b){this.preBanner(i,m,w,h,l,t,b);var lnk=(this.link==null||this.link=="")?false:true;if(m!=null&&m!='')this.movie=m+((lnk)?"?"+this.urlparam+"="+escape(this.link):"");this.write();}
Flash.prototype.preBanner=function(i,m,w,h,l,t,b){if(i!=null&&i!="")this.img=i;if(l!=null&&l!="")this.link=l;if(t!=null&&t!="")this.tracker=t;if(w!=null&&w!="")this.width=w;if(h!=null&&h!="")this.height=h;if(b!=null&&b!="")this.bgcolor=b;var lnk=(this.link==null||this.link=="")?false:true;if(lnk&&(this.tracker!=null&&this.tracker!=""))this.link=this.tracker+escape(this.link);var a='<img src="'+this.img+'" width="'+this.width+'" height="'+this.height+'" alt="" border="0" class="'+this.className+'" />';this.alt=((!lnk)?a:'<a href="'+this.link+'" target="'+this.target+'">'+a+'</a>');}
Flash.prototype.HTML=function(m,w,h,a,b){if(m!=null&&m!="")this.movie=m;if(w!=null&&w!="")this.width=w;if(h!=null&&h!="")this.height=h;if(a!=null&&a!="")this.alt=a;if(b!=null&&b!="")this.bgcolor=b;var ci=(this.ie)?' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"':'';var p=(this.ie&&this.install)?' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.ver+',0,0,0"':'';var o;var z=this.iF(this.ver);var z1=this.iF(1);if (this.movie!=null&&this.movie!=""&&(this.install||(z1&&z)||(!z1&&!z)))o='<object type="application/x-shockwave-flash" data="'+this.movie+'" width="'+this.width+'" height="'+this.height+'"'+ci+p+' id="'+this.id+'" class="'+this.className+'" >'+this.param("movie",this.movie)+((this.flashvars!=null)?this.param("flashvars",this.flashvars):"")+this.param("quality","high")+this.param("menu","false")+((this.bgcolor=="transparent")?this.param("wmode","transparent"):this.param("bgcolor",this.bgcolor))+this.alt+'</object>';else o=this.alt;return o}
Flash.prototype.writeTo=function(id,m,w,h,a,b){var el=document.getElementById(id);if(el)el.innerHTML=this.HTML(m,w,h,a,b)}

function language_init(id,text){
  var el=document.getElementById(id);
  var act=null;
  var close=null;
  if(el){var a=el.getElementsByTagName('a');
  for(var i=0;a[i];i++)
  if(a[i].className.search(/select-active/)!=-1){act=a[i].cloneNode(a[i]);break}
  if(act==null)act=a[0].cloneNode(a[0]);act.onclick=function(){this.blur();return false};
  var d1=document.createElement("div");var d2=document.createElement("strong");
  d1.appendChild(d2);d1.id=el.id;el.id="";el.parentNode.insertBefore(d1,el);d2.appendChild(act);if(text&&text!="")
  {var d3=document.createElement("span");d3.className="text";d3.appendChild(document.createTextNode(text));act.appendChild(d3);}d1.appendChild(el);d1.className='select hide-menu';el.className="select-menu";var fce=function(){d1.className='select hide-menu';};var fceclose=function(){close=setTimeout(fce,400)};var fcestop=function(){clearTimeout(close)};d2.onclick=function(){d1.className='select';fcestop();};d2.onmouseout=fceclose;d2.onmouseover=fcestop;el.onmouseout=fceclose;el.onmouseover=fcestop;var mw=0;el.style.display='block';for(var i=0;a[i];i++){if(mw<a[i].offsetWidth)mw=a[i].offsetWidth;};el.style.width=mw+'px';el.style.display='';}}

function Open(id,scroll){if(scroll==null)scroll=true;var a=gEI(id);var b='open';if(a){if(CN(a,b))rCN(a,b);else aCN(a,b);if(scroll)a.scrollIntoView(true);}return false;}
function ShowMore(el,id,txtmore,txtone){var a=gEI(id);var b='open';if(a){var d=CN(a,b);var c={'false':txtmore,'true':txtone};el.innerHTML=el.innerHTML.replace(new RegExp(c[d]),c[!d]);Open(id,false);}return false;}

function showBubble(e,el,txt){
	tooltips.hide();
	var mousePosition=gM(e);
	el.tooltip=txt;
	aV(el,'mouseout',tooltips.hide);
	tooltips.show(el,mousePosition);
}

var tooltips={
className:'tooltip',
showDelay:100,
animateInterval:30,
border:'1px solid #000000',
fontSize:'0.9em',
backgroundColor:'#fefee2',
shadowColor:'black',
bubbleClassName:'tooltipBubble',
textColor:'#000000',
padding:'5px 10px 5px 10px',
maxWidth:300,
isTop:true,
timer:null,amimateTimer:null,lastTooltip:null,
init:function(){var a=gEC(document,tooltips.className,'*');for(var i=0;a[i];i++){if(a[i].title!=''){aV(a[i],'mouseover',tooltips.delayShow);aV(a[i],'mousemove',tooltips.delayShow);aV(a[i],'mouseout',tooltips.hide);a[i].tooltip=a[i].title;a[i].title='';}}},
delayShow:function(e){if(tooltips.lastTooltip!=null)return true;var el=gPC(gE(e),tooltips.className);var mousePosition=gM(e);tooltips.clearTimer();var f=function(){tooltips.show(el,mousePosition)};tooltips.timer=window.setTimeout(f,tooltips.showDelay);},
clearTimer:function(){if(tooltips.timer!=null){window.clearTimeout(tooltips.timer);tooltips.timer=null;}},
show:function(el,mousePosition){var a=document.createElement('div');var b=document.createElement('div');var t=document.createTextNode(el.tooltip);a.appendChild(b);b.appendChild(t);document.body.appendChild(a);tooltips.lastTooltip=a;a.style.cssText='min-height:1px;_height:1px;position:absolute';b.style.cssText='';a.style.opacity='0';a.style.filter='alpha(opacity=0)';b.className=tooltips.bubbleClassName;b.style.border=''+tooltips.border;b.style.backgroundColor=tooltips.backgroundColor;b.style.color=tooltips.textColor;b.style.padding=tooltips.padding;b.style.fontSize=tooltips.fontSize;b.style.lineHeighte="1.2em";b.style.zIndex='2';a.style.zIndex=2000;a.style.paddingTop='6px';a.style.paddingBottom='6px';a.style.paddingRight='2px';a.style.left='0px';var width=a.offsetWidth;a.style.left=mousePosition.x-20+'px';a.style.top=mousePosition.y+24+"px";a.style.width=((width>tooltips.maxWidth)?tooltips.maxWidth:width)+'px';var wind=gW();var scroll=gSr();var size={x:a.offsetWidth,y:a.offsetHeight};var position={x:a.offsetLeft,y:a.offsetTop};tooltips.isTop=(position.y+size.y-scroll.y<wind.y);var dart=document.createElement('div');dart.style.cssText='position:absolute;margin-left:15px;z-index:3';dart.style.opacity='1';dart.style.filter='alpha(opacity=100)';for(var i=6,j=0;i>-1;i--,j++){var line=document.createElement('div');line.style.cssText='positon:absolute;overflow:hidden;height:1px;width:'+((tooltips.isTop?j:i)*2)+'px;margin-left:'+(tooltips.isTop?i:j)+'px;top:'+6+'px;border-left:'+tooltips.border+';border-right:'+tooltips.border+';background:'+tooltips.backgroundColor;dart.appendChild(line);}a.appendChild(dart);if(size.x+position.x-scroll.x>wind.x){var div=(size.x+position.x-scroll.x)-wind.x;a.style.left=position.x-div+"px";dart.style.left=((35+div<size.x)?div-5:size.x-35)+"px";}if(tooltips.isTop){dart.style.top="0px";}else{a.style.top=mousePosition.y-a.offsetHeight-10+'px';dart.style.top=a.offsetHeight-7+'px';}tooltips.animate();a.appendChild(tooltips.shadow(1,b.offsetHeight-1,8,b.offsetWidth,0.3));a.appendChild(tooltips.shadow(b.offsetWidth-1,1,b.offsetHeight+6,1,0.3));a.appendChild(tooltips.shadow(1,b.offsetHeight-1,9,b.offsetWidth+1,0.1));a.appendChild(tooltips.shadow(b.offsetWidth-1,1,b.offsetHeight+7,2,0.1));},
animate:function(){var f=function(){var a=tooltips.lastTooltip;if(a==null){tooltips.clearAnimateTimer();return true;}var b=parseFloat(gS(a,'opacity'));if(b<1){b=b+0.1;a.style.opacity=b;a.style.filter='alpha(opacity='+(b*100)+')';}else tooltips.clearAnimateTimer();};tooltips.animateTimer=window.setInterval(f,tooltips.animateInterval);},
shadow:function(width,height,top,left,opacity){var a=document.createElement('div');a.style.cssText='position:absolute;overflow:hidden;top:'+top+'px;left:'+left+'px;z-index:1;width:'+width+'px;height:'+height+'px';a.style.opacity=opacity;a.style.background=tooltips.shadowColor;a.style.filter='alpha(opacity='+(opacity*100)+')';return a;},
clearAnimateTimer:function(){if(tooltips.animateTimer!=null){window.clearInterval(tooltips.animateTimer);tooltips.animateTimer=null;}},
hide:function(){tooltips.clearTimer();if(tooltips.lastTooltip!=null){document.body.removeChild(tooltips.lastTooltip);tooltips.lastTooltip=null;}}
}
aV(window,'load',tooltips.init);

var CTBR_Events={
	IsIE:(navigator.userAgent.toLowerCase().indexOf("windows")!=-1&&navigator.userAgent.toLowerCase().indexOf("opera")==-1&&navigator.appName=="Microsoft Internet Explorer")?true:false,
	IsFF:(navigator.userAgent.toLowerCase().indexOf("windows")!=-1&&navigator.userAgent.toLowerCase().indexOf("firefox")!=-1&&"createEvent" in document)?true:false,
	IsToolbarInstalled:false,
	IsToolbarInstallAble:false,
	/*
	Init, need to be run while page is rendering
	*/
	Init:function(){
		if(this.IsIE){
			document.write("<" + "OBJECT classid='clsid:8736C681-37A0-40C6-A0F0-4C083409151C' ID=tbr width=0 height=0></OBJECT>")
		}
		this.IsToolbarInstalled=this._IsToolbarInstalled();
		this.IsToolbarInstallAble=(this.IsIE||this.IsFF);
	},
	/*
	main comunication function
		Argument 0:    tbr object method name
		Arguments 1-N: method arguments
	
	*/
	Get:function(){
		if(!this.IsToolbarInstalled)return null;
		if(this.IsIE){
			var a=[];
			for(var i=1;i<arguments.length;i++){a.push("'"+arguments[i]+"'")};
			return eval("tbr."+arguments[0]+"("+a.join(",")+")");
		}
		else if(this.IsFF){
			var el=document.createElement("CTBR_Get");
			for(var i=0;i<arguments.length;i++)
				el.setAttribute("Attribute"+i,arguments[i]);
			document.documentElement.appendChild(el);
			var evt = document.createEvent("Events");
			evt.initEvent("CTBR_Get", true, false);
			el.dispatchEvent(evt);
			return el.getAttribute("return");
		}
		else return null;
	},
	/*
	check if plugin is installed
	*/
	IsPluginInstalled:function(plugin){
		return (CTBR_Events.IsToolbarInstalled && this.Get("PluginState",plugin)==0);
	},
	/*
	internal function
	*/
	_IsToolbarInstalled: function(){
		this.IsToolbarInstalled=true;
		if(this.IsIE){
			this.IsToolbarInstalled=(typeof(tbr.GetDllVer)!=='undefined'&&tbr.GetFileVer("APP") != '0.0.0.0');
		}
		else if(this.IsFF){
			this.IsToolbarInstalled=(!(this.Get('GetFileVer','APP')==null));
		}
		else this.IsToolbarInstalled=false;
		return this.IsToolbarInstalled;
	}
};
CTBR_Events.Init();



var Texts=[];

function opted_init(url,server_color){

	if(CTBR_Events.IsPluginInstalled("STWSG")&&CTBR_Events.Get("GetText","STWSG","GETDETAILSSUPPORTED","")=="1"){
		hidePreventInfectionButton();

		var user_do_rating=CTBR_Events.Get("GetText","STWSG","GETUSERDORATING",url);
		if(user_do_rating=="1"){
			var local=CTBR_Events.Get("GetText","STWSG","GETDOMAININFO",url);

			if(local!=""&&local!="0"){
				var color_names=['gray','green','orange','red'];
				var head=gEI('website-head');
				head.className="class-"+color_names[local]+"-user";
				var p=gEI('website-head-text');
				p.innerHTML=Texts["WEBSITE_CLASSIFICATION_"+local];
			}
		}
			
		var blocked=CTBR_Events.Get("GetText","STWSG","GETDOMAINBLOCKED",url);
		
		/* alert("User do raiting: "+user_do_rating+"\nLocal info: "+local+"\nServer info: "+server_color+"\nBlocked: "+blocked); */
		gEI("opted_to_block").style.display="none";
		gEI("opted_to_nowarn").style.display="none";
		gEI("website-head-link").style.display="inline";

		if(blocked=="1"){
			/*is blocked*/
			gEI("opted_to_block").style.display="block";
			gEI("website-head-link").style.display="none";
		}
		else if(blocked=="0"){
			/* is warning disabled */
			gEI("opted_to_nowarn").style.display="block";
		}
	} else {
		if(server_color == 0 || server_color == 1) hidePreventInfectionButton()
	}
}

function hidePreventInfectionButton(){
	var a=gEI("preventInfectionButton");
	if(a)a.style.display='none';
}


function undisable(e,el,url){
	var a=CTBR_Events.Get("GetText","STWSG","DELETEDOMAININFO",url);
	if(a=="1"){
		alert(Texts["DOMAIN_INFO_DELETED"]);
		gEI("opted_to_block").style.display="none";
		gEI("opted_to_nowarn").style.display="none";
		gEI("website-head-link").style.display="inline";
	}
	return false;
}

var is_rated_dialog_open=false;

function doRating(e,el,url,onSuccess){
	if(is_rated_dialog_open==true)return false;

	if(CTBR_Events.IsPluginInstalled("STWSG")){
		if(CTBR_Events.Get("GetText","STWSG","GETDETAILSSUPPORTED","")=="1"){
			var handle=CTBR_Events.Get("GetText","STWSG","SHOWRATEDIALOG",url);
			var ratelinks=gEC(document,"rate","a");
			if(ratelinks)for(var i=0;i<ratelinks.length;i++)aCN(ratelinks[i],'rate-disabled');
			is_rated_dialog_open=true;
			var timer=null;
			var fce=function(){
				var a=CTBR_Events.Get("GetText","STWSG","GETRATEWINDOWINFO",handle);
				if(a==1){
					clearInterval(timer);
					if(typeof(onSuccess)=="function")onSuccess(url);
					if(ratelinks)for(var i=0;i<ratelinks.length;i++)rCN(ratelinks[i],'rate-disabled');					
					is_rated_dialog_open=false;
				}
			}
			timer=setInterval(fce,2000);
		}
		else showBubble(e,el,Texts["NOT_SUPPORTED"]);
	}
	else{
		if(CTBR_Events.IsFF){
			/*can be old FF version, with no ability to detect toolbar */
			showBubble(e,el,Texts["FF_NOTICE"]);
		}
		else{
			showBubble(e,el,Texts[(CTBR_Events.IsToolbarInstallAble)?"NOT_INSTALLED":"NOT_INSTALLABLE"]);
		}
	}
	return false;
}


function rate_website(e,el,url){
	doRating(e,el,url,opted_init);
}
