/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}
/*function checkCart() {
	alert("hello");
	with (window.document.frmCart) {
		if (cartColours[].selectedIndex == 0) {
			alert('Choose a colour');
			cartColours.focus();
			return;
		} else if (cartSizes.selectedIndex == 0) {
			alert('Choose a size');
			cartSizes.focus();
			return;
		} else {
			submit();
		}	
	}

}
/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

/*
	Set one value in combo box as the selected value
*/
function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}

//  New function to replace the images in productDetail

function changeImage(imageId, url) {
	//	alert (imageId);
	
		if (imageId == ''){
			document.getElementById('imageContainer').innerHTML = '<img src=' + url + ' border=0 class=prod_image alt=product image>';
			//document.getElementById('imageContainer').innerHTML = '<img src=images/addToCart.gif border=0 alt=product image>';
		} else if (imageId == '2'){
			document.getElementById('imageContainer').innerHTML = '<img src=' + url + ' border=0 class=prod_image alt=product image>';
		} else if (imageId == '3'){
			document.getElementById('imageContainer').innerHTML = '<img src=' + url + ' border=0 class=prod_image alt=product image>';
		} else if (imageId == '4'){
			document.getElementById('imageContainer').innerHTML = '<img src=' + url + ' border=0 class=prod_image alt=product image>';
		} else if (imageId == '5'){
			document.getElementById('imageContainer').innerHTML = '<img src=' + url + ' border=0 class=prod_image alt=product image>';
		}
	
	
}

function changeTeamImage(url) {
		// alert (url);
	
		
			document.getElementById('centerTeam').innerHTML = '<img src=\"' + url + '" border=0 class=\"centralTeamImageChange\"></img>';
		
	
}

function viewColours(url) {
	
	document.getElementById('imageContainer').innerHTML = url;

}
