//Replacing Content-Images with flash-containers - jg

function replaceImageFlash(cclass, flashfile, width, height) {
	if(document.getElementsByClassName(cclass).length > 0) {
		var replImagesCont = document.getElementsByClassName(cclass);
		var i=0;
		if(replImagesCont.length > 0) {
			while(i<replImagesCont.length){
				var replImage = replImagesCont[i].getElementsByTagName('img')[0];
				var replLink = replImagesCont[i].getElementsByTagName('a');
				if(replLink.length > 0) var replUrl = replLink[0].href;
				else var replUrl = '';
				if(replImage)replImagesCont[i].innerHTML = '<EMBED type="application/x-shockwave-flash"  src="fileadmin/templates/flash/'+flashfile+'.swf"  width="'+width+'px"  height="'+height+'px"  style="z-index:200;"  id="stage"  name="stage"  bgcolor="#FFFFFF"  quality="high" wmode="transparent" flashvars="imgscr='+replImage.src+'&linkurl='+escape(replUrl)+'" ></EMBED>';
				i++;
			}
		}
	}
}

function replaceVideoFlash()
{

	if(document.getElementsByClassName('whvideoembed').length > 0) {
		var replCont = document.getElementsByClassName('whvideoembed');
		var i=0;
		if(replCont.length > 0) {
			while(i<replCont.length){
				var videoCode = replCont[i].innerHTML;
				//alert(videoCode);
				replCont[i].innerHTML = '<object width="410" height="328"><param name="movie" value="http://travelclipps.de/com.cityclipps/docs/fileadmin/worldhotels/whembedplayer.swf?width=410&height=328&autostart=false&bufferlength=0&film_id='+videoCode+'" /><param name="wmode" value="transparent" />'
					+'<embed src="http://travelclipps.de/com.cityclipps/docs/fileadmin/worldhotels/whembedplayer.swf?width=410&height=328&autostart=false&bufferlength=0&film_id='+videoCode+'" type="application/x-shockwave-flash" wmode="transparent" '
					+'width="410" height="328" allowfullscreen="true"/></object>';
				replCont[i].style.visibility = "visible";
				i++;
			}
		}
	}

	//remove empty coloured headline-span -> grey bar in FFox / First-Line-Margin in IE.
	var bgClassObj = document.getElementsByClassName('bg');
	if(bgClassObj.length > 0) {
		var i=0;
		while (i < bgClassObj.length) {
			if(bgClassObj[i].innerHTML == '')
				bgClassObj[i].style.display = 'none';
				i++;
		}
	}
}
	


//replace
function replaceFlash(){
	replaceImageFlash('box_2col_teaser_img', '246x65', '246', '93');//tt_news
	replaceImageFlash('pic246', '246x65', '246', '65');
	replaceImageFlash('picClr', '246x93', '246', '93');//color
	replaceImageFlash('cnt_pic_small', '210x93', '183', '93');
	replaceImageFlash('cnt_pic_large', '376x93', '376', '93');
	replaceImageFlash('pic376', '376x93', '376', '93'); //noch gebraucht??
	replaceImageFlash('pic210', '210x93', '210', '93');
	replaceImageFlash('pic245', '570x93_2bilder1', '245', '93');
	replaceImageFlash('pic323', '570x93_2bilder2', '323', '93');
	replaceImageFlash('4img1', '570x93_4bilder1', '142', '93');
	replaceImageFlash('4img2', '570x93_4bilder2', '142', '93');
	replaceImageFlash('4img3', '570x93_4bilder3', '142', '93');
	replaceImageFlash('4img4', '570x93_4bilder4', '142', '93');
	replaceImageFlash('pic150', '150x150', '150', '150');
	
	
	replaceVideoFlash();
}
	


if (window.addEventListener) //DOM method for binding an event
	window.addEventListener("load", replaceFlash, false);
else if (window.attachEvent) //IE exclusive method for binding an event
	window.attachEvent("onload", replaceFlash);
else if (document.getElementById) //support older modern browsers
	window.onload=replaceFlash;
	
var isMSIE = /*@cc_on!@*/false;
	function pngfix(){
		$$('img[src $=".png"] ').each(function(img){
			
			//img.addClassName('png');
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML
			});//.addClassName('png');
	}
	if(isMSIE){
	
		var pngfixed = false;
		document.observe('dom:loaded', function(){
			if(pngfixed){return}
			pngfixed = true;
			pngfix();
		});
		document.observe('load', function(){
		if(pngfixed){return}
			pngfixed = true;
			pngfix();
		});
	}
	

