var to = null;
var msg = null;
var msg_pos = null;

function clearMsg()
{
	msg.hide('normal', function(){
		$(msg).empty();
	});
}
function showMsg(m_text, m_time)
{
	if (msg==null || msg.length==0) 
	{
		$('#site_content').prepend('<div id="message"></div>');
		msg = $('#message');
	}
	msg.append('<p>'+m_text+'</p>').hide().show('normal', setMsgPos);
	hideMsg(m_time);
	
}
function hideMsg(m_time)
{
	if (to!=null)
	{
		clearTimeout(to); 
		to = null;
	}
	if (m_time==undefined) m_time = 8000;
	to = setTimeout(clearMsg, m_time);
}
function setMsgPos()
{
	if (msg!=null && msg.length > 0) 
	{
		if (msg_pos==null || msg.length == 0)
		{
			msg.prepend('<div id="msg_pos"></div>');
			msg_pos = $('#msg_pos');
		}
		var messages_height = 0;
		$('p', msg).each(function(){messages_height += $(this).height();});
		var prep_height = (msg.height() - messages_height) / 2;
		if (prep_height>0) msg_pos.height(prep_height);
		else msg_pos.height(0);
	}
}

$(document).ready(function(){
	$('span.embed').each(function(){
		var val = $(this).attr('title').split('|');
		if (val.length>0) {
			$(this).parent().parent().flashembed({
					src: val[0], 
					width: parseInt(val[1]),
					height: parseInt(val[2])
				}, {
					'clickTAG': '/ad/redirect/' + val[3], 
					'clickTARGET': '_blank'
				});
		}
	});
	if (ie==false || parseInt(ie)>=7)
	{
		$('.rounded5').corners('5px');
		$('.rounded').corners('15px');
		$('.rounded10').corners('10px');
	}
	$('a.newWindow').click(function(e){
		e.preventDefault();
		var hj_popup = window.open(this.href, 'hj_popup', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=600,height=500,left=200,top=120');
	});
	
	msg = $('#message');
	if (msg.length > 0) 
	{
		setMsgPos();
		hideMsg();
	}
});