/*
Strip whitespace from the beginning and end of a string
Input : a string
*/

function getit(pd_id)

{
	var productSize = eval('document.productlist.cboSize'+pd_id+'.value');
	var productColor = eval('document.productlist.cboColor'+pd_id+'.value');

	if (productSize == "") {
					
		alert ('Please select the product size');
		
	} else if (productColor == "") {
					
		alert ('Please select the product color');
		
	}else{
	
		var qtyjs=eval('document.productlist.qty'+pd_id+'.value');
	
		
		window.location.href='cart.php?action=add&p='+pd_id+'&qty='+qtyjs+'&size='+productSize+'&color='+productColor;
	
	}

}


function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
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;
		}
	}	
}

/*
	Load the cradit cart form
*/

function creditCartForm (){
	if(document.frmCheckout.optFaxCrd.checked=true){
	
		if (document.all) {var xMax = screen.width, yMax = screen.height} else if (document.layers) {var xMax = window.outerWidth, yMax = window.outerHeight} else {var xMax = 640, yMax=480}; var xOffset = (xMax - 650)/2, yOffset = (yMax - 600)/2; window.open('include/faxCreditCard.php','myExample7','width=650,height=600,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=yes');
		
	/*	window.open('include/faxCreditCard.php','popup','resizable=no,width=screen.availWidth, height=600,menubar=no,scrollbars=yes,statusbar=no,toolbar=no');
	window.open('include/autoform.php','popup','resizable=no,width=650, height=600,menubar=no,scrollbars=yes,statusbar=no,toolbar=no');return false	*/
		
	}
}