function SetState()
{
	document.getElementById('imageurl').disabled = ! document.getElementById('imageselection3').checked;
	
	if (document.getElementById('imageurl').disabled)
	{
		document.getElementById('imageurl').style.backgroundColor = '#e0e0e0';
	}
	else
	{
		document.getElementById('imageurl').style.backgroundColor = '';
	}
}

function RefreshSaveShareScript()
{
	var sImageURL = '';
	
	if (document.getElementById('imageselection1').checked)
	{
		sImageURL = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.blastcasta.com/images/socialbookmarking/savesharecompact.gif';
	}
	else if (document.getElementById('imageselection2').checked)
	{
		sImageURL = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.blastcasta.com/images/socialbookmarking/savesharelarge.gif';
	}
	else if (document.getElementById('imageselection3').checked)
	{
		sImageURL = Trim(document.getElementById('imageurl').value);
	}

	document.getElementById('codescript').value = '<script type="text/javascript">\n' +
		'var BC_ImageOverride = \'' + sImageURL + '\';	// Your own image to override the "Save & Share" image.\n' +
		'var BC_BGImageOverride = \'' + Trim(document.getElementById('bgimageurl').value) + '\';	// URL to another background image.\n' +
		'var BC_BorderColor = \'' + Trim(document.getElementById('bordercolor').value) + '\';	// Border color - Hexidecimal color code.\n' +
		'var BC_BGColorOverride = \'' + Trim(document.getElementById('bgcolor').value) + '\';	// Background color - Hexidecimal color code. NOTE: changing this will also hide the background image.\n' +
		'var BC_LinkColor = \'' + Trim(document.getElementById('linkcolor').value) + '\';	// Text link color - Hexidecimal color code.\n' +
		'var BC_TitleOverride = \'' + Trim(document.getElementById('titleoverride').value) + '\';		// If this is blank, then the current page title is used\n' +
		'var BC_URLOverride = \'' + Trim(document.getElementById('urloverride').value) + '\';		// If this is blank, then the current page URL is used\n' +
		'var BC_NewWindow = ' + (document.getElementById('newwindow').checked ? '1' : '0') + ';		// Open links in new window\n' +
		'document.write(unescape(\'%3Cscript type="text/javascript" src="\' + (document.location.protocol == \'https:\' ? \'https\' : \'http\') + \'://www.blastcasta.com/javascript/saveshare.js"%3E%3C/script%3E\'));\n' +
		'</script>\n' +
		'<noscript>\n' +
		'	<a href="http://www.blastcasta.com/" title="Add News to Your Website"><img src="http://www.blastcasta.com/images/tp.gif" width="1" height="1" border="0" alt="Add News to Your Website" /></a>\n' +
		'</noscript>\n';
}

function Trim(sValue)
{
	return sValue.replace(/^\s+|\s+$/g, '');
}

