var aptIDG=null;
var mapTypeG=null;
var onlinePG=null;
var a40G = null;
var leadBoth = null;

/* General Site */

function callEvent28(plusone) {
    SocialEvent28('gplus');
} 

function SocialEvent28(socialeng) {
    var s = s_gi(sitecatalyst_account_id);
    var ev10 = s.pageName + "_" + socialeng;
    var txtsoc = "Social" + " " + socialeng
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar10,prop34,eVar7,events';
    s.linkTrackEvents = 'event28';
    s.events = 'event28';
    s.eVar10 = ev10;    
    s.tl(this, 'e', txtsoc);
    ClearOmnitureCodes();
}

function addCookie(name, value, days)
{    
   if(days)
   {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toUTCString();
   }
   else
    var expires = "";    
   
   document.cookie = name+"="+value+expires+"; domain="+afdomain+"; path=/";
      
   if (document.cookie.indexOf(name,0) < 0) 
   {
      var msg = document.getElementById("nocookie");
      if (msg != null) msg.innerHTML = "Cookies must be enabled to use the site.";
   }    
}

function getCookie(c_name)
{
  if (document.cookie.length>0)
  {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
      { 
        c_start=c_start + c_name.length+1; 
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
      } 
  }
  return "";
}

function simplewait(millis) 
{
   var date = new Date();
   var curDate = null;

   do 
   { 
      curDate = new Date(); 
   }
   while(curDate-date < millis);

}


/* Singin/register */

function OmnitureModalRegister() {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,events';
    s.linkTrackEvents = 'event1';
    s.events = 'event1';
    s.t();
    ClearOmnitureCodes();
}

/* Home/market page */

function OmnitureBrowseOverlay(p4, p39) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,eVar39,prop1,prop2,prop3,prop4,prop5,eVar4,eVar5,eVar42,prop34,prop39';    
    s.pageName = 'home-browse';
    s.channel = 'home';
    s.prop1 = 'home-browse';
    s.prop2 = 'home-browse';
    s.prop3 = 'home-browse';
    s.prop4 = p4;
    s.eVar4 = p4;
    s.prop39 = p39;
    s.eVar39 = p39;
    s.t();
    //s.tl(this, 'o', 'Home Browse');
    ClearOmnitureCodes();
}

function OmnitureFeaturedShow1(apartmentId, onlinePackageId)
{
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,events,products';
    s.linkTrackEvents='event7';
    s.events='event7';
    s.pageName = page_name;
    s.server = page_server;
    s.channel = page_eVar40;        
    s.products=';' + apartmentId +';;;event7=1;evar33=' + onlinePackageId + '|evar40=' + page_eVar40;
    s.tl(this, 'o', 'Featured Apartment');
    ClearOmnitureCodes();
}


function OmnitureFeaturedClick(apartmentId, onlinePackageId)
{
    //keep function for flash call
    //omniture code will be set at the link via ListingProvider web method
}

function OmnitureFeatured(apartmentId, onlinePackageId)
{
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar1,eVar2,eVar3,prop34,events,products';
    s.linkTrackEvents='event8';
    s.events = 'event8';
    s.eVar1=apartmentId;
    s.eVar2=apartmentId;
    s.eVar3="featured";
    var eVar40 = getCookie('PageRef');
    s.products=';' + apartmentId + ';;;event8=1;evar33=' + onlinePackageId + '|evar40=' + eVar40;
    s.tl(this, 'o', description);
    ClearOmnitureCodes();
    addCookie('add40','true',7);
}


function OmnitureApartmentImpression(apartmentId, onlinePackageId, description, eVar40Value)
{
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar33,prop34,events,products';
    s.linkTrackEvents = 'event7';
    s.events = 'event7';
    s.products = ';' + apartmentId + ';;;event7=1;evar33=' + onlinePackageId + '|evar40=' + eVar40Value;
    s.tl(this, 'o', description);
    ClearOmnitureCodes();
}

function OmnitureApartmentClick(apartmentId, onlinePackageId, description)
{
    OmnitureFeaturedClick(apartmentId, onlinePackageId, description, 'srch-sugg')
}

