var ns4 = (document.layers) ? true : false;
var ns6 = (!document.all && document.getElementById) && (navigator.appName == "Netscape") ? true : false;
var ie4 = (document.all && document.getElementById) ? true : false;

function preload(imgObj, imgSrc, width, height) {
	if (document.images) {
		eval(imgObj + ' = new Image(' + width + ', ' + height + ')');
		eval(imgObj + '.src = "' + imgSrc + '"');
	}
}

function changeImage(imgName, imgSrc) {
	if (!document.images) {
		return false;
	}

	document.images[imgName].src = navLinks[imgSrc].src;
}

if (top.parent.frames.length > 0) {
	top.parent.location.href = self.location.href;
}

function changeDropdown(frm, first_ele, second_ele, arr, choice, select1, select2) {
	var f = document.forms[frm];
	var g = f.elements[second_ele];
	var h = f.elements[first_ele];
	var str;

	if (g.length > 0) {
		for (i = g.length - 1; i >= 0; i--) {
			g[i] = null;
		}
	}

	var intCount = 0;

	for (i = 0; i < eval(arr).length; i++) {
		if (h.value == eval(arr)[i][2]) {
			str = eval(arr)[i][0];
			g[intCount] = new Option(eval(arr)[i][1], eval(arr)[i][0]);
			intCount++;
		}
	}

	choice = parseInt(choice);

	if (g.length > 1) {
		if (choice > 0) {
			g.selectedIndex = choice;
		} else if (h.selectedIndex == (select1 - 1)) {
			g.selectedIndex = t;
		}
	} else if (h.selectedIndex == (select1 - 1)) {
		g.selectedIndex = t;
	}
}

function fadeOut(obj) {
	if (ns4) {
		document.layers[obj].visibility = "hide";
	} else if (ns6) {
		document.getElementById(obj).style.visibility = "hidden";
	} else if (ie4) {
		document.all[obj].style.visibility = "hidden";
	}
}

function fadeIn(obj) {
	if (ns4) {
		document.layers[obj].document.bgColor = "#FFFFFF";
		document.layers[obj].visibility = "show";
	} else if (ns6) {
		document.getElementById(obj).style.backgroundColor = "#FFFFFF";
		document.getElementById(obj).style.visibility = "visible";
	} else if (ie4) {
		document.all[obj].style.visibility = "visible";
	}
}

function updateCategoryDropdown(form) {
	form.submit();
}

function windowLargeProductImage(id, image, dir, w, h) {
	var width = 20;
	if (w != '') {
		width = width + parseInt(w);
	}
	var height = 80;
	if (h != '') {
		height = height + parseInt(h);
	}
	var winURL = '';
	if (id == '') {
		winURL = dir + 'largeprodimage.asp?image=' + image + '&width=' + w + '&height=' + h;
	} else {
		winURL = dir + 'largeprodimage.asp?product_id=' + id + '&width=' + w + '&height=' + h;
	}
	var winName = 'prodLargeImage';
	var winProdImage = '';
	var winSettings = 'top=50,screenY=50,left=50,screenX=50,toolbar=no,location=no';
	winSettings += ',directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
	if (width != 20 && height != 80) {
		winSettings += ',width=' + width + ',height=' + height;
	}

	winProdImage = window.open(winURL, winName, winSettings);
	winProdImage.resizeTo(width + 10, height + 20);
	winProdImage.focus();
}

function windowLargeWantedImage(id, image, dir, w, h) {
	var width = 20;
	if (w != '') {
		width = width + parseInt(w);
	}
	var height = 80;
	if (h != '') {
		height = height + parseInt(h);
	}
	var winURL = '';
	if (id == '') {
		winURL = dir + 'largewantedimage.asp?image=' + image + '&width=' + w + '&height=' + h;
	} else {
		winURL = dir + 'largewantedimage.asp?wanted_id=' + id + '&width=' + w + '&height=' + h;
	}
	var winName = 'wantedLargeImage';
	var winWantedImage = '';
	var winSettings = 'top=50,screenY=50,left=50,screenX=50,toolbar=no,location=no';
	winSettings += ',directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
	if (width != 20 && height != 80) {
		winSettings += ',width=' + width + ',height=' + height;
	}

	winWantedImage = window.open(winURL, winName, winSettings);
	winWantedImage.resizeTo(width + 10, height + 20);
	winWantedImage.focus();
}

function windowCloseupProductImage(product_id, part_number, image, dir, w, h) {
	var width = 20;
	if (w != '') {
		width = width + parseInt(w);
	}
	var height = 80;
	if (h != '') {
		height = height + parseInt(h);
	}
	var winURL = '';
	if (part_number == '') {
		winURL = dir + 'closeupprodimage.asp?product_id=' + product_id + '&image=' + image + '&width=' + w + '&height=' + h;
	} else {
		winURL = dir + 'closeupprodimage.asp?product_id=' + product_id + '&part_number=' + part_number + '&width=' + w + '&height=' + h;
	}
	var winName = 'prodCloseupImage';
	var winProdImage = '';
	var winSettings = 'top=50,screenY=50,left=50,screenX=50,toolbar=no,location=no';
	winSettings += ',directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
	if (width != 20 && height != 80) {
		winSettings += ',width=' + width + ',height=' + height;
	}

	winProdImage = window.open(winURL, winName, winSettings);
	winProdImage.resizeTo(width + 10, height + 20);
	winProdImage.focus();
}