// global.js

// Universal Coookie Functions
var today = new Date();
var expiration = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000 * 10);

function setCookie(name, value) {
  
  var curCookie = getCookieAll("answerlivec");
  var newCookie = "";

  if (curCookie != null)  {
 	var prefix = "^^" + name + "=";
 	var begin = curCookie.indexOf(prefix);
	var end = curCookie.indexOf("^^", begin + 3);
  	if (end == -1)
   		end = curCookie.length;
  	if (begin > -1) {
		if (begin == 0)  {
		   newCookie = curCookie.substring(end, curCookie.length);

		}
		else  {
 		   newCookie = curCookie.substring(0, begin) + curCookie.substring(end, curCookie.length);

		}
  	}
	else  {
		newCookie = curCookie;
	}
  }
  
  curCookie = "answerlivec=" + newCookie + "^^" + name + "=" + (value) +  
      ((expiration) ? "; path=/; expires=" + expiration.toGMTString() : "");
	  

  document.cookie = curCookie;

}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = getCookieAll("answerlivec");
  if (dc == null) return "";
  var prefix = name + "=";
  var begin = dc.indexOf("^^" + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin == -1) return "";
  } else
    begin += 2;
  var end = dc.indexOf("^^", begin + 3);
  if (end == -1)  {
    end = dc.length;
  }
  return (dc.substring(begin + prefix.length, end));
}


// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookieAll(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return (dc.substring(begin + prefix.length, end));
 
}

function clearCookie(name)
{
	document.cookie = name + "=" + "; expires=Tue, 01-Jan-80 00:00:01 GMT; path=/";
}


// Set Phone Number
var alsite = getCookie("alsite");
var alsite_phone = "800-243-9712";
var alsite_phonep = "(800) 243-9712";
var imgLogo = "answerlive_logo.gif";
var imgPhone = "phone_number.gif";
var imgLogolp = "answerlive_logo.gif";
var imgPhonelp = "phone_number.gif";

if (alsite == undefined || alsite == null)
	alsite = "";
if (alsite == "T") {
	alsite_phone = "800-753-0140";
	alsite_phonep = "(800) 753-0140";
	imgLogo = "answerlive_logo_land.gif";
	imgPhone = "phone_number_land.gif";
	imgLogolp = "answerlive_logo_land.gif";
	imgPhonelp = "phone_number_land.gif";
}

imgLogo = "<img src='images/" + imgLogo + "' width='235' height='110' border='0' alt='AnswerLive'>";
imgPhone = "<img src='images/" + imgPhone + "' name='imgPhone' id='imgPhone' width='166' height='30' alt='Telephone Answering Services'>";

imgLogolp = "<img src='../images/" + imgLogolp + "' width='235' height='110' border='0' alt='AnswerLive'>";
imgPhonelp = "<img src='../images/" + imgPhonelp + "' name='imgPhonelp' id='imgPhonelp' width='166' height='30' alt='Telephone Answering Services'>";


