// make sure we have full browser
// if (top.location != location) { top.location.href = document.location.href }

/*
 * (c)2006 Jesse Skinner/Dean Edwards/Matthias Miller/John Resig
 * Special thanks to Dan Webb's domready.js Prototype extension
 * and Simon Willison's addLoadEvent
 *
 * For more info, see:
 * http://www.thefutureoftheweb.com/blog/adddomloadevent
 * http://dean.edwards.name/weblog/2006/06/again/
 * http://www.vivabit.com/bollocks/2006/06/21/a-dom-ready-extension-for-prototype
 * http://simon.incutio.com/archive/2004/05/26/addLoadEvent
 * 
 *
 * To use: call addDOMLoadEvent one or more times with functions, ie:
 *
 *    function something() {
 *       // do something
 *    }
 *    addDOMLoadEvent(something);
 *
 *    addDOMLoadEvent(function() {
 *        // do other stuff
 *    });
 *
 */
 
addDOMLoadEvent=(function(){var e=[],t,s,n,i,o,d=document,w=window,r='readyState',c='onreadystatechange',x=function(){n=1;clearInterval(t);while(i=e.shift())i();if(s)s[c]=''};return function(f){if(n)return f();if(!e[0]){d.addEventListener&&d.addEventListener("DOMContentLoaded",x,false);/*@cc_on@*//*@if(@_win32)d.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();

function sendMailTo(account, domain)
{
	window.location.href = 'mail' + 'to:' + account + '@' + domain;
}

function setMailToStatus(account, domain)
{
	window.status = 'mail' + 'to:' + account + '@' + domain;
}


$(document).ready(function(){

	function getBackgroundPositionX(obj) {
		if( $(obj).hasClass("threestate-right") )
			return "right";
		return "left";
	}

	function setSelected(obj) {
		$(obj).css("background-position", getBackgroundPositionX(obj) + " top");
	}
	
	function setHover(obj) {
		$(obj).css("background-position", getBackgroundPositionX(obj) + " center");
	}
	
	function setNormal(obj) {
		$(obj).css("background-position", getBackgroundPositionX(obj) + " bottom");
	}
	
	setNormal(".threestate");
	setSelected(".threestate-selected");
	
	$(".threestate").mousedown(function(){
		setSelected(this);
	});
	$(".threestate").mouseover(function(){
		setHover(this);
	});
	$(".threestate").mouseout(function(){
		setNormal(this);
	});

	$(".threestate").each(function(){
		setNormal(this);
	});
	
	$(".threestate-selected").each(function(){
		setSelected(this);
	});	
	
	// Vertical Align 
	function setVerticalAlign(obj){
		var objHeight = $(obj).height();
		var parentHeight = $(obj).parent().height();
		var marginTop = (parentHeight - objHeight) / 2; 
		var newHeight = objHeight + 0; 
		$(obj).css('margin-top', marginTop);
		$(obj).css('height', objHeight);
	}
	
	$(".tmpMainTitle").each(function(){
		if(!$(this).children().length)
			$(this).css('display', 'block');
		$(this).children().each(function(){
			if($(this).is(".tmpOver")) 
				$(this).css('display', 'block');
			else
				$(this).parent(".tmpMainTitle").css('display', 'block');	
		});				
		setVerticalAlign(this);	
	});	
	
	$(".vAlignTrue").css('display', 'block');
	$(".vAlignTrue").each(function(){
		setVerticalAlign(this);
	});		

});

