// ***** Cookies ***************************************************************

// ***** setCookie *****

/*

PARAMETERS:

name, value  - cookie name & value
expires      - cookie expiration date (defaults to end of current session)
path, domain - cookie path & domain (defaults to document's path & domain)
secure       - cookie sent only over secure connection

example CALLS:

setCookie("counter", "1");
setCookie("counter", "1", Date("January 01, 2010 00:00:01"));
setCookie("counter", "1", undefined, '/');

*/

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" : "");
}

// ***** setCookieLT *****

// PARAMETERS: lifetime - cookie lifetime in seconds

function setCookieLT(name, value, lifetime, path, domain, secure)
{
  if (lifetime) lifetime = new Date(Date.parse(new Date())+lifetime*1000);
  setCookie(name, value, lifetime, path, domain, secure);
}

// ***** getCookie *****

function getCookie(name)
{
  var cookie, offset, end;
  cookie  = " "+document.cookie;
  offset  = cookie.indexOf(" "+name+"=");
  if (offset == -1) return undefined;
  offset += name.length+2;
  end     = cookie.indexOf(";", offset)
  if (end    == -1) end = cookie.length;
  return unescape(cookie.substring(offset, end));
}

// ***** delCookie *****

// PARAMETERS:
//
// name         - cookie name
// path, domain - cookie path & domain (the same as those used to create cookie)

function delCookie(name, path, domain)
{
  if (getCookie(name))
    setCookie(name, "", new Date("January 01, 2000 00:00:01"), path, domain);
}

function laMoneda()
{
	
	var lamo;
	lamo = getCookie('moneda');
//	alert(lamo);
	if (lamo == undefined)
	{
	document.form1.ccur.value='EUR';
	 setCookie('moneda','EUR');
	}
	else
	{
	 document.form1.ccur.value = getCookie('moneda');
	}
	}
	
//ESTO NO VA AQUI PERO AJA TENIA QUE METERLO EN ALGUNA PARTE

function lookup(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue) {
		$('#inputString').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
