function browserCheck() {
	var b = navigator.appName;
	if (b == "Netscape")
		this.b = "ns";
	else if (b == "Microsoft Internet Explorer")
		this.b = "ie";
	else
		this.b = b
	this.us = navigator.userAgent;

	//Opera check

	this.opera = this.us.indexOf("Opera");
	if (this.opera != -1) {
		this.opera = true;
		this.b = "";
	}
	else {
		this.opera = false;
	}

	//Firefox Check

	this.firefox = this.us.indexOf("Firefox");
	if (this.us.indexOf("Firefox") != -1) {
		this.firefox = true;
	} else {
		this.firefox = false;
	}

	this.version = navigator.appVersion;
	if (this.b == 'ie') { // Internet Explorer aica?auaao '4.0 (compatible; MSIE 5.5...'
		var ve = this.version.indexOf("MSIE")
		this.v = parseInt(this.version.substr(ve + 4))
	}
	else
		this.v = parseInt(this.version)
	this.ns = (this.b == "ns" && this.v >= 4)
	this.ns4 = (this.b == "ns" && this.v < 5)
	this.ns5 = (this.b == "ns" && this.v == 5)
	this.ie = (this.b == "ie" && this.v >= 4)
	this.ie4 = (this.version.indexOf('MSIE 4') > 0)
	this.ie5 = (this.version.indexOf('MSIE 5') > 0)
	this.ie55 = (this.version.indexOf('MSIE 5.5') > 0)
	this.ie6 = (this.version.indexOf('MSIE 6.0') > 0)
	this.ie7 = (this.version.indexOf('MSIE 7') > 0)
	this.min = (this.ns || this.ie)
} //end BrowserCheck() 

is = new browserCheck();

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i = 0; i < changeImages.arguments.length; i += 2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i + 1];
		}
	}
}

var preloadFlag = false;

function preloadImages() {
}

function WindowProperty() {
	if (is.ie) {
		this.iH = document.body.clientHeight;
		this.iW = document.body.clientWidth;
	} else {
		this.iH = window.innerHeight;
		this.iW = window.innerWidth;
	}
}

function setHeight(a, b) {

	WinProp = new WindowProperty();
	Obj = document.getElementById("content");

	ObjSubmenu = document.getElementById("submenu");
	ObjSubH = ObjSubmenu.offsetHeight;
	ObjSubH = ObjSubH + 63;

	ContainerObj = document.getElementById("container");
	ContainerObjH = ContainerObj.offsetHeight;

	if (ObjSubH > ContainerObjH) {
		ContainerObj.style.height = ObjSubH + "px";
	}

	try {
		if (parseInt(Obj.offsetHeight) > (screen.height - 60)) {
			if (document.getElementById("link_top")) {
				document.getElementById("link_top").style.display = "block";
				document.getElementById("link_top").style.visibility = "visible";
			}
			if (document.getElementById("button_top")) {
				document.getElementById("button_top").style.display = "block";
				document.getElementById("button_top").style.visibility = "visible";
			}
		}
	} catch (err) { }
	if (document.getElementById("valve"))
		document.getElementById("valve").style.display = "block";

}

var SelectedPartner = "none";

function ViewCountry(name) {

	setHeight("np", "cert");

	if (document.getElementById("certimage")) {
		document.getElementById("certimage").innerHTML = "";
	}

	if (SelectedPartner != "none") {
		document.getElementById(SelectedPartner).style.display = "none";
	}

	document.getElementById(name).style.display = "block";
	SelectedPartner = name;

	if (document.height > window.innerHeight) {
		document.getElementById("content").style.height = "auto";
	}

}

function ViewCertF(name) {

	setHeight("", "cert");

	if (document.getElementById("certimage")) {
		document.getElementById("certimage").innerHTML = "";
	}

	if (SelectedPartner != "none") {
		document.getElementById(SelectedPartner).style.display = "none";
	}

	document.getElementById(name).style.display = "block";
	SelectedPartner = name;

	if (document.height > window.innerHeight) {
		document.getElementById("content").style.height = "auto";
	}

}

var CurCert = "none";

function ViewCert() {

	document.getElementById("certifnumber").innerHTML = arguments[0];

	imgHTML = "";

	for (i = 1; i < arguments.length; i++) {
		imgHTML = imgHTML + "<img class='cert' src='img/" + arguments[i] + "'><br>";
	}

	document.getElementById("content").style.height = "auto";
	document.getElementById("certimage").innerHTML = imgHTML;

}

function whichElement(e) {
	var targ
	if (!e) var e = window.event
	if (e.target) targ = e.target
	else if (e.srcElement) targ = e.srcElement
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode
	var tname
	tname = targ.tagName
}