function OmnitureApartmentClick(apartmentId, onlinePackageId, description, eVar40Value)
{
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,eVar40,prop5,eVar5,prop16,eVar16,eVar42,eVar1,eVar3,prop34,events,products';
    s.pageName = 'property details';
    s.linkTrackEvents = 'event8';
    s.events = 'event8';    
    s.eVar1 = apartmentId;
    s.eVar3 = description;
    s.products = ';' + apartmentId + ';;;event8=1;evar33=' + onlinePackageId + '|evar40=' + eVar40Value;
    s.tl(this, 'o', description);
    ClearOmnitureCodes();    
}

function OmnitureGetYourMoveOn(linktype,variable)
{
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = "eVar12,eVar34,prop5,prop16,eVar5,eVar16,eVar42,prop34,events";
    s.linkTrackEvents="event6";
    s.events="event6";
    s.eVar12 = linktype;
    if (variable != null && variable != undefined) {
        s.prop16 = variable;
        s.eVar16 = variable;
    }
    if (variable == 'cyc')
        s.tl(this, 'e', 'Get Your Move on');
    else
        s.tl(this, 'e', 'Get Your Credit Score');
    ClearOmnitureCodes();    
}

/* Search Results page */

function OmnitureEvent9(text) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = "eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar44,prop34,events";
    s.linkTrackEvents = "event9";
    s.events = "event9";
    s.eVar44 = text;
    s.tl(this, 'o', text);
    ClearOmnitureCodes();
}

function OmnitureShowOnMap(apartmentId, onlinePackageId, map, op) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = "eVar33,eVar34,eVar36,prop5,eVar5,prop16,eVar16,eVar42,prop8,prop34,prop36,events,products"; //eVar44
    s.linkTrackEvents = "event20";
    s.events = "event20";
    if (op == '1') {
        s.products = ';' + aptIDG + ';;;;eVar33=' + onlinePG;
        s.prop8 = mapTypeG;
    }
    else if (op == '2') {
        s.products = ';' + apartmentId + ';;;;eVar33=' + onlinePackageId;
        s.prop8 = map;
    }
    s.eVar36 = "map and directions tab";
    s.prop36 = "map and directions tab";
    s.tl(this, 'o', 'Show on Map');
    ClearOmnitureCodes();
}

    
function OmnitureVirtualTour(add40, aptId, vtType, disp,url)
{            
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar9,eVar17,eVar33,events,products';
    s.linkTrackEvents='event11';
    s.events='event11';
    s.eVar9=aptId;
    s.eVar17=vtType;
    var rr = aptId;
    var ee = vtType;    
    if(add40 == "True")
    {
        var eVar40 = getCookie('PageRef');
        s.products=';'+s.eVar9+';;;;eVar33='+disp+"|eVar40="+eVar40;
    }
    else
    {
        s.products=';'+s.eVar9+';;;;eVar33='+disp;
    }    
    s.tl(this, 'e', 'Virtual Tour');
    ClearOmnitureCodes();
    window.open(url, "_blank")
    return false;
}

function OmniturePhotosVideoLink(add40, aptId, displayPoint, event, text) {
    var s = s_gi(sitecatalyst_account_id);
    var eVar40 = getCookie('PageRef');
    if (event == 'event15') {
        s.linkTrackVars = 'eVar9,eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop1,prop2,prop3,prop7,prop34,events,products';
    }
    else if (event == 'event11') {
        s.linkTrackVars = 'eVar9,eVar17,eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,events,products';
    }
    s.linkTrackEvents = event;
    s.events = event;
    s.eVar9 = aptId;
    s.eVar17 = "other";
    if (add40 == "True") {
        s.products = ';' + s.eVar9 + ';;;;eVar33=' + displayPoint + "|eVar40=" + eVar40;
    }
    else {
        s.products = ';' + s.eVar9 + ';;;;eVar33=' + displayPoint;
    }
    s.tl(this, 'e', text);
    ClearOmnitureCodes();
}


function OmnitureEvent19(add40, aptId, displayPoint, ev6, text) {    
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar6,events,products';
    s.linkTrackEvents = 'event19';
    s.events = 'event19';
    s.eVar6 = ev6;
    if (add40 == "True") {
        var eVar40 = getCookie('PageRef');
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint + '|eVar40=' + eVar40;
    }
    else {
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint;
    }
    if (text == undefined || text == null || text == "")
        text = 'web';
    
    s.tl(this, 'e', text);
    ClearOmnitureCodes();
}


