function compareProducts(id) {
	var elID='compareCheckbox_'+id;
	var elObject=document.getElementById(elID);
	var cookieContent=getCookie('compare');

	if (elObject.checked==true) {
		if (cookieContent==null) {
			cookieContent=','+id+',';
		} else {
			cookieContent=cookieContent+','+id+',';
		}
	} else {
		cookieContent=cookieContent.replace(','+id+',', '');
	}
	//alert(cookieContent);
	setCookie('compare', cookieContent, '', '/');

	var cmp_string=cookieContent.slice(1, -1);
	cmp_string=cmp_string.replace(/,,/g, ',');

	if (cmp_string.length==0) {
		cmp_array_count=0;
	} else {
		cmp_array=cmp_string.split(",");
		cmp_array_count=cmp_array.length;
	}
	var cmp_count=document.getElementById('cmp_count');
	cmp_count.innerHTML='('+cmp_array_count+')';
}

function uncheckProducts() {
	deleteCookie('compare', '/');
	var cmp_count=document.getElementById('cmp_count');
	cmp_count.innerHTML='(0)';
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
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" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    //if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    //}
}

// z(ne)viditelneni prvku
function showElement(name1, fields) {
	var obj1 = document.getElementById(name1);
	obj1.style.display = 'block';

	name1=name1+'-tb';
	var obj1 = document.getElementById(name1);
	obj1.className='tab-sel';

	// projdeme vsechny zalozky v poli ktere se maji schovat
	for (var i=0; i<fields.length; i++) {
		field_name=fields[i];
		obj=document.getElementById(field_name);

		if (obj!=null) {
			obj.style.display = 'none';

			name2=field_name+'-tb';
			var obj2 = document.getElementById(name2);
			if (obj2!=null) {
				obj2.className='';
			}
		}
	}
}

