function $(obj) { return document.getElementById(obj); }

//########################################################################
//	browserCheck
//########################################################################

function browserCheck() {
	var agent = navigator.userAgent;
	if (agent.indexOf("MSIE") > -1) {
		var anfang = agent.indexOf("MSIE");
		var ende = agent.lastIndexOf(";");
		var version = parseInt(agent.substring(anfang+5,ende-2));
		return "IE" + version;
	}
	else { return "MO"; }
}

//########################################################################
//	correctPNG
//########################################################################

function correctPNG() {
	// Correctly handle PNG transparency in Win IE 5.5 or higher.
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		var sizMethod = null;
		// sizingMethod for IE
		if (img.className == "stretchBoxHGB") { sizMethod = "scale"; }
		else { sizMethod = "image"; }
		
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID		= (img.id) ? "id='" + img.id + "' " : "";
			var imgName		= (img.name) ? "name='" + img.name + "' " : "";
			var imgClass	= (img.className) ? "class='" + img.className + "' " : "";
			var imgTitle	= (img.title) ? "title='" + img.title + "' " : "";
			var imgOver		= (img.onmouseover) ? "onmouseover='hossa(this);' " : ""
			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 " + imgOver + imgID + imgName + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='" + sizMethod + "');" + "\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}

//########################################################################
//	Scroll buttons Galerie
//########################################################################

var scrollCont = null;
var cont = null;

function startScroll(button, id, pos)
{
	button.onmouseup	= function() { clearInterval(scrollCont); }
	button.onmouseout	= function() { clearInterval(scrollCont); }
	cont = $(id);
	scrollCont = setInterval("scroll" + pos + "()", 90);
}
function scrolldown() { cont.scrollTop += 16; }
function scrollup() { cont.scrollTop -= 16; }

//########################################################################
//	popUp
//########################################################################

function popup(/*target, width, height, left, top, scrollBar*/)
{
	var target		= popup.arguments[0];
	var w			= popup.arguments[1];
	var h			= popup.arguments[2];
	var x			= (popup.arguments[3])?popup.arguments[3]:'0';
	var y			= (popup.arguments[4])?popup.arguments[4]:'0';
	var scrollB		= (popup.arguments[5])?"scrollbars=yes":"scrollbars=no";
	var dimension	= "width=" + w + ",height=" + h;
	var position	= "left=" + x + ",top=" + y;
	
	window.open(target,'',dimension + "," + position + "," + scrollB);
}

//==================================================================================
// imagePreloader
//==================================================================================

function imagePreloader() {
	if(document.images) {
		if(!document.aPics) document.aPics = new Array();
			var i,j = document.aPics.length, argumente = imagePreloader.arguments;
			for(var i = 0; i < argumente.length; i++) {
				if (argumente[i].indexOf("#")!=0) {
				document.aPics[j] = new Image;
				document.aPics[j++].src = argumente[i];
			}
		}
	}
}

//==================================================================================
// changeOpacity
//==================================================================================

function changeOpacity(obj, objOpacity)
{
	if(document.getElementById(obj)) obj = document.getElementById(obj);
	if(obj) {
		obj.style.opacity 		= (objOpacity/100);
		obj.style.MozOpacity 	= (objOpacity/100);
		obj.style.KhtmlOpacity	= (objOpacity/100);
		obj.style.filter		= "alpha(opacity="+objOpacity+")";
	}
}

//########################################################################
//	START
//########################################################################

start = function() {
	browser = browserCheck();
	if (browser == "IE6"){ correctPNG(); }
	if(subsection=="shop") { imagePreloader("/pix/service/shop/btWarenkorb_hover.gif","/pix/service/shop/btWarenkorb_press.gif","/pix/service/shop/btPlus_hover.gif","/pix/service/shop/btPlus_press.gif","/pix/service/shop/btMinus_hover.gif","/pix/service/shop/btMinus_press.gif"); }
	
}

//====================================================================================================

window.onload=start;

//====================================================================================================