	function compara(id) {
		familii = new Array("1","21","2","3","4");
		familie = -1;

		var iduri = getCookie("comparator_tehnologic");
		var stergere_iduri = false;
		if (!iduri) { //nu avem setat cookie
			setCookie("comparator_tehnologic",id);
		} else { //avem cookie
			iduri = iduri.split(",");
			for (i=0; i<iduri.length; i++) { //verific daca id-ul nou este deja printre cele vechi, ca sa-l scot
				if (i==0) {
					for (j=0; j<familii.length; j++) {
						if (iduri[i].indexOf(familii[j])==0) {
							familie = j; //gasesc familia curenta
							break;
						}
					}
				}
				
				if (iduri[i]==id) {
					stergere_iduri = true;
					iduri.splice(i,1);
					iduri = iduri.join(",");
					if (iduri) {
						setCookie("comparator_tehnologic",iduri);
					} else {
						setCookie("comparator_tehnologic","");
						//delCookie("comparator_tehnologic");
					}
				}
			}
			if (!stergere_iduri) { //daca nu am performat deja o stergere, atunci adaug noul id
				if (iduri.length >= 5) {
					alert ("Atentie! Puteti compara maxim 5 produse, iar Dvs ati bifat deja 6 pina acum.\nUltimul produs selectat va fi ignorat.\n\nPentru a putea vedea rezultatele compararii, apasati butonul \"Compara produsele selectate\" din partea de jos a paginii.");
					document.getElementById(id).checked = false;
				} else {
					//verificari de familii
					id += "";
					if (id.indexOf(familii[familie])==0) {
						setCookie("comparator_tehnologic",iduri+","+id);
					} else {
						alert ("Ne pare rau! Produsul bifat acum nu poate fi comparat cu cele selectate anterior.\nVa rugam cititi instructiunile de comparare.");
						document.getElementById(id).checked = false;
					}
				}
			}
		}
		
		//alert (getCookie("comparator_tehnologic"));
	}

	function comparator() {
		var iduri = getCookie("comparator_tehnologic");
		if (iduri) {
			iduri = iduri.split(",");
			if (iduri.length >1) {
				document.comparator.submit();
			} else {
				//alert ("Atentie! Ati bifat un singur produs pina acum.\nPentru comparare sunt necesare 2 pina la 5 produse.");
				document.comparator.submit();
			}
		} else {
			alert ("Atentie! Nu ati bifat inca nici un produs pentru comparare.");
		}
	}
	
	function getCookie(NameOfCookie) {
		// First we check to see if there is a cookie stored.
		// Otherwise the length of document.cookie would be zero.
		if (document.cookie.length > 0) {
			// Second we check to see if the cookie's name is stored in the
			// "document.cookie" object for the page.

			// Since more than one cookie can be set on a
			// single page it is possible that our cookie
			// is not present, even though the "document.cookie" object
			// is not just an empty text.
			// If our cookie name is not present the value -1 is stored
			// in the variable called "begin".
			begin = document.cookie.indexOf(NameOfCookie+"=");
			if (begin != -1) {// Note: != means "is not equal to"
				// Our cookie was set.
				// The value stored in the cookie is returned from the function.
				begin += NameOfCookie.length+1;
				end = document.cookie.indexOf(";", begin);
				if (end == -1) end = document.cookie.length;
				return unescape(document.cookie.substring(begin, end));
			}
		}
		return null;
		// Our cookie was not set.
		// The value "null" is returned from the function.
	}
	
	function setCookie(NameOfCookie, value, expiredays) {
		// Three variables are used to set the new cookie.
		// The name of the cookie, the value to be stored,
		// and finally the number of days until the cookie expires.
		// The first lines in the function convert
		// the number of days to a valid date.
		var ExpireDate = new Date ();
		ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
		// The next line stores the cookie, simply by assigning
		// the values to the "document.cookie" object.
		// Note the date is converted to Greenwich Mean time using
		// the "toGMTstring()" function.
		document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) + "; path=/";
	}
	
	function delCookie (NameOfCookie) {
		// The function simply checks to see if the cookie is set.
		// If so, the expiration date is set to Jan. 1st 1970.
		if (getCookie(NameOfCookie)) {
			document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}
	
	function numaicomparanimic() {
		setCookie("comparator_tehnologic","");
		window.location.href=window.location.href;
	}

