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 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)}

window.onresize=function(){if(gEI('main')){gEI('main').style.display='none';gEI('main').style.display='block'}}

var IE=((navigator.userAgent.toLowerCase().indexOf("opera")==-1)&&navigator.appName=="Microsoft Internet Explorer")?true:false;
if (IE){s=navigator.appVersion;a = s.indexOf("MSIE");b = s.indexOf(";",a);var IEversion = parseFloat(s.substring(a+4,b))}
function pIE(ul) {if (IE) {if (IEversion >= 5.5) {var iframe=document.createElement("iframe");iframe.src="javascript:false";iframe.frameBorder="0";iframe.className = "ie-iframe";iframe.style.width=ul.offsetWidth+"px";iframe.style.height=ul.offsetHeight+"px";iframe.style.left=ul.offsetLeft+"px";iframe.style.top=ul.offsetTop+"px";ul.parentNode.insertBefore(iframe,ul);iframe.tabIndex=-1}else {windowed_element_visibility("SELECT",-1,ul);windowed_element_visibility("OBJECT",-1,ul);}}}
function rIE(ul) {var iframe;if (IE) {if (IEversion >= 5.5) {iframe = ul.parentNode.getElementsByTagName("iframe");if (iframe.length>0) iframe[0].parentNode.removeChild(iframe[0]);}else {windowed_element_visibility("SELECT",+1,ul);windowed_element_visibility("OBJECT",+1,ul);}}}
function windowed_element_visibility(tagName, change, menu) {if (document.all) {var els = document.getElementsByTagName(tagName);var i;var rect = new el_rect(menu);var elsLength = els.length;for (i=0; i < elsLength; i++){var el = els.item(i);if (el_overlap(el, rect)){if (el.visLevel)el.visLevel += change;else el.visLevel = change;if (el.visLevel == -1 && change == -1){el.visibilitySave = el.style.visibility;el.style.visibility = "hidden";}else if (el.visLevel == 0 && change == +1){el.style.visibility = el.visibilitySave;}}}}}
function el_rect(el) {var left = 0;var top = 0;this.width = el.offsetWidth;this.height = el.offsetHeight;while (el){left += el.offsetLeft;top += el.offsetTop;el = el.offsetParent;}this.left = left;this.top = top;}
function el_overlap(el, rect) {var r = new el_rect(el);return ((r.left < rect.left + rect.width) && (r.left + r.width > rect.left) && (r.top < rect.top + rect.height) && (r.top + r.height > rect.top));}


function Flash(){this.movie="";this.img="";this.width="";this.height="";this.alt="";this.bgcolor="transparent";this.ver=6;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 fixMouseOut(el){
	if(document.all)el.style.display='none';el.style.display='block'
}

function downloadAndGo2(el,url){
	var downloadwin=window.open(url,'down','width=1,height=1,top=4000,left=0');
	var fce2=function(){try{downloadwin.window.close()}catch(e){}}
	setTimeout(fce2,500);
	var fce=function(){location.href=el.href}
	setTimeout(fce,1000);
	return false;
}


function downloadAndGo(el,url){
	var fce=function(){location.href=url}
	setTimeout(fce,1000);
	return true;
}

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){
	var a=gEI(id);
	var b='open';
	if(a){
		var d=CN(a,b);
		var c={'false':'Show','true':'Hide'};
		el.innerHTML=el.innerHTML.replace(new RegExp(c[d]),c[!d]);
		Open(id,false);
	}
	return false;
}

function frm_CAHelp(){
		var a=gEC(document,'FRM_hint',"div");
		for(var i=0;a[i];i++){
			rCN(a[i],FRM_open);
			rIE(a[i])
		}
}

function openWin(el){
	window.open(el.href,el.target,'width=800,height=600,toolbar=0,resizable=1');
	return false;
}

var tooltips={
	className:'tooltip',
	showDelay:200,
	timer:null,
	amimateTimer:null,
	lastTooltip:null,
	border:'1px solid #42433f',
  backgroundColor:'#fcf88e',
  bubbleClassName:'tooltipBubble',
	textColor:'#42433f',
	padding:'4px 10px 4px 30px',
	maxWidth:400,
	
	init:function(){
		var a=gEC(document,tooltips.className,'*');
		for(var i=0;a[i];i++){
			if(a[i].title!=''){
				//a[i].onmouseover=function(){tooltips.show(this)};
				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){
		//alert(el.tooltip+' '+mousePosition.x+','+mousePosition.y);
		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.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;
		var dart=document.createElement('div');
		dart.style.cssText='position:absolute;margin-left:20px';
		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:'+(i*2)+'px;margin-left:'+j+'px;top:'+j+'px;border-left:'+tooltips.border+';border-right:'+tooltips.border+';background:'+tooltips.backgroundColor;
			dart.appendChild(line);
		}
		a.appendChild(dart);
		a.style.position='absolute';
		a.style.zIndex=100;
		a.style.paddingBottom='6px';
		a.style.left=mousePosition.x-25+'px';
		if(a.offsetWidth>tooltips.maxWidth)a.style.width=tooltips.maxWidth+'px';

		a.style.top=mousePosition.y-a.offsetHeight-10+'px';
		dart.style.top=a.offsetHeight-7+'px';
		tooltips.animate();
	},
	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,50);
	},
	clearAnimateTimer:function(){
		if(tooltips.animateTimer!=null){
			window.clearInterval(tooltips.animateTimer);
			tooltips.animateTimer=null;
		}
	},
	hide:function(){
		tooltips.clearTimer();
		//tooltips.clearAnimateTimer();
		if(tooltips.lastTooltip!=null){
			document.body.removeChild(tooltips.lastTooltip);
			tooltips.lastTooltip=null;
		}
	}

}

aV(window,'load',tooltips.init);

function fix_eolas(id){
	if(IE){
		var o=document.getElementById(id);
		if(o)o.outerHTML = o.outerHTML;
	}
}

function smiley_view_preinit(){
	document.write('<style type="text/css">.loading #smiley-view-smiley-container{visibility:hidden}</style>');
}


function smiley_view_init(){
	fix_eolas('view-smiley-flash');

	var check=function(){
		var image=document.getElementById('smiley-view-smiley');
		var container=document.getElementById('smiley-view-smiley-container');
		if(image.offsetHeight>64||image.offsetWidth>215){
		container.className="big";
		}
		document.getElementById('smiley-view').className="";
	}
	setTimeout(check,1000);
}



$(function(){
	var dd=$.dDialog({
		apppath:'/',
		html:'<div class="ddialog"><div class="ddialog-title"><strong>How to install Crawler Smileys.</strong><br />Please follow these instructions:</div><div class="ddialog-step ddialog-step1"><strong>Click the &ldquo;%BUTTON%&rdquo; button</strong></div><div class="ddialog-dialog"><p><img src="%IMAGE%" /></p><p><strong>Important:</strong> The download may take a few minutes depending on your Internet connection speed. <strong>Please be patient.</strong></p><p>Did you accidentally close the %BUTTON% dialog?<br /><a href="%LINK%">Resume Your Download</a></p></div><div class="ddialog-step ddialog-step2"><strong>Follow the instructions</strong>in the wizard to install the Crawler Smileys.</div><div class="ddialog-step ddialog-step3"><strong>Send Smileys</strong> and view them directly in your IM.</div></div>'
	});

	$('a[href$=.exe]').click(function(){
		dd.open(this.href);
	});


});