function setCookie (name, 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 = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires)) +
((path == null) ? "; path=/" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function getCookie(name) {
  var prefix = name + "=";
  var cookieStartIndex = document.cookie.indexOf(prefix);
  if (cookieStartIndex == -1) return null;
  var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
  if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
  return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function getBaloonHash(name) {
	var hash = {};
	if (name == null) return hash;
	var arr = name.split(',');
	var part_num=0;
	while (part_num < arr.length){
	    if (arr[part_num] != null){
		    var nv = arr[part_num].split('-');
		    hash[nv[0]] = nv[1] == '1' ? 1:0;
	    }
		part_num+=1;
	}
	return hash;
}

function setBaloonParam(name,value) {
//	var hash = getBaloonHash(getCookie('boo'));
	hash[name] = value == '1' ? 1:0;
	var stm = '';
    if (typeof(hash) == "object") {
        for (var ktm in hash) {
            if(ktm.length){
	            stm += ktm + '-' + hash[ktm] + ',';
            }
        }
    }
	setCookie('gta_boo',stm,'Fri, 02-Jan-2010 00:00:00 GMT');
	return hash;
}

// type: 0 - hidden 1 - show
function setBaloonStyle(name,type,silent) {
    var tb = 'block';
    var th = 'none';

	if((silent == '1' || silent == '0')  && hash[name] == null){
		hash = setBaloonParam(name,silent);
	}
	if(hash[name] != null){
		if (hash[name] == '1'){
			return type == '1' ? tb:th;
		}
		return type == '1' ? th:tb;
	}
	return type == '1' ? tb:th;

}

function checkBaloonStyle(idh,ids,name,silent) {
	document.getElementById(idh).style.display = setBaloonStyle(name,'0',silent);
	document.getElementById(ids).style.display  = setBaloonStyle(name,'1',silent);
}