/***********************************************************************
*
* getCookie		-	Generic Get Cookie routine
*
************************************************************************/

function getCookie(name) 
	{ 				// use: getCookie("name");
	var cookiecrumbs = document.cookie.split("; "); 	// break cookie into crumbs array
    for (var i=0; i < cookiecrumbs.length; i++) 
    	{
      nextcrumb = cookiecrumbs[i].split("="); 		// break into name and value
      if (nextcrumb[0] == name) 			// if name matches
        return unescape(nextcrumb[1]); 			// return value
    	}
   return null;
	}

/***********************************************************************
*
* getCartItem		-	Gets the Actinic Cart Value & No of Items
*
************************************************************************/

//CART_CONTENT = Cookie name
//1 = TOTAL_VALUE
//3 = CART_COUNT

function getCartItem(index)
	{
	var act_cart= getCookie("CART_CONTENT")
	temp =(act_cart != null) ? temp=act_cart.split("\t"):0;
	return (temp.length > 0) ? temp[index] : 0;
	}
	
/***********************************************************************
*
* win	- calls up the WUP window
*
************************************************************************/

function win()
	{
	msg = window.open("paycash1.htm","","height = 507, width = 400, left = 378, top = 40");
	}

/***********************************************************************
*
* GotoAnchor - JS for jumping to an anchor - some user agents don't handle
*				anchors correctly if BASE HREF is present
*
************************************************************************/

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){

var exclude=['Macaulay','Macauley','Macclesfield','Mace','Macey','Mack','Macham','Machen','Macken','USA' ];

if (!el.value) return false;
var str=el.value;
if (f=="cc"){
	var chr=" ";
	str=str.replace(/[^\d]/gi,"");
	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"){
	str=str.toLowerCase();
	str=str.replace(/\./g, ". ");
	str=str.replace(/\,/g, ", ");
	str=str.replace(/\s+/g, " ");
	var arr=str.match(/(^.|\s.)/gi);
	for (var i=0;i<arr.length;i++) str=str.replace(arr[i],arr[i].toUpperCase());
	str=str.split(" ");
	for (var i=0;i<str.length;i++){
		index=has(exclude,str[i],1);
		if (index===false){
			var arr=str[i].match(/(-(.)|Mc(.)|Mac(.)|O'(.))/g);
			if (arr){
				for (var j=0;j<arr.length;j++){
					str[i]=str[i].replace(arr[j],arr[j].substring(0,arr[j].length-1)+(arr[j].substring(arr[j].length-1,arr[j].length)).toUpperCase());
					}
				}
			}
		else{
			str[i]=exclude[index];
			}
		}
	str=str.join(" ");
	}
el.value=str;

function has(a,v,m){
for (var i=0;i<a.length;i++){
	if (a[i].toLowerCase()===v.toLowerCase()) return (m ? i : true);
	}
return false;
}
}
