function word(sep,which,inwhat){ 
	var n = 0			
	var wstr = 0		
	var i = 0			
	var s = 0			
	var f = 0			
	for (i = 1 ; i < which ; i++) 
		{
			n = inwhat.indexOf(sep,n)	
			if (n < 0 )						
				{	
					return ''				
					break					
				}	
			n++										
		}
	
	if ( n >= 0)							
	{											
		var s = n							
		var f = inwhat.indexOf(sep,n)	
		if (f < 0 ) f = inwhat.length	
		wstr = inwhat.substring(n,f)	
	}
	return wstr							
												
}
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0) 
    date.setTime (date.getTime() - skew);
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
 var orderline = 0;

function makeArray(numElements) {

	this.lenght = numElements;

	for (count = 1; count <= numElements; count++) {

		this[count] = 0;

		};
	
	return (this);

	

};

function register_access_phone() {
		//alert ("Do we store: "  + document.forms[0].keep_phone.checked);
	if (document.forms[0].keep_phone.checked) {
		access_phone = document.forms[0].account_number.value
		//alert ("Phone: "  + access_phone);
		orderdate = new Date();
		FixCookieDate (orderdate);
		orderid = "DICOM";
		orderline = "";
		orderline += orderid;
		orderline += "**:"
		orderline += access_phone + ":,E*N*D";
		//alert ("Orderline: "  + orderline);
		var expdate = new Date();
		FixCookieDate (expdate);
		//alert ("Today: " + expdate);
		expdate.setTime (expdate.getTime() + (32000000000));
		//alert ("Expire: " + expdate);
		SetCookie ("dicom_access_phone",orderline,expdate,"/");
		//alert ("Cookie: " + GetCookie("dicom_access_phone"));
		}
		else
		{
		DeleteCookie ("dicom_access_phone","/");
		//alert ("Cookie: " + GetCookie("dicom_access_phone"));
		};
		
	};

		
function get_access_phone() {
	
	if (GetCookie("dicom_access_phone")) {
			
			regline = GetCookie("dicom_access_phone");
			
			//alert ("" + regline);
			access_phone = "" + word(":",2,regline);
			
			document.forms[0].account_number.value = access_phone;
	};						
				
};
