/*
 * Copyright 2003-2006, Peter Rowntree. All Rights Reserved.
 * http://www.hdyn.com/wr/common/contact.php?addr=pr
 */
 
var c_yrSecs=31557600;

//if abs(sDeltaEx) < c_yrSecs, uses ms resolution
function buildExpiry(sDeltaEx)
{
   var d=new Date();
   if(sDeltaEx > -c_yrSecs && sDeltaEx < c_yrSecs)
      d.setTime(d.getTime() + sDeltaEx * 1000);
   else
      d.setUTCFullYear(d.getFullYear()+sDeltaEx/c_yrSecs);
   var dStr=d.toGMTString();
   return "expires="+dStr;
}

//returns the decoded cookie, or ""
function readCookie(name)
{
   var metaCookie=document.cookie.toString();
   if(name == "" || metaCookie == "")
      return "";
   var kvPairs=metaCookie.split(/;[ ]?/);
   for(var i=0; i < kvPairs.length; ++i)
   {
      var onePair=kvPairs[i].split("=");
      if(onePair.length == 2 && onePair[0] == name)
         return unescape(onePair[1]);
   }
   return "";
}

//encodes & writes the cookie
//setting sDeltaEx to < 0 will delete the cookie
//+"; domain="+location.hostname chokes modern bowsers
function writeCookie(name,val,sDeltaEx)
{
   if(isNaN(sDeltaEx) && sDeltaEx.indexOf("y") == 0)
      sDeltaEx=sDeltaEx.substr(1)*c_yrSecs;
   document.cookie=name+"="+escape(val.toString())
      +"; path=/"
      +"; "+buildExpiry(sDeltaEx);
}

function sslPrefix()
{
  	var h=location.hostname;
   if(h == "localhost" || h == "192.168.0.1")
   	return "http://192.168.0.1:8084";
   return "https://www.22true.com";
}