function setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure) {
	var sCookie = sName + "=" + encodeURIComponent(sValue);
	if (oExpires) {
		sCookie += "; expires=" + oExpires.toGMTString();
	}
	if (sPath) {
		sCookie += "; path=" + sPath;
	}
	if (sDomain) {
		sCookie += "; domain=" + sDomain;
	}
	if (bSecure) {
		sCookie += "; secure";
	}
	document.cookie = sCookie;
}

function getCookie(sName) {
	var sRE = "(?:; )?" + sName + "=([^;]*);?";
	var oRE = new RegExp(sRE);
	if (oRE.test(document.cookie)) {
		return decodeURIComponent(RegExp["$1"]);
	} else {
		return null;
	}
}

function clearMess() {
	document.getElementById("addDiv").style.display = 'none';	
}

function addFavor(id) {
	var tmp = getCookie("prog");
	setCookie("prog",tmp+","+id,'','/');
	var htmlOutput = "<table width=\"200\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\" bgcolor=\"#4A4949\" style=\"border:4px solid #4A4949\">" +
	  "<tr> " +
	   " <td align=center><font color=white>Добавляется..." +
	   " </td>" +
	  "</tr>" +
	"</table>";   
	
	document.getElementById("addDiv").innerHTML = htmlOutput;
	document.getElementById("addDiv").style.left = ((window.screen.width / 3) + 50) + 'px';
	document.getElementById("addDiv").style.top = ((document.getElementsByTagName("html")[0].scrollTop + (window.screen.height / 2)) - 150) + 'px';
//	document.getElementById("addDiv").style.top = ((200 + (window.screen.height / 2))) + 'px';
	document.getElementById("addDiv").style.display = 'block';	
	setTimeout(clearMess,2000);
}