function OmnitureFloorPlan(apt, displayPoint)
{
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,events,products';
    s.linkTrackEvents='event16';
    s.events='event16';        
    s.products=';'+apt+';;;;eVar33='+displayPoint;    
    s.tl(this, 'o', 'Floor Plan View');
    ClearOmnitureCodes();
}


//Use this for Send/Save and LogCheckAvailability
function OmnitureSendSaveCheck(add40, aptId, displayPoint, actionItem) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,events,products';
    s.linkTrackEvents = 'event20';
    s.events = 'event20';
    s.eVar36 = actionItem;
    s.prop36 = actionItem;
    if (add40 == "True") {
        var eVar40 = getCookie('PageRef');
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint + '|eVar40=' + eVar40;
    }
    else {
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint;
    }
    s.tl(this, 'o', actionItem);
    ClearOmnitureCodes();
}


function OmnitureOrderMagazine(pagename)
{    
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar7,events';
    s.linkTrackEvents='event5';
    s.events='event5';
    s.eVar7 = s.pageName;    
    s.tl(this, 'e', 'Order Magazine');    
    ClearOmnitureCodes();
}

function OmnitureFootLinks(pagename) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34';    
    s.tl(this, 'e', '');    
    ClearOmnitureCodes();
}

function OmnitureHoverBox(apt, displayPoint)
{
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,prop34,eVar11,eVar33,eVar42,products,events,prop11';
    s.eVar11='RESHBXREQ';
    s.prop11='RESHBXREQ';    
    s.products=';'+apt+';;;;eVar33='+displayPoint;
    s.tl(this, 'o', 'Hover Box Free Brochure');
    ClearOmnitureCodes();    
}

function OmnitureLeadForm(apt, displayPoint, linktype)
{
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar11,eVar33,products,events,prop11';
    s.eVar11=linktype;
    s.prop11=linktype;    
    s.products=';'+apt+';;;;eVar33='+displayPoint;
    s.tl(this, 'o', 'Free Brochure');
    ClearOmnitureCodes();    
}

function OmnitureMapViewClick(aptId, displayPoint, srchType)
{           
    var s=s_gi(sitecatalyst_account_id);
 
    s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar1,eVar2,eVar3,eVar33,eVar40,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar8,events,products';
    s.linkTrackEvents='event10';
    s.events='event10';
    s.eVar1=aptId;
    s.eVar2=aptId;
    s.eVar3=srchType;
    s.eVar8=aptId;       
    var eVar40 = getCookie('PageRef');
    s.products=';' + aptId +';;;;evar33='+ displayPoint + '|evar40=' + eVar40;
    s.tl(this, 'o', 'Map View Click');    
    ClearOmnitureCodes();
}

function OmnitureAptSavedWithLead()
{
    //Event14
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,events';
    s.linkTrackEvents='event14';
    s.events='event14';         
    s.tl(this, 'o', 'Save Apartment'); 
    ClearOmnitureCodes();
}

function OmnitureLeadSubmitted(apt, displayPoint, add40,marketID, uniqueUser)
{
    //Event12
    var s=s_gi(sitecatalyst_account_id); 
    var id = apt;
    var disp = displayPoint;
    var add40v = add40;
    s.linkTrackVars = 'eVar34,eVar15,prop5,prop16,prop11,eVar5,eVar16,eVar11,eVar41,eVar42,eVar43,prop34,events,products';
    s.linkTrackEvents='event12';
    s.events = 'event12';
    s.eVar41 = "1";
    if (leadBoth != null)
        if (leadBoth == "1")
            s.eVar15 = "new";
        else
            s.eVar15 = "control";
    if (typeof (useTip) == "undefined")
        s.eVar43 = 'n';
    else
        s.eVar43 = useTip;    
    if(id == null || id == "" || id == "missing")
        if(aptIDG != null)
            id = aptIDG;
    if(disp == null || disp == "")
        if(onlinePG != null)
            disp = onlinePG;
    if(add40v == 'True')
    {
        var eVar40 = getCookie('PageRef');
        s.products=';'+id+';;;;eVar33='+disp+'|eVar40='+eVar40;
    }
    else
    {
        s.products=';'+id+';;;;eVar33='+disp;
    }
    if (typeof (marketID) != "undefined") {
        s.prop34 = marketID;
        s.eVar34 = s.prop34;
    }
    if (typeof (uniqueUser) != "undefined") {
        s.eVar42 = uniqueUser;
    }        
    s.tl(this, 'o', 'Lead Submission'); 
    ClearOmnitureCodes();
}

