/***********************************************************************
*
* getCartItem		-	Gets the Actinic Cart Value & No of Items
*
* Input: nIndex	-	Cart item index to retrieve
*							1 = TOTAL_VALUE
*							3 = CART_COUNT
*
* Returns:				Requested cart item or 0 (zero) if not found
*
************************************************************************/

//CART_CONTENT = Cookie name
//1 = TOTAL_VALUE
//3 = CART_COUNT

function getCartItem(nIndex)
	{
	var act_cart= getCookie("CART_CONTENT")
	var sTemp =(act_cart != null) ? sTemp=act_cart.split("\t"):0;
	return (sTemp.length > 0) ? sTemp[nIndex] : 0;
	}

/***********************************************************************
*
* GotoAnchor - JS for jumping to an anchor - some user agents don't handle
*				anchors correctly if BASE HREF is present
*
* Input: 				sAnchor
*
* Returns:				nothing
*
************************************************************************/

function GotoAnchor(sAnchor)
	{
	window.location.hash = sAnchor;
	}
/***********************************************************************
*
* format		-	formats user input
*
* Graham Bradley 2006
* Comments & bug reports to web@gbradley.co.uk
*
*
************************************************************************/

function format(el,f){
if (!el.value) return false;
var str=el.value;
if (f=="cc"){
	chr=" ";
	re=/[^\d]/gi;
	str=str.replace(re,"");
	str=str.substring(0,4)+chr+str.substring(4,8)+chr+str.substring(8,12)+chr+str.substring(12,str.length);
	}
else if (f=="upper"){
	str=el.value.toUpperCase();
	}
else if (f=="postcode" && isNaN(el.value)){
	str=(str.split(" ")).join("");
	str=str.substring(0,(str.length-3))+" "+str.substring((str.length-3),str.length)
	str=str.toUpperCase();
	}
else if (f=="lower"){
	str=el.value.toLowerCase();
	}
else if (f=="capitals"){
	var exclude=['Macclesfield'];
	str=str.toLowerCase();
	var re=/(^.|\s.)/gi;
	var arr=str.match(re);
	for (var i=0;i<arr.length;i++){
		str=str.replace(arr[i],arr[i].toUpperCase());
		}
	if (!has(exclude,str)){
		var re=/(Mc(.)|Mac(.)|O'(.))/g;
		var arr=str.match(re);
		if (arr){
			for (var i=0;i<arr.length;i++){
				str=str.replace(arr[i],arr[i].substring(0,arr[i].length-1)+(arr[i].substring(arr[i].length-1,arr[i].length)).toUpperCase());
				}
			}
		}
	}
el.value=str;

function has(a,v){
for (var i=0;i<a.length;i++){
	if (a[i]===v) return true;
	}
return false;
}
}

