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) 
		{
			positiony = '';
			
			myObj = document.getElementsByTagName(htmltag)[i];
			myParent = myObj.parentNode;
			myClassname = myObj.lang
			
			if(htmltag == "em")
			{
				if(myClassname == "sub")
				{
					width = 100;
					height = '';
					color = '505a5a';
					font = 'Univers-Condensed.ttf';
					size = '9.1';
					bgcolor = 'e1dad4';
					doit = true;
					positiony = 11;
					myValue = myValue.toUpperCase();
				}
				else
				{
					width = '';
					height = 17;
					color = '505a5a';
					font = 'Univers-Condensed.ttf';
					size = '9.1';
					bgcolor = 'e1dad4';
					doit = true;
					myValue = myValue.toUpperCase();
				}
			
			}
			
			if(htmltag == "h2")
			{
				if(myClassname == "pos")
				{
					width = 100;
					height = '';
					color = 'c80032';
					font = 'Univers-Condensed.ttf';
					size = '9.1';
					bgcolor = 'e1dad4';
					doit = true;
					myValue = myValue.toUpperCase();
				}
			}
			
			if(htmltag == "h3")
			{
				if(myClassname == "portal")
				{	
					width = 100;
					height = '';
					color = '505a5a';
					font = 'Univers-Condensed.ttf';
					size = '9.1';
					bgcolor = 'e1dad4';
					doit = true;
					myValue = myValue.toUpperCase();
				}
			}
			
			if(htmltag == "h1")
			{
					width = 370;
					height = '';
					color = '505a5a';
					font = 'Univers-CondensedLight.ttf';
					size = '18.2';
					bgcolor = 'e1dad4';
					doit = true;
					myValue = myValue.toUpperCase();
			}
			
			
			
			if(doit == true)
			{
				//alert("DO IT");
				myValue = URLEncode(myValue);			
				
				replaceDiv = document.createElement('img');
				replaceDiv.src = '/extensions/php_to_img/output.php?text=' + myValue + '&width=' + width + '&height=' + height + '&color=' + color + '&font=' + font + '&size=' + size + '&bgcolor=' + bgcolor + '&positiony=' + positiony;
				replaceDiv.className = htmltag;
				myParent.replaceChild(replaceDiv, myObj);

				i--;
			}			
		}	
	}	
}



replaceHeading("em");
replaceHeading("h3");
replaceHeading("h2");
replaceHeading("h1");