var mailId="mail"; 
var mailWidth=366; 
var mailHeight=200+110; 
var firstShow=true; 
var mailVisible=false;

function getAvailableWidth(){
	var calcWidth=0;
	if(window.innerWidth)calcWidth=window.innerWidth;
	else calcWidth=(document.compatMode=='CSS1Compat'?document.documentElement.clientWidth:document.body.clientWidth);
	return calcWidth;
}
function getAvailableHeight(){
	var calcHeight=0;
	if(window.innerHeight) calcHeight=window.innerHeight;
	else calcHeight=(document.compatMode=='CSS1Compat'?document.documentElement.clientHeight:document.body.clientHeight);
	return calcHeight;
}
function toggleMail(){
	if(firstShow){
		var style=document.getElementById(mailId).style;
		style.left=Math.round((getAvailableWidth()-mailWidth)/2)+"px";
		style.top=Math.round((getAvailableHeight()-mailHeight)/2)+"px";
		firstShow=false;
	}
	if(mailVisible){
		document.getElementById('mail').style.display='none';
		mailVisible=false;
	}
	else{
		var style=document.getElementById('mail').style;
		style.left=Math.round((getAvailableWidth()-mailWidth)/2)+"px";
		style.top=Math.round((getAvailableHeight()-mailHeight)/2)+"px";
		style.display='block';
		mailVisible=true;
	}
}
function initMail(){
	var element=document.getElementById(mailId);
	if(element==null) return;
	var style=element.style;
	if(style==null) return;
	style.visibility="visible";
	style.position="absolute";
	style.width=mailWidth+"px";
	style.height=mailHeight+"px";
}
function loadMail(){
	toggleMail();
}
