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" : "");
    }
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;
   }

// Below is javascript for navigation image rollovers - could be CSS replace too
imagepath = 'http://www.riograndeins.com/images/nav/';
var goodBrowser = 0;
// let's make sure you can use this script!!
if(navigator.appName == "Netscape")
{
        if(parseInt(navigator.appVersion) >=3)
                {
                 goodBrowser=1;
                }
}
if(navigator.appName == "Microsoft Internet Explorer")
{
        if(parseInt(navigator.appVersion) >=4)
                {
                goodBrowser=1;
                }
        }
if(goodBrowser == 1)
{
// preload onmouseover images
homeImage = new Image();
homeImage.src = imagepath + "a.gif";
aboutImage = new Image();
aboutImage.src = imagepath + "a.gif";
contactImage = new Image();
contactImage.src = imagepath + "a.gif";
azlocImage = new Image();
azlocImage.src = imagepath + "a.gif";
calocImage = new Image();
calocImage.src = imagepath + "a.gif";
nmlocImage = new Image();
nmlocImage.src = imagepath + "a.gif";
utlocImage = new Image();
utlocImage.src = imagepath + "a.gif";
serviceImage = new Image();
serviceImage.src = imagepath + "a.gif";
policyImage = new Image();
policyImage.src = imagepath + "a.gif";
agentImage = new Image();
agentImage.src = imagepath + "a.gif";
projectImage = new Image();
projectImage.src = imagepath + "a.gif";
faqImage = new Image();
faqImage.src = imagepath + "a.gif";
// preload onmouseout images
homeImage1 = new Image();
homeImage1.src = imagepath + "up.gif";
aboutImage1 = new Image();
aboutImage1.src = imagepath + "up.gif";
contactImage1 = new Image();
contactImage1.src = imagepath + "up.gif";
azlocImage1 = new Image();
azlocImage1.src = imagepath + "up.gif";
calocImage1 = new Image();
calocImage1.src = imagepath + "up.gif";
nmlocImage1 = new Image();
nmlocImage1.src = imagepath + "up.gif";
utlocImage1 = new Image();
utlocImage1.src = imagepath + "up.gif";
serviceImage1 = new Image();
serviceImage1.src = imagepath + "up.gif";
policyImage1 = new Image();
policyImage1.src = imagepath + "up.gif";
agentImage1 = new Image();
agentImage1.src = imagepath + "up.gif";
projectImage1 = new Image();
projectImage1.src = imagepath + "up.gif";
faqImage1 = new Image();
faqImage1.src = imagepath + "up.gif";
}
// this is the rollover
function over_img(imagename, action) {
   if(goodBrowser==1)
   {
           if(action=='over') {document[imagename].src=eval(imagename + 'Image.src')}
           if(action=='out') {document[imagename].src=eval(imagename + 'Image1.src')}
	}
}

// Cookie setting routine
// last modified: 9/12/07 by NET MAN
// All of the below is for setting cookies to determine referrers in forms
// We set the cookie with a 300 day expiration
 // setup some locals for this setting routine
 var expdate = new Date();
 expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 300));
// First check to see if this visitor already has an identity
// If so, do not run any setting routines - the reason for this is that
// We only want to know here where our first visit to the RGI site (in the last 300 days)
// came from, not every link (they may return to google for a re-visit to the site and search on the domain)
var is_set;
// For testing, let's allow cookie to be set all the time
if(!(is_set = GetCookie("Referer")))
{
 if (refer != "(none)")
 {
// Do not set cookie if Referer matches one of these
var pos = refer.indexOf("riograndeins.com");
var pos2 = refer.indexOf("riograndeinsurance.com");
var here = refer.indexOf("none");
if ((pos == -1) && (pos2 == -1) && (here == -1))
  {
  SetCookie("Referer", refer, expdate, "/", ".riograndeins.com", false);
  }
 } // end of routine to set cookie based on referring URL, if (refer != "(none)")
} // end of routine if cookie is NOT set

// Below sets cookie if current DOM location includes shopping_com which overrides
// referring URL to let us know sales based on Google.com listings
// And, the cookie gets set regardless of whether a previous cookie is in place
var adqueryShopping = refer.indexOf("shopping_com");
if (adqueryShopping != -1)
  {
SetCookie("Referer", "http://Shopping_com_Listings.com", expdate, "/", ".riograndeins.com", false);
  } // End of setting Shopping.com cookie

