function URLEncode(s) {
     if (window.encodeURIComponent) {
        return encodeURIComponent(s);
     }
     else if (window.escape) {
        return escape(s); 
     }
     return s;
}


function replaceHeading(htmltag) {
	
	for(var i = 0; i < document.getElementsByTagName(htmltag).length; i++) 
	{
		doit = false;
		myValue = document.getElementsByTagName(htmltag)[i].innerHTML;

		if (myValue != undefined) 
		{
			
			myObj = document.getElementsByTagName(htmltag)[i];
						
			if(htmltag == "em")
			{
				width = '';
				height = '20';
				color = '003867';
				font = 'optima.ttf';
				size = '11';
				bgcolor = 'FFCB04';
				positiony = 13;
				
				myValue = myValue.toUpperCase();
				
				
				if(myObj.className == "img")
				{
					doit = true;
				}
			}
			
			
			if(doit == true)
			{
				myValue = URLEncode(myValue);
				myFlash = ('<img src="/extensions/php_to_img/output.php?text=' + myValue + '%20&width=' + width + '&height=' + height + '&color=' + color + '&font=' + font + '&size=' + size + '&bgcolor=' + bgcolor + '&positiony=' + positiony + '" />');
								
				replaceDiv = document.createElement('span');
				replaceDiv.innerHTML = myFlash;
				myObj.parentNode.replaceChild(replaceDiv, myObj);
				i--;
			}			
		}	
	}	
}

