function $(el){
	try{return document.getElementById(el);}
	catch(e){return {};}
}
Object.extend = function(destination, source) {
  for (var property in source)
		destination[property] = source[property];
  return destination;
};
var Event = {
	observe:function(el,evt,lambda){
		if (el.addEventListener) el.addEventListener(evt, lambda, false);
		else el.attachEvent("on" + evt, lambda);
	},
	element:function(e){
		e=e||window.event;
		return e.target||e.srcElement;
	}
};
Object.extend(Function.prototype,{
	bind:function(scope){
		var __method = this;
		return function(){return __method.apply(scope);}
	}
});
Object.extend(Array.prototype,{
	find:function(value){
		for(i in this) if(this[i]==value) return i;
		return false;
	},
	last:function(){
		return this[this.length-1];
	}
});
function Check(form,checkers,postchecks,onError){
	this.form=form;
	this.checkers=checkers||{};
	this.postchecks=postchecks||[];
	this.onError=onError||this.onError;
}
Object.extend(Check.prototype,{
	validate:function(){
		var _t=true;
		for(var i in this.checkers){
			var el=this.form[i];
			var _a=$(this.checkers[i].error||i+'_error');
			if(!this.checkers[i].check(el)){
				if(_t) el.focus();
				this.onError(el);
				_t=false;
				_a.style.display='inline';
				continue;
			}
			_a.style.display='none';
		}
		for(i=0;i<this.postchecks.length;i++)
			_t=(_t && this.postchecks[i](this));
		if(_t) this.form.submit();
	},
	onError:function(el){}
});
function Checker(regexp,needed,error,lambda){
	this.regexp=regexp;
	this.needed=needed;
	this.error=error||null;
	this.lambda=lambda||false;
}
Object.extend(Checker.prototype,{
	check:function(el){
		if(this.regexp){
			var _t=true;
			var v=el.value;
			if(this.needed || (!this.needed && v.length>0))
				_t=this.regexp.test(v);
			if(_t && this.lambda) _t=this.lambda(el);
			return _t;
		}
		return true;
	}
});

function GetWidth(){
	var width = 1024;
	if (document.documentElement && document.documentElement.clientWidth)
		width = document.documentElement.clientWidth;
	else if (document.body.clientWidth)
		width = document.body.clientWidth;
	else if (self.innerWidth)
		width = self.innerWidth;
	return width;
}

function GetHeight(){
	var height = 768;
	if (self.innerHeight)
		height = self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		height = document.documentElement.clientHeight;
	else if (document.body.clientHeight)
		height = document.body.clientHeight;
	return height;
}

function Ajax(){
	var _transport = null;
	var that = this;
	var _states = ['Uninitialize','Loading','Loaded','Interactive',['Failure','Success']];
	try{_transport=new XMLHttpRequest();}catch(e){try{_transport = new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{_transport = new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
	this.stateChange=function(){
		var r =_transport.readyState;
		var evt=_states[r];
		if(r==4)var evt=evt[_transport.status==200?1:0];
		that.Options['on'+evt](_transport);
	};
	if(_transport!=null) _transport.onreadystatechange=this.stateChange;
	
	this.transport=_transport;
	this._request=function(uri,options){
		if(this.transport==null) return;
		for(var i in options) this.Options[i]=options[i];
		this.transport.open(this.Options.method, uri, this.Options.asynchronous);
		this.transport.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		this.transport.setRequestHeader("Referer", document.location.href);
		this.transport.setRequestHeader("X-Requested-With", 'EmailClick Ajax Service');
		this.send(this.Options.postBody||null);
		if (!this.Options.asynchronous && this.transport.overrideMimeType) this.stateChange();
	};
}
Ajax.prototype={       
	Options:{
		onUninitialize:function(){},
		onLoading:function(){},
		onLoaded:function(){},
		onInteractive:function(){},
		onSuccess:function(){},
		onFailure:function(){},
		method:'post',
		postBody:null,
		asynchronous:true,
		valorize:function(n,v){Ajax.prototype[n]=v;}
	},
    request:function(uri,options){
		this._request(uri,options);
	},
	update:function(uri,el,options){
		var success=options.onSuccess||function(){};
		options.onSuccess=function(t){
			el.innerHTML=t.responseText;
			success(t);
		};
		this._request(uri,options);
	},
	send:function(data){
		data=''+data;
		this.transport.setRequestHeader("Content-Length", data.length);
		this.transport.send(data);
	},
	close:function(){if (this.transport) this.transport.abort();}
};
function get_url_params(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec(window.location.href);
  if( results == null ) return ''; else  return results[1];
}
var	Googleizer={
	start:function(){
		var _info=$('gooinfo');
		_info.style.display='block';
		Event.observe(_info,'click',function(e){
			Event.element(e).style.display='none';
			$('goolangs').style.display='block';
		});
	}
};
var Menu={
	start:function(){
		Event.observe($('clang'),'click',Menu.menu_event);
	},
	menu_event:function(e){
		var el=Event.element(e);
		var nodes=el.parentNode.childNodes;
		var display=(!el.opened)?'block':'none';
		el.parentNode.className=!el.opened?'cunt':'';
		for(var i=0;i<nodes.length;i++)	if(!!nodes[i].style && nodes[i].id!='clang') nodes[i].style.display=display;
		el.opened=!el.opened;
	}
};
Event.observe(window,'load',function(){
	try{WidgetManager.start();}catch(e){}
	try{Googleizer.start();}catch(e){}
	Menu.start();
});
CheckEndCheckMailHandler=function(){};
SetStateTextHandler=function(){};
SetRetrievingMessageHandler=function(){};
SetCheckingFolderHandler=function(){};