function OmnitureLeadSubmittedCompare(apt, add40, marketID, uniqueUser) {
    //Event12
    var s = s_gi(sitecatalyst_account_id);
    var id = apt.split(',');
    var disp;    
    var add40v = add40;
    s.linkTrackVars = 'eVar34,eVar15,prop2,prop5,prop16,prop11,eVar5,eVar16,eVar8,eVar11,eVar41,eVar42,eVar43,prop34,events,products';
    s.linkTrackEvents = 'event12';
    s.events = 'event12';
    s.eVar41 = id.length.toString();
    if (leadBoth != null)
        if (leadBoth == "1")
            s.eVar15 = "new";
        else
            s.eVar15 = "control";
    s.products = "";
    if (usecaptcha) {
        s.prop2 = 'y';
        s.eVar8 = 'y';
        usecaptcha = false;
    }
    else {
        s.prop2 = 'n';
        s.eVar8 = 'n';
    }
    if (typeof (useTip) == "undefined")
        s.eVar43 = 'n';
    else
        s.eVar43 = useTip;    
    if (add40v == 'True') {
        var eVar40 = getCookie('PageRef');            
    
        for (index = 0; index < id.length; index++) {
            disp = id[index].split('|')[1].toString();                        
            s.products = ';' + id[index].split('|')[0].toString() + ';;;;eVar33=' + disp + '|eVar40=' + eVar40;                    
        }                        
    }
    else {        
        for (index = 0; index < id.length; index++) {
            disp = id[index].split('|')[1].toString();            
            s.products = ';' + id[index].split('|')[0].toString() + ';;;;eVar33=' + disp;                            
        }                
    }
    if (typeof (marketID) != "undefined") {
        s.prop34 = marketID;
        s.eVar34 = s.prop34;
    }
    if (typeof (uniqueUser) != "undefined") {
        s.eVar42 = uniqueUser;
    }
    s.tl(this, 'o', 'Lead Submission Compare');
    ClearOmnitureCodes();
    $("#name2").text(sname);
}

function OmnitureLeadSubmittedDetails(apt, displayPoint, add40, detcode)
{
    //Event12
    var s=s_gi(sitecatalyst_account_id); 
    var id = apt;
    var disp = displayPoint;
    var add40v = add40;
    s.linkTrackVars = 'eVar34,eVar15,prop5,eVar5,prop16,eVar16,eVar41,eVar42,eVar11,eVar43,prop11,prop34,events,products';
    s.linkTrackEvents='event12';
    s.events = 'event12';
    s.eVar41 = "1";
    s.eVar43 = useTip;
    s.eVar11 = detcode;
    s.prop11 = detcode;
    if (leadBoth != null)
        if (leadBoth == "1")
            s.eVar15 = "new";
        else
            s.eVar15 = "control";
    
    if(id == null || id == "" || id == "missing")
        if(aptIDG != null)
            id = aptIDG;
    if(disp == null || disp == "")
        if(onlinePG != null)
            disp = onlinePG;
    if(add40v == 'True')
    {
        var eVar40 = getCookie('PageRef');
        s.products=';'+id+';;;;eVar33='+disp+'|eVar40='+eVar40;
    }
    else
    {
        s.products=';'+id+';;;;eVar33='+disp;
    }
                
    s.tl(this, 'o', 'Lead Submission'); 
    ClearOmnitureCodes();
}

function OmnitureSendToFriendOrMobile(actionItem,vapt,displayPoint,vadd40)
{
    var s=s_gi(sitecatalyst_account_id); 
    var add40 = vadd40;
    var apt = vapt;
    //Event20
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,events,products';
    s.linkTrackEvents='event20';
    s.events='event20'; 
    s.eVar36= actionItem; 
    s.prop36= actionItem; 
    if(add40 == 'True')
    {
        var eVar40 = getCookie('PageRef');
        s.products=';'+apt+';;;;eVar33='+displayPoint+'|eVar40='+eVar40;
    }
    else
    {
        s.products=';'+apt+';;;;eVar33='+displayPoint;
    }
    s.tl(this, 'o', actionItem); 
    ClearOmnitureCodes();         
}

function OmnitureSignIn(source) {
    var s = s_gi(sitecatalyst_account_id);
    if (source == '1') {
        s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,events';
    }
    else if (source == '2') {
        s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar39,prop34,prop39,events';
        s.eVar39 = "fbc";
        s.prop39 = "fbc";
    }
    s.linkTrackEvents = 'event2';
    s.events = 'event2';        
    s.tl(this, 'o', 'Sign In');
    ClearOmnitureCodes();
}


function FBOmnitureRegister() {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar39,prop34,prop39,events';
    s.linkTrackEvents = 'event1';
    s.eVar39 = "fbc";
    s.prop39 = "fbc";
    s.events = 'event1';
    s.tl(this, 'o', 'Register');
    ClearOmnitureCodes();
}

/* Community Details page */

function OmnitureLeadImpressions()
{
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars='eVar10,eVar33,eVar34,eVar40,prop5,eVar5,prop16,eVar16,eVar42,prop34,events,products';
    s.linkTrackEvents='event7';
    s.events='event7';            
    s.eVar10 = 'lead confirmation';
    s.products=impressions;
    s.tl(this, 'o', 'Lead Confirmation Impressions');
    ClearOmnitureCodes();
}


function OmnitureGetDirections20(add40, aptId, displayPoint)
{                            
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,events,products';
    s.linkTrackEvents='event20';
    s.events='event20';
    s.eVar36='Get Directions';
    s.prop36='Get Directions';
    if(add40 == "True")
    {
        var eVar40 = getCookie('PageRef');
        s.products=';'+ aptId +';;;;eVar33='+ displayPoint +'|eVar40='+eVar40;
    }
    else
    {
        s.products=';'+ aptId +';;;;eVar33='+ displayPoint;
    }
    s.tl(this, 'o', 'Get Directions');
    ClearOmnitureCodes();                                
}


function OmnitureContactApt(add40, aptId, displayPoint, codename, text) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar11,eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,products,prop11';
    s.eVar11 = codename;
    s.prop11 = codename;
    if (add40 == "True") {
        var eVar40 = getCookie('PageRef');
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint + '|eVar40=' + eVar40;
    }
    else {
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint;
    }
    s.tl(this, 'o', text);
    ClearOmnitureCodes();
}

                                                  
function SendOmnitureCodesForTabs(add40, aptId, displayPoint, TabName, OmnitureChannelName, OmnitureSettingsLvl2, OmnitureSettingsLvl3, ServerName)
{
    ClearOmnitureCodes();
    var s=s_gi(sitecatalyst_account_id);

    if(TabName == 'find out more direct')
    {
        s.eVar11='FINDOUTMORE';
        s.prop11='FINDOUTMORE';
        TabName = 'find out more';
    }

    s.pageName = OmnitureSettingsLvl3 + ':' + TabName;
    s.prop1 = OmnitureSettingsLvl2;
    s.prop2 = OmnitureSettingsLvl3;
    s.prop3 = OmnitureSettingsLvl3 + ':' + TabName;
    s.prop7 = aptId;
    s.server = ServerName;
    s.channel = OmnitureChannelName;
    
    var s_code;
    if(TabName == 'floor plan')
    {
        s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop7,prop34,events,products';
        s.linkTrackEvents='event16';
        s.events='event16';
        if(add40 == "True")
        {
            var eVar40 = getCookie('PageRef');
            s.products=';'+ aptId +';;;;eVar33='+ displayPoint +'|eVar40='+eVar40;
        }
        else
        {
            s.products=';'+ aptId +';;;;eVar33='+ displayPoint;
        }                                                                      
    }    
    
    if(TabName == 'map and directions')
    {
        s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop7,prop34,prop8,products';
        s.events = 'event20'
        s.eVar36 = 'map and directions tab'
        s.prop36='map and directions tab'
        var mapState="";
        var FF=document.getElementById&&!document.all; //Firefox flag (true=FF)
        if (!FF)
        {
            //IE           
            mapState = (document.getElementById("ctl00$mst$hdnMapType")) ? document.getElementById("ctl00$mst$hdnMapType").value : null;
        }
        else
        {
            //FF
            mapState = (document.getElementById("ctl00_cphPrimaryContentSection_hdnMapType")) ? document.getElementById("ctl00_cphPrimaryContentSection_hdnMapType").value : null;
        }
        s.prop8=mapState;
        if(add40 == "True")
        {
            var eVar40 = getCookie('PageRef');
            s.products=';'+ aptId +';;;;eVar33='+ displayPoint +'|eVar40='+eVar40;
        }
        else
        {
            s.products=';'+ aptId +';;;;eVar33='+ displayPoint;
        }

        if (typeof (maptabvar) != "undefined") {
            if (maptabvar == 0) {
                s_code = s.t(); //initial click to increment pageview and record the pageName
            }
            else {
                s_code = s.tl(this, 'o', 'Map and Directions: map type');  //other clicks are not pageView
            }

            maptabvar++;
        }
    } 
    else
    {
        s_code=s.t();
    }

    if(s_code)
        document.write(s_code)
        
    ClearOmnitureCodes();
}

function OmnitureMiscClick(add40, aptId, displayPoint, lnk, text) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,events,products';
    s.linkTrackEvents = 'event20';
    s.events = 'event20';
    s.eVar36 = text;
    s.prop36 = text;
    if (add40 == "True") {
        var eVar40 = getCookie('PageRef');
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint + '|eVar40=' + eVar40;
    }
    else {
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint;
    }
    s.tl(this, lnk, text);
    ClearOmnitureCodes();
}

function LogOmnitureMisc(eventName, apartmentID, onlinePackageID, add40, friendlyUrl, text) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar11,eVar33,products,events,prop11';
    s.eVar11 = eventName;
    s.prop11 = eventName;
    var evar40 = '';
    if (eventName == 'HOMEFEATREQ')
        evar40 = 'home';
    else
        evar40 = 'srch-feat';
    if (evar40 == '')
        s.products = ';' + apartmentID + ';;;;eVar33=' + onlinePackageID;
        else
            s.products = ';' + apartmentID + ';;;;eVar33=' + onlinePackageID + '|evar40=' + evar40;
    s.tl(this, 'o', text);
    ClearOmnitureCodes();
    addCookie(add40, 'false', 7);
}


function LogOmnitureFacebookShareSearch(marketID) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = "eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar44,prop34,events";
    s.linkTrackEvents = "event9";
    s.events = "event9";
    s.eVar44 = "fbc-facebook share search";
    s.tl(this, 'o', 'facebook share search');
    ClearOmnitureCodes(); 
}

//action:
//Answer a question : 'post_answer'
//View results : 'view_results'
//See more questions : 'see_more_questions'
//Preview responses to a question : 'view_recent'
//View All XX Responses for a question : 'view_all'
//View More Comments for a reply : 'view_comments'
//Add a comment : 'post_comment'
//Submit a new question : 'ask'
function LogOmnitureForum(questionID, action) {
var s = s_gi(sitecatalyst_account_id);
s.linkTrackVars = 'eVar34,eVar38,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,prop38,prop45,eVar45,eVar46,events,products';
    s.linkTrackEvents = 'event14';
    s.events = 'event14';
    s.prop45 = questionID; 
    s.eVar45 = questionID;
    s.eVar46 = action;
    s.tl(this, 'o', action);
    ClearOmnitureCodes();
}

//Report as offensive : 'report_offensive'
function LogOmnitureForumReportOffensive(questionID) {
var s = s_gi(sitecatalyst_account_id);
s.linkTrackVars = 'eVar34,eVar38,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,prop38,prop43,prop45,eVar45,eVar46,products';
    if (s.prop34 != null)
    {
        s.prop43='flag:' +  s.prop34 + ':' + questionID;
    }
    s.prop45 = questionID; 
    s.eVar45 = questionID;
    s.eVar46 = 'report_offensive';
    s.tl(this, 'o', 'report_offensive');
    ClearOmnitureCodes();
}

