function WriteCookie (cookieName, cookieValue, expiry)
{
  var expDate = new Date();
  if(expiry)  {
    expDate.setTime (expDate.getTime() + expiry);
    document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString();

  }
  else
  {
    document.cookie = cookieName + "=" + escape(cookieValue);
  }
}

function setCookie (CookieName, CookieValue)
{
    WriteCookie(CookieName, CookieValue, 0);
}

function ReadCookie (CookieName) {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces;
  var ReturnValue = "";
  var ReturnValue2 = "";
  var x = 0;

  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {

    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ') {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }

    if (CookiePieces[0] == CookieName) {
      ReturnValue = CookiePieces[1];
      ReturnValue2 = CookiePieces[0];
    }
  }
  document.forms[0].elements[1].value = ReturnValue2;
  document.forms[0].elements[2].value = ReturnValue;
}

function AppendCookie (CookieName, itemToAppend) {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces;
  var CookieValue = "";
  var CookieFound = 0;
  var x = 0;
  for (x = 0; ((x < SetSize) && (CookieValue == "")); x++) {

    CookiePieces = CookieSet[x].split ('=');
    if (CookiePieces[0].substring (0,1) == ' ') {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }

    if (CookiePieces[0] == CookieName) {
      CookieFound = 1;
      CookieValue = unescape(CookiePieces[1]) + ',' + itemToAppend;
      WriteCookie(CookiePieces[0], CookieValue, 0);
    }

  }
  if (CookieFound == 0)  {
    WriteCookie(CookieName, itemToAppend, 0);
  }
}

function RemoveCookieItem (CookieName, itemToRemove) {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces;
  var CookieSubPieces;
  var CookieValue = "";
  var SubSetSize;


  var x = 0;
  var i = 0;

  for (x = 0; ((x < SetSize) && (CookieValue == "")); x++) {

    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ') {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }

    if (CookiePieces[0] == CookieName) {
      CookieSubPieces = unescape(CookiePieces[1]).split(',');
      SubSetSize = CookieSubPieces.length;
      for (i = 0; i < SubSetSize; i++) {
        if (CookieSubPieces[i] != itemToRemove)  {
          CookieValue = CookieValue + ',' + CookieSubPieces[i];
        }
      }
      if (CookieValue == ',')  {
        CookieValue = '';
      }
      WriteCookie(CookiePieces[0], CookieValue, 0);
    }

  }
}

function ValidateCookie(CookieName)  {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces;
  var CookieValue = "";
  var CookieFound = 0;
  var x = 0;

  for (x = 0; ((x < SetSize) && (CookieValue == "")); x++) {
    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ') {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }
    if (CookiePieces[0] == CookieName) {
      CookieFound = 1;
      return;
    }
  }

  if (CookieFound == 0)  {
    WriteCookie(CookieName, '1', 0);
  }
}

function concatSelect(f, separate) {
    if (!separate) {
        separate = '|';
    }

    for (var i = 0; i < f.elements.length; i++) {
        if (f.elements[i].type == 'select-multiple') {
            var temp = '';
            for (var k = 0; k < f.elements[i].length; k++) {
                if (f.elements[i].options[k].selected) {
                    if (temp == '') {
                        temp = f.elements[i].options[k].value;
                    } else {
                        temp = temp + separate + f.elements[i].options[k].value;
                    }
                    f.elements[i].options[k].selected = false;
                }
            }

            oldName = f.elements[i].name;
            endex = oldName.indexOf("Select");
            newName = oldName.substring(0, endex);
            for (var j = 0; j < f.elements.length; j++) {
                if (f.elements[j].name == newName && f.elements[j].type != 'submit') {
                    f.elements[j].value = temp;
                }
            }
        }
    }

    return true;
}

function replaceMainImage(imagename) {
        document.getElementById('mainimage').src = imagename;
}

if (top.location != self.location) {top.location = self.location;}

var preview;
function Start(URL1, URL2, URL3, URL4, URL5, URL6, URL7, URL8, WIDTH, HEIGHT) {
        windowprops = "left=10,top=10,width=" + (WIDTH+50) + ",height=" + (HEIGHT+80) + ';alwaysRaised=yes';
        text  = '<html><head><title></title>';
        text += '<script language=javascript>function replaceMainImage(imagename){ document.getElementById(\'mainimage\').src = imagename; }<\/script>';
        text += '</head><body bgcolor="#EFEFEF" link="#000000" alink="#000000" vlink="#000000">';
        text += '<table width="299" align="center"><tr><td colspan="5" align="center">';
        text += '<img src=' + URL1 + ' " border="1" id="mainimage">';
        text += '</td></tr><tr><td width="20%" align="center">';
        if (URL1) {
                text += '<a href="javascript:replaceMainImage(\'' + URL1 + '\');"><img src="' + URL1 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td><td width="20%" align="center">';
        if (URL2) {
                text += '<a href="javascript:replaceMainImage(\'' + URL2 + '\');"><img src="' + URL2 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td><td width="20%" align="center">';
        if (URL3) {
                text += '<a href="javascript:replaceMainImage(\'' + URL3 + '\');"><img src="' + URL3 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td><td width="20%" align="center">';
        if (URL4) {
                text += '<a href="javascript:replaceMainImage(\'' + URL4 + '\');"><img src="' + URL4 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td></tr><tr><td width="20%" align="center">';
        if (URL5) {
                text += '<a href="javascript:replaceMainImage(\'' + URL5 + '\');"><img src="' + URL5 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td><td width="20%" align="center">';
        if (URL6) {
                text += '<a href="javascript:replaceMainImage(\'' + URL6 + '\');"><img src="' + URL6 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td><td width="20%" align="center">';
        if (URL7) {
                text += '<a href="javascript:replaceMainImage(\'' + URL7 + '\');"><img src="' + URL7 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td><td width="20%" align="center">';
        if (URL8) {
                text += '<a href="javascript:replaceMainImage(\'' + URL8 + '\');"><img src="' + URL8 + '" border="1" height="40" width="53"></a>';
        }
        text += '</td></tr></table>';
        text += '<P>';
        text += '<center><a href="JavaScript:window.close();"><img src="http://www.augustarealestate.com/prudential/images/close.gif" alt="Click to close this window" border=0></a>';
        text += '</center></body></html>';
        if ((preview) && (document.all)) {
                preview.close();
        }
        preview = window.open("", "preview", windowprops);
        preview.document.open();
        preview.document.write(text);
        preview.document.close();
}

function new_window(url) {
        link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=620,height=600,left=80,top=50");
}