var preloadedImages = new Array();
function preload() {
	var args = preload.arguments;
		
	for(var i = 0; i < args.length; i++) {
		var image = new Image();
		image.src = args[i];
		preloadedImages.push(image);		
	}
}

function enterExitValue(which, what) {
	if(what && which.value == '0') {
		which.value = '';
	} else if(!what && which.value == '') {
		which.value = '0';
	}
}

function checkValue(e) {
	var keyCode;
	if(window.event) {
		keyCode = e.keyCode;
	} else if(e.which) {
		keyCode = e.which;
	}
	
	return !(/[a-zA-Z\.]/.test(String.fromCharCode(keyCode)));
}

function toggleAddress(which) {
	if(which.checked) {
		document.orderForm.shipping_name.disabled = true;
		document.orderForm.shipping_address.disabled = true;
		document.orderForm.shipping_city.disabled = true;
		document.orderForm.shipping_state.disabled = true;
		document.orderForm.shipping_zip.disabled = true;
		document.orderForm.shipping_country.disabled = true;
		document.orderForm.shipping_phone.disabled = true;
		document.orderForm.shipping_fax.disabled = true;
		
		document.orderForm.shipping_name.value = '';
		document.orderForm.shipping_address.value = '';
		document.orderForm.shipping_city.value = '';
		document.orderForm.shipping_state.value = '';
		document.orderForm.shipping_zip.value = '';
		document.orderForm.shipping_country.value = '';
		document.orderForm.shipping_phone.value = '';
		document.orderForm.shipping_fax.value = '';
		
		document.getElementById('label_name').style.color = 'black';
		document.getElementById('label_address').style.color = 'black';
		document.getElementById('label_city').style.color = 'black';
		document.getElementById('label_state').style.color = 'black';
		document.getElementById('label_zip').style.color = 'black';
		document.getElementById('label_country').style.color = 'black';
		document.getElementById('label_phone').style.color = 'black';
	} else {
		document.orderForm.shipping_name.disabled = false;
		document.orderForm.shipping_address.disabled = false;
		document.orderForm.shipping_city.disabled = false;
		document.orderForm.shipping_state.disabled = false;
		document.orderForm.shipping_zip.disabled = false;
		document.orderForm.shipping_country.disabled = false;
		document.orderForm.shipping_phone.disabled = false;
		document.orderForm.shipping_fax.disabled = false;
	}
}

function toggleCat(cat, from) {
	var catEl = document.getElementById('cat_'+cat);
	
	if(catEl.style.display == 'none') {
		catEl.style.display = 'block';
		document.cookie = 'jthCat_'+cat+'=show; path=/';
		if(from) {
			from.className = 'categoryOpen';
		}
	} else {
		catEl.style.display = 'none';
		document.cookie = 'jthCat_'+cat+'=; path=/';
		if(from) {
			from.className = 'categoryClosed';
		}
	}
}

function toggleJTechComments() {
	var jtechComments = document.getElementById('jtechCommentsContainer');
	
	if(jtechComments) {	
		jtechComments.style.display = jtechComments.style.display == 'block' ? 'none' : 'block';
	}
}