﻿function showImage(imageUrl, dialogId, htmlPlaceholderId)
{
	try
	{
		$("#dialog-modal").attr("title", "Ultimate Software");

		var s = "<img id=\"replaceableimage1\" style=\"border: 0;\" src=\"" + unescape(imageUrl) + "\" />";

		$("#" + htmlPlaceholderId).html(s);

		$("#replaceableimage1").load(function ()
		{
			$("#" + dialogId).dialog({
				autoOpen: true,
				modal: true,
				position: "center",
				width: "auto",
				height: "auto",
				resizable: false
			});
			$("#" + dialogId).dialog("open");
		}); 
		
		/*
		*/
	}
	catch (exc)
	{
		//alert(exc.Message);
	}
}

function playVideo(title, videoStream)
{
	//alert(title);
	//alert(videoStream);
	var dialogId = "dialog-modal";
	var htmlPlaceholderId = "pVideoEmbed";

	try
	{
		$("#" + htmlPlaceholderId).html(unescape(unescape(videoStream)));
		$("#" + dialogId).dialog({
			title: unescape(unescape(title)),
			zindex: 9999,
			autoOpen: true,
			height: "auto",
			width: "auto",
			modal: true,
			draggable: true,
			position: "center",
			resizable: true,
			beforeClose: function (event, ui)
			{
				$("#" + htmlPlaceholderId).html("");
			}
		});
	}
	catch (exc)
	{
		//alert(exc.Message);
	}
}

function showVideo(videoStream, dialogId, htmlPlaceholderId)
{
	try
	{
		$("#" + htmlPlaceholderId).html(unescape(unescape(videoStream)));
		$("#" + dialogId).dialog({
			zindex: 9999,
			autoOpen: true,
			height: "auto",
			width: "auto",
			modal: true,
			draggable: true,
			position: "center",
			resizable: true,
			beforeClose: function (event, ui)
			{
				$("#" + htmlPlaceholderId).html("");
			}
		});
	}
	catch (exc)
	{
		//alert(exc.Message);
	}
}

function popLarge(imageUrl, deprecated_Width, deprecated_Height)
{
	if (!isNaN(imageUrl))
	{
		//alert('number');
		imageUrl = "http://www.ultimatesoftware.com/images/features_large_" + imageUrl + ".jpg";
		//alert(imageUrl);
	}

	showImage(imageUrl, "dialog-modal", "imageHtml");
}

function getVideo(id)
{
	var jqxhr = $.ajax(
	{
		url: "/services/website/getvideo.aspx?v=" + id,
		global: false,
		cache: false,
		type: "POST",
		dataType: "html",
		async: true,
		complete: function (jqxhr, d)
		{
			var vvv = d.toString();

			if (vvv != null && vvv != '')
			{
				var title = "";
				var videoStream = "";

				var ss = jqxhr.responseText.split(",");

				playVideo(ss[0], ss[1]);
			}
		},
		success: function (msg)
		{
		//	alert(msg);
		}
	});

	return false;
}

function launchVideo(id)
{
	window.open("http://www.ultimatesoftware.com/videos/ultimate-video-player.asp?i=" + id + "&from=banner", "UltimateVideo");
	return false;
}


