
/*
 * Parse JSON OF InfoWindow
**/
if(!cba)var cba = {};

var m_agriBusiness = false;

cba.InfoWindow = function() {
    // increment the info window id so every window has it's own id
    //cba.InfoWindow.CURRENT_INFO_WINDOW_INDEX++;
    var id = "InfoWindow"; // + cba.InfoWindow.CURRENT_INFO_WINDOW_INDEX;
    var getId = this.getId = function() { return id; }

    // add info window to info windows list
    cba.InfoWindow.INFO_WINDOWS_LIST = [];
    cba.InfoWindow.INFO_WINDOWS_LIST.push(this);

    // declare variables

    var m_infoWindowTitle = "no title";
    var m_longitude;
    var m_latitude;
    var m_branch;
    var m_ATMType;
    var m_ATMID;
    var currLatitude;
    var currLongitude;

    // pages
    var m_locationPage = new cba.InfoWindowPage(getId(), "Location", 0);
    var m_hoursPage = new cba.InfoWindowPage(getId(), "Hours", 1);
    var m_servicesPage = new cba.InfoWindowPage(getId(), "Services", 2);
    var m_contactPage = new cba.InfoWindowPage(getId(), "Contact", 3);


    var m_locationIcons;
    var m_servicesContent = new cba.ServicesContent(m_servicesPage.getPageId());
    var m_windowTitleContent = new cba.WindowTitle();

    // new line added for new json atm content
    var m_atmContent;

    // this is the list of pages for the different location
    // hours, services pages etc
    var m_pagesList = [m_locationPage, m_hoursPage, m_servicesPage, m_contactPage];



    var ParseXmlObject = this.ParseXmlObject = function(a_data, popupType) {
        parseXmlContent(a_data);
        parseXmlContent(popupType);
    }

    function parseXmlContent(a_content) {
        //alert("a_content  "+typeof(a_content));
        var l_contentChild = null;


        for (var b in a_content) {
            l_contentChild = a_content[b];

            var l_isObject = typeof (l_contentChild) == "object";
            var l_isValidType = l_isObject || typeof (l_contentChild) == "string" || typeof (l_contentChild) == "number" || typeof (l_contentChild) == "boolean";
            if (l_isValidType) {
                checkObjectVariableType(b, l_contentChild);
                if (l_isObject) parseXmlContent(l_contentChild);

            }
        }

    }


    var showContentByIndex = this.showContentByIndex = function(a_contentIndex) {
        var l_page;

        for (var b = 0; b < m_pagesList.length; b++) {
            l_page = m_pagesList[b];

            l_page.showContent((b == a_contentIndex));
        }
    }

    var getPageByIndex = this.getPageByIndex = function(a_pageIndex) {
        var l_page;
        for (var b = 0; b < m_pagesList.length; b++) {
            l_page = m_pagesList[b];
            if (b == a_pageIndex) return l_page;
        }
    }



    function checkObjectVariableType(a_type, a_object) {
        switch (a_type) {
            /* Branch - image */ 
            case "Branch":
                //salert(a_object.Notes);
                m_infoWindowTitle = a_object.BuildingName;
                m_windowTitleContent.setTitle(m_infoWindowTitle);

                var l_buildingLevelAddress = a_object.BuildingLevelAddress;
                var l_address = a_object.BuildingAddress;
                var l_phone = a_object.PrimaryPhone;
                var l_bsb = a_object.BSB;
                var l_branchNotes = a_object.Notes;
                var l_agEmail ;
                var l_suburb = a_object.Suburb;
                var l_postcode = a_object.PostCode;
                var l_state = a_object.State;

                currLongitude = a_object.Longitude;
                currLatitude = a_object.Latitude;
                var productID = GetSelectedProduct();  
                if(a_object.ImagePath == 'App_Themes/Default/Images/PorductGeneralImages/Agribusiness.jpg'){
               l_agEmail  = "agline@cba.com.au";
                }
                else {
                l_agEmail='';
                }
                var l_locationContent = new cba.LocationContent(m_infoWindowTitle, l_buildingLevelAddress, l_address, l_phone, l_bsb,'',l_suburb, l_postcode, l_state);
                m_locationPage.addChild(l_locationContent);

                m_locationIcons = new cba.LocationIconsContent();
                m_locationPage.addChild(m_locationIcons);

                // add contact us content
                var l_primaryEmail = a_object.PrimaryEmail;
                var l_secondaryEmail = a_object.SecondaryEmail;

                var l_contactContent = new cba.ContactContent(l_phone, l_primaryEmail, l_secondaryEmail,l_agEmail);
                m_contactPage.addChild(l_contactContent);

                //access ImagePath object
                var l_imagePath = a_object.ImagePath;
                
                if (l_imagePath != null) {
                    m_locationPage.setImage(l_imagePath);
                    m_hoursPage.setImage(l_imagePath);
                    m_contactPage.setImage(l_imagePath);
                    m_servicesContent.setImage(l_imagePath);
                }

                m_hoursPage.setExtraContent(l_branchNotes);

                break;

            case "ATM":

                m_infoWindowTitle = a_object.BuildingName;
                m_windowTitleContent.setTitle(m_infoWindowTitle);

                m_ATMID = a_object.ATMID;
                var l_atmType = m_ATMType = a_object.ATMType;
                var l_buildingName = a_object.BuildingName;
                var l_buildingLevelAddress = a_object.Address2;
                var l_address = a_object.Address1;
                var l_suburb = a_object.Suburb;
                var l_postcode = a_object.PostCode;
                var l_state = a_object.State;
                var l_accessibilities = a_object.Accessibilities;
                var m_longitude = currLongitude = a_object.Longitude;
                var m_latitude = currLatitude = a_object.Latitude;


                m_locationIcons = new cba.LocationIconsContent();
                //m_locationPage.addChild(m_locationIcons);

                var l_imagePath = a_object.ImagePath;
                if (l_imagePath != null) {
                    m_locationPage.setImage(l_imagePath);
                }
                
                var l_atmImgPath = a_object.ATMImagePath;
                if (l_atmImgPath != null) {
                    m_locationPage.setImage(l_atmImgPath);
                    l_imagePath = l_atmImgPath;
                }
                m_atmContent = new cba.ATMContent(l_buildingName, l_atmType, l_buildingName, l_buildingLevelAddress, l_address, l_suburb, l_postcode, l_state, l_imagePath);
                m_atmContent.setLng(m_longitude);
                m_atmContent.setLat(m_latitude);
                m_atmContent.setLocationIcons(m_locationIcons);
                break;


            case "HasBranch":
                m_windowTitleContent.hasBranch(a_object);
                break;
            case "HasATM":
                m_windowTitleContent.hasATM(a_object);
                break;
            case "ATMType":
                m_windowTitleContent.ATMType(a_object);
                break;

            /* Hours */ 
            case "SundayWorkingHours":
                var l_imgRef;
                var l_hoursContent = new cba.HoursContent();
                var l_weekdayObject = null;
                var l_timeStr = null;
                //for (var b = 0; b < a_object.length; b++) {
                    l_weekdayObject = a_object;
                    if (l_weekdayObject.toLowerCase() == "closed") {
                        l_timeStr = "Not open";
                    } else {
                        l_timeStr = l_weekdayObject;
                    }
                    l_hoursContent.addDayTime("Sunday", l_timeStr);
                    
                m_hoursPage.addChild(l_hoursContent);


                break;
                case "MondayWorkingHours":
                var l_imgRef;
                var l_hoursContent = new cba.HoursContent();
                var l_weekdayObject = null;
                var l_timeStr = null;
                
                    l_weekdayObject = a_object;
                    if (l_weekdayObject.toLowerCase() == "closed") {
                        l_timeStr = "Not open";
                    } else {
                        l_timeStr = l_weekdayObject;
                    }
                    l_hoursContent.addDayTime("Monday", l_timeStr);
                    
                m_hoursPage.addChild(l_hoursContent);


                break;
                case "TuesdayWorkingHours":
                var l_imgRef;
                var l_hoursContent = new cba.HoursContent();
                var l_weekdayObject = null;
                var l_timeStr = null;
                
                    l_weekdayObject = a_object;
                    if (l_weekdayObject.toLowerCase() == "closed") {
                        l_timeStr = "Not open";
                    } else {
                        l_timeStr = l_weekdayObject;
                    }
                    l_hoursContent.addDayTime("Tuesday", l_timeStr);
                    
                m_hoursPage.addChild(l_hoursContent);


                break;
                case "WendayWorkingHours":
                var l_imgRef;
                var l_hoursContent = new cba.HoursContent();
                var l_weekdayObject = null;
                var l_timeStr = null;
                
                    l_weekdayObject = a_object;
                    if (l_weekdayObject.toLowerCase() == "closed") {
                        l_timeStr = "Not open";
                    } else {
                        l_timeStr = l_weekdayObject;
                    }
                    l_hoursContent.addDayTime("Wednesday", l_timeStr);
                    
                m_hoursPage.addChild(l_hoursContent);


                break;
                case "ThudayWorkingHours":
                var l_imgRef;
                var l_hoursContent = new cba.HoursContent();
                var l_weekdayObject = null;
                var l_timeStr = null;
                
                    l_weekdayObject = a_object;
                    if (l_weekdayObject.toLowerCase() == "closed") {
                        l_timeStr = "Not open";
                    } else {
                        l_timeStr = l_weekdayObject;
                    }
                    l_hoursContent.addDayTime("Thursday", l_timeStr);
                    
                m_hoursPage.addChild(l_hoursContent);


                break;
                case "FridayWorkingHours":
                var l_imgRef;
                var l_hoursContent = new cba.HoursContent();
                var l_weekdayObject = null;
                var l_timeStr = null;
                
                    l_weekdayObject = a_object;
                    if (l_weekdayObject.toLowerCase() == "closed") {
                        l_timeStr = "Not open";
                    } else {
                        l_timeStr = l_weekdayObject;
                    }
                    l_hoursContent.addDayTime("Friday", l_timeStr);
                    
                m_hoursPage.addChild(l_hoursContent);


                break;
                case "SatdayWorkingHours":
                var l_imgRef;
                var l_hoursContent = new cba.HoursContent();
                var l_weekdayObject = null;
                var l_timeStr = null;
                
                    l_weekdayObject = a_object;
                    if (l_weekdayObject.toLowerCase() == "closed") {
                        l_timeStr = "Not open";
                    } else {
                        l_timeStr = l_weekdayObject;
                    }
                    l_hoursContent.addDayTime("Saturday", l_timeStr);
                    
                
                m_hoursPage.addChild(l_hoursContent);


                break;


            /* Product List - Services */ 
            
            case "MobilelenderProduct":

                var l_serviceContentObject;
                
                
                m_agriBusiness = false;
                    /* product object */
                    var l_productObject;
                    var l_productButtonTitle;
                    var l_productPageTitle;
                    var l_productNotes;
                    var l_productImage;
                    var l_phoneDescription;
                    var l_productPrimaryPhone;

                    /* manager object */
                    var l_managerFullName;
                    var l_managerJobTitle;
                    var l_managerPrimaryEmail;
                    var l_managerSecondaryEmail;
                    var l_managerPrimaryPhone;
                    var l_managerSecondaryPhone;
                    var l_managerPrimaryMobile;
                    var l_managerSecondaryMobile;
                    var l_managerNotes;
                    var l_managerImage;
                    var l_managerEmail;
                    l_productObject = a_object.split('::');
                    l_productButtonTitle = l_productObject[0];
                    l_productPageTitle = l_productObject[0];
                    l_productNotes = l_productObject[2];
                    l_productPrimaryPhone = l_productObject[3];
                    l_phoneDescription = l_productObject[4];
                    l_productImage = l_productObject[1];

                    if (l_productObject[5] != '') {
                        l_managerFullName = l_productObject[5] + " " + l_productObject[6];
                        l_managerJobTitle = l_productObject[7];
                        l_managerPrimaryEmail = l_productObject[8];
                        l_managerSecondaryEmail = l_productObject[9];
                        l_managerPrimaryPhone = l_productObject[10];
                        l_managerSecondaryPhone = l_productObject[11];
                        l_managerPrimaryMobile = l_productObject[12]; 
                        l_managerSecondaryMobile = l_productObject[13];
                        l_managerNotes = l_productObject[14];
                        l_managerImage = l_productObject[15];                    
        

                        //l_managerEmail = "localbusinessbanking@cba.com.au";
                    }
                    else {
                        l_managerFullName = null;
                        l_managerJobTitle = null;
                        l_managerPrimaryEmail = null;
                        l_managerSecondaryEmail = null;
                        l_managerPrimaryPhone = null;
                        l_managerSecondaryPhone = null;
                        l_managerPrimaryMobile = null;
                        l_managerSecondaryMobile = null;
                        l_managerNotes = null;                        
                        l_managerEmail = null;
                        
                    }
//                    if((l_productImage != '')&& (l_productObject[5] != ''))
//                    {
                    l_managerImage = l_productImage;
                    //}
                   
                    l_serviceContentObject = new cba.ServicesContentProduct(5, m_servicesContent.getProductTitleScreenId(), l_productButtonTitle, l_productPageTitle, l_productNotes, l_managerImage, l_managerFullName, l_managerJobTitle, l_managerPrimaryEmail, l_managerSecondaryEmail, l_productPrimaryPhone, l_managerPrimaryPhone, l_managerSecondaryPhone, l_managerPrimaryMobile, l_managerSecondaryMobile, l_managerNotes, l_phoneDescription, l_managerEmail);
                    m_servicesContent.addProduct(l_serviceContentObject);

                    //m_servicesPage.addChild(m_servicesContent);

                break;
                
            case "BusinessBankerProduct":

                var l_serviceContentObject;
                
                m_agriBusiness = false;
                
                    /* product object */
                    var l_productObject;
                    var l_productButtonTitle;
                    var l_productPageTitle;
                    var l_productNotes;
                    var l_productImage;
                    var l_phoneDescription;
                    var l_productPrimaryPhone;

                    /* manager object */
                    var l_managerFullName;
                    var l_managerJobTitle;
                    var l_managerPrimaryEmail;
                    var l_managerSecondaryEmail;
                    var l_managerPrimaryPhone;
                    var l_managerSecondaryPhone;
                    var l_managerPrimaryMobile;
                    var l_managerSecondaryMobile;
                    var l_managerNotes;
                    var l_managerImage;
                    var l_managerEmail;
                    
                    l_productObject = a_object.split('::');
                    if(l_productObject[0]  != '')
                    {
                    l_productButtonTitle = l_productObject[0];
                    l_productPageTitle = l_productObject[0];
                    l_productNotes = l_productObject[2];
                    l_productPrimaryPhone = l_productObject[3];
                    l_phoneDescription = l_productObject[4];
                    l_productImage = l_productObject[1];

                    if (l_productObject[5] != '') {
                        l_managerFullName = l_productObject[5] + " " + l_productObject[6];
                        l_managerJobTitle = l_productObject[7];
                        l_managerPrimaryEmail = l_productObject[8];
                        l_managerSecondaryEmail = l_productObject[9];
                        l_managerPrimaryPhone = l_productObject[10];
                        l_managerSecondaryPhone = l_productObject[11];
                        l_managerPrimaryMobile = l_productObject[12]; 
                        l_managerSecondaryMobile = l_productObject[13];
                        l_managerNotes = l_productObject[14];
                        l_managerImage = l_productObject[15];                     
        

                        //l_managerEmail = "localbusinessbanking@cba.com.au";
                    }
                    else {
                        l_managerFullName = null;
                        l_managerJobTitle = null;
                        l_managerPrimaryEmail = null;
                        l_managerSecondaryEmail = null;
                        l_managerPrimaryPhone = null;
                        l_managerSecondaryPhone = null;
                        l_managerPrimaryMobile = null;
                        l_managerSecondaryMobile = null;
                        l_managerNotes = null;                        
                        l_managerEmail = null;
                        
                    }
                    if((l_managerFullName == '')||(l_managerFullName == null))
                    {         
                        l_managerImage = l_productImage;                    
                    }
                   
                    l_serviceContentObject = new cba.ServicesContentProduct(1, m_servicesContent.getProductTitleScreenId(), l_productButtonTitle, l_productPageTitle, l_productNotes, l_managerImage, l_managerFullName, l_managerJobTitle, l_managerPrimaryEmail, l_managerSecondaryEmail, l_productPrimaryPhone, l_managerPrimaryPhone, l_managerSecondaryPhone, l_managerPrimaryMobile, l_managerSecondaryMobile, l_managerNotes, l_phoneDescription, l_managerEmail);
                    m_servicesContent.addProduct(l_serviceContentObject);
            }
                    //m_servicesPage.addChild(m_servicesContent);

                break;
                
               
                case "ForeignExchangeProduct":

                var l_serviceContentObject;
                
                m_agriBusiness = false;
                
                    /* product object */
                    var l_productObject;
                    var l_productButtonTitle;
                    var l_productPageTitle;
                    var l_productNotes;
                    var l_productImage;
                    var l_phoneDescription;
                    var l_productPrimaryPhone;

                    /* manager object */
                    var l_managerFullName;
                    var l_managerJobTitle;
                    var l_managerPrimaryEmail;
                    var l_managerSecondaryEmail;
                    var l_managerPrimaryPhone;
                    var l_managerSecondaryPhone;
                    var l_managerPrimaryMobile;
                    var l_managerSecondaryMobile;
                    var l_managerNotes;
                    var l_managerImage;
                    var l_managerEmail;
                    l_productObject = a_object.split('::');
                    l_productButtonTitle = l_productObject[0];
                    l_productPageTitle = l_productObject[0];
                    l_productNotes = l_productObject[2];
                    l_productPrimaryPhone = l_productObject[3];
                    l_phoneDescription = l_productObject[4];
                    l_productImage = l_productObject[1];

                    if (l_productObject[5] != '') {
                        l_managerFullName = l_productObject[5] + " " + l_productObject[6];
                        l_managerJobTitle = l_productObject[7];
                        l_managerPrimaryEmail = l_productObject[8];
                        l_managerSecondaryEmail = l_productObject[9];
                        l_managerPrimaryPhone = l_productObject[10];
                        l_managerSecondaryPhone = l_productObject[11];
                        l_managerPrimaryMobile = l_productObject[12]; 
                        l_managerSecondaryMobile = l_productObject[13];
                        l_managerNotes = l_productObject[14];
                        l_managerImage = l_productObject[15];                     
        

                        //l_managerEmail = "localbusinessbanking@cba.com.au";
                    }
                    else {
                        l_managerFullName = null;
                        l_managerJobTitle = null;
                        l_managerPrimaryEmail = null;
                        l_managerSecondaryEmail = null;
                        l_managerPrimaryPhone = null;
                        l_managerSecondaryPhone = null;
                        l_managerPrimaryMobile = null;
                        l_managerSecondaryMobile = null;
                        l_managerNotes = null;                        
                        l_managerEmail = null;
                        
                    }
//                    if((l_productImage != '')&& (l_productObject[5] != ''))
//                    {
                    l_managerImage = l_productImage;
                    //}
                   
                   
                    l_serviceContentObject = new cba.ServicesContentProduct(3, m_servicesContent.getProductTitleScreenId(), l_productButtonTitle, l_productPageTitle, l_productNotes, l_managerImage, l_managerFullName, l_managerJobTitle, l_managerPrimaryEmail, l_managerSecondaryEmail, l_productPrimaryPhone, l_managerPrimaryPhone, l_managerSecondaryPhone, l_managerPrimaryMobile, l_managerSecondaryMobile, l_managerNotes, l_phoneDescription, l_managerEmail);
                    m_servicesContent.addProduct(l_serviceContentObject);

                    //m_servicesPage.addChild(m_servicesContent);

                break;
                
                
                
                case "FinancialPlannerProduct":

                var l_serviceContentObject;
                
                m_agriBusiness = false;
                
                    /* product object */
                    var l_productObject;
                    var l_productButtonTitle;
                    var l_productPageTitle;
                    var l_productNotes;
                    var l_productImage;
                    var l_phoneDescription;
                    var l_productPrimaryPhone;

                    /* manager object */
                    var l_managerFullName;
                    var l_managerJobTitle;
                    var l_managerPrimaryEmail;
                    var l_managerSecondaryEmail;
                    var l_managerPrimaryPhone;
                    var l_managerSecondaryPhone;
                    var l_managerPrimaryMobile;
                    var l_managerSecondaryMobile;
                    var l_managerNotes;
                    var l_managerImage;
                    var l_managerEmail;
                    
                    l_productObject = a_object.split('::');
                    
                    l_productButtonTitle = l_productObject[0];
                    l_productPageTitle = l_productObject[0];
                    l_productNotes = l_productObject[2];
                    l_productPrimaryPhone = l_productObject[3];
                    l_phoneDescription = l_productObject[4];
                    l_productImage = l_productObject[1];
//                    alert(l_productObject[5]);
//                    alert(l_productObject[2]);

                    if (l_productObject[5] != '') {
                        l_managerFullName = l_productObject[5] + " " + l_productObject[6];
                        l_managerJobTitle = l_productObject[7];
                        l_managerPrimaryEmail = l_productObject[8];
                        l_managerSecondaryEmail = l_productObject[9];
                        l_managerPrimaryPhone = l_productObject[10];
                        l_managerSecondaryPhone = l_productObject[11];
                        l_managerPrimaryMobile = l_productObject[12]; 
                        l_managerSecondaryMobile = l_productObject[13];
                        l_managerNotes = l_productObject[14];
                        l_managerImage = l_productObject[15];                    
        

                        //l_managerEmail = "localbusinessbanking@cba.com.au";
                    }
                    else {
                        l_managerFullName = null;
                        l_managerJobTitle = null;
                        l_managerPrimaryEmail = null;
                        l_managerSecondaryEmail = null;
                        l_managerPrimaryPhone = null;
                        l_managerSecondaryPhone = null;
                        l_managerPrimaryMobile = null;
                        l_managerSecondaryMobile = null;
                        l_managerNotes = null;                        
                        l_managerEmail = null;
                        
                    }
                    
                    l_managerImage = l_productImage;                    
                    
                    l_serviceContentObject = new cba.ServicesContentProduct(2, m_servicesContent.getProductTitleScreenId(), l_productButtonTitle, l_productPageTitle, l_productNotes, l_managerImage, l_managerFullName, l_managerJobTitle, l_managerPrimaryEmail, l_managerSecondaryEmail, l_productPrimaryPhone, l_managerPrimaryPhone, l_managerSecondaryPhone, l_managerPrimaryMobile, l_managerSecondaryMobile, l_managerNotes, l_phoneDescription, l_managerEmail);
                    m_servicesContent.addProduct(l_serviceContentObject);

                    //m_servicesPage.addChild(m_servicesContent);

                break;               
              
              case "AgriBusinessProduct":

                var l_serviceContentObject;
                
                
                
                    /* product object */
                    var l_productObject;
                    var l_productButtonTitle;
                    var l_productPageTitle;
                    var l_productNotes;
                    var l_productImage;
                    var l_phoneDescription;
                    var l_productPrimaryPhone;

                    /* manager object */
                    var l_managerFullName;
                    var l_managerJobTitle;
                    var l_managerPrimaryEmail;
                    var l_managerSecondaryEmail;
                    var l_managerPrimaryPhone;
                    var l_managerSecondaryPhone;
                    var l_managerPrimaryMobile;
                    var l_managerSecondaryMobile;
                    var l_managerNotes;
                    var l_managerImage;
                    var l_managerEmail;
                    
                    l_productObject = a_object.split('::');
                    if(l_productObject[0]  != '')
                    {
                    m_agriBusiness = true;
                    l_productButtonTitle = l_productObject[0];
                    l_productPageTitle = l_productObject[0];
                    l_productNotes = l_productObject[2];
                    l_productPrimaryPhone = l_productObject[3];
                    l_phoneDescription = l_productObject[4];
                    l_productImage = l_productObject[1];
//                    alert(l_productObject[5]);
//                    alert(l_productObject[2]);

                    if (l_productObject[5] != '') {
                        l_managerFullName = l_productObject[5] + " " + l_productObject[6];
                        l_managerJobTitle = l_productObject[7];
                        l_managerPrimaryEmail = l_productObject[8];
                        l_managerSecondaryEmail = l_productObject[9];
                        l_managerPrimaryPhone = l_productObject[10];
                        l_managerSecondaryPhone = l_productObject[11];
                        l_managerPrimaryMobile = l_productObject[12]; 
                        l_managerSecondaryMobile = l_productObject[13];
                        l_managerNotes = l_productObject[14];
                        l_managerImage = l_productObject[15];                    
        

                        //l_managerEmail = "localbusinessbanking@cba.com.au";
                    }
                    else {
                        l_managerFullName = null;
                        l_managerJobTitle = null;
                        l_managerPrimaryEmail = null;
                        l_managerSecondaryEmail = null;
                        l_managerPrimaryPhone = null;
                        l_managerSecondaryPhone = null;
                        l_managerPrimaryMobile = null;
                        l_managerSecondaryMobile = null;
                        l_managerNotes = null;                        
                        l_managerEmail = null;
                        
                    }

                    
                    l_managerImage = l_productImage;
                    
                   if (m_contactPage != null && m_contactPage.getChildAt(0))
                            m_contactPage.getChildAt(0).setExtraContact("Call to talk to your local agribusiness specialist");
                            
                        m_locationPage.setExtraContent("<strong>Email: </strong><a href='javascript:void(0);' onclick='window.open(\"mailto:" + 'agline@cba.com.au' + "\", \"EmailAGLine\")' >" + 'agline@cba.com.au' + "</a>"+"<br/><br/>"+"We have agribusiness specialists with all the right financial solutions for your business.");
                        //m_locationPage.setExtraContent("We have agribusiness specialists with all the right financial solutions for your business.");
                        
                    l_serviceContentObject = new cba.ServicesContentProduct(4, m_servicesContent.getProductTitleScreenId(), l_productButtonTitle, l_productPageTitle, l_productNotes, l_managerImage, l_managerFullName, l_managerJobTitle, l_managerPrimaryEmail, l_managerSecondaryEmail, l_productPrimaryPhone, l_managerPrimaryPhone, l_managerSecondaryPhone, l_managerPrimaryMobile, l_managerSecondaryMobile, l_managerNotes, l_phoneDescription, l_managerEmail);
                    m_servicesContent.addProduct(l_serviceContentObject);

                    m_servicesPage.addChild(m_servicesContent);
                    }
                    else
                    {
                    
                    m_servicesPage.addChild(m_servicesContent);
                    }

                break;  
                
//            case "ProductList":

//                var l_serviceContentObject;
//                m_agriBusiness = false;
//                for (var b = 0; b < a_object.length; b++) {

//                    /* product object */
//                    var l_productObject;
//                    var l_productButtonTitle;
//                    var l_productPageTitle;
//                    var l_productNotes;
//                    var l_productImage;
//                    var l_phoneDescription;
//                    var l_productPrimaryPhone;

//                    /* manager object */
//                    var l_managerFullName;
//                    var l_managerJobTitle;
//                    var l_managerPrimaryEmail;
//                    var l_managerSecondaryEmail;
//                    var l_managerPrimaryPhone;
//                    var l_managerSecondaryPhone;
//                    var l_managerPrimaryMobile;
//                    var l_managerSecondaryMobile;
//                    var l_managerNotes;
//                    var l_managerImage;
//                    var l_managerEmail;

//                    l_productObject = a_object[b];

//                    if (l_productObject.ProductID == "4") {
//                        m_agriBusiness = true;
//                        if (m_contactPage != null && m_contactPage.getChildAt(0))
//                            m_contactPage.getChildAt(0).setExtraContact("Call to talk to your local agribusiness specialist");

//                        m_locationPage.setExtraContent("We have agribusiness specialists with all the right financial solutions for your business.");
//                    }

//                    l_productButtonTitle = l_productObject.Product;
//                    l_productPageTitle = l_productObject.Product;
//                    l_productNotes = l_productObject.Notes;
//                    l_productPrimaryPhone = l_productObject.PrimaryPhone;
//                    l_phoneDescription = l_productObject.PhoneDescription;
//                    l_productImage = l_productObject.ImagePath;

//                    if (l_productObject.Manager) {
//                        l_managerFullName = l_productObject.Manager.FirstName + " " + l_productObject.Manager.LastName;
//                        l_managerJobTitle = l_productObject.Manager.JobTitle;
//                        l_managerPrimaryEmail = l_productObject.Manager.PrimaryEmail;
//                        l_managerSecondaryEmail = l_productObject.Manager.SecondaryEmail;
//                        l_managerPrimaryPhone = l_productObject.Manager.PrimaryPhone;
//                        l_managerSecondaryPhone = l_productObject.Manager.SecondaryPhone;
//                        l_managerPrimaryMobile = l_productObject.Manager.PrimaryMobile; ;
//                        l_managerSecondaryMobile = l_productObject.Manager.SecondaryMobile; ;
//                        l_managerNotes = l_productObject.Manager.Notes;
//                        l_managerImage = l_productObject.Manager.ImagePath;                    
//        

//                        l_managerEmail = "localbusinessbanking@cba.com.au";
//                    }
//                    else {
//                        l_managerFullName = null;
//                        l_managerJobTitle = null;
//                        l_managerPrimaryEmail = null;
//                        l_managerSecondaryEmail = null;
//                        l_managerPrimaryPhone = null;
//                        l_managerSecondaryPhone = null;
//                        l_managerPrimaryMobile = null;
//                        l_managerSecondaryMobile = null;
//                        l_managerNotes = null;                        
//                        l_managerEmail = null;
//                        
//                    }
//                    if((l_productImage != '')&& (!l_productObject.Manager))
//                    {
//                    l_managerImage = l_productImage;
//                    }
//                    l_serviceContentObject = new cba.ServicesContentProduct(l_productObject.ProductID, m_servicesContent.getProductTitleScreenId(), l_productButtonTitle, l_productPageTitle, l_productNotes, l_managerImage, l_managerFullName, l_managerJobTitle, l_managerPrimaryEmail, l_managerSecondaryEmail, l_productPrimaryPhone, l_managerPrimaryPhone, l_managerSecondaryPhone, l_managerPrimaryMobile, l_managerSecondaryMobile, l_managerNotes, l_phoneDescription, l_managerEmail);
//                    m_servicesContent.addProduct(l_serviceContentObject);

//                    var l_imgRef = "App_Themes/Default/Images/iconTypeBranch_FX.gif";
//                    if (l_productObject.ProductID == "3") {
//                        if (l_imgRef != null) {
//                            m_locationIcons.addFacility(l_imgRef, "Foreign Exchange");
//                        }
//                    }
//                }


//                m_servicesPage.addChild(m_servicesContent);



//                break;


            case "Longitude":
                m_longitude = a_object;
                m_locationPage.setLng(m_longitude);
                m_contactPage.setLng(m_longitude);
                m_hoursPage.setLng(m_longitude);
                m_servicesContent.setLng(m_longitude);
                break;

            case "Latitude":
                m_latitude = a_object;
                m_locationPage.setLat(m_latitude);
                m_contactPage.setLat(m_latitude);
                m_hoursPage.setLat(m_latitude);
                m_servicesContent.setLat(m_latitude);
                break;

            case "BuildingServiceID":
                m_branch = a_object;
                break;

            case "BuildingAddress":

                break;


            // facility list object   
            case "ForeignExchange":

                var l_imgRef;
                var l_altTag = a_object;

                if(a_object) {
                    
                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_FX.gif";
                        m_locationIcons.addFacility(l_imgRef, 'Foreign Exchange');
                }
                break; 
                
             case "CoinCountMachine":

            var l_imgRef;
            var l_altTag = a_object;

            if(a_object) {
                
                    l_imgRef = "App_Themes/Default/Images/iconTypeBranch_CCM.gif";
                    m_locationIcons.addFacility(l_imgRef, 'Coin Count Machine');
            }
            break; 
            
            case "DepositMachine":

                var l_imgRef;
                var l_altTag = a_object;

                if(a_object) {
                    
                       l_imgRef = "App_Themes/Default/Images/iconTypeBranch_DM.gif";
                        m_locationIcons.addFacility(l_imgRef, 'Deposit Machine');
                }
                break; 
                
            case "ChangeMachine":

                var l_imgRef;
                var l_altTag = a_object;

                if(a_object) {
                    
                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_CM.gif";
                        m_locationIcons.addFacility(l_imgRef, 'Change Machine');
                }
                
                break;
                
               
                case "NetBankAccess":

                var l_imgRef;
                var l_altTag = a_object;

                if(a_object) {
                    
                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_NK.gif";
                        m_locationIcons.addFacility(l_imgRef, 'Net Bank Access');
                }
                break;   
                case "WeekendTrading":

                var l_imgRef;
                var l_altTag = a_object;
                
                if(a_object) {
                    
                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_WE.gif";
                        m_locationIcons.addFacility(l_imgRef, 'Weekend Trading');
                }
                break;    
                 
                                                    
//            case "Facility":

//                var l_imgRef;
//                var l_altTag = a_object;

//                switch (a_object) {
//                    case "Change Machine":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_CM.gif";
//                        break;
//                    case "Deposit Machine":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_DM.gif";
//                        break;
//                    case "Coin Count Machine":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_CCM.gif";
//                        break;
//                    case "Net Bank Access":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_NK.gif";
//                        break;
//                    case "Weekend Trading":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_WE.gif";
//                        break;
//                    case "Foreign Exchange":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeBranch_FX.gif";
//                        break;
//                }

//                m_locationIcons.addFacility(l_imgRef, l_altTag);

//                break;
case "Accessibility":

                var l_imgRef;
                var l_altTag = a_object;
                //m_locationIcons = new cba.LocationIconsContent();

                switch (a_object) {
                    case "Audio Enabled ATM":
                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_AE.gif";
                        break;
                    case "Deposit ATM":
                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_AD.gif";
                        break;
                    case "Wheel Chair ATM":
                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_WA.gif";
                        break;
                }

                m_locationIcons.addAccessibility(l_imgRef, l_altTag);

                break;
            // accessibility list objects                                           
            case "WheelChair":

                var l_imgRef;
                var l_altTag = a_object;

                if(a_object) {
                    
                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_WA.gif";
                        
//                    case "Deposit ATM":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_AD.gif";
//                        break;
//                    case "Wheel Chair ATM":
//                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_WA.gif";
//                        break;
                    m_locationIcons.addAccessibility(l_imgRef, 'Wheelchair ATM');
                }
                
                break;

                case "AudioEnabled":

                var l_imgRef;
                var l_altTag = a_object;

                if(a_object) {
                    
                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_AE.gif";
                        m_locationIcons.addAccessibility(l_imgRef, 'Audio Enabled ATM');
                }
                break;
                
                case "Deposit":

                var l_imgRef;
                var l_altTag = a_object;

                if(a_object) {
                    
                        l_imgRef = "App_Themes/Default/Images/iconTypeATM_AD.gif";
                        m_locationIcons.addAccessibility(l_imgRef, 'Deposit ATM');
                }
                break;
        }
    }


    var toHtmlString = this.toHtmlString = function() {
        var l_returnHtml = "";

        // add title div
        l_returnHtml += m_windowTitleContent.toHtmlString();
        l_returnHtml += "<div class='infoWinBody'>";

        if (m_windowTitleContent.getHasBranch()) {
            l_returnHtml += "<ul class='infoWinNavigation'>";
            for (var b = 0; b < m_pagesList.length; b++) {
                var l_page = m_pagesList[b];
                l_returnHtml += l_page.toTabHtmlString();
            }
            l_returnHtml += "</ul>";
        }

        // add pages content divs
        l_returnHtml += "<div class='infoWinContent'>";

        if (!m_windowTitleContent.getHasBranch()) {
            l_returnHtml += m_atmContent.toHtmlString();
        } else {

            for (var b = 0; b < m_pagesList.length; b++) {
                var l_page = m_pagesList[b];
                l_returnHtml += l_page.toContentHtmlString();
            }
        }
        l_returnHtml += "</div>";

        // end infoWindowBody div
        l_returnHtml += "</div>";

        // add footer content div
        l_returnHtml += "<div class='infoWinFooter'>";
        if (m_ATMType == null || m_ATMType == '') {
            //alert(currLatitude + " " + currLongitude);
            l_returnHtml += "<a href='javascript:void(0);' onclick='onDirectionsRequest(" + currLatitude + "," + currLongitude + ");'>Get directions</a><a href='javascript:void(0);' onclick='PrintBranchDetails(" + currLatitude + "," + currLongitude + "," + m_branch + ",true);'>Print details</a>";
        }
        else {
            //alert(currLatitude + " " + currLongitude);
            l_returnHtml += "<a href='javascript:void(0);' onclick='onDirectionsRequest(" + currLatitude + "," + currLongitude + ");'>Get directions</a><a href='javascript:void(0);' onclick='PrintBranchDetails(" + currLatitude + "," + currLongitude + "," + m_ATMID + ",false,\"" + m_ATMType + "\");'>Print details</a>";
        }

        l_returnHtml += "</div>";
        // end info window div

        return l_returnHtml;
    }
}
cba.InfoWindow.INFO_WINDOWS_LIST = [];
cba.InfoWindow.CURRENT_INFO_WINDOW_INDEX = 0;


