var coverOn = false;
var ease = 3;

function openChat(){
	cover();
	/*
	var wrapper = document.getElementById('chatcover');
	var handlelink = document.getElementById('chathandlelink');
	var intervalWidth = setInterval(function(){
		var curWidth = parseInt(wrapper.style.width);
		if(!curWidth) curWidth = minWidth;
		wrapper.style.width = Math.round(curWidth + (maxWidth-curWidth)/ease) + 'px';
		if(parseInt(wrapper.style.width) >= maxWidth - 5) clearInterval(intervalWidth);
	},100);
	handlelink.onclick = new Function('closeChat()');
	*/
}

function cover(){
	var wrapper = document.getElementById('specialcontentwrapper');
	var cover = document.getElementById('cover');
	var stageResolution = getStageResolution();
	wrapper.style.left = Math.round((stageResolution[0] - 780)/2) + 'px';
	wrapper.style.height = stageResolution[1] + 'px';
	cover.style.height = stageResolution[1] + 'px';
	if(coverOn){
		cover.style.top = '0px';
		var goal = stageResolution[1];
	}else{
		cover.style.top = '-' + stageResolution[1] + 'px';
		var goal = 0;
	}
	var interval = setInterval(function(){
		var current = parseInt(cover.style.top);
		var step = Math.round((stageResolution[1] - Math.abs(current))/20)+3;
		if(current + step > goal) step = Math.abs(goal - current);
		cover.style.top = current + step + 'px';
		if(parseInt(cover.style.top) >= goal){
			coverOn = !coverOn;
			if(!coverOn) wrapper.style.left = '-10000px';
			clearInterval(interval);
		}
	},10);
}

function getStageResolution(){
	var width, height;
	if (document.compatMode && document.compatMode != "BackCompat"){
	   width = document.documentElement.clientWidth;
	   height = document.documentElement.clientHeight;
	}else{
	   width = document.body.clientWidth;
	   height = document.body.clientHeight;
	}
   return new Array(width,height);
}
