// Original JavaScript code by Duncan Crombie: dcrombie@chirp.com.au
// Please acknowledge use of this code by including this header.

  var bikky = document.cookie;

  function getCookie(name) { // use: getCookie("name");
    var index = bikky.indexOf(name + "=");
    if (index == -1) return null;
    index = bikky.indexOf("=", index) + 1;
    var endstr = bikky.indexOf(";", index);
    if (endstr == -1) endstr = bikky.length;
    return unescape(bikky.substring(index, endstr));
  }

  var today = new Date();
  var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days
  var expired = new Date(today.getTime() - 28 * 24 * 60 * 60 * 1000); // less 28 days

  function setCookie(name, value) { // use: setCookie("name", value);
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value);
    bikky = document.cookie; // update bikky
    return getCookie(name) != null; // return false if the cookie was refused
  }

  function deleteCookie(name) { // use: deleteCookie("name");
    document.cookie=name + "=null; expires=" + expired.toGMTString(); // delete cookie
    bikky = document.cookie; // update bikky
    document.forms[0].cookieContent.value = formatCookie(); // display cookie content
  }

  function makeCookie() { // make sure the cookie is set
    var form = document.cookieTest;
    if (!setCookie(form.targetcookie.value, form.content.value)) {
      document.location='../Common/errorCookie.jsp';
    }
  }

  function formatCookie() {
    var retValue = "";
    with (bikky) {
      for (var i=0; i < length; i++)
        retValue += (charAt(i) != " ") ? charAt(i) : "\n";
    }
    return retValue;
  }

	function nnAcroDetect() {
	var mime, version, acroplugin, descr;

	mime = navigator.mimeTypes['application/pdf'];
	if (mime && (mime.enabledPlugin != null)) {
		version = 1;
		if (navigator.plugins && navigator.plugins.length) {
			acroplugin = navigator.plugins[mime.enabledPlugin.name];
			if (acroplugin && acroplugin.description) {
				descr = acroplugin.description;
				version = descr.charAt(descr.indexOf('.')-1);
				if (version == 0)
					version = 1;
			}
		}
	} else {
		version = 0;
	}
	return(version);
	}


	function acroDetect() {
	if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
		if(!nnAcroDetect()) {
		  document.location='../Common/errorBrowser.jsp?prev=Iscrizioni/sStudentiLogin2.jsp';
                }
	} else {
		if(!ieAcroDetect()) {
		  document.location='../Common/errorBrowser.jsp?prev=Iscrizioni/sStudentiLogin2.jsp';
                }
	}
}
