//**********************************************************************
//                        Personal Identifier II
//            by Tim Wallace   (timothy@essex1.com)
//
//      Cookie Functions - Second Helping  (21-Jan-96)
//  Written by:  Bill Dortch, hIdaho Design <bdortch@netw.com>
//***********************************************************************

// The following 3 functions are required to set and get cookies.

function getCookieVal (offset) 
   {

   var endstr = document.cookie.indexOf (";", offset);

   if (endstr == -1)

      endstr = document.cookie.length;

   return unescape(document.cookie.substring(offset, endstr));

   }

function GetCookie (name) 
   {

   var arg = name + "=";

   var alen = arg.length;

   var clen = document.cookie.length;

   var i = 0;

   while (i < clen) 
      {

      var j = i + alen;

      if (document.cookie.substring(i, j) == arg)

         return getCookieVal (j);

      i = document.cookie.indexOf(" ", i) + 1;

      if (i == 0) break; 

      }

   return null;

   }

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.toGMTString())) +

        ((path == null) ? "" : ("; path=" + path)) +

        ((domain == null) ? "" : ("; domain=" + domain)) +

        ((secure == true) ? "; secure" : "");

   }

// Called by Delete Cookie button - removes cookie set by this example.

function DeleteCookie (name) {
	if (GetCookie(name) != null) {	
	var exp = new Date();
	exp.setTime (exp.getTime() - 1000000000);  // This cookie is history
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
//	alert("\n\nih... esqueci o seu nome!");
	}
//	else alert("\n\nacho que nunca fomos apresentados...");	
}

// Displays ID followed by a comma and a space

function idCommaName () {
if(GetCookie('Ritz_id') != null) {
	document.write(', ');
	document.write(GetCookie('Ritz_id'));
	}
}
function idName () {
if(GetCookie('Ritz_id') != null) {
	document.write(' ');
	document.write(GetCookie('Ritz_id'));
	}
}

function emailEntry () {
if(GetCookie('Ritz_email') != null) {
	document.write('&lt;');
	document.write(GetCookie('Ritz_email'));
	document.write('&gt;');
	
	}
}

function emailCheck () {
if(GetCookie('Ritz_email') != null && (GetCookie('Ritz_email') != "Digite Seu Email Aqui")) {
	document.write('Este email &lt;');
	document.write(GetCookie('Ritz_email'));
	document.write('&gt; &eacute; inv&aacute;lido ou foi digitado com erros.');	
	} else {
	document.write('O campo de email n&atilde;o foi preenchido.');	
	}
}

// Displays prompt box if ID cookie doesn't exist.

function idPrompt () {
	if(GetCookie('Ritz_id') == null) {
   		var Ritz_id_Name =  prompt ("Meu apelido e\' Ritchie.\nE o seu...?", "" );
		if (Ritz_id_Name != null && Ritz_id_Name != "") {
		var expdate = new Date (); 
		expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
		SetCookie('Ritz_id', Ritz_id_Name, expdate);  
		}
	}
idCommaName ();

}

function grabNewEmail () {
	if(GetCookie('Ritz_email') == null) {
   		var Ritz_email_Name =  document.rform.address.value;
//alert(Ritz_email_Name);
		if (Ritz_email_Name != null && Ritz_email_Name != "") {
		var expdate = new Date (); 
		expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
		SetCookie('Ritz_email', Ritz_email_Name, expdate);  
		}
	}
}

function wipeOldEmail () {
DeleteCookie('Ritz_email');
}


//*******************************************************************************************
//
// Today's Date Example
//
// Developed by Timothy Wallace ,  timothy@essex1.com
//
//******************************************************************************************
brVer = parseInt(navigator.appVersion);
var now = new Date();
if(brVer >=4) {var yr = now.getFullYear();}else{var yr = "";}
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;

var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();


   if(dName==1) Day = "Domingo";
   if(dName==2) Day = "Segunda-feira";
   if(dName==3) Day = "Ter&ccedil;a-feira";
   if(dName==4) Day = "Quarta-feira";
   if(dName==5) Day = "Quinta-feira";
   if(dName==6) Day = "Sexta-feira";
   if(dName==7) Day = "Sabado";

   if(mName==1) Month="de Janeiro";
   if(mName==2) Month="de Fevereiro";
   if(mName==3) Month="de Mar&ccedil;o";
   if(mName==4) Month="de Abril";
   if(mName==5) Month="de Maio";
   if(mName==6) Month="de Junho";
   if(mName==7) Month="de Julho";
   if(mName==8) Month="de Agosto";
   if(mName==9) Month="de Setembro";
   if(mName==10) Month="de Outuburo";
   if(mName==11) Month="de Novembro";
   if(mName==12) Month="de Dezembro";


// String to display current date.

   var todaysDate =(" "

       + Day

       + ", "

       + dayNr

       + " "

       + Month

       + " "

       + yr
);
