/*jslint strict:true, evil: true, onevar: true, nomen: false  */ /*global $, jQuery, console, hbx, window, ndm, document  */

"use strict";

var afs_context='',
    afs_link ='',
    currGoogleParam ='';

//function to append a text to the given value if search text not found
function appendText(value, addText, searchText){
    if(value){
        if(value.indexOf(searchText)==-1){
            value = addText + value;
        }
    }
    return value;
}

//function to compare 2 strings and extract the difference
function getGoogleAFSLink(curr, prev){
    var linkValue = "", found = 'false',currArray="",prevArray = "", i=0, j=0;
    if(curr){
        if(prev){
            currArray = curr.split("|");
            prevArray = prev.split("|");

            //loop through both the arrays and compare
            for(i=0; i<currArray.length; i++){
                found = 'false';
                for(j=0; j<prevArray.length; j++){
                    if(currArray[i]===prevArray[j]){
                        found = 'true';
                        break;
                    }
                }
                if(found==='false'){ //if not found in other array then consider it as link value
                    linkValue = currArray[i];
                    break;
                }
            }
        }
    }
    return linkValue;
}

