function inputChange(obj) {
  obj.style.backgroundPosition = (obj.value == '')?'0px 0px':'0px -23px';
}

function selectColour(strIdPrefix, strColourHex, strColourName, strHiddenElementId, nColourId) {
	document.getElementById(strIdPrefix + 'colour_choose_message').style.display = 'none';
	document.getElementById(strIdPrefix + 'colour_chosen').style.display = '';
	document.getElementById(strIdPrefix + 'colour_block').style.backgroundColor = strColourHex;
	document.getElementById(strIdPrefix + 'colour_name').innerHTML = strColourName;
	
	document.getElementById(strHiddenElementId).value = nColourId;


}

function showHideProducts(selectObj){
	//show the number of products they have chosen
	for (i = 0; i < selectObj.options.length; i++){
		if(selectObj.value >= i) {
			//show product
			document.getElementById('dress' + (i+1)).style.display = '';
		} else {
			//hide product
			document.getElementById('dress' + (i+1)).style.display = 'none';
		}
	}
}

function setQuantityPrice(){
	selectObj = document.getElementById('quantity');
	var nQuantity = (selectObj.selectedIndex+1);
	var nTotalPrice = 0;
	
	for(i=0;i<nQuantity;i++){
		nTotalPrice += parseFloat(document.getElementById('dress' + (i+1) + '_price').value);
	}
	
  //update the quantity div
  document.getElementById('buy_quantity').innerHTML = nQuantity;
	
	//update the price div
	document.getElementById('buy_price').innerHTML = 'Total: &pound;' + nTotalPrice;
}

function addOption(selectbox,text,value ) {
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function validateRequired(field){
  with (field) {
    if (value==null||value==""){
      return false;
    } else { 
      return true; 
    }
  }
}

function validateDate(value){
  var regexp = /^(0{0,1}[1-9]|[1-2]\d|3[0-1])\/(0{0,1}[1-9]|1[0-2])\/[1-9]\d{0,3}$/;
  return regexp.test(value);
}