function MenuItem(ObjA, over) {

	if (is.ie) {
		classAtr = "className";
	} else {
		classAtr = "class";
	}

	TDObj = ObjA.parentNode;

	if (over) {
		TDObj.setAttribute(classAtr, "menuitemover");
	} else {
		TDObj.setAttribute(classAtr, "menuitem");
	}

}

var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = 0;
offsetY = 15;
var toolTipSTYLE = "";

function initToolTips() {
	if (is.firefox) {
		WinProp = new WindowProperty();
		offsetX = WinProp.iW - 788;
		offsetX = offsetX * 0.5;
		offsetX = offsetX - 5;
	} else {
		offsetX = offsetX - 163;
		offsetY = offsetY + 83;
	}

	if (ns4 || ns6 || ie4) {
		if (ns4) toolTipSTYLE = document.toolTipLayer;
		else if (ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
		else if (ie4) toolTipSTYLE = document.all.toolTipLayer.style;
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		else {
			toolTipSTYLE.visibility = "visible";
			toolTipSTYLE.display = "none";
		}
		document.onmousemove = moveToMouseLoc;
	}
}

function toolTip(content) {

	if (toolTip.arguments.length < 1) // hide
	{
		if (ns4) toolTipSTYLE.visibility = "hidden";
		else toolTipSTYLE.display = "none";
	}
	else // show
	{
		if (ns4) {
			toolTipSTYLE.document.write(content);
			toolTipSTYLE.document.close();
			toolTipSTYLE.visibility = "visible";
		}
		if (ns6) {
			document.getElementById("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block';
		}
		if (ie4) {
			document.all("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block'
		}
	}
}

function moveToMouseLoc(e) {
	try {
		if (ns4 || ns6) {
			x = e.pageX;
			y = e.pageY;
		}
		else {
			x = event.x + document.body.scrollLeft;
			y = event.y + document.body.scrollTop;
		}
		toolTipSTYLE.left = x - offsetX + "px";
		toolTipSTYLE.top = y + offsetY + "px";
	} catch (e) { }
	return true;
}

function clear_html(myString) {
	myString = myString.replace(/<a id=\"print_link\"[^>].*>(.*)<\/a>/gi, "");
	myString = myString.replace(/<a id=print_link[^>].*>(.*)<\/a>/gi, "");
	myString = myString.replace(/([\r\n])/gi, "");
	myString = myString.replace(/<script([^>].*?)>(.*?)<\/script>/mgi, "");
	myString = myString.replace(/onmouseover="(.*?)"/gi, "");
	myString = myString.replace(/onmouseout="(.*?)"/gi, "");
	myString = myString.replace(/onmouseout=([^ >].*?)/gi, "");
	myString = myString.replace(/<a([^>].*?)>(.*?)<\/a>/gi, "$2");
	myString = myString.replace('<TD class=pagebreak colSpan=2></TD>', '<td class=pagebreak colspan=2>&nbsp;</td>');
	myString = myString.replace('class="pagebreak"><', 'class="pagebreak">&nbsp;<');
	myString = myString.replace(/<noprint>(.*?)<\/noprint>/mgi, "");
	myString = myString.replace(/<span noprint(.*?)<\/span>/mgi, "");
	return myString;
}

//Generating Pop-up Print Preview page
function getPrint(print_area) {
	var prtContent = document.getElementById(print_area);
	//Creating new page
	var w = '';
	var h = '';
	if (prtContent.offsetWidth > 0)
		w = 'width=' + (prtContent.offsetWidth + 20) + ',';
	if (prtContent.offsetHeight > 0)
		h = 'height=' + prtContent.offsetHeight + ',';
	var pp = window.open('', '', w + h + 'letf=0,top=0,toolbar=0,scrollbars=1,status=0');
	//Adding HTML opening tag with <HEAD> … </HEAD> portion
	pp.document.writeln('<HTML><HEAD><title>Print Preview</title>')
	pp.document.writeln('<script language="javascript" src="js/scripts.js" type="text/javascript"></script>')
	pp.document.writeln('<LINK href="images/printstyle.css" type="text/css" rel="stylesheet" >')
	pp.document.writeln('<STYLE type="text/css" media="print">.non_print, input { display: none; visibility:hidden } .pagebreak {page-break-before: always; border: 0;}</STYLE>');
	pp.document.writeln('<base target="_self"></HEAD>')
	//Adding Body Tag
	pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');
	pp.document.writeln(' leftMargin="0" topMargin="0" rightMargin="0">');
	//Creating two buttons Print and Close within a HTML table
	pp.document.writeln('<TABLE width=100% border=0 class="non_print"><TR><TD align=right>');
	pp.document.writeln('<INPUT ID="PRINT" type="button" class="button" value="Print" ');
	pp.document.writeln('onclick="javascript:printpr();">');
	pp.document.writeln('<INPUT ID="CLOSE" type="button" value="Close" class="button" onclick="window.close();">');
	pp.document.writeln('</TD></TR></TABLE>');
	//Writing print area of the calling page
	pp.document.writeln(clear_html(prtContent.innerHTML));
	//Ending Tag of </form>, </body> and </HTML>
	//if (is.ie)
	//pp.document.writeln('<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	//    pp.document.writeln('<script language="javascript">printpr();< / script>');
	pp.document.writeln('</body></HTML>');
	pp.document.close();
	//pp.focus();    
	//pp.print();
	//pp.close();
}

function printpr() {
	if (is.ie) {
		try {
			var OLECMDID = 7;
			/* OLECMDID values:
			* 6 - print
			* 7 - print preview
			* 1 - open window
			* 4 - Save As
			*/
			var PROMPT = 1; // 2 DONTPROMPTUSER
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			//document.innerHTML+=WebBrowser;
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			WebBrowser1.ExecWB(OLECMDID, PROMPT);
			WebBrowser1.outerHTML = "";
		}
		catch (ex) {
			window.print();
		}
	}
	else
		window.print();
}

function ShowHide(id) {
	if (document.getElementById('sect' + id).style.display == 'none') {
		document.getElementById('sect' + id).style.display = 'block';
		document.getElementById('itm' + id).style.listStyleImage = 'url(img/minus.gif)';
	} else {
		document.getElementById('sect' + id).style.display = 'none';
		document.getElementById('itm' + id).style.listStyleImage = 'url(img/plus.gif)';
	}
}

function CheckSerial(pos, ser) {
	if (document.getElementById('s_' + pos + '_' + ser).checked) {
		document.getElementById('c_' + pos).checked = true;
	}
}

function CheckPos(pos, ser) {
	document.getElementById('s_' + pos + '_' + ser).checked = document.getElementById('c_' + pos).checked;
}

var RangeArray = new Array();

var fadingSpeed = 10;
var ImgObj = document.getElementById("product-range");
var alphavalue = 0;
var TimerID, TimerID1;

function PlayImage() {

	ImgObj = document.getElementById("product-range");

	alphavalue = alphavalue + 5;

	if (is.ie) {
		ImgObj.style.filter = 'alpha(opacity=' + alphavalue + ')';
	} else {
		ImgObj.style.opacity = alphavalue / 100;
	}

	if (alphavalue < 100) {
		TimerID1 = setTimeout('PlayImage()', fadingSpeed);
	} else {
		alphavalue = 0;
		clearTimeout(TimerID1);
	}

}

function SetDefImage() {
	ImgObj = document.getElementById("product-range");
	ImgObj.src = RangeArray[0];
	if (is.ie) {
		ImgObj.style.filter = 'alpha(opacity=100)';
	} else {
		ImgObj.style.opacity = 0.99;
	}
}

function showRange(i) {
	alphavalue = 0;
	clearTimeout(TimerID1);
	clearTimeout(TimerID);

	ImgObj = document.getElementById("product-range");
	if (i) {
		ImgObj.src = RangeArray[i];
		if (is.ie) {
			ImgObj.style.filter = 'alpha(opacity=1)';
		} else {
			ImgObj.style.opacity = 0.01;
		}
		PlayImage();
	} else {
		TimerID = setTimeout('SetDefImage()', 500);
	}
}

function HomePagePreload_en() {
	RangeArray = new Array(
	    "images/product-range.png",
	    "images/ranges/api-en.png",
	    "images/ranges/compact-en.png",
	    "images/ranges/highperfomance-en.png",
	    "images/ranges/clean-en.png",
	    "images/ranges/critical-en.png",
	    "images/ranges/modulate-en.png",
	    "images/ranges/change-over-en.png",
	    "images/ranges/supplementary-en.png",
	    "images/ranges/bursting-en.png",
	    "images/ranges/sr-en.png",
	    "images/ranges/posv-en.png"
    )
	LoadImages(RangeArray);
}

function HomePagePreload_de() {
	RangeArray = new Array(
	    "images/product-range.png",
	    "images/ranges/api-de.png",
	    "images/ranges/compact-de.png",
	    "images/ranges/highperfomance-de.png",
	    "images/ranges/clean-de.png",
	    "images/ranges/critical-de.png",
	    "images/ranges/modulate-de.png",
	    "images/ranges/change-over-de.png",
	    "images/ranges/supplementary-de.png",
	    "images/ranges/bursting-de.png",
	    "images/ranges/sr-de.png",
	    "images/ranges/posv-de.png"
    )
	LoadImages(RangeArray);
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
		window.onload = func;
	else
		window.onload = function() { oldonload(); func(); }
}

function LoadImages() {
	var Imgs = new Array();
	for (var i = 0; i < LoadImages.arguments[0].length; i++) {
		Imgs[i] = newImage(LoadImages.arguments[0][i]);
	}
}
