
     /*
     *  Ident Engine
     *  0.1.2
     *  Copyright 2009, Glenn Jones
     *  Licensed under the MIT license
     *  http://identengine.com/license/
     *  More information on this file: http://identengine.com/
     */


    ident = new function(){};
    
    // Public use
    ident.version = "0.1.3";
    ident.useInwardEdges = true;
    ident.identities = new Array();    
    ident.domains = new Array();
    ident.history = new Array();
    ident.ufParser = null;
    ident.rssParser = null; 
    ident.atomParser = null;
    ident.iconPath = "ident/icons/";
    ident.addPrimaryURL = true;

    
    // Internal use
    ident._startUrl = '';
    ident._apiReturnCount = 0;
    ident._usernames =  new Array();
    ident._primaryCalled = false; 
    ident._secondaryCalled = false; 

    // A updated version of this JSON data can be found at: http://identengine.com/
    ident._endPoints = {"sites": []} // Object stucture now built from compact array
    ident._endPointsArray = [["12seconds tv", "12seconds.tv", [["http://12seconds.tv/channel/{username}", "hCard", "Profile", "Html"], ["http://12seconds.tv/followers/{username}", "hCard", "Friends", "Html"], ["http://12seconds.tv/followers/{username}?page={pagenumber}", "hCard", "Friends", "Html"], ["http://12seconds.tv/channel/{username}", "hAtom", "Video", "Html"]]], ["43things", "43things.com", [["http://www.43things.com/person/{username}", "None", "None", "Html"], ["http://www.43things.com/rss/uber/author?username={username}", "Rss", "Activity", "Rss"]]], ["43people", "43people.com", [["http://{username}.43people.com/", "None", "None", "Html"], ["http://www.43people.com/rss/uber/person?person={username}", "Rss", "Activity", "Rss"]]], ["Backnetwork", "backnetwork.com", []], ["Backtype", "backtype.com", [["http://www.backtype.com/{username}/", "None", "Profile", "Html"], ["http://feeds.backtype.com/{username}", "Rss", "Activity", "Rss"]]], ["BarCamp Brighton 3", "barcampbrighton3.backnetwork.com", [["http://barcampbrighton3.backnetwork.com/people/person.aspx?personid={username}", "hCard", "Profile", "Html"], ["http://barcampbrighton3.backnetwork.com/people/person.aspx?personid={username}", "XFN-hCard", "Friends", "Html"]]], ["BarCamp London 5", "barcamplondon5.backnetwork.com", [["http://barcamplondon5.backnetwork.com/people/person.aspx?personid={username}", "hCard", "Profile", "Html"], ["http://barcamplondon5.backnetwork.com/people/person.aspx?personid={username}", "XFN-hCard", "Friends", "Html"]]], ["Blip.fm", "blip.fm", [["http://blip.fm/profile/{username}/", "None", "None", "Html"], ["http://blip.fm/feed/{username}", "Atom", "Audio", "Atom"]]], ["Blip.tv", "blip.tv", [["http://{username}.blip.tv/", "None", "None", "Html"]]], ["BlogSpot", "blogspot.com", []], ["Blogger", "blogger.com", [["http://www.blogger.com/profile/{userid}", "None", "Profile", "Html"]]], ["Brightkite", "brightkite.com", [["http://brightkite.com/people/{username}", "hCard", "Profile", "Html"], ["http://brightkite.com/people/{username}/friends?page={pagenumber}", "None", "Friends", "Html"], ["http://brightkite.com/people/{username}/objects.rss", "Atom", "Activity", "Atom"]]], ["ClaimId", "claimid.com", [["http://claimid.com/{username}", "hCard", "Profile", "Html"]]], ["CoComment", "cocomment.com", [["http://www.cocomment.com/comments/{username}", "None", "None", "Html"], ["http://www.cocomment.com/webRssUser/{username}.rss", "Rss", "Activity", "Rss"]]], ["Corkd", "corkd.com", [["http://corkd.com/people/{username}", "hCard", "Profile", "Html"], ["http://corkd.com/people/{username}/buddies?page={pagenumber}", "XFN", "Friends", "Html"]]], ["d.construct 08", "dconstruct08.backnetwork.com", [["http://dconstruct08.backnetwork.com/people/person.aspx?personid={username}", "hCard", "Profile", "Html"], ["http://dconstruct08.backnetwork.com/people/person.aspx?personid={username}", "XFN-hCard", "Friends", "Html"]]], ["Delicious", "del.icio.us", [["http://feeds.delicious.com/v2/rss/{username}?count=20", "Atom", "Bookmarks", "Atom"], ["http://del.icio.us/rss/{username}", "Rss", "Bookmarks", "Rss"], ["http://del.icio.us/{username}#bundle-tags", "rel-tag", "Interests", "Html"], ["http://del.icio.us/{username}", "None", "None", "Html"], ["http://delicious.com/{username}", "None", "None", "Html"]]], ["Digg", "digg.com", [["http://digg.com/users/{username}", "hCard", "Profile", "Html"], ["http://digg.com/users/{username}/friends/view/page{pagenumber}", "XFN-hCard", "Friends", "Html"]]], ["Disqus", "disqus.com", [["http://www.disqus.com/people/{username}/", "None", "Profile", "Html"], ["http://www.disqus.com/people/{username}/comments.rss", "Rss", "Lifestream", "Rss"]]], ["Django People", "djangopeople.net", [["http://djangopeople.net/{username}/", "hCard", "Profile", "Html"], ["http://djangopeople.net/{username}/", "XFN", "Services", "Html"]]], ["Dopplr", "dopplr.com", [["http://www.dopplr.com/traveller/{username}", "hCard", "Profile", "Html"]]], ["Edenbee", "edenbee.com", [["http://www.edenbee.com/users/{username}", "hCard", "Profile", "Html"], ["http://www.edenbee.com/users/{username}/relationships?page=(pagenumber}", "hCard", "Friends", "Html"], ["http://www.edenbee.com/users/{username}/relationships", "hCard", "Friends", "Html"], ["http://edenbee.com/users/{username}", "None", "None", "Html"]]], ["Emberapp", "emberapp.com", [["http://emberapp.com/{username}", "None", "Profile", "Html"], ["http://emberapp.com/{username}/images.rss", "None", "Images", "Rss"]]], ["Facebook", "facebook.com", []], ["FFFFound", "ffffound.com", [["http://ffffound.com/home/{username}/found/feed", "Rss", "Images", "Rss"], ["http://ffffound.com/home/{username}/found/", "None", "None", "Html"]]], ["Flickr", "flickr.com", [["http://www.flickr.com/people/{username}/", "hCard", "Profile", "Html"], ["http://api.flickr.com/services/feeds/photos_public.gne?id={userid}&format=rss_200", "Rss", "Images", "Rss"], ["http://api.flickr.com/services/feeds/photos_public.gne?id={userid}&format=atom", "Atom", "Images", "Atom"], ["http://www.flickr.com/photos/{username}/", "None", "Images", "Html"], ["http://www.flickr.com/people/{username}/contacts/?page={pagenumber}", "None", "Friends", "Html"]]], ["FOTB 08", "fotb08.backnetwork.com", [["http://fotb08.backnetwork.com/people/person.aspx?personid={username}", "hCard", "Profile", "Html"], ["http://fotb08.backnetwork.com/people/person.aspx?personid={username}", "XFN-hCard", "Friends", "Html"]]], ["Fotolog", "fotolog.com", [["http://www.fotolog.com/{username}", "None", "Profile", "Html"]]], ["FriendFeed", "friendfeed.com", [["http://friendfeed.com/{username}", "hCard", "Profile", "Html"], ["http://friendfeed.com/{username}/services", "XFN", "Services", "Html"], ["http://friendfeed.com/{username}?format=atom", "Atom", "Lifestream", "Atom"]]], ["GetSatisfaction", "getsatisfaction.com", [["http://getsatisfaction.com/people/{username}", "hCard", "Profile", "Html"], ["http://getsatisfaction.com/people/{username}.rss", "Rss", "Activity", "Rss"]]], ["Github", "github.com", [["http://github.com/{_usernames}/", "hCard", "Profile", "Html"], ["http://github.com/{username}.atom", "Atom", "Activity", "Atom"]]], ["Google", "google.com", [["http://www.google.com/profiles/{username}", "hCard", "Profile", "Html"], ["http://www.google.com/profiles/{username}", "XFN", "Services", "Html"], ["http://www.google.com/profiles/{userid}", "XFN", "Services", "Html"], ["http://www.google.com/profiles/{userid}", "hCard", "Profile", "Html"]]], ["hi5", "hi5.com", []], ["Huffduffer", "huffduffer.com", [["http://huffduffer.com/{username}", "hCard", "Profile", "Html"], ["http://huffduffer.com/{username}/rss", "Rss", "Audio", "Rss"], ["http://huffduffer.com/{username}", "hAtom", "Audio", "Html"]]], ["Identica", "identi.ca", [["http://identi.ca/{username}", "hCard", "Profile", "Html"], ["http://identi.ca/{username}/foaf", "FOAF", "Profile", "Xml"], ["http://identi.ca/{username}/subscriptions?page={pagenumber}", "hCard", "Friends", "Html"], ["http://identi.ca/{username}", "hAtom", "Status", "Html"], ["http://identi.ca/{username}", "rel-tag", "Interests", "Html"], ["http://identi.ca/{username}/all", "hAtom", "Friends Status", "Html"]]], ["Jaiku", "jaiku.com", [["http://{username}.jaiku.com/", "hCard", "Profile", "Html"]]], ["JPG", "jpgmag.com", [["http://www.jpgmag.com/people/{username}/photos", "hCard", "Profile", "Html"], ["http://www.jpgmag.com/people/{username}/rss", "Rss", "Images", "Rss"], ["http://www.jpgmag.com/people/{username}/stories/rss", "Rss", "Entries", "Rss"], ["http://www.jpgmag.com/people/{username}/stories", "None", "None", "Html"]]], ["krop.com", "krop.com", [["http://www.krop.com/{username}/resume/", "None", "Resume", "Html"], ["http://www.krop.com/{username}/portfolio/", "None", "Profile", "Html"]]], ["Last.fm", "last.fm", [["http://www.last.fm/user/{username}", "hCard", "Profile", "Html"], ["http://www.last.fm/user/{username}/friends?page={pagenumber}", "hCard", "Friends", "Html"], ["http://ws.audioscrobbler.com/1.0/user/{username}/recenttracks.rss", "Rss", "Activity", "Rss"], ["http://www.last.fm/user/{username}", "hCalendar", "Events", "Html"], ["http://ws.audioscrobbler.com/1.0/user/{username}/events.rss", "Rss", "Events", "Rss"]]], ["Linked-in", "linkedin.com", [["http://www.linkedin.com/in/{username}", "hCard", "Profile", "Html"], ["http://www.linkedin.com/in/{username}", "hResume", "Resume", "Html"], ["http://www.linkedin.com/pub/{username}", "hCard", "Profile", "Html"], ["http://www.linkedin.com/pub/{username}", "hResume", "Resume", "Html"]]], ["Livejournal", "livejournal.com", [["http://{username}.livejournal.com/", "None", "Profile", "Html"]]], ["MadgexLab", "ufapi.lab.madgex.com", [["http://ufapi.lab.madgex.com/profile/{username}", "hCard", "Profile", "Html"]]], ["Mashed 08", "mashed08.backnetwork.com", [["http://mashed08.backnetwork.com/people/person.aspx?personid={username}", "hCard", "Profile", "Html"], ["http://mashed08.backnetwork.com/people/person.aspx?personid={username}", "XFN-hCard", "Friends", "Html"]]], ["Meetup", "meetup.com", []], ["Microformats.org", "microformats.org", [["http://microformats.org/wiki/User:{username}", "hCard", "Profile", undefined]]], ["Mybloglog", "mybloglog.com", [["http://www.mybloglog.com/buzz/members/{username}/hcard", "hCard", "Profile", "Html"], ["http://www.mybloglog.com/buzz/members/{username}/", "None", "None", "Html"], ["http://www.mybloglog.com/buzz/members/{username}/me/rss.xml", "Atom", "Lifestream", "Atom"]]], ["My Name is E", "mynameise.com", [["http://www.mynameise.com/{username}", "None", "Profile", "Html"], ["http://mynameise.com/{username}", "None", "Profile", "Html"], ["http://mynameise.com/{username}", "XFN", "Services", "Html"]]], ["MyOpenid", "myopenid.com", [["http://{username}.myopenid.com/", "None", "None", "Html"]]], ["MySpace", "myspace.com", [["http://myspace.com/{username)", "None", "None", "Html"], ["http://www.myspace.com/{username)", "None", "None", "Html"]]], ["Newsvine", "newsvine.com", [["http://{username}.newsvine.com/", "None", "None", "Html"]]], ["Odeo", "odeo.com", [["http://odeo.com/users/{username}", "None", "None", "Html"]]], ["Orkut", "orkut.com", [["http://www.orkut.com/Profile.aspx?uid={userid}", "None", "None", "Html"]]], ["Picasa", "picasaweb.google.com", [["http://picasaweb.google.com/{username}", "None", "Profile", "Html"], ["http://picasaweb.google.com/data/feed/base/user/{username}?alt=rss&kind=album&hl=en_US&access=public", "Rss", "Images", "Rss"]]], ["Plaxo", "plaxo.com", [["http://{username}.myplaxo.com/", "hCard", "Profile", "Html"]]], ["Plazes", "plazes.com", [["http://plazes.com/whereis/{username}", "hCard", "Profile", "Html"], ["http://plazes.com/whereis/{username}", "hCalendar", "Events", "Html"]]], ["Profilactic", "profilactic.com", [["http://www.profilactic.com/profile/{username}", "None", "Profile", "Html"]]], ["Readernaut", "readernaut.com", [["http://readernaut.com/{username}", "None", "Profile", "Html"], ["http://readernaut.com/feeds/rss/{username}", "Rss", "Activity", "Rss"]]], ["Seesmic", "seesmic.com", [["http://new.seesmic.com/{username}", "hCard", "Profile", "Html"], ["http://feeds.seesmic.com/user.{username}.atom", "Atom", "Video", "Atom"]]], ["Slideshare", "slideshare.net", [["http://www.slideshare.net/rss/user/{username}", "Rss", "Slides", "Rss"], ["http://www.slideshare.net/{username}", "None", "Profile", "Html"], ["http://slideshare.net/{username}", "None", "Profile", "Html"]]], ["Stumbleupon", "stumbleupon.com", [["http://www.stumbleupon.com/stumbler/{username}", "None", "Profile", "Html"], ["http://rss.stumbleupon.com/user/{username}/favorites", "Rss", "Bookmarks", "Rss"]]], ["Technorati", "technorati.com", [["http://technorati.com/people/technorati/{username}", "hCard", "Profile", "Html"]]], ["Threadless", "threadless.com", []], ["Times People", "timespeople.nytimes.com", [["http://timespeople.nytimes.com/view/user/{username}/", "None", "Profile", "Html"], ["http://timespeople.nytimes.com/view/user/{username}/rss.xml", "Rss", "Activity", "Rss"]]], ["Tumblr", "tumblr.com", [["http://{username}.tumblr.com/", "None", "None", "Html"], ["http://{username}.tumblr.com/rss", "Rss", "Lifestream", "Rss"]]], ["Twitter", "twitter.com", [["http://twitter.com/{username}", "hCard", "Profile", "Html"], ["http://twitter.com/{username}#people", "XFN-hCard", "Friends", "Html"], ["http://twitter.com/{username}", "hAtom", "Status", "Html"]]], ["Upcoming", "upcoming.yahoo.com", [["http://upcoming.yahoo.com/user/{userid}/", "hCard", "Profile", "Html"], ["http://upcoming.yahoo.com/user/{userid}/", "hCalendar", "Events", "Html"], ["http://upcoming.yahoo.com/user/{userid}/past/", "hCalendar", "Events", "Html"], ["http://upcoming.yahoo.com/syndicate/v2/my_events/{userid}", "Rss", "Events", "Rss"]]], ["Vimeo", "vimeo.com", [["http://www.vimeo.com/{username}", "hCard", "Profile", "Html"], ["http://www.vimeo.com/{username}/contacts/sort:newest/page:{pagenumber}", "None", "Friends", "Html"], ["http://vimeo.com/{username}/videos/rss", "Atom", "Video", "Atom"]]], ["Vox", "vox.com", [["http://{username}.vimeo.com/profile/", "hCard", "Profile", "Html"]]], ["Windows Live", "spaces.live.com", [["http://{username}.spaces.live.com/", "None", "Profile", "Html"]]], ["Yelp", "yelp.com", []], ["Youtube", "youtube.com", [["http://gdata.youtube.com/feeds/base/users/{username}/uploads?alt=rss&v=2", "Atom", "Video", "Atom"], ["http://youtube.com/rss/user/{username}/videos.rss", "Rss", "Video", "Rss"], ["http://youtube.com/user/{username}", "None", "Profile", "Html"], ["http://www.youtube.com/profile?user={username}", "None", "Profile", "Html"], ["http://www.youtube.com/user/{username}", "None", "Profile", "Html"]]]]
    ident._excludeDomains = ["pownce.com","ma.gnolia.com","huff-duff.com","lastfm.com.br","lastfm.com.tr","lastfm.de","lastfm.es","lastfm.fr","lastfm.it","lastfm.jp","lastfm.pl","lastfm.ru","lastfm.se","cn.last.fm","radio.aol.fr"];
    ident._excludeUrls = ["twitter.com/#replies","twitter.com/#inbox","twitter.com/#favorites","twitter.com/following","twitter.com/followers","identi.ca/group","identi.ca/tag","identi.ca/featured","identi.ca/favorited"];
    
    
    // Describes a profile node for identities collection
    ident.profile = function(url,domain){
        this.name = '';
        this.domain = '';
        this.username = new Array();
        this.profileUrl = domain;
        this.iconUrl = new Array();
    };
    
    // Describes a domain node
    ident.domain = function(url,domain){
        this.name = '';
        this.urls = new Array();
        this.domain = domain;
        this.accounts = new Array();
        this.hashCard = false;
        this.hashResume = false;
    };
    
    // Describes a identity node of a domain
    ident.account = function(sgn,verified,profile,resume,ident,pk){
        this.sgn = sgn;
        this.verified = verified;
        this.profile = profile;
        this.resume = resume;
        this.ident = ident;
        this.pk = pk;
    };
    
    // Describes a API call event
    ident.historyItem = function(url,apiurl){
        this.url = url;
        this.apiurl = apiurl;
        this.domain = ''; 
        this.name = '';
        this.contentType = ''; 
        this.schema = ''; 
        this.rawJSON = '';
    }
    
    // Describes a username object
    ident.username = function(){
        this.name = '';
        this.rank = 0;
    }
    
    // The main public function for startings a search
    ident.search = function(url) {
        ident.reset();
        
        var urls = new Array();
        if(url.indexOf(',') > -1)
            urls = url.split(',');
        else
            urls[0] = url;
        
        for(var x = 0; x <= urls.length-1; x++){
            if(x < 49){
                var item = ident.convertShorthandAddress(urls[x]);
                if(ident.isUrl(item)){
                    if(ident.isExcludedUrl(item) == false){
                        ident._startUrl += item + ',';
                    }else{
                        ident.error('Sorry web addresses have to represent a person like profile page or a blog i.e. "http://twitter.com/<strong>glennjones</strong>"');
                        ident._startUrl = '';
                        break;
                    }
                }else{
                    ident.error('Sorry there seem to be a problem with the format of the web address you entered: "' + url + '"');
                    ident._startUrl = '';
                    break;
                }
            }  
        }
        
        ident.apiManager();
        // Hack by Arron -- trigger "all is done here" event.
        jQuery(document).trigger('ident:done');
    }
    
    // Controls identity API request
    ident.apiManager = function(json, historyItem) {
       
       if(ident._startUrl != ''){
       
            if(json != null){
                // Parse return data
                ident.parseSGN(json, historyItem);
                ident.statusUpdateEvent(['data-change']);
            }
            
            // Thrid call
            if(ident._primaryCalled == true && ident._secondaryCalled == true ){
                // If the profile module is present
                // To do - Add friendfeed.com, mybloglog.com and blog if found;
            } 
            
            // Second call - using edgeOut and edgeIn
            if(ident._primaryCalled == true && ident._secondaryCalled == false ){
                // Call if we want to use inward edges
                if( ident.useInwardEdges == true ){
                    ident._secondaryCalled = true;
                    ident.getSocialGraphData(ident._startUrl, 1 ); 
                }
            } 
            
            // First call - using edgeOut
            if(ident._primaryCalled == false){
                ident._primaryCalled = true;
                ident.getSocialGraphData(ident._startUrl, 0 );    
            } 
            
        }else{
            ident.error('Sorry web addresses have to represent a person like profile page or a blog i.e. "http://twitter.com/<strong>glennjones</strong>"');
        }
             
    }
    
    // Resets properties and page elements so they can be reused
    ident.reset = function(){
        ident.domains = new Array();
        ident.history = new Array();
        ident.profiles = new Array();
        ident._startUrl = '';
        ident._apiReturnCount = 0;
        ident._primaryCalled = false; 
        ident._secondaryCalled = false; 
        ident._usernames =  new Array();
        ident.resetTrigger();
    }
    
    
    // Assigns the best parser to use
    ident.registerParser = function(parser){
        if( (parser.parseUf > 0 && ident.ufParser == null) || ( ident.ufParser != null && parser.parseUf > ident.ufParser.parseUf  ))
            ident.ufParser = parser;
            
        if( (parser.parseRss > 0 && ident.rssParser == null ) || ( ident.rssParser != null && parser.parseRss > ident.rssParser.parseRss  ))
            ident.rssParser = parser;
            
        if( (parser.parseAtom > 0 && ident.atomParser == null ) || ( ident.atomParser != null && parser.parseAtom > ident.atomParser.parseAtom  ))
            ident.atomParser = parser; 
          
    }
    
    

    // Fires request to Google Social Graph API for data in JSON format
    ident.getSocialGraphData = function(url, edgeIn ){
            
         // Remove options - only inward bound edges - update code
         var apiurl = "http://socialgraph.apis.google.com/lookup?q=" + encodeURIComponent(url) + "&fme=1&edo=1&edi=" + edgeIn + "&sgn=1&pretty=1&jme=1"; 
            
         var historyItem = new ident.historyItem(url,apiurl);
         historyItem.apiName = 'googlesoicalgraph'; 
         ident.history[ident.history.length] = historyItem;

         ident.GoogleGraphAPICall( apiurl, historyItem );
    };

    

    // Parses the returned JSON data from Google Social Graph API
    ident.parseSGN = function(json, historyItem) {

        // Record the returned API call
        ident._apiReturnCount ++;

        if(json != null)
        {
           historyItem.rawJSON = json;
           
           var queryUrl = ''; 
           for(var item in json.canonical_mapping)
                queryUrl = item; // Canonical url
                
            //First - Load all the sgn nodes 
            for(var item in json.nodes){
                if(item.indexOf('sgn://') > -1){
                    var node = json.nodes[item];
                    var profileUrl = '';
                    var nodeUrl = '';
          
                    if(node['attributes']['profile'] != null)
                        profileUrl = node['attributes']['profile'];
                        
                    if(node['attributes']['url'] != null)
                        nodeUrl = node['attributes']['url'];
                
                    ident.appendDomainNode(item,nodeUrl,true,profileUrl);
                    ident.processClaimedNodes(node);
                }
            }
            
            //Second - Load all non sgn nodes
            for(var item in json.nodes){
                if(item.indexOf('http://') > -1){
                    var node = json.nodes[item];
                    ident.appendDomainNode('',item,false,'');
                    ident.processClaimedNodes(node);
                } 
            }
        }
        
        ident.postProcessDomainNode();
       
    };
    
    
    ident.processClaimedNodes = function(node){
    
        if(node["claimed_nodes"] != null){
            // Load sgn's first
            for(var x = 0; x <= node["claimed_nodes"].length-1; x++){
                var tempNode = node["claimed_nodes"][x];
                if(tempNode.indexOf('sgn://') > -1){
                    ident.appendDomainNode(tempNode,'',true,'');
                }
            }
            // Load http's second
            for(var x = 0; x <= node["claimed_nodes"].length-1; x++){
                var tempNode = node["claimed_nodes"][x];
                if(tempNode.indexOf('http://') > -1){
                    ident.appendDomainNode('',tempNode,true,'');
                }
            } 
        }
        
        // Finds unverified claimed nodes when your check in and out edges
        if(node["unverified_claiming_nodes"] != null){
            // Load sgn's first
            for(var x = 0; x <= node["unverified_claiming_nodes"].length-1; x++){
                var tempNode = node["unverified_claiming_nodes"][x];
                if(tempNode.indexOf('sgn://') > -1){
                    ident.appendDomainNode(tempNode,'',false,'');
                }
            }
            // Load http's second
            for(var x = 0; x <= node["unverified_claiming_nodes"].length-1; x++){
                var tempNode = node["unverified_claiming_nodes"][x];
                if(tempNode.indexOf('http://') > -1){
                    ident.appendDomainNode('',tempNode,false,'');
                }
            }
        }
    
    }
    
    
    // Post processes any domain to find addition hits
    ident.postProcessDomainNode = function(sgn, uri, verified, profile) {
        
        // Loop all the found domains and call the append custom data method
        for (var i = 0; i < ident.domains.length; i++){
            ident.appendCustomSGNData(ident.domains[i]);
        }
        ident.disambiguateNodes();
        
        // Sort the collection of domains into order
        ident.domains.sort(ident.sortByName);
        
        ident.buildIdentitiesCollection();
        
        // After all processing trigger custom update event 
        ident.statusUpdateEvent(['data-change']);
    };
    
    
    // Post processes any domain to find addition hits
    ident.buildIdentitiesCollection = function() {
          
        ident.identities = new Array(); 
        ident.disambiguateNodes();
            
            
        // Display top URL if its not in social media sites - often blog 
        if(ident.addPrimaryURL){
            var topDeclaredUrl = ident.topDeclaredProfileUrl();
            if(topDeclaredUrl != ''){
                var topDeclaredDomain = ident.parseDomainFromURL( topDeclaredUrl );
                var found = false;
                // Check its not a known soical media site
                for (var y = 0; y < ident._endPoints.sites.length; y++) {
                    if(ident.compareRootDomains(ident._endPoints.sites[y].domain, topDeclaredDomain))
                        found = true;
                }
                if(!found){
                    var profile = new ident.profile();
                    profile.name = '';
                    profile.domain = topDeclaredDomain; 
                    profile.iconUrl = ident.iconPath + 'website.png';  
                    profile.profileUrl = topDeclaredUrl; 
                    ident.identities[ident.identities.length] = profile; 
                }  
            }
        }
            
        // Loop for profiles
        for (var x = 0; x < ident.domains.length; x++) {
            // If we have a named social media site list it
            if( ident.domains[x].name ){ 
               
                for (var y = 0; y < ident.domains[x].accounts.length; y++) {
                    var profile = new ident.profile();
               
                   // Find username/id
                   profile.username = ident.domains[x].accounts[y].ident;
                   if( ident.domains[x].accounts[y].ident == '')
                       profile.username = ident.domains[x].accounts[y].pk;
                       
                   profile.name = ident.domains[x].name;
                   profile.domain = ident.domains[x].domain; 
                   profile.iconUrl = ident.iconPath + ident.domains[x].name.replace(/[\-,., ]/g,'').toLowerCase() + '.png';  
                   
                   if(ident.domains[x].accounts[y].profile != '' ){
                        profile.profileUrl = ident.domains[x].accounts[y].profile;
                   }else{
                        // If we have no profile link find any url containing correct username
                        if(ident.domains[x].urls)
                            profile.profileUrl = ident.findUserNameBasedURL(ident.domains[x].urls,profile.username)
                   }  
                   if(profile.profileUrl != '' && profile.username != '')
                        ident.identities[ident.identities.length] = profile;
               }
            }
        }
    };
    
    
    // Appends a new domain or/and identity node to collection
    ident.appendDomainNode = function(sgn, uri, verified, profile) {
        var domain = '';
        
        if(uri.indexOf('http://') == 0)
            domain = ident.parseDomainFromURL(uri);
       
        if(sgn != '')
            if(sgn.indexOf('sgn://') == 0)
                domain = ident.parseDomainFromSGN(sgn);     
            
               
        if(domain.length > 0)
        {   
            // Have we already got an object for this domain
            found = null;
            for (var i = 0; i < ident.domains.length; i++) {
                if (ident.compareRootDomains(domain, ident.domains[i].domain)) {
                    found = ident.domains[i];
                    break;
                }
            }
            
            // Don't use any domain on the exclude list
            var excludeIt = ident.domainIsExcluded(domain);
            
            // Exclude if its mail info
            if(domain == 'mboxsha1')
                excludeIt = true;
            
            if( excludeIt == false)
            {
                if(found == null){
                    // Create a new domain node
                    var newDomain = new ident.domain('','');
                    newDomain.domain = domain.replace('www.','');
                    ident.domains[ident.domains.length] = newDomain;
                    found = newDomain;
                }
                
                // Append url to the domain array of urls
                if(uri != '')
                    ident.appendUrl(found.urls,uri);

                
                if( sgn != ''){
  
                    // Append identity node
                    var identity = new ident.account('','','','','',''); 
                    identity.verified = verified;
                    identity.profile = profile;
                    identity.sgn = sgn;
                    
                    // Find ident and pk from sgn
                    if(identity.sgn != ''){
                        var parts = new Array();
                        if(identity.sgn.indexOf('/?ident=') > -1){
                            parts = identity.sgn.split('/?ident=');
                            if(parts.length == 2){
                                ident.appendUsername(parts[1]);
                                identity.ident = parts[1];
                            } 
                        }
                        
                        if(identity.sgn.indexOf('/?pk=') > -1){
                           parts = identity.sgn.split('/?pk=');
                           if(parts.length == 2)
                                identity.pk = parts[1]; 
                        }
                     }
                     
                     ident.appendUniqueIdentityNode(found,identity);
                 }       
            }  
        }  
    };
    
    // Find and resolve issue of disambiguity in identity nodes
    ident.disambiguateNodes = function(){
    
        for (var i = 0; i < ident.domains.length; i++) {
            // If we have more then one identity node
            if(ident.domains[i].accounts.length > 1){
                var userBaseNodeCount = 0;
                // Count different _usernames
                for(var z = 0; z <= ident.domains[i].accounts.length-1; z++){
                    if(ident.domains[i].accounts[z].ident != '')
                        userBaseNodeCount ++;
                }
                // If we have more than one username based identity node
                if( userBaseNodeCount > 1){
                    var tempArray = new Array();
                    var topName = ident.topUsername();
                    for(var z = 0; z <= ident.domains[i].accounts.length-1; z++){
                        // Add the username node which matches the most common username
                        if(ident.domains[i].accounts[z].ident == topName )
                            tempArray[tempArray.length] = ident.domains[i].accounts[z];
                        // Add all id based nodes
                        if(ident.domains[i].accounts[z].pk != '' )
                            tempArray[tempArray.length] = ident.domains[i].accounts[z];
                    }
                    ident.domains[i].accounts = tempArray;   
                }
            }
        }
    }
    
    // Search through an array of URLs for the first one containing the username
    ident.findUserNameBasedURL = function(urls, username){
        for (var i = 0; i < urls.length; i++) {
            if(urls[i].indexOf(username) > -1){
                return urls[i];
            }
        }
        return '';
    };
    
    
    // Does domains array contain a given domain object
    ident.domainNodeContains = function(domain){
        found = false;
        for (var i = 0; i < ident.domains.length; i++) {
            if(ident.compareRootDomains(domain, ident.domains[i].domain)){
                found = true;
                break;
            }
        }
        return found;
    }
    
    // Finds out if domain is on the exclude list
    ident.domainIsExcluded = function(domain){
        var excludeIt = false;
        for (var i = 0; i < ident._excludeDomains.length; i++) {
            if (ident.compareRootDomains(domain, ident._excludeDomains[i])) {
                excludeIt = true;
                break;
            }
        }
        return excludeIt;
    }
    
    
    // Checks to see if we have already made a API call
    ident.hasAPIBeenCalled = function(url, schema, apiurl){
        var found = false;
        for (var i = 0; i < ident.history.length; i++) {
            if(apiurl != '')
                if(ident.history[i].apiurl == apiurl)
                    found = true;
            if(url != '' && schema != '' && ident.history[i].schema != '')
                if(ident.history[i].url == url && ident.history[i].schema.indexOf(schema) > -1 )
                    found = true;
        }
        return found;
    };
    
    
    // Sorts objects into order using the name property
    ident.sortByName = function(a, b) {
        var x = a.name.toLowerCase();
        var y = b.name.toLowerCase();
        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    };
    
    // Sorts objects into order using the domain property
    ident.sortByDomain = function(a, b) {
        var x = a.domain.toLowerCase();
        var y = b.domain.toLowerCase();
        return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    };
    
    
    // Parse the username or userid from SGN
    ident.parseUserFromSGN = function(siteNode) {
        var sgn = siteNode.sgn.substring(6,siteNode.sgn.length);
        parts = sgn.split('?');
    
        if(parts[1].indexOf('ident=') > -1){
            siteNode.username =  parts[1].replace('ident=','');
        }
        else{
            siteNode.userid =  parts[1].replace('pk=','');
        }
    };
    
    
    // Append url to collection
    ident.appendUrl = function(urls,url) {    
        var found = false;
        for(var x = 0; x <= urls.length-1; x++){
            if(urls[x] == url){
                found = true;
                break
            }
        }
        if(found == false)
            urls[urls.length] = url;
    };
    
    
    // Append username to collection or up ranking if it exisits
    ident.appendUsername = function(username) {    
        var found = false;
        for(var x = 0; x <= ident._usernames.length-1; x++){
            if(ident._usernames[x].name == username){
                
                found = true;
                ident._usernames[x].rank ++;
                break
            }
        }
        if(found == false)
        {
            var user = new ident.username();
            user.name = username;
            ident._usernames[ident._usernames.length] = user;
        }
    };
    
    
    // Find custom SGN data and append it to collection
    ident.appendCustomSGNData = function(domain) {    
 
        for(var x = 0; x <= ident._endPoints.sites.length-1; x++){
            var testdomain = ident._endPoints.sites[x].domain.replace(' ', '');
             
            if(ident.compareRootDomains(domain.domain,testdomain) ){
                domain.name = ident._endPoints.sites[x].name;
                ident.createCustomSGN(domain, ident._endPoints.sites[x]);
            }
        }
    };
                

    
    // Given a site description from the custom SGN data 
    // Append extra data into collection 
    ident.createCustomSGN = function(domain, siteDescription) {
        
        // Append all the url mapping for this domain
        domain.urlmappings = siteDescription.urlmappings;
      
        // Loop the found urls for this domain and find new sgn's;
        for(var z = 0; z <= domain.urls.length-1; z++){
            
             var url = domain.urls[z];
            
             // Loop all the urlmappings for site description
             for(var y = 0; y <= siteDescription.urlmappings.length-1; y++){
                
                var urlmapping = siteDescription.urlmappings[y];
                var urltemplate = urlmapping.urltemplate;
                
                // The urltemplate contains a username or userid parse it
                if (urltemplate != "" && (urltemplate.indexOf("{username}") > -1 || urltemplate.indexOf("{userid}") > -1)) {
                    // Find the char number where the username/userid starts
                    var start = 0;
                    if( urltemplate.indexOf("{username}") > -1 )
                        start = urltemplate.indexOf("{username}");

                    if (urltemplate.indexOf("{userid}") > -1)
                        start = urltemplate.indexOf("{userid}");
                     
                    var parts = new Array(2); 
                     
                    if (start != 0){
                        parts[0] = urltemplate.toLowerCase().substring(0, start);
                        if (urltemplate.indexOf("{username}"))
                            parts[1] = urltemplate.toLowerCase().substring(start + 10);
                        else
                            parts[1] = urltemplate.toLowerCase().substring(start + 8); 
                    }            
        
                    startMatch = false;
                    endMatch = false;
                    user = url;

                    // Romove unneeded front section of url
                    if (url.indexOf(parts[0]) == 0){
                        startMatch = true;
                        part = parts[0];
                        user = user.substring(part.length, user.length);
                    }
                    
                    // Romove end element
                    if (parts.length == 2){
                        if (parts[1].length > 0){
                            if (ident.endsWith(url,parts[1]) ){
                                endMatch = true;
                                user = user.replace(parts[1], "");
                            }
                            else if (ident.endsWith(url,parts[1] + "/"))
                            {
                                endMatch = true;
                                user = user.replace(parts[1] + "/", "");
                            }
                        }
                        else
                        {
                            endMatch = true;
                        }
                    }
                    
                    // Romove any trailing /
                    if (ident.endsWith(user,"/"))
                        user = user.substring(0, user.length - 1);

                    // If the user contain anymore /
                    if (user.indexOf("/") > -1)
                        endMatch = false;

                    // Remove any querystring additions
                    if (user.indexOf("?") > -1){
                        userParts = user.split('?');
                        user = userParts[0];
                    }
                    
                    // Remove any name additions
                    if (user.indexOf("#") > -1){
                        userParts = user.split('#');
                        user = userParts[0];
                    }
                    
                    if (startMatch && endMatch){
                    
                        var identity = new ident.account('','','','','',''); 
                        identity.verified = false;
                        identity.profile = '';
                           
                        if (urlmapping.urltemplate.indexOf("{username}") > -1){
                            identity.ident = user;
                            ident.appendUsername(user);
                            identity.sgn = "sgn://" + domain.domain + "/?ident=" + user;
                        }

                        if (urlmapping.urltemplate.indexOf("{userid}") > -1){
                            identity.pk = user;
                            identity.sgn = "sgn://" + domain.domain + "/?pk=" + user;
                        }
                        
                        ident.appendProfileData(siteDescription.urlmappings, identity, url, domain);
                        
                        if(ident.domainIsExcluded( domain.domain ) == false)
                            ident.appendUniqueIdentityNode(domain,identity);
                        
                     }                       
                } 
            }
        }  
        
        // Loop all identity nodes to find addional sgn's information 
        for(var z = 0; z <= domain.accounts.length-1; z++){
            ident.appendProfileData(siteDescription.urlmappings,domain.accounts[z], '', domain);
        }
          
    } 
    
    // Looks at current identity nodes and work weather a new one needs appending
    ident.appendUniqueIdentityNode = function(domain,identity)
    {
        var found = null;
        
        // Find any node with sgn
        for(var y = 0; y <= domain.accounts.length-1; y++){
            if(domain.accounts[y].sgn == identity.sgn){
                found = domain.accounts[y];
                break;
            }
        }
             
        if(found == null)
            domain.accounts[domain.accounts.length] = identity;
             
    }
    
    
    // Adds a profile and resume mapping date to identity
    // Pre processed for fast excution for identity and profiles 
    ident.appendProfileData = function(urlmappings, identity, url, domain) {
        
           identity.profile = ident.getAPIEndPoint('Profile','hCard',urlmappings, identity);
           identity.resume = ident.getAPIEndPoint('Resume','hResume',urlmappings, identity);
           
           if(identity.profile != '')
                domain.hashCard = true;
                
           if(identity.resume != '')
                domain.hashResume = true;
    }
    
    
    ident.getAPIEndPoint = function(type, schema, urlmappings, identity, page) {
         var url = '';
         if(urlmappings != undefined){
             if(urlmappings.length){
                 for(var y = 0; y <= urlmappings.length-1; y++){
                    var urlmapping = urlmappings[y];

                    if( urlmapping.contenttype == type && urlmapping.schema == schema ){
                        var found = false;
                        url = urlmapping.urltemplate;
                         
                        if(identity.ident != '' && url.indexOf('{username}') > -1){
                            url = url.replace('{username}',identity.ident);
                            found = true; 
                        }
            
                        if(identity.pk != '' && url.indexOf('{userid}') > -1){
                            url = url.replace('{userid}',identity.pk);
                            found = true; 
                        }

                        // Add page number    
                        if(page != undefined)
                            url = url.replace('{pagenumber}',page);
                            
                        if(!found)
                            url = '';      
               
                    }
                    
                    if(url != '')
                        break;
                }
            }
        }
        return url;
    }
    
    
    
    // Finds the top username by rank
    ident.topUsername = function(){
        var top = new ident.username();
        for(var x = 0; x <= ident._usernames.length-1; x++){
            if(ident._usernames[x].rank > top.rank)
                top = ident._usernames[x];
        }
        return top.name;
    }
 
    // Have all the API calls returned 
    ident.isSearching = function(){
        if(ident._apiReturnCount >= ident.history.length){
            return false;
        }else{
            return true;
        }
    }
    
    // Add top level domain pages to excluded urls list
    ident.buildExcludeUrlList = function(){
        for(var x = 0; x <= ident._endPoints.sites.length-1; x++){
            ident._excludeUrls[ident._excludeUrls.length] = ident._endPoints.sites[x].domain; 
        }
    }
    ident.buildExcludeUrlList();
    
    ident.buildEndPointList = function(){
        var sites = new Array();
        for(var x = 0; x <= ident._endPointsArray.length-1; x++){
            var site = new Object();
            site.name = ident._endPointsArray[x][0];
            site.domain = ident._endPointsArray[x][1];
            site.urlmappings = new Array();
            for(var i = 0; i <= ident._endPointsArray[x][2].length-1; i++){
                var mapping = new Object();
                mapping.urltemplate = ident._endPointsArray[x][2][i][0];
                mapping.schema = ident._endPointsArray[x][2][i][1];
                mapping.contenttype = ident._endPointsArray[x][2][i][2];
                mapping.mediatype = ident._endPointsArray[x][2][i][3];
                site.urlmappings[site.urlmappings.length] = mapping;
            }
            sites[sites.length] = site;
        }
        ident._endPoints = {'sites': sites };
    }
    ident.buildEndPointList();
    
    
    ident.isExcludedUrl = function(url){
        for(var x = 0; x <= ident._excludeUrls.length-1; x++){
            if(ident.compareUrl(url, 'http://' + ident._excludeUrls[x]))
                return true;
        }
        return false;
    }
    
    // Finds shorthand address
    ident.convertShorthandAddress = function(url){
        var foundUrl = '';
        
        if(url != ''){
            url = url.replace('acct:','');
            url = ident.trim(url,' ');
            var parts = new Array();
            
            // format: glennjones@twitter.com i.e. WebFinger style not email
            if(url.indexOf('@' > -1) && url.indexOf('/') == -1 ){  
                parts = url.split('@');
                parts = [parts[1],parts[0]]
            }
            
            // format: twitter.com/glennjones or twitter/glennjones
            if(url.match(/\//g) != null ){  
                if(url.match(/\//g).length == 1 ){  
                    parts = url.split('\\');
                }
            }
            
            // format: twitter.com glennjones or twitter glennjones
            if(url.indexOf(' ') > -1){ 
                parts = url.split(' ');
            } 
            
            // format: twitter.com glennjones or twitter glennjones
            if(parts.length == 2){   
                var identity = new Object();
                var domainPart = ident.trim(parts[0].toLowerCase(),' ');
                var username = ident.trim(parts[1].toLowerCase(),' ');
                identity.ident = username;
                identity.pk = username;
                for(var x = 0; x <= ident._endPoints.sites.length-1; x++){
                    if(domainPart == ident._endPoints.sites[x].domain){
                       foundUrl = ident.getAPIEndPoint('Profile','hCard',ident._endPoints.sites[x].urlmappings, identity);
                       if(foundUrl == '')
                            foundUrl = ident.getAPIEndPoint('Profile','None',ident._endPoints.sites[x].urlmappings, identity);
                            
                    }

                    if(domainPart == ident._endPoints.sites[x].name.toLowerCase().replace(/\s/g, '')){
                       if(foundUrl == '')
                            foundUrl = ident.getAPIEndPoint('Profile','hCard',ident._endPoints.sites[x].urlmappings, identity);
                                if(foundUrl == '')
                                     foundUrl = ident.getAPIEndPoint('Profile','None',ident._endPoints.sites[x].urlmappings, identity);
                    }
                    
                    if(foundUrl != '')
                       break;
                }
            }
            if(foundUrl != '')
                url = foundUrl;
        }
        
        return url;
    }
 
 
    // Utility functions
    // ----------------------------------------------------
 
 
     // Compares a full domain from url to a root domain
    // ie www.twitter.com to twitter.com = true
    ident.compareRootDomains = function(fullDomain, rootDomain) {
        var same = false;
        if(fullDomain != '' || rootDomain != ''){
            //Remove common subdomain
            fullDomain = fullDomain.toLowerCase().replace('www.','');
            // Look for full match
            if(fullDomain == rootDomain){
                same = true;
            }else{
                // Look for part match
                if( fullDomain.indexOf(rootDomain) > -1)
                    same = true;
            }
        }
        return same;
    };
    
    
    // Compares urls for match
    // ie www.twitter.com/glennjones = twitter.com/GlennJones/ 
    ident.compareUrl = function(urlA, urlB) {
        var same = false;
        
        // Remove url fragments
        if( urlA.indexOf('#') > -1)
            urlA = urlA.split('#')[0];
       
        if( urlB.indexOf('#') > -1)
            urlB = urlB.split('#')[0];
        
        if(urlA != '' || urlB != ''){
            //Remove common subdomain
            urlA = urlA.toLowerCase().replace('www.','');
            urlB = urlB.toLowerCase().replace('www.','');
            
            // Make sure anything ends with / 
            if( ident.endsWith(urlA,'/') == false)
                urlA = urlA + '/';
                
            if( ident.endsWith(urlB,'/') == false)
                urlB = urlB + '/';    
                
            // Look for full match
            if(urlA.toLowerCase() == urlB.toLowerCase())
                same = true;
           
        }
        return same;
    };
 
     // Parses the domain name from a given URL
    ident.parseDomainFromURL = function(url) {
        var domain = "";
        if(url != undefined && url != '')
        {
            if (url.indexOf("//") > 0 ){ 
                var parts = url.split("/");
                domain = parts[2];
            }
        }
        return domain;
    };
    
    // Parses the domain name from a given SGN
    // Structure of sgn - sgn://twitter.com/?pk=12497 or sgn://twitter.com/?ident=glennjones
    ident.parseDomainFromSGN = function(sgn) {
        var domain = "";
        sgn = sgn.substring(6,sgn.length);
        var parts = sgn.split('/');
        if(parts[0].length > -1)
            domain = parts[0];
        return domain;
    };
    
 
    // Very simple endsWith function. Use with care
    ident.endsWith = function(str,test)
    {
        var lastIndex = str.lastIndexOf(test);
        return (lastIndex != -1) && (lastIndex + test.length == str.length);
    }
    
    
    // Returns true/false if obj is a object
    ident.isObject =  function(obj) {
        return (typeof obj == "object");
    };
    
    // Returns true/false if obj is a array
    ident.isArray = function(obj) {
       if (obj.constructor.toString().indexOf("Array") == -1)
          return false;
       else
          return true;
    };
    
    // Returns true/false if obj is a string
    ident.isString = function(obj) {
        return typeof obj == 'string';
    };
    
    // Returns true/false if a string is in an array
    ident.contains = function (array, string) {
        var found = false;
        for (var i = 0; i < array.length; i++) {
            if (array[i] == string) {
                found = true;
                break;
            }
        }
        return found;
    };
    
    ident.isUrl = function(string) {
	    var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	    return regexp.test(string);
	 };

 
    // Returns a string value what every is paased
    ident.tidyString = function(str){
        var output = "";
        if(ident.isString(str)){
            if(str != undefined){
                if(str != null){
                    output = ident.trim( str )
                }else{
                    output = '';
                }
            }else{
               output = '';
            }
        }
        return output;
    };
    
    
    ident.trim = function(str, chars) {
        if(str != '' && chars != '')
	        return ident.ltrim(ident.rtrim(str, chars), chars);
	    else
	        return '';
    };
 
    ident.ltrim = function(str, chars) {
	    chars = chars || "\\s";
	    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
    };
 
    ident.rtrim = function(str, chars) {
	    chars = chars || "\\s";
	    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
    };
    
    // Checks string is Null or Empty
    ident.isNullorEmpty = function(string){
        if (string == null || string == undefined || string == '' )
            return true
        else
            return false
    };
    
     
    // A helper function to finds a value of a given JSON property
    ident.getNodeVaue = function( test, obj ) {
        // Gets a value from a JSON object
        // vcard[0].url[0]
        var output = null;
        try{
            var currentOject = obj;
            var arrayDots = test.split(".");
            for (var i = 0; i < arrayDots.length; i++) {
                if( arrayDots[i].indexOf('[') > -1 )
                {
                    var arrayAB = arrayDots[i].split("[");
                    var arrayName = arrayAB[0];
                    var arrayPosition = Number( arrayAB[1].substring(0,arrayAB[1].length-1) );
		            
		            if( currentOject[arrayName] != null || currentOject[arrayName] != 'undefined' ) {
		                if( currentOject[arrayName][arrayPosition] != null || currentOject[arrayName][arrayPosition] != 'undefined' )
                   	        currentOject = currentOject[arrayName][arrayPosition];
                   	           
                    }
                    else {
                        currentObject = null; 
                    }    
                }
                else
                {
	                if( currentOject[arrayDots[i]] != null || currentOject[arrayDots[i]] != 'undefined'   )
                	    currentOject = currentOject[arrayDots[i]];    
                }
            }
            output = currentOject;
        }catch(err){
            output = null;
        }
        return output;
    }
    





    // jQuery functions
    // ------------------------------------------------------
    
    ident.GoogleGraphAPICall = function( apiurl, historyItem ){
        jQuery.getJSON(apiurl + "&callback=?", function(json){
            ident.apiManager( json, historyItem );
        });
    }
    
    ident.resetTrigger = function(){
        jQuery(document).trigger('ident:reset');
    }

    ident.statusUpdateEvent = function(){
        if(arguments.length > -1)
            jQuery(document).trigger('ident:update', arguments[0]);
        else
            jQuery(document).trigger('ident:update');
    }
    
    ident.error = function(){
        if(arguments.length > -1)
            jQuery(document).trigger('ident:error', arguments[0]);
        else
            jQuery(document).trigger('ident:error');
            
        ident.reset();     
    }
    
    
   