var caution = false
function setCookie(name, value, expires, path, domain, secure)
{
 var curCookie = name + "=" + escape(value) +
  ((expires) ? "; expires=" + expires.toGMTString() : "") +
  ((path) ? "; path=" + path : "") +
  ((domain) ? "; domain=" + domain : "") +
  ((secure) ? "; secure" : "");

 if (!caution || (name + "=" + escape(value)).length <= 4000) {
  document.cookie = curCookie;
 } else {
  if (confirm("Cookie exceeds 4KB and will be cut!")) {
   document.cookie = curCookie;
  }
 }
}

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));
}

var CurrentURL = location.href;
var boardIDLocation = CurrentURL.indexOf('board.id=') + 9;
var urlEnd = CurrentURL.length;

for (var x=boardIDLocation; x<urlEnd; x++) {
 if ((CurrentURL.charAt(x) == "&") || (CurrentURL.charAt(x) == "/")) { var urlEnd = x; break;}           
}

var boardID = CurrentURL.slice(boardIDLocation,urlEnd);

var postVisitExp = new Date();
postVisitExp.setHours(postVisitExp.getHours() + 1);
var x=0
var y=0;

while (x<6) {
 if (getCookie(boardID + x)) {
  y++;
 }
 x++;
}

function setBoardCookie() {
	if ((document.referrer.indexOf('post?board.id') != -1) && (document.referrer.indexOf('message.reply_to_id') == -1)) {
		if (y<5) {
		 var z=1;
		 while (z<6) {
		  if (!getCookie(boardID + z)) {
		   setCookie(boardID + z, 'true', postVisitExp);
		   break;
		  }
		  z++;
		 }
		}
	}
}

function bounceUser() {
	if ((y>4) && (CurrentURL.indexOf('message.reply_to_id') == -1)) {
	document.location.replace('http://www.univision.com/contentroot/uol/10portada/content/jhtml/NOMETA_postlimit.jhtml');
	}
}