// admin.js

// newFunction
    function changeCursorOn(cell, cursorType) {
      cell.style.cursor=cursorType;
      cell.className="list_hover";
    }
    function changeCursorOff(cell, cursorType,style) {
      cell.style.cursor=cursorType;
       cell.className="odd";       
    }
    
    function go(url){
    	location.href=url;
    }
    
    
	function pickShowOrHide(divName) {
		var objDivStyle = eval('document.getElementById(divName).style');
		if (objDivStyle.display == 'inline') {
			hideDiv(divName);
		} else {
			showDiv(divName);
		}
	}
	function showDiv(divName) {
		var objDivStyle = eval('document.getElementById(divName).style');
		objDivStyle.display = 'inline';
	}
	
	function hideDiv(divName) {
		var objDivStyle = eval('document.getElementById(divName).style');
		objDivStyle.display = 'none';
	}
	
	
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;


   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function submitRefund(maxAmount) {
	var val = document.orderForm.refAmount.value;
	if (IsNumeric(document.orderForm.refAmount.value) == false) {
		alert("Please enter a numeric value (no £ signs)");
	} else if ((val - maxAmount) > 0) {
		alert("Please enter a numeric value less or equal to the available refund amount of "+maxAmount);
	} else { 
		if (confirm("You are about to submit a refund for £"+val+". Are you sure you wish to refund this amount?")) {
			submitForm('','','refund');
		}
	}
}		   
	
function submitCancel(isPaid, refundableAmount) {	  
	
	if (isPaid=='CHARGING' || isPaid=='CHARGEABLE') {
		if (confirm("Are you sure you wish to cancel this order?")) {
			submitForm('','','cancel');
		}
	} else { 
		if (refundableAmount>0) {
			alert("Please refund this order in full and then cancel the order");
		} else {
			if (confirm("Are you sure you wish to cancel this order?")) {
				submitForm('','','cancel');
			}
		}
	}
}

function checkAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = true ;
	}
}

function uncheckAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = false ;
	}
} 