 function cat_selected (cookie_name, value) {
	var id = value.replace(/\_.+$/,'');
	var url = value.replace(/^\d+\_/,'');  
	set_cookie(cookie_name, id, url);
	document.location.href = url;
}

function set_cookie(name,value,url,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";        
}

function reload_page(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.location.href = name;
}

function load_cookie(name, value, days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
        document.location.reload();
}

function sort_click(value){

    var url = document.location.href;
    url = url.replace(/[\?\&]sort=.+?(&|$)/g, '&');
    url = url.replace(/\&\&+/g, '&');
    url = url.replace(/(^\&+|\&$)/g, '');
    url = url.replace(/\?$/,'');
    if (/\?/.test(url)) {
        url = url + '&sort=' + value;
    } else {
        url = url + '?sort=' + value;
    }

    document.location.href = url;
}