<!-- Original:  Joe Norman (joe@wdrealty.com) -->
<!-- Web Site:  http://www.jacksonville.net/~joman/ArraysNCookies.html -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

myclick=0

var Now=new Date()
var dumdd=Now.getDate()
var dummm=Now.getMonth()
var dumyy=Now.getYear()


var arrRecords = new Array();
var arrCookie = new Array();

var arrMyRecords= new Array();
var arrMyCRecords= new Array();

var recCount = 0;
var strRecord="";
expireDate = new Date;


function gsremote(strpth,strtitle)
{
//var mywin=window.open("../remote.htm","","width=160,height=290,resizable=0");
//var mywin=window.open("../remote.htm","","width=300,height=300,resizable=0");

//alert(strpth);

var mywin=window.open(strpth,"","width=300,height=270,resizable=0");
//mywin.creator=self;
mywin.moveTo(60,205);
}

function gsremote2(strpth,strtitle,strw,strh,strx,stry)
{
//var mywin=window.open("../remote.htm","","width=160,height=290,resizable=0");
//var mywin=window.open("../remote.htm","","width=300,height=300,resizable=0");

//alert(strpth);

var mywin=window.open(strpth,"","width="+strw+",height="+strh+",resizable=0");
//mywin.creator=self;
mywin.moveTo(strx,stry);
}


function gsLabelObj(obj,gcolor,gcolorf)
{
	obj.style.backgroundColor=gcolor
	obj.style.color=gcolorf
}

function gsLabelObj2(obj,gcolor,flag)
{
	obj.style.color=gcolor;
}


function gsTime()
{
  var d = new Date();
  s = d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
  //s += d.getMilliseconds();
  return(s);
}




function gsdate()
{
	var str=dumyy+'/'+dummm+'/'+dumdd;
	return(str);
	
}

expireDate.setDate(expireDate.getDate()+365);

function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ")
for (i = 0; i < thisCookie.length; i++) {
if (cookieName == thisCookie[i].split("=")[0]) {
return thisCookie[i].split("=")[1];
   }
}
return 0;
}

function loadCookie() {
if(document.cookie != "") {
arrRecords = cookieVal("Records").split(",");
currentRecord();
   }
}

function gsShowMyData(indx)
{
	loadCookie();
	//alert(arrMyCRecords[0]+'\n'+arrMyCRecords[1]+'\n'+arrMyCRecords[2]+'\n'+arrMyCRecords[3]+'\n'+indx);
	var cdata=arrMyCRecords[indx]
	return(cdata);
}

function gsSetMyData(logid,userid1,userid2,cstatus)
{
	arrMyRecords[0]=logid;
	arrMyRecords[1]=userid1;
	arrMyRecords[2]=userid2;
	arrMyRecords[3]=gsdate();
	arrMyRecords[4]=cstatus;
	
	//alert(arrMyRecords[0]+arrMyRecords[4]);
	setRec();
}



function setRec() {
strRecord = "";
for(i = 0; i < arrMyRecords.length; i++) {
strRecord = strRecord + arrMyRecords[i] + ":";
}
//alert(strRecord);
arrRecords[recCount] = strRecord;
//document.frm2.add.value = "  NEW  ";
document.cookie = "Records="+arrRecords+";expires=" + expireDate.toGMTString();
}
function newRec() {
switch (document.frm2.add.value) {
case "  NEW  " :
   varTemp = recCount;
   for(i = 0; i < document.frm1.elements.length; i++) {
   document.frm1.elements[i].value = ""
   }
   recCount = arrRecords.length;
   document.frm2.add.value = "CANCEL";
   break;
case "CANCEL" :
   recCount = varTemp;
   document.frm2.add.value = "  NEW  ";
   currentRecord();
   break;
   }
}
function countRecords() {
//document.frm2.actual.value = "Record " + (recCount+1)+";  "+arrRecords.length+" saved records";
}
function delRec() {
arrRecords.splice(recCount,1);
navigate("previous");
setRec();
}

function currentRecord() {
if (arrRecords.length != "") {
strRecord = arrRecords[recCount];
currRecord = strRecord.split(":");
for(i = 0; i <= 4; i++) {
arrMyCRecords[i] = currRecord[i];
//alert(arrMyCRecords[i]);
      }
   }
}
function navigate(control) {
switch (control) {
case "first" :
   recCount = 0;
   currentRecord();
   document.frm2.add.value = "  NEW  ";
   break;
case "last" :
   recCount = arrRecords.length - 1;
   currentRecord();
   document.frm2.add.value = "  NEW  ";
   break;
case "next" :
   if (recCount < arrRecords.length - 1) {
   recCount = recCount + 1;
   currentRecord();
   document.frm2.add.value = "  NEW  ";
   }
   break;
case "previous" :
   if (recCount > 0) {
   recCount = recCount - 1;
   currentRecord();
   }
   document.frm2.add.value = "  NEW  ";
   break;
   default:
   }
}

// Splice method Protype Function
// Peter Belesis, Internet.com
// http://www.dhtmlab.com/
 
if (!Array.prototype.splice) {
function array_splice(ind,cnt) {
if (arguments.length == 0) return ind;
if (typeof ind != "number") ind = 0;
if (ind < 0) ind = Math.max(0,this.length + ind);
if (ind > this.length) {
if (arguments.length > 2) ind = this.length;
else return [];
}
if (arguments.length < 2) cnt = this.length-ind;
cnt = (typeof cnt == "number") ? Math.max(0,cnt) : 0;
removeArray = this.slice(ind,ind+cnt);
endArray = this.slice(ind+cnt);
this.length = ind;
for (var i = 2; i < arguments.length; i++) {
this[this.length] = arguments[i];
}
for(var i = 0; i < endArray.length; i++) {
this[this.length] = endArray[i];
}
return removeArray;
}
Array.prototype.splice = array_splice;
}
recCount = 0;
//loadCookie();
//countRecords();
