	// Copyright © 2001 SolWeb Informática S.L. All rights reserved.
	// This script may not be copied, reproduced, republished, posted, or
	// distributed in any way, without the  prior written permission of
	// SolWeb Informática S.L.

	
	function delCookie(cookieName) {
		var expDays = 365; // number of days the cookie should last
		var expDate = new Date();
		expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
		SetCookie(cookieName, '', expDate);
		window.location.reload();
		getRefsCookie(cookieName)
	}
	
	function delRefCookie(ref, cookieName) {
		var refs = GetCookie(cookieName);
		var arrayOfStrings = refs.split(';');
		refs = '';
		for (var i=0; i<arrayOfStrings.length; i++) {
			if (arrayOfStrings[i] != ref && arrayOfStrings[i] != '') {
				refs = refs + arrayOfStrings[i]
				if (i < (arrayOfStrings.length - 2)) {
					refs = refs + ';';
				} else if (i < (arrayOfStrings.length - 1)) {
					if (arrayOfStrings[i+1] != ref) refs = refs + ';'
				}
			}
		}
		var expDays = 365; // number of days the cookie should last
		var expDate = new Date();
		expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
		SetCookie(cookieName, refs, expDate);
		window.location.reload();
	}

	function setRefsCookie(ref, cookieName) {
		var expDays = 365; // number of days the cookie should last
		var expDate = new Date();
		expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
		var refs = GetCookie(cookieName);
		if (refs==null) refs='';
		if (refs == '') {
			SetCookie(cookieName, ref, expDate);
		} else {
			refs = refs + ';' + ref;
			SetCookie(cookieName, refs, expDate);
		}
		window.location.reload();
	}

	function getRefsCookie(cookieName) {
		var refs = GetCookie(cookieName);
		if (refs=='') refs=null;
		var i;
		if (document.forms.length>0) {
			for (var i=0; i<document.forms.length; i++) {
				if (document.forms[i].name=='format') {
					for (var i=0; i<document.forms.format.sort.length; i++) {
						if (document.forms.format.sort[i].checked=="1") {
							var sort=document.forms.format.sort[i].value;
						}
					}
					window.location.href='search.asp?References='+escape(refs)+'&OrderBy='+escape(document.forms.format.OrderBy.options[document.forms.format.OrderBy.selectedIndex].value)+'&Sort='+sort+'&Currency='+escape(document.forms.format.Currency.options[document.forms.format.Currency.selectedIndex].value);
				}
			}
			if (i==document.forms.length) {
				window.location.href='search.asp?References=' + escape(refs);
			}
		} else {
			window.location.href='search.asp?References=' + escape(refs);
		}
	}

	function GetCookie(cookieName) {
		var arg = cookieName + "=";
		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 getCookieVal(offset) {
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1) endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
	}

	function SetCookie(cookieName, value) {
		var argv = SetCookie.arguments;
		var argc = SetCookie.arguments.length;
		var expires = (argc > 2) ? argv[2] : null;
		var path = (argc > 3) ? argv[3] : null;
		var domain = (argc > 4) ? argv[4] : null;
		var secure = (argc > 5) ? argv[5] : false;
		document.cookie = cookieName + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
	}