cba.InfoWindow.getInfoWindowById = function(a_windowId)
{
	var l_infoWindow;
	
	for(var b=0;b < cba.InfoWindow.INFO_WINDOWS_LIST.length; b++)
	{
		l_infoWindow = cba.InfoWindow.INFO_WINDOWS_LIST[b];
		if(l_infoWindow.getId() == a_windowId)return l_infoWindow;
	}
	
	return null;
}


// this method is run by the tabs in the info window to show their content
// @see cba.InfoWindowPage.toTabHtmlString
cba.InfoWindow.showWindowContent = function(a_contentId) {
    var l_idsArray = a_contentId.split("_");
    var l_windowId = l_idsArray[0];
    var l_contentIndex = parseFloat(l_idsArray[1]);

    /* Omniture code begin */
    //Hours
    if (l_contentIndex == 1) 
    {
        ResetKPI();
        s.pageName = 'cba:find-us:branch locator:hours';
        s.t();
    }

    //Contact
    if (l_contentIndex == 3) {
        ResetKPI();
        s.pageName = 'cba:find-us:branch locator:contact';
        s.t();
    }
    /* Omniture code end */

    var l_infoWindow = cba.InfoWindow.getInfoWindowById(l_windowId);
    if (l_infoWindow != null) {
        // we now want to only display the content for the index id of the content in the selected window
        l_infoWindow.showContentByIndex(l_contentIndex);
        /* Dependant on Agribusiness productID = 4. Hard coded */
        
        if (m_agriBusiness) {
            cba.ServicesContent.showContentPageById("InfoWindow_2_contentPage_4");
        }
    }
}


    cba.InfoWindow.getDirections = function(a_longitude, a_latitude) {
        alert("cba.InfoWindow.getDirections  Longitude : " + a_longitude + "  Latitude : " + a_latitude);
    }

    cba.InfoWindow.printDetails = function(a_longitude, a_latitude) {
        alert("cba.InfoWindow.printDetails  Longitude : " + a_longitude + "  Latitude : " + a_latitude);
    }

