﻿$(
	function()
	{
		/* START: IMG FIX */
		$('img').each
		(
			function()
			{
				//vspace
				if (!isNaN($(this).attr("vspace")) && $(this).attr("vspace") != undefined && $(this).attr("vspace") != '' && $(this).attr("vspace") != -1)
				{
					$(this).css("margin-top", $(this).attr("vspace"));
					$(this).css("margin-bottom", $(this).attr("vspace"));
				}
				//hspace
				if (!isNaN($(this).attr("hspace")) && $(this).attr("hspace") != undefined && $(this).attr("hspace") != '' && $(this).attr("hspace") != -1)
				{
					$(this).css("margin-left", $(this).attr("hspace"));
					$(this).css("margin-right", $(this).attr("hspace"));
				}
				//border
				if (!isNaN($(this).attr("border")) && $(this).attr("border") != undefined && $(this).attr("border") != '' && $(this).attr("border") != -1)
				{
					$(this).css("border-width", $(this).attr("border"));
				}
			}
		);
		/* END: IMG FIX */
		
		/* START: TABLE FIX */
		$('table').each
		(
			function()
			{
				//cellpadding
				if (!isNaN($(this).attr("cellpadding")) && $(this).attr("cellpadding") != undefined && $(this).attr("cellpadding") != '' && $(this).attr("cellpadding") != -1)
				{
					var cellp = $(this).attr("cellpadding");
					$(this).find('td').css("padding", cellp.toString());
				}
				//cellspacing
				if (!isNaN($(this).attr("cellspacing")) && $(this).attr("cellspacing") != undefined && $(this).attr("cellspacing") != '' && $(this).attr("cellspacing") != -1)
				{
					$(this).css("border-collapse", "separate");
				}
				//border (width, color, style = solid)
				if (!isNaN($(this).attr("border")) && $(this).attr("border") != undefined && $(this).attr("border") != '' && $(this).attr("border") != -1)
				{
					var brdclr;
					if ($(this).attr("bordercolor") != 'undefined')
					{
						$(this).css("border-color", $(this).attr("bordercolor"));
						$(this).find('td').css("border-color", $(this).attr("bordercolor"));
					}
					$(this).css("border-style", "solid");
					$(this).find('td').css("border-style", "solid");
					$(this).css("border-width", $(this).attr("border"));
					$(this).find('td').css("border-width", $(this).attr("border"));
				}
			}
		);
		/* END: TABLE FIX */
	}
);
