linker = new Array();


MakeLink('socionic','http://www.socionics.com/main/intro.htm','active-text');
MakeLink('hidden agenda','http://www.socionics.com/advan/hiddena.htm','active-text');
MakeLink('rational','http://www.socionics.com/advan/irra.htm','active-text');
MakeLink('irrational','http://www.socionics.com/advan/irra.htm','active-text');
MakeLink('visual identification','http://www.socionics.com/advan/vi/vi.htm','active-text');
MakeLink('psychological type','http://www.socionics.com/main/types.htm','active-text');
MakeLink('dual','http://www.socionics.com/rel/dlt.htm','active-text');
MakeLink('vi','http://www.socionics.com/advan/vi/vi.htm','active-text');
MakeLink('v.i.','http://www.socionics.com/advan/vi/vi.htm','active-text');

MakeLink('intertype relation','http://www.socionics.com/rel/rel.htm','active-text');

MakeLink('extravert','http://www.socionics.com/main/types.htm','active-text');
MakeLink('extrovert','http://www.socionics.com/main/types.htm','active-text');
MakeLink('introvert','http://www.socionics.com/main/types.htm','active-text');

MakeLink('sensing type','http://www.socionics.com/main/types.htm','active-text');
MakeLink('intuitive type','http://www.socionics.com/main/types.htm','active-text');
MakeLink('feeling type','http://www.socionics.com/main/types.htm','active-text');
MakeLink('thinking type','http://www.socionics.com/main/types.htm','active-text');
MakeLink('judging type','http://www.socionics.com/main/types.htm','active-text');
MakeLink('perceiving type','http://www.socionics.com/main/types.htm','active-text');


MakeLink('type distribution','http://www.socionics.com/statistics/statistics.html','active-text');

MakeLink('psychometric test','http://www.socionics.com/advan/tests.html','active-text');
MakeLink('personality test','http://www.socionics.com/advan/tests.html','active-text');
MakeLink('psychological test','http://www.socionics.com/advan/tests.html','active-text');

MakeLink('socionics type assistant','http://www.socionics.com/sta/sta-1-r.html','active-text');


MakeLink('entp','http://www.socionics.com/main/disambiguation.html?ENTp','active-text');
MakeLink('isfp','http://www.socionics.com/main/disambiguation.html?ISFp','active-text');
MakeLink('esfj','http://www.socionics.com/main/disambiguation.html?ESFj','active-text');
MakeLink('intj','http://www.socionics.com/main/disambiguation.html?INTj','active-text');
MakeLink('enfj','http://www.socionics.com/main/disambiguation.html?ENFj','active-text');
MakeLink('istj','http://www.socionics.com/main/disambiguation.html?ISTj','active-text');
MakeLink('estp','http://www.socionics.com/main/disambiguation.html?ESTp','active-text');
MakeLink('infp','http://www.socionics.com/main/disambiguation.html?INFp','active-text');
MakeLink('esfp','http://www.socionics.com/main/disambiguation.html?ESFp','active-text');
MakeLink('intp','http://www.socionics.com/main/disambiguation.html?INTp','active-text');
MakeLink('entj','http://www.socionics.com/main/disambiguation.html?ENTj','active-text');
MakeLink('isfj','http://www.socionics.com/main/disambiguation.html?ISFj','active-text');
MakeLink('estj','http://www.socionics.com/main/disambiguation.html?ESTj','active-text');
MakeLink('infj','http://www.socionics.com/main/disambiguation.html?INFj','active-text');
MakeLink('enfp','http://www.socionics.com/main/disambiguation.html?ENFp','active-text');
MakeLink('istp','http://www.socionics.com/main/disambiguation.html?ISTp','active-text');



CLASS='';


v_ending = ["","s","es","ed","ity"];

for(ve=0; ve<v_ending.length; ve++){

k=0;

for(p=0; p<document.getElementsByTagName('td').length; p++){

    if(document.getElementsByTagName('td')[p].className == 'mid-col' || document.getElementsByTagName('td')[p].className == 'tdstrip-qabodyalt1' || document.getElementsByTagName('td')[p].className == 'tdstrip-qabodyalt2' || document.getElementsByTagName('td')[p].id == "atext_it"){

    postObj = document.getElementsByTagName('td')[p];


for (var active_word_orig in linker){

            active_word=active_word_orig+v_ending[ve];

      if(linker[active_word_orig] != null) {

            k=0;
            while(typeof(postObj.childNodes[k]) != 'undefined'){
    
                   if(postObj.childNodes[k].nodeType == 3){
    
                   node_txt = postObj.childNodes[k].nodeValue.toLowerCase();
       

                                  curPos = 0;
                                  startPos = 0;
                                  while (node_txt.indexOf(active_word, curPos) >= 0){

                                       if (node_txt.charAt(node_txt.indexOf(active_word, curPos)+active_word.length).match(/[a-zA-z]/) || node_txt.charAt(node_txt.indexOf(active_word, curPos)-1).match(/[a-zA-z]/)){curPos = node_txt.indexOf(active_word, curPos)+active_word.length;}
                                       else {
                                             startPos = node_txt.indexOf(active_word, curPos);
                                             postObj.childNodes[k].splitText(startPos);
                                             k++; 
                                             postObj.childNodes[k].splitText(active_word.length);
 
                                             postObj.replaceChild(getLink(postObj.childNodes[k].nodeValue, active_word_orig), postObj.childNodes[k]);
                                                                      
                                             linker[active_word_orig] = null;

                                             break;

                                       }//end else

                                  }//end while
                      
                        
                   }//end if

                   if ( linker[active_word_orig] == null){break;}
                   else {k++;}

            }//end while

      }//if
}//for


                                  

}

}
 
}                          




function MakeLink (word_, href_, class_){
  if (typeof(word_)!='undefined'){


cannot = 0;
if(document.location.href.split('\/').reverse()[0].split('\.htm')[0]== href_.split('\/').reverse()[0].split('\.htm')[0]){cannot = 1;}
//else {eval ("if(document.location.href.split('\/').reverse()[0].split('\.htm')[0].match(/"+word_+"/i)){cannot = 1;}");}
if (cannot) {return false;}


    linker[word_] = new Array();
    linker[word_]['href'] = (typeof(href_)=='undefined')?'#':href_;
    linker[word_]['class'] = (typeof(class_)=='undefined')?'':class_;
    
  }
}


function getLink(wpar_txt, wpar){

w = wpar.toLowerCase();

link = document.createElement('a');
image = document.createElement('img');
image.src = "common/graph/q-mark.gif";
image.border = "0";

link.setAttribute('href',linker[w]['href']);
link.setAttribute('title','More about '+ wpar_txt);
link_text = document.createTextNode(wpar_txt);
link.appendChild(link_text);
link.appendChild(image);
link.className=linker[w]['class'];
if (CLASS !=''){link.className=CLASS;}

return link;

}

