
/**
 * Display popup with title and description
 */
function clientPopup(message, description, width)
	{
	s = '<h2>' + message + '</h2><p>' + description + '</p>';
	clientPopupRaw(s);
	}

/**
 * Display raw popup
 */
function clientPopupRaw(message)
	{
	$.fancybox(
		message,
		{
       		'autoDimensions'	: false,
			'width'         	: 350,
			'height'        	: 'auto',
			'transitionIn'		: 'none',
			'transitionOut'		: 'none'
		});
	}

function clientPopupOld(sMsg, sDesc, iWidth)
	{
	oContainer = document.getElementById('dynPopup_container');
	oDiv = document.createElement('div');

	if (iWidth)
		{
		oDiv.style.width = iWidth + 'px';
		}

	sTmp = '<strong>' + sMsg + '</strong>';
	if (sDesc != '') sTmp += '<br /><br />' + sDesc;
	sTmp += '<br /><br />';
	oDiv.innerHTML = sTmp;

	oDiv.style.position="fixed";
	oDiv.style.visibility = "hidden";
	oDiv.style.display = "block";

	oBut = document.createElement('button');
	oBut.innerHTML="Close";
	oBut.onclick = function () { oDiv.parentNode.removeChild(oDiv); };
	oDiv.appendChild(oBut);
	oContainer.appendChild(oDiv);

	var iPopHeight = oDiv.offsetHeight;
	var iPopWidth = oDiv.offsetWidth;
	var screenW = document.documentElement.clientWidth;
	var screenH = document.documentElement.clientHeight;
	var browserversion="1";
	browsername=navigator.appName;

	// IE6 hack
	if (navigator.appVersion.indexOf("6.")!=-1) {browserversion="6"};
	if ((browserversion = "6") && (browsername.indexOf("Microsoft")!=-1))
		{
		var sHori = document.documentElement.scrollTop;
		var sVert = document.documentElement.scrollLeft;
		iPosLeft = ((screenW - iPopWidth)/2)+sVert;
		iPosTop = ((screenH - iPopHeight)/2)+sHori;
		oDiv.style.left = iPosLeft;
		oDiv.style.top = iPosTop;
		oDiv.style.position = 'absolute';
		}
	// all the normal browsers
	else
		{
		iPosLeft = (screenW - iPopWidth)/2;
		iPosTop = (screenH - iPopHeight)/2;	
		oDiv.style.left = iPosLeft+'px';
		oDiv.style.top = iPosTop+'px';
		}

	oDiv.style.visibility = "";
	}
	
/**
 * Vote comment up
 */
function voteUp(iComment)
	{
	vote(iComment, 'voteUp');
	}

/**
 * Vote comment down
 */
function voteDown(iComment)
	{
	vote(iComment, 'voteDown');
	}

/**
 * Send vote to server
 */
function vote(iComment, sAction)
	{
	data = {
		action: sAction,
		comment: iComment
		};

	$.ajax({
		type: "POST",
		url: "/comment_ajax.php",
		data: data,
  		dataType: 'json',
		success: function(data) {clientPopup(data,data)}
		});

	}



