
function createCookie(name,value,minutes,path,domain)
{
//Pass in all args, pass in "" if need be...
//Argument "Minutes" expires a cookie in "x" minutes...Only pass in minutes: no dates.
//Important: if you want cookie to expire after browser closes then pass in 0.
//For fields and values that are going to be readable on the server-side with _
//ASP.NET use (pass in): 'Field1=Value1&Field2=Value2'

//Naming the cookie the same name as an existing cookie will replace that cookie._
//It will not create another cookie...
//Use erasecookie function below to erase a cookie

	var vdate=new Date()
	vdate.setTime(vdate.getTime()+(minutes*60*1000));

	var expires = "; expires="+vdate.toUTCString()
	
	if (minutes != 0){
	//document.cookie = name+"="+value+expires+"; path="+path+"; domain="+domain;
		document.cookie = name+"="+value+expires+"; path="+path+((domain) ? "; domain=" + domain : "");
	}
	else{
		document.cookie = name+"="+value+";"+"; domain="+domain;	
	}
}

function readCookie(name)
//Returns the *value* of the cookie when the cookie name is passed in...
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function readFieldValue(cookiestringvalue, fieldname)
{
//Returns a field's value if you pass in the field name contained in  _
//the cookies's value setting

	var splitValues= new Array();
	var loc;
	var tempstring;
	var i;
	var valforreturn=""
	var teststring;
	
	splitValues=cookiestringvalue.split("&");
	
	for (i=0; i < splitValues.length; i++) {
		
		tempstring=splitValues[i];
		loc=tempstring.indexOf("=");
		teststring=splitValues[i].substring(0,loc)

		if (teststring == fieldname){
			valforreturn= splitValues[i].substring(loc+1,splitValues[i].length);	
		}
	}
		if (valforreturn==""){
			return "No field with that name!";
		}
		else{
			return valforreturn;
		}
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}


	//Sets the value of an ASP, server-side control from Javascript
	//document.Form1.elements("txtServerTextBox").value="test" 
	//and read it...
	//var test = document.Form1.elements("txtServerControl").value
	//Move image...
	//document.getElementById("imgStatus").style.left = wd;
