var IE5 = navigator.userAgent.match(/MSIE\ [5-9]/i);
var NS4 = navigator.userAgent.match(/^Mozilla\/4\.[7-9]/i);
var MGE = navigator.userAgent.match(/^Mozilla\/[5-9].*Gecko/i);
var OP6 = navigator.userAgent.match(/Opera[\/ ][6-9]/i);
if ((NS4 != null) && (OP6 == null)) {
	var browserID = 1;
} else if ((MGE != null) && (OP6 == null)) {
	var browserID = 2;
} else if ((IE5 != null) && (OP6 == null)) {
	var browserID = 3;
} else if (OP6 != null) {
	var browserID = 4;
} else {
	var browserID = 0;
}

function pictureExchange(c1, c2, c3, c4, oldPic, newPic, activePic, secID, activePicX, inactivePicX){
	if (document.images)
		document.images[oldPic].src = newPic;
		var plink1ID = "plink1"+secID;
		var plink2ID = "plink2"+secID;
		var plink3ID = "plink3"+secID;
		var plink4ID = "plink4"+secID;
		if (c1 == "1") document.images[plink1ID].src = inactivePicX;
		if (c2 == "1") document.images[plink2ID].src = inactivePicX;
		if (c3 == "1") document.images[plink3ID].src = inactivePicX;
		if (c4 == "1") document.images[plink4ID].src = inactivePicX;
		document.images[activePic].src = activePicX;
}

function openNewWindow(SeitenURL){
    window.open(SeitenURL, "newWindow");
}

function popupPicture(SeitenURL, window_width, window_height, scroll_bar) {
		window_width *= 1;
		window_width += 30;
		window_height *= 1;
		window_height += 55;
		var top_margin = (screen.height - window_height) / 2;
		var left_margin = (screen.width - window_width) / 2;

	newWindow = window.open(SeitenURL, "newWindow", "width=" + window_width 
				+ ",height=" + window_height
				+ ",scrollbars=" + scroll_bar
				+ ",left=" + left_margin
				+ ",top=" + top_margin);
	
	newWindow.moveTo(left_margin,top_margin);
	newWindow.resizeTo(window_width, window_height);
	newWindow.focus();
}

function popupWindow(SeitenURL, window_width, window_height, scroll_bar) {

	var top_margin = (screen.height - window_height) / 2;
	var left_margin = (screen.width - window_width) / 2;

	newWindow = window.open(SeitenURL, "newWindow", "width=" + window_width 
				+ ",height=" + window_height
				+ ",scrollbars=" + scroll_bar
				+ ",left=" + left_margin
				+ ",top=" + top_margin);
	
	newWindow.moveTo(left_margin,top_margin);
	newWindow.resizeTo(window_width, window_height);
	newWindow.focus();
}

function printWindow(SeitenURL, window_width, window_height, scroll_bar, menu_bar) {

	var top_margin = (screen.height - window_height) / 2;
	var left_margin = (screen.width - window_width) / 2;

	newWindow = window.open(SeitenURL, "newWindow", "width=" + window_width 
				+ ",height=" + window_height
				+ ",scrollbars=" + scroll_bar
				+ ",menubar=" + menu_bar
				+ ",left=" + left_margin
				+ ",top=" + top_margin);
	
	newWindow.moveTo(left_margin,top_margin);
	newWindow.resizeTo(window_width, window_height);
	newWindow.focus();
}

function startSearch(pageRef) {
	var formString=document.getElementById('searchString').value;
	var formOption=document.getElementById('searchOption').value;
	var formURL=document.getElementById('searchURL').value;
	var formID=document.getElementById('searchID').value;
	if(formID == "1") this.location.href = pageRef+"?searchString="+formString+"&searchOption="+formOption;
	if(formID == "2") window.open(formURL);
}

function switchSearch(newURL,hideLayer,showLayer,setID) {
	var newBG = "url("+newURL+")";
	document.getElementById('searchFrame').style.background = newBG;
	document.getElementById(hideLayer).style.display = 'none';
	document.getElementById(showLayer).style.display = 'block';
	document.getElementById('searchID').value = setID;
}

function setIFrameHeight(s, d){	
	var h = document.getElementById(s);
	var g = document.getElementById(d);

	if(browserID == 3){
		var height = document.body.offsetHeight-144;
	}
	if(browserID == 2){
		var height = document.body.offsetHeight-160;
	}
	
	if(height < 600){
		height = 600;
	}
	
	g.height = height;
}

//Change Images

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() {
  if (document.images) {
  	v2_02_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_02-over.gif");
    v2_03_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_03-over.gif");
    v2_06_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_06-over.gif");
    v2_07_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_07-over.gif");
  	v2_10_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_10-over.gif");
    v2_11_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_11-over.gif");
    v2_14_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_14-over.gif");
    v2_15_1 = newImage("../../../media/_shared_media/Taper Roller Bearings/x-life/quality/v2_15-over.gif");
    preloadFlag = true;
  }
}

function changeLink(id, what) {
	document.getElementById(id).className=what;
}
