/*switch_class.js3*/

//set up arrays with more_link id's, collapse_link id's, and rest_of_article id's:
var rest_of_articles=new Array("rest_of_navfeatures", "rest_of_art1", "rest_of_art2", "rest_of_gov");
var more_links=new Array("more_navfeatures", "more_art1", "more_art2", "more_gov");
var collapse_links=new Array("collapse_navfeatures", "collapse_art1", "collapse_art2", "collapse_gov");

// window.onload=initialize;
// Ken Ford (ProjectSeven.com) told me to commment out the above line and add initialize() to my onload body tag.

//executes after the html in the body already exists:
function initialize(){

for(var i=0; i < rest_of_articles.length; i++)
{
     document.getElementById(rest_of_articles[i]).className="no_display";
     document.getElementById(more_links[i]).className="display_link";

     document.getElementById(more_links[i]).onclick=more_article;
     document.getElementById(collapse_links[i]).onclick=collapse_article;
}
}

function more_article(){

//find position in the more_links array of the link that was clicked:
for(var position=0; position < more_links.length; position++){

     //this.id is the id of the link that was clicked:
     if(this.id == more_links[position]) break;
}

//display full article corresponding to the link that was clicked:
if(position <  more_links.length) // then found position in more_links array
{
     document.getElementById(rest_of_articles[position]).className="display_text";
     document.getElementById(more_links[position]).className="no_display";
     document.getElementById(collapse_links[position]).className="display_link";
     return false;
}
else
{
    alert("error");
}

}


function collapse_article(){

//find position in the collapse_links array of the link that was clicked:
for(var position=0; position < collapse_links.length; position++){

    //this.id is the id of the link that was clicked:
    if(this.id == collapse_links[position]) break;  
}

//hide rest of article and display the 'more' link:
if(position < more_links.length) // then found position in collapse_links array
{
     document.getElementById(rest_of_articles[position]).className="no_display";
     document.getElementById(more_links[position]).className="display_link";
     return false;
}
else //didn't find position in array--something is wrong!
{
     alert("error");
}

}