/*
 * Ersetzt ein DIV durch ein Flash, das den gleichen Text (ohne HTML-Tags)
 * anzeigt.
 */
function replaceHeadline(id,width,height,color,size,padding) {
	var div = document.getElementById(id);
	if (div) {
		// Text der Headline suchen
		var text = div.innerHTML;// ? div.innerText : div.textContent;
		if (text) {
			text = text.replace(/^\s+/, "");
			text = text.replace(/&/, "%26");
		}

		// Link der Headline suchen
		var link;
		var atags = getElementsByTagName(div, "a");
		if (atags && atags.length > 0) {
			link = atags[0].href;
		}

		// Flash einsetzen
		var so = new SWFObject("/swf/headline-at.swf", id, width, height, "8", "#FFFFFF");
		so.addVariable("text", text);
		so.addVariable("colorhex", color);
		so.addVariable("fontsize", size);
		so.addVariable("padding_left", padding);
		if (link && link != '') {
			so.addVariable("link", link);
		}
		so.addParam("wmode", "transparent");
		so.write(id);

		// Gefundened DIV zurückliefern
		return div;
	}
}

/*
 * Liefert alle Tags eines bestimmten Namens unterhalb des
 * übergebenen Root-Knotens
 */
function getElementsByTagName(root, tagname) {
	// Neue Liste für zu bearbeitende Knoten
	var todo = new Array(root);
	// Neue Liste für gefundene Tags
	var found = new Array();
	// Tagnamen auf Großbuchstaben bringen
	tagname = tagname.toUpperCase();

	// Liste abarbeiten
	while(todo.length > 0) {
		var tag = todo.pop();
		if (tag.nodeName.toUpperCase() == tagname) {
			found.push(tag);
		}
		if (tag.childNodes) {
			for(var i=tag.childNodes.length-1 ; i>=0 ; --i) {
				todo.push(tag.childNodes[i]);
			}
		}
	}

	return found;
}


function productIconMouseOver(which)
{
	$('#producticontitle'+which).show();
	$('#producticontitle'+which).stop().animate({height:"22px",paddingTop:"4px"}, {duration:150})
}


function productIconMouseOut(which)
{
	$('#producticontitle'+which).stop().animate({paddingTop:"0px",height:"0px"}, {duration:290},function(){$('#producticontitle'+which).hide();})
}


function showPopupWithLink(phoneId, w, h, pageId) 
{
	var popupLink = pageId + "?productId=" + phoneId;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var properties = "width=" + w + ",height=" + h + ",top="+wint+",left="+winl+",scrollbars=1,addressbar=0,toolbar=0,resizable=yes";
	window.open(popupLink, 'popup',properties);
	return false;
}

function showPopup(popupLink, w, h) 
{
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var properties = "width=" + w + ",height=" + h + ",top="+wint+",left="+winl+",scrollbars=1,addressbar=0,toolbar=0,resizable=yes,target=_blank";
	window.open(popupLink, 'popup', properties);
}




