
function pageInit() {

	var is = new BrowserCheck();

	if (is.safari) {document.getElementById('metanav').style.marginTop = '-2px';}

	if (is.ie) 
	{
	// replacePngWithFlash(); 
	}

}

function replacePngWithFlash() {
	if ( !is.ie || detectFlash() < 5 ) { return false; }

	var elAry = getElementsByClass('png')
	var n = elAry.length;

	while (n--)
	{
		var el = elAry[n];
		var swfWidth = parseInt(el.offsetWidth)
		var swfHeight = parseInt(el.offsetHeight)
		var swfFile = (el.title) ? el.title :  el.id ;

		var swfUrl = '/img/'+swfFile+'.swf';
//		var swfUrl = '/img/'+el.id+'.swf';
//		var swfUrl = '/img/gen_visual_faq.swf';
		el.style.background = 'none';
//		el.style.border = '1px solid red';
		el.innerHTML = '<div align="right"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+swfWidth+'" HEIGHT="'+swfHeight+'" id="visual" ALIGN="RIGHT"> <PARAM NAME=movie VALUE="'+swfUrl+'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="="'+swfUrl+'"" quality=high wmode=transparent bgcolor=#FFFFFF  WIDTH="'+swfWidth+'" HEIGHT="'+swfHeight+'" NAME="Untitled-2" ALIGN="RIGHT"  TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT></div>';
//alert(el.innerHTML)
//alert(swfUrl+':'+swfWidth+':'+swfHeight)
	}

}

// preloading images 
function loadImg(imgAry) {

		var loadedImg=new Array
		var n = imgAry.length;
		while (n--)
		{
			loadedImg[n]=new Image();
			loadedImg[n].src=imgAry[n];
		}
}


// fix ie text-selection bug
// other posibilities: 
// - remove position: absolute from #content
// - body: margin-top: 1px (doesn't work this time)

if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat"){
	document.onreadystatechange = onresize = function fixIE6AbsPos(){
    if (!document.body) return;
    if (document.body.style.margin != "0px") document.body.style.margin = 0;
    onresize = null;
    document.body.style.height = 0;
    setTimeout(function(){ document.body.style.height = document.documentElement.scrollHeight+"px"; }, 1);
    setTimeout(function(){ onresize = fixIE6AbsPos; }, 100); 
  }
}

function openWindow(_url){
	window.open(_url, 'Produktinfos', 'width=655,height=370,left=100,top=200,scrollbars=no');
}

function openWindowPortion(_url){
	window.open(_url, 'Produktinfos', 'width=655,height=480,left=100,top=200,scrollbars=no');
}

function openWindowSchaum(_url){
	window.open(_url, 'Schaummasken', 'width=655,height=530,left=100,top=200,scrollbars=no');
}



function getElementsByClass(clazz) {
	elements = new Array();
	var j = 0;
	var allelements = document.all?document.all:document.getElementsByTagName('*');
	for (var i=0; i<allelements.length; i++){
		if (allelements[i].className.indexOf(clazz) != -1) {
			elements[j++] = allelements[i];
		}
	}
	return elements;
}

// IE flash detection.
function detectFlash () {
	for(var i=7; i>0; i--){
		var flashVersion = 0;
		try {
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
 			flashVersion = i;
			return flashVersion;
		}
			catch(e){
		}
	}
}

// seite drucken
function printWindow() {
	if (window.print) window.print();
}

function showLayer(action,layer) {
	if (action == 1) {
		document.getElementById(layer).style.display = "block";
		document.getElementById(layer).style.visibility = "visible";
	}
	if (action == 0) {
		document.getElementById(layer).style.display = "none";
		document.getElementById(layer).style.visibility = "hidden";	
	}
}
