
function showPopup(link, holderId)
{
	holderId = (holderId == null) ? 'popup-holder' : holderId;
	$('#'+holderId).remove();
	var a = $("<div></div>").attr('id',holderId).css('text-align', 'left');
	$('body').append(a);
	$('#'+holderId).load(link);
	$('#'+holderId).dialog({ width:'auto',modal: true, zIndex: 1000, position: ['static',250]});
	return true; 
}

function showPage(link, holderId)
{
	holderId = (holderId == null) ? 'content' : holderId;
	$('#'+holderId).load(link);
	return true; 
}

function sendTopic(userId)
{
	var amp = '&';
	pagesObj = document.getElementById("selectTestimonial2");
	id = pagesObj.options[pagesObj.selectedIndex].value;
	
	$('#content').load('index.php?page=ajaxUserTestimonials' + amp + 'userId=' + userId + amp + 'topic=' + id);
}
function sendTopic1(userId)
{
	var amp = '&';
	pagesObj = document.getElementById("selectTestimonial1");
	id = pagesObj.options[pagesObj.selectedIndex].value;
	
	$('#content').load('index.php?page=ajaxUserTestimonials' + amp + 'userId=' + userId + amp + 'topic=' + id);
}


function sendTopic2()
{
	pagesObj = document.getElementById("selectTopic2");
	id = pagesObj.options[pagesObj.selectedIndex].value;
	
	$('#content').load('index.php?page=ajaxAnonymousTestimonials&group=anonymous&topic=' + id);
}
function sendTopic3()
{
	pagesObj = document.getElementById("selectTopic1");
	id = pagesObj.options[pagesObj.selectedIndex].value;
	
	$('#content').load('index.php?page=ajaxAnonymousTestimonials&group=anonymous&topic=' + id);
}

function bookmark(server, idTestimonial)
{
	bookmarkurl = "http://" + server + "/index.php?page=testimonial&idTestimonial=" + idTestimonial;
	bookmarktitle = "Testimonial from LDPA";
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
	else if (window.sidebar) // firefox
	window.sidebar.addPanel(bookmarktitle, bookmarkurl, "");
}

function closeDialog(idDialog)
{
	$('#' + idDialog).remove();
}

$(document).ready(function() {
	$('.noBehavior').click(function (event) {event.preventDefault();});
});


function logout()
{
	$.get('index.php?page=logout', '', function (data) { 
		if(data.logout == 'true')
			showPopup('index.php?page=logoutPopup', 'logout');
	}, 'json');
}

function logoutRedirect()
{
	closeDialog('logout');
	window.location = 'index.php';
}