function LogAdvertiserPopUnder(eventName, aptID, pkgID) {
    s.linkTrackVars = 'eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,eVar6,eVar11,prop11,events,products';
    s.linkTrackEvents = String.format("event19{0}", eventName != '' ? String.format(",{0}", eventName) : '');
    s.events = String.format("event19{0}", eventName != '' ? String.format(",{0}", eventName) : '');
    s.products = String.format(";{0};;;;evar33={1}", aptID, pkgID);
    s.prop11 = "advweb-auto";
    s.eVar11 = "advweb-auto";
    s.eVar6 = "advweb";
    if (eventName == 'event20') {
        s.prop36 = "avail-auto";      //pass conditionally, only if event20-Vaultware
        s.eVar36 = "avail-auto";
    }
    s.tl(this, 'e', 'Advertiser Website');
    ClearOmnitureCodes();
        //pass conditionally, only if event19

}

function LogLeadPopUnder(eventName, aptID, pkgID) {
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,eVar6,events,products';
    s.linkTrackEvents = String.format("event12{0}", eventName != '' ? String.format(",{0}", eventName) : '');
    s.events = String.format("event12{0}", eventName != '' ? String.format(",{0}", eventName) : '');
    s.products = String.format(";{0};;;;evar33={1}", aptID, pkgID);
    if (eventName.toString().indexOf("event19") > -1) {
        s.eVar6 = "advweb-auto";
    }
    if (eventName.toString().indexOf("event20") > -1) {
        s.prop36 = "avail-auto";
        s.eVar36 = "avail-auto";
    }
    s.tl(this, 'o', 'Submit Lead');
    ClearOmnitureCodes();
}

function LogAvailPopUnder(eventName, aptID, pkgID) {
    s.linkTrackVars = 'eVar33,eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,eVar6,eVar11,prop11,events,products';
    s.linkTrackEvents = String.format("event20{0}", eventName != '' ? String.format(",{0}", eventName) : '');
    s.events = String.format("event20{0}", eventName != '' ? String.format(",{0}", eventName) : '');
    s.products = String.format(";{0};;;;evar33={1}", aptID, pkgID);
    s.prop11 = "avail-auto";
    s.eVar11 = "avail-auto";
    if (eventName.toString().indexOf("event19") > -1) {
        s.eVar6 = "advweb-auto";
    }
    s.prop36 = "avail";
    s.eVar36 = "avail";
    s.tl(this, 'o', 'Check Availability');
    ClearOmnitureCodes();
}

function ViewAllFloorPlans13(aptID, pkgID, OmnitureSettingsLvl2, OmnitureSettingsLvl3, OmnitureChannelName, OmnitureServer) {
    var s=s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,eVar42,eVar38,eVar39,prop34,eVar2,eVar3,eVar4,eVar10,prop1,prop2,prop3,prop4,prop7,events,products';
    s.linkTrackEvents = 'event13';
    s.events = 'event13';
    s.products = String.format(";{0};;;;evar33={1}", aptID, pkgID);
    s.prop10 = s.pageName;
    s.eVar2 = aptID;
    s.eVar10 = s.pageName;        
    s.server = OmnitureServer;
    s.channel = OmnitureChannelName;
    s.prop1 = OmnitureSettingsLvl2;
    s.prop2 = OmnitureSettingsLvl3;
    s.prop3 = OmnitureSettingsLvl3;
    s.prop7 = aptID;
    s.tl(this, 'o', 'Property View');
    ClearOmnitureCodes();
}


function OmnitureHeaderPicsClicks2() {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,events,products';
    s.linkTrackEvents = 'event15';
    s.events = 'event15';
    if (a40G == 'True') {
        var eVar40 = getCookie('PageRef');
        s.products = ';' + aptIDG + ';;;;eVar33=' + onlinePG + '|eVar40=' + eVar40;
    }
    else {
        s.products = ';' + aptIDG + ';;;;eVar33=' + onlinePG;
    }
    s.tl(this, 'o', 'Slide Control Pictures Click');
    ClearOmnitureCodes();
}

function OmnitureIPhoneAppLink() {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = "eVar34,prop5,eVar5,prop16,eVar16,eVar42,eVar44,prop34,events";
    s.linkTrackEvents = "event9";
    s.events = "event9";
    s.eVar44 = "iphone-app-iphone";
    var lt = obj.href != null ? s.lt(obj.href) : "";
    if (lt == "") {
        s.tl(obj, 'e', 'iphone-app-iphone');
    }
    ClearOmnitureCodes();
}

