function fader_in(letter,fadein){
	document.getElementById(fadein).style.visibility="visible";
	letter.style.color="#c8c8c8";
	letter.style.background="#373737";
}
function fader_out(letter,fadeout){
	document.getElementById(fadeout).style.visibility="hidden";
	letter.style.color="#373737";
	letter.style.background="#c8c8c8";
}
function frontbox(action,getcontentfrom,content_source,title,height,width){
/*
	frontbox v2.o
	includes AJAX functionality
*/
	if(action=="close"){
		if(getcontentfrom=="no-confirm"){
			$("#frontbox").fadeOut('fast');
			$("#frontbox_ajax").fadeOut('fast');
			$("#frontbox_ajax_tick").fadeOut('fast');
			$("#frontbox_ajax_warning").fadeOut('fast');
			$("#frontbox_ajax_cross").fadeOut('fast');
			$("#blanket").fadeOut('fast');
			document.getElementById('frontbox_content').innerHTML="";
		}else{
			if(confirm("Are you sure you want to close frontBox?\nAny changes you made within it will be lost if you don't save them first.")){
				document.getElementById('blanket').style.display="none";
				document.getElementById('frontbox').style.display="none";
				$("#frontbox_ajax").fadeOut('fast');
				document.getElementById('frontbox_content').innerHTML="";
			}
		}
	}else if(action=="hide"){
		$("#frontbox").fadeOut('fast');
		$("#blanket").fadeOut('fast');
	}else if(action=="open"){
		if(height!=null && height!=undefined && height!=""){
			margin_h=-(height/2);
			height_c=height-23;
			document.getElementById('frontbox').style.height=height;
			document.getElementById('frontbox').style.marginTop=margin_h;
			document.getElementById('frontbox_content').style.height=height_c;
		}else{
			height=250;
			margin_h=-(height/2);
			height_c=height-30;
			document.getElementById('frontbox').style.height=height;
			document.getElementById('frontbox').style.marginTop=margin_h;
			document.getElementById('frontbox_content').style.height=height_c;
		}
		if(width!=null && width!=undefined && width!=""){
			margin_w=-(width/2);
			title_w=width-150;
			document.getElementById('frontbox').style.width=width;
			document.getElementById('frontbox').style.marginLeft=margin_w;
			document.getElementById('frontbox_title').style.width=title_w;
			document.getElementById('frontbox_content').style.width=width;
		}else{
			width=440;
			margin_w=-(width/2);
			title_w=width-150;
			document.getElementById('frontbox').style.width=width;
			document.getElementById('frontbox').style.marginLeft=margin_w;
			document.getElementById('frontbox_title').style.width=title_w;
			document.getElementById('frontbox_content').style.width=width;
		}
		if(title!=null && title!=undefined && title!=""){
			document.getElementById('frontbox_title').innerHTML=title;
		}else{
			document.getElementById('frontbox_title').innerHTML="enVisage";		
		}
		if(getcontentfrom=="var"){
			document.getElementById('frontbox_content').innerHTML=content_source;
			setTimeout(function(){$("#blanket").fadeIn('fast');},100);
			setTimeout(function(){$("#frontbox").fadeIn('fast');},110);
		}else if(getcontentfrom=="div"){
			document.getElementById('frontbox_content').innerHTML=document.getElementById(content_source).innerHTML;
			setTimeout(function(){$("#blanket").fadeIn('fast');},100);
			setTimeout(function(){$("#frontbox").fadeIn('fast');},110);
		}else if(getcontentfrom=="ext" || getcontentfrom=="iframe"){
			document.getElementById('frontbox_content').innerHTML='<iframe src="'+content_source+'" height="'+height_c+'" width="'+width+'">Please enable frames in your browser.</iframe>';
			setTimeout(function(){$("#blanket").fadeIn('fast');},100);
			setTimeout(function(){$("#frontbox").fadeIn('fast');},110);
		}else if(getcontentfrom=="ajax"){
			$.ajax({
			    url: content_source,
			    type: 'POST',
			    dataType: 'html',
			    timeout: 10000,
				beforeSend: function(){
					$("#frontbox_ajax").fadeIn('fast');
					$("#blanket").fadeIn('fast');
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					if(textStatus=="timeout" || textStatus==timeout){
						alert("url: "+baseurl+"\n"+"err: "+XMLHttpRequest+"\nstxt: "+textStatus+"\nerrThro: "+errorThrown);
					}else{
						alert("url: "+baseurl+"\n"+"err: "+XMLHttpRequest+"\nstxt: "+textStatus+"\nerrThro: "+errorThrown);
					}
					setTimeout(function(){document.getElementById('chead_title').innerHTML="";},500);
					setTimeout(function(){document.getElementById('chead_module').innerHTML="Error";},500);
					setTimeout(function(){document.getElementById('content').innerHTML="An error occurred trying to load the content you requested.<br>Please check your connection to the server, and try again.";},500);
					setTimeout(function(){document.getElementById('sidebar').innerHTML="Whoops";},500);
					$("#frontbox_ajax").fadeOut('fast');
					$("#blanket").fadeOut('fast');
				},
				success: function(html){
					if(html=="null"){
						alert("dead page.");
					}else{
						h = eval( "(" + html + ")" );
						if(h.error!="" && h.error!=undefined){
							alert(h.error);
						}
						if(h.control_refresh!="" && h.control_refresh!=undefined){
							alert(h.error);
						}
						if(h.norefresh==0 || h.norefresh==undefined){
							document.getElementById('frontbox_content').innerHTML=h.content;
							$("#frontbox_ajax").fadeOut('fast');
							document.getElementById('frontbox').style.display="block";
/* 							$("#frontbox").fadeIn('fast'); */
							setTimeout(function(){document.getElementById('blanket').style.display="block";},1100);
						}
					}				
			    }
			})
		}else if(getcontentfrom=="ajaxloader"){
			$("#frontbox_ajax").fadeIn('fast');
			$("#blanket").fadeIn('fast');
		}else{
			alert("No source passed to frontBox.");
		}
	}else{
		alert("No action passed to frontBox.\nCanceling and closing frontBox.");
		document.getElementById('blanket').style.display="none";
	}
}
function frontbox_forceclose(){
	$("#frontbox_ajax").fadeOut('fast');
	document.getElementById('frontbox').style.display="none";
	$("#blanket").fadeOut('fast');
}