function ol_funcs() {
	msie_replace_png_imgs();
	so_init()
}


function msie_replace_png_imgs() {
	if (!is_msie()) return;
	if (is_msie() && navigator.userAgent.toLowerCase().indexOf("msie 7.0") != -1) return;
	if (agent.toLowerCase().indexOf('mac')>-1) return;
	var i, elements;

	elements = document.getElementsByTagName("img");
	for (i = 0; i < elements.length; i++) {
		var img = elements[i];
		if (img.src.toLowerCase().search(/\.png$/) < 0) continue;

		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src  + "', sizingMethod='image')";
		img.src = "/clear.gif";

	}
}

function is_msie() {
	agent = navigator.userAgent;
	return navigator.userAgent.toLowerCase().indexOf("msie") != -1; 
}
agent = navigator.userAgent;


/*****
Last revision: 02.15.2006
steve@slayeroffice.com

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*****/


//window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;
	
	css = d.createElement("link");
	css.setAttribute("href","/fileadmin/templates/xfade.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);
	
	if (d.getElementById("pic")) {
		imgs = d.getElementById("pic").getElementsByTagName("img");
		if (imgs.length > 0) {
			for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
			imgs[0].style.display = "block";
			imgs[0].xOpacity = .99;
	
			setTimeout(so_xfade,6000);
		}
	}
}
function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,6000);
	} else {
		setTimeout(so_xfade,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}

function setstartOpacity(obj) {
	obj.style.opacity = .99;
	obj.style.MozOpacity = .99;
	obj.style.filter = "alpha(opacity=99)";
}

Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

colors = new Array('beige','black','blue','light-blue','brown','green','light-green','grey','ivory','orange','pink','purple','red','light-red','violet','white','yellow');

$(document).ready(function() {
	if ($.browser.msie) {
		$(".csc-textpic-clear + a + table.contenttable-0").css("margin-top","10px");
		$("table.contenttable-0").find("caption").each(function(i) {
			$(this).parents("table").addClass("prodtbl-notopborder");
		});
	}
	$("table.contenttable-0").find("caption").each(function(i) {
		$(this).colSpan="3";
		$(this).html('&nbsp;'+$(this).html());
	});
	thenext = $("#main > a + div > .csc-textpic-imagewrap dl").css("margin-top","0");
	
	$("table.contenttable-0").find("td").each(function(i) {
		color = $(this).html();
		if (colors.in_array(color)) {
			$(this).html('<div class="cc cc_'+color+'">&nbsp;</div>'+color+'');
			$(this).css("width","80px");
		}
	});
	$("table.contenttable-0").find(".td-0").each(function(i) {
		htmlcon = $(this).html();
		if (htmlcon.substr(htmlcon.length-1,1) == '#') {
			$(this).addClass("prodtd-name");
			$(this).html(htmlcon.substr(0,htmlcon.length-1));
		}
	});
});

