

function openWindow(url, pad, x, y, options, name)
{
	try
	{
		if (null == name || undefined == name)
			name = "_blank";
			
		if (null == options || undefined == options)
			options = "location=1,menubar=1,status=1,titlebar=1,toolbar=1,resizable=1,scrollbars=1";
			
		if (null == pad || undefined == pad)
			pad = 100;
			
		if (null == x || undefined == x)
			x = 25;
			
		if (null == y || undefined == y)
			y = 25;
			
		var w = window.open(url, name, options);
		
		w.resizeTo(screen.width - (2 * pad), screen.height - (2 * pad));
		w.moveTo(x, y);
		w.focus();
	}
	catch (e)
	{
	}
}

function showWebmail(token, rest)
{
	if (undefined == token || null == token || "" == token)
		return;
		
	var url = "https://webmail.glidefree.com/default.aspx?token=" + token;
	
	if (rest != undefined && rest != null && rest != "")
		url += "&" + rest;
	
	openWindow(url, 50, 25, 25, null, "glide_webmail");
}

function showWebmailForProfile(token, profileId)
{
	showWebmail(token, "profile=" + profileId);
}

function	sendEmail(token, contactIds, assetIds)
{
	if (assetIds != undefined && assetIds != null && assetIds != "")
		showWebmail(token, "toContacts=" + contactIds + "&attachIds=" + assetIds);
	else
		showWebmail(token, "toContacts=" + contactIds);
}

function	sendEmailAttach(token, assetIds)
{
	showWebmail(token, "attachIds=" + assetIds);
}

function	showUserProfile(username)
{
	openWindow("http://www.glidesociety.com/" + username, 50, 15, 15);
}

function	showPopoutImage(id)
{
	window.open("http://content.glidesociety.com/image.aspx?id=" + id);
}

function	showDocument(id)
{
	window.open("http://content.glidesociety.com/document.aspx?id=" + id);
}

function	showPopoutPlayer(id)
{
	window.open("http://content.glidesociety.com/player.aspx?id=" + id);
}

function viewPresentation(id)
{
	openWindow("http://desktop.glidesociety.com/ui/presenter/default.aspx?id=" + id + "&mode=viewer",
		50, 25, 25, "location=0,menubar=0,status=0,titlebar=1,toolbar=0,resizable=1");
}

function showWriteDocWindow(url)
{
	openWindow(url, 10, 2, 2, "titlebar=1,location=0,resizable=1");
}
