	function linkText()
	{
		links = new Array('Turning Point Debt Settlement', 'Debt Settlement', 'Debt Settlement Company', 'Debt Relief', 'Debt Relief Place', 'Eliminate Credit Card Debt');

		return(links);
	}

	function generateWidgetCode()
	{
		var theCode;
		var errorMessages = new Array();
		errorMessages = validateWidgetCode();

		if(errorMessages.length == 0)
		{
			theCode = '&lt;script type="text/javascript" src="http://www.debtreliefplace.com/debt-calc/widget/?color='
			+ document.getElementById('color').value
			+ '&width='
			+ document.getElementById('width').value
			+ '&height='
			+ document.getElementById('height').value
			+ '&consolidate-color='
			+ document.getElementById('consolidate-color').value
			+ '&counseling-color='
			+ document.getElementById('counseling-color').value
			+ '&donothing-color='
			+ document.getElementById('donothing-color').value
			+ '&turningpoint-color='
			+ document.getElementById('turningpoint-color').value
			+ '">&lt;/script>';

			var links = new Array();
			links = linkText();

			theCode += '&lt;br /&gt;&lt;a href="http://www.debtreliefplace.com"&gt;' + links[Math.floor(Math.random()*links.length)] + '&lt;/a&gt;';
		}
		else { theCode = 'Correct the errors highlighted in red.'; }

		document.getElementById('widgetbox').innerHTML = theCode;

		// Display Error Messages
		if(errorMessages.length > 0)
		{
			var errMessage = 'Please correct the following errors:\n\n';
			for($i = 0; $i < errorMessages.length;$i++)
			{
				errMessage = errMessage + '*' + errorMessages[$i] + '\n';
			}

			alert(errMessage);
		}
	}

	function validateWidgetCode()
	{
		var errorMessages = new Array();
		var errorCount = 0;


		// Theme
		if(document.getElementById('color').value == '')
		{
			var oldHTML = document.getElementById('colorText').innerHTML;
			document.getElementById('colorText').style.color = '#ff0000';
			document.getElementById('colorText').style.fontWeight = 'bold';
			errorMessages[errorCount++] = 'Theme is required.';
		}
		else
		{
			var oldHTML = document.getElementById('colorText').innerHTML;
			document.getElementById('colorText').style.color = '#243789';
			document.getElementById('colorText').style.fontWeight = 'bold';
		}

		// Width
		if(document.getElementById('width').value == '')
		{
			var oldHTML = document.getElementById('widthText').innerHTML;
			document.getElementById('widthText').style.color = '#ff0000';
			document.getElementById('widthText').style.fontWeight = 'bold';
			errorMessages[errorCount++] = 'Width is required.';
		}
		else
		{
			if(document.getElementById('width').value >= 289)
			{
				var oldHTML = document.getElementById('widthText').innerHTML;
				document.getElementById('widthText').style.color = '#000000';
				document.getElementById('widthText').style.fontWeight = 'normal';
			}
			else
			{
				var oldHTML = document.getElementById('widthText').innerHTML;
				document.getElementById('widthText').style.color = '#ff0000';
				document.getElementById('widthText').style.fontWeight = 'bold';
				errorMessages[errorCount++] = 'Width must be greater than or equal to 289 pixels.';
			}
		}

		// Height
		if(document.getElementById('height').value == '')
		{
			var oldHTML = document.getElementById('heightText').innerHTML;
			document.getElementById('heightText').style.color = '#ff0000';
			document.getElementById('heightText').style.fontWeight = 'bold';
			errorMessages[errorCount++] = 'Height is required.';
		}
		else
		{
			if(document.getElementById('height').value >= 500)
			{
				var oldHTML = document.getElementById('heightText').innerHTML;
				document.getElementById('heightText').style.color = '#000000';
				document.getElementById('heightText').style.fontWeight = 'normal';
			}
			else
			{
				var oldHTML = document.getElementById('heightText').innerHTML;
				document.getElementById('heightText').style.color = '#ff0000';
				document.getElementById('heightText').style.fontWeight = 'bold';
				errorMessages[errorCount++] = 'Height must be greater than or equal to 500 pixels.';
			}
		}

		// Consolidation Loans
		if(document.getElementById('consolidate-color').value == '')
		{
			var oldHTML = document.getElementById('consolidatecolorText').innerHTML;
			document.getElementById('consolidatecolorText').style.color = '#ff0000';
			document.getElementById('consolidatecolorText').style.fontWeight = 'bold';
			errorMessages[errorCount++] = 'Consolidation Loans Graph Color is required.';
		}
		else
		{
			var oldHTML = document.getElementById('consolidatecolorText').innerHTML;
			document.getElementById('consolidatecolorText').style.color = '#000000';
			document.getElementById('consolidatecolorText').style.fontWeight = 'normal';
		}

		// Credit Counseling
		if(document.getElementById('counseling-color').value == '')
		{
			var oldHTML = document.getElementById('counselingcolorText').innerHTML;
			document.getElementById('counselingcolorText').style.color = '#ff0000';
			document.getElementById('counselingcolorText').style.fontWeight = 'bold';
			errorMessages[errorCount++] = 'Credit Counseling Graph Color is required.';
		}
		else
		{
			var oldHTML = document.getElementById('counselingcolorText').innerHTML;
			document.getElementById('counselingcolorText').style.color = '#000000';
			document.getElementById('counselingcolorText').style.fontWeight = 'normal';
		}

		// Do Nothing
		if(document.getElementById('donothing-color').value == '')
		{
			var oldHTML = document.getElementById('donothingcolorText').innerHTML;
			document.getElementById('donothingcolorText').style.color = '#ff0000';
			document.getElementById('donothingcolorText').style.fontWeight = 'bold';
			errorMessages[errorCount++] = 'Do Nothing (Minimum Payments Only) Graph Color is required.';
		}
		else
		{
			var oldHTML = document.getElementById('donothingcolorText').innerHTML;
			document.getElementById('donothingcolorText').style.color = '#000000';
			document.getElementById('donothingcolorText').style.fontWeight = 'normal';
		}

		// Turning Point
		if(document.getElementById('turningpoint-color').value == '')
		{
			var oldHTML = document.getElementById('turningpointcolorText').innerHTML;
			document.getElementById('turningpointcolorText').style.color = '#ff0000';
			document.getElementById('turningpointcolorText').style.fontWeight = 'bold';
			errorMessages[errorCount++] = 'Turning Point Debt Settlement Graph Color is required.';
		}
		else
		{
			var oldHTML = document.getElementById('turningpointcolorText').innerHTML;
			document.getElementById('turningpointcolorText').style.color = '#000000';
			document.getElementById('turningpointcolorText').style.fontWeight = 'normal';
		}

		return(errorMessages);
	}

	generateWidgetCode();
