// IMAGE REPLACE FUER PORTALBEREICH


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 = '';
			positionx = '';
			
			myObj = document.getElementsByTagName(htmltag)[i];
			myParent = myObj.parentNode;
			myClassname = "";
			myClassname = myObj.className;
			
			if(htmltag == "em")
			{
				if(myClassname == "logo")
				{
					width = 90;
					height = 70;
					color = 'ffffff';
					font = 'TheSans-B6SemiBold.ttf';
					size = '11';
					doit = true;
					myValue = myValue.toUpperCase()
					
					if(portal == "grossglockner")
					{
						bgcolor = '3d78a0';
					}
					else if(portal == "villach")
					{
						bgcolor = '9d5706';
					}
					else if(portal == "gerlos")
					{
						bgcolor = '068aa7';
					}
					else if(portal == "nockalm")
					{
						bgcolor = '426b29';
					}
				}
				else
				{
					
					width = 220;
					height = 22;
					color = 'ffffff';
					font = 'TheSans-B6SemiBold.ttf';
					size = '11';
					doit = true;
					
					
					if(portal == "grossglockner")
					{
						bgcolor = '3d78a0';
					}
					else if(portal == "villach")
					{
						bgcolor = 'cb6c04';
					}
					else if(portal == "gerlos")
					{
						bgcolor = '068ca9';
					}
					else if(portal == "nockalm")
					{
						bgcolor = '426b29';
					}
				}
					
			}
		
			if(htmltag == "h3")
			{
				if(myClassname == "img")
				{	
					width = 170;
					height = 20;
					font = 'TheSans-B6SemiBold.ttf';
					size = '11';
					doit = true;
					bgcolor = '273947';
					
					if(portal == "grossglockner")
					{
						color = '50a0c8';
					}
					else if(portal == "villach")
					{
						color = 'ffb238';
					}
					else if(portal == "gerlos")
					{
						color = '00d8ff';
					}
					else if(portal == "nockalm")
					{
						color = 'a5be28';
					}
				
				}
				else if(myClassname == "teaser_img")
				{
					width = 170;
					//height = 20;
					height = '';
					font = 'TheSans-B6SemiBold.ttf';
					size = '11';
					doit = true;
					bgcolor = '273947';
					
					if(portal == "grossglockner")
					{
						color = '50a0c8';
					}
					else if(portal == "villach")
					{
						color = 'ffb238';
					}
					else if(portal == "gerlos")
					{
						color = '00d8ff';
					}
					else if(portal == "nockalm")
					{
						color = 'a5be28';
					}
				
				
				}
			}
			
		
			
			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 + '&positionx=' + positionx;
				replaceDiv.className = htmltag;
				myParent.replaceChild(replaceDiv, myObj);

				i--;
			}			
		}	
	}	
}


replaceHeading("em");
replaceHeading("h3");