function OmnitureRequest(opt) {
    var isch;
    var aptId;
    var displayPoint;
    var s = s_gi(sitecatalyst_account_id);
    var reqList = requestListID.split(',');
    s.linkTrackVars = 'eVar11,eVar33,eVar34,prop2,prop5,eVar5,prop16,eVar16,eVar8,eVar42,prop34,events,products,prop11';
    if (usecaptcha) {
        s.prop2 = 'y';
        s.eVar8 = 'y';
    }
    else {
        s.prop2 = 'n';
        s.eVar8 = 'n';
    }
    if (opt == "1") {
        if (reqList.length > 1) {
            $("#PropCount").text(reqList.length + " properties");
        }
        else {
            $("#PropCount").text("property");
        }

        s.eVar11 = "COMPALLBTN";
        s.prop11 = "COMPALLBTN";
    }
    else {
        var chprops = 0;
        for (index = 0; index < reqList.length; index++) {
            isch = reqList[index].split('|')[2].toString();
            if (isch == "1")
                ++chprops;
        }

        if (chprops > 1) {
            $("#PropCount").text(chprops + " properties");
        }
        else {
            $("#PropCount").text("property");
        }

        s.eVar11 = "COMPTOPBTN";
        s.prop11 = "COMPTOPBTN";
    }
    var add40 = '<%= _add40 %>';
    var prods = "";

    if (add40 == "True") {
        var eVar40 = getCookie('PageRef');
        for (index = 0; index < reqList.length; index++) {
            //alert('2: ' + reqList);
            isch = reqList[index].split('|')[2].toString();
            if (opt == "1")
                isch = "1";
            if (isch == "1") {
                aptId = reqList[index].split('|')[0];
                //alert('3: ' + aptId)
                //var aptId = reqList[index].split('|')[0];
                displayPoint = reqList[index].split('|')[1];
                //var displayPoint = reqList[index].split('|')[1];
                if (prods == "")
                    prods = ';' + aptId + ';;;;eVar33=' + displayPoint + '|eVar40=' + eVar40;
                else
                    prods += ',' + ';' + aptId + ';;;;eVar33=' + displayPoint + '|eVar40=' + eVar40;
            }
        }
    }
    else {
        for (index = 0; index < reqList.length; index++) {
            //alert('4: ' + reqList);
            isch = reqList[index].split('|')[2].toString();
            if (opt == "1")
                isch = "1";
            if (isch == "1") {
                aptId = reqList[index].split('|')[0];
                //alert('5: ' + aptId)
                //var aptId = reqList[index].split('|')[0];
                displayPoint = reqList[index].split('|')[1];
                //var displayPoint = reqList[index].split('|')[1];
                if (prods == "")
                    prods = ';' + aptId + ';;;;eVar33=' + displayPoint;
                else
                    prods += ',' + ';' + aptId + ';;;;eVar33=' + displayPoint;
            }
        }
    }
    s.products = prods;
    s.tl(this, 'o', 'Contact Apartment Compare');
    ClearOmnitureCodes();
}


function OmniturePlayYouTube(add40, aptId, displayPoint) {
    var s = s_gi(sitecatalyst_account_id);
    s.linkTrackVars = 'eVar34,prop5,eVar5,prop16,eVar16,eVar42,prop34,eVar36,prop36,events,products';
    s.linkTrackEvents = 'event20';
    s.events = 'event20';
    s.eVar36 = 'youtube-play';
    s.prop36 = 'youtube-play';
    if (add40 == "True") {
        var eVar40 = getCookie('PageRef');
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint + '|eVar40=' + eVar40;
    }
    else {
        s.products = ';' + aptId + ';;;;eVar33=' + displayPoint;
    }
    s.tl(this, 'o', 'Play YouTube');
    ClearOmnitureCodes();
}
function logMobileClick() {
    var s = s_gi(sitecatalyst_account_id);
    s = s_gi(sitecatalyst_account_id);
    s.events = 'event37';
    s.tl(this, 'o', 'Mobile Promo Click');
    ClearOmnitureCodes();
}
