﻿

    //CONSTRUCTOR
    DataFloat.Agora.NewTrack = function(ActionType, ContactKey, RecordType, PropertyKey, PropertyIDE){
        if (DataFloat.Agora.Util.IsEmptyOrNull(Agora_Default_Agent_Key)){
            alert('Default Agent Key is not defined \'Agora_Default_Agent_Key\'. Is not possible to run the NewTrack function.');
            return false;
        }
        var formParams = 'CREATOR=' + Agora_Default_Agent_Key + '&ActionType=1&' + DataFloat.Agora.NewTrack.Meta.Type + "=" + ActionType + "&" + DataFloat.Agora.NewTrack.Meta.Contact + "=" + ContactKey + "&" + DataFloat.Agora.NewTrack.Meta.PropertyType + "=" + RecordType + "&" + DataFloat.Agora.NewTrack.Meta.PropertyKey + "=" + PropertyKey + "&" + DataFloat.Agora.NewTrack.Meta.IDE + "=" + escape(PropertyIDE);
        $("#AgoraTrackingControl").append('<img src="/Services/Agora_ContentManager_Tracking.aspx?' + formParams + '" width="1" height="1" />');
        
    }
    
    DataFloat.Agora.NewTrackAjax = function(ActionType, ContactKey, RecordType, PropertyKey, PropertyIDE, CallBack){
        if (DataFloat.Agora.Util.IsEmptyOrNull(Agora_Default_Agent_Key)){
            alert('Default Agent Key is not defined \'Agora_Default_Agent_Key\'. Is not possible to run the NewTrack function.');
            return false;
        }
        if (DataFloat.Agora.Util.IsEmptyOrNull(ContactKey))
            ContactKey = '';
            
        var formParams = 'CREATOR=' + Agora_Default_Agent_Key + '&' + DataFloat.Agora.NewTrack.Meta.Type + "=" + ActionType + "&" + DataFloat.Agora.NewTrack.Meta.Contact + "=" + ContactKey + "&" + DataFloat.Agora.NewTrack.Meta.PropertyType + "=" + RecordType + "&" + DataFloat.Agora.NewTrack.Meta.PropertyKey + "=" + PropertyKey + "&" + DataFloat.Agora.NewTrack.Meta.IDE + "=" + escape(PropertyIDE);
        
        
        var InsertObject = new DataFloat.Agora.AjaxManager(formParams);
        InsertObject.NewSystemRequest(DataFloat.Agora.Services.ServiceTracking, 1, CallBack);
        
        
    }
    
    
    //Setting
        DataFloat.Agora.NewTrack.Meta = 
            {RecordType     : '43', 
            Type           : 'WATYPE', //'0010', 
            Contact        : 'WALINKCONTACT', //'0020_n_k', 
            PropertyType   : 'WAPROPERTYTYPE', //'0030', 
            PropertyKey    : 'WAPROPERTYKEY', //'0040', 
            IDE            : 'WAIDE'}; //'0070'}
            
            
            
        
    //Setting
    //This enumeration is based on enum in meta
    
    
    DataFloat.Agora.NewTrack.TrackingType = 
            {
            
            Login : 1,                            //Number of times someone logged into their My Home Finder account from your property detail //#######Working
            ViewPropertyResult : 2,                 // Number of times your property appeared in search results  //#######Working
            ViewPropertyDetail : 3,                 // Number of times your property details were viewed         //#######Working
            InquirePropertyResult : 4,
            InquirePropertyDetail : 5,
            MortgageCalculatorSearchResult : 6,
            MortgageCalculatorDetailPage : 7,
            InsuranceQuoteDetailPage : 8,
            PropertyComment :  9,
            ScheduleShowing : 10,                   // Number of times a showing was requested on your property   //#######Working
            SaveProperty : 11,                      // Number of times your property was saved in their My Home Finder account  //#######Working
            MapProperty : 12,                       // Number of times someone mapped out directions to your property //######Working
            PrintDetail : 13,                       // Number of times someone printed your listing detail page  //#####Working
            Email : 14,                             // Number of times someone emailed your listing detail page  //#####Working
            OpenHouse : 15,
            VirtualTour : 16,                       // Number of times someone viewed your listing%27s virtual tour !!!!!!!!!!!!!!!!!!!
            ContactListingAgentForm :17,
            CompareProperties : 18
            
            
            /*ViewPropertyResult : 1,                 // Number of times your property appeared in search results  //#######Working
            ViewPropertyDetail : 2,                 // Number of times your property details were viewed         //#######Working
            Login : 3,                              //Number of times someone logged into their My Home Finder account from your property detail //#######Working
            InquirePropertyResult : 4,      
            InquirePropertyDetail : 4,
            PrintDetail : 5,                        // Number of times someone printed your listing detail page  //#####Working
            Email : 6,                              // Number of times someone emailed your listing detail page  //#####Working
            SaveProperty : 7,                       // Number of times your property was saved in their My Home Finder account  //#######Working
            SaveSearch : 10,    
            VirtualTour : 11,                       // Number of times someone viewed your listing%27s virtual tour !!!!!!!!!!!!!!!!!!!
            MortgageCalculatorSearchResult : 12,
            MortgageCalculatorDetailPage : 12,
            MapProperty : 13,                       // Number of times someone mapped out directions to your property //######Working
            ScheduleShowing : 14,                   // Number of times a showing was requested on your property   //#######Working
            RemoveProperty : 15*/

            };
    
        
    
    $(document).ready(function(){
        $("body").append('<div id="AgoraTrackingControl">&nbsp;</div>');
    });