// On page load show the html version

// in the preview pane

$(document).ready(function()

{

	jQuery.ajax({

		type: "GET",

		url: "ajax.send3.php",

		data: 	"id="+jsid+"&type=html",

		error: function (data)

		{

			//jQuery('#systemerror').html("<div class='error'>" + data + "<br />Please try again.<div>")

		},

		success: function (data)

		{

			$('#renderview').html(data);

			$('#progressbar').hide();

		}

	});

});



/*

update the content of preview page

based the tab selected.

*/



function updateTabs(tab)

{

	$('#progressbar').show();

	$('#previewhtml').addClass('active');

	$('#previewcode').removeClass('active');

	$('#previewtext').removeClass('active');



	if (tab == 'previewhtml')

	{

		jQuery.ajax({

			type: "GET",

			url: "ajax.send3.php",

			data: 	"id="+jsid+"&type=html",

			error: function (data)

			{

				alert("Error loading data, please refresh the page and try again.");

			},

			success: function (data)

			{

				$('#renderview').html(data);

				$('#progressbar').hide();

			}

		});

	}

	else if (tab == 'previewcode')

	{

		$('#previewhtml').removeClass('active');

		$('#previewcode').addClass('active');

		$('#previewtext').removeClass('active');



		jQuery.ajax({

			type: "GET",

			url: "ajax.send3.php",

			data: "id="+jsid+"&type=code",

			error: function (data)

			{

				alert("Error loading data, please refresh the page and try again.");

			},

			success: function (data)

			{

				$('#renderview').html(data);

				$('#progressbar').hide();

			}

		});

	}

	else if (tab == 'previewtext')

	{

		$('#previewhtml').removeClass('active');

		$('#previewcode').removeClass('active');

		$('#previewtext').addClass('active');



		jQuery.ajax({

			type: "GET",

			url: "ajax.send3.php",

			data: "id="+jsid+"&type=text",

			error: function (data)

			{

				alert("Error loading data, please refresh the page and try again.");

			},

			success: function (data)

			{

				$('#renderview').html(data);

				$('#progressbar').hide();

			}

		});

	}

}