 /*
 **  Developer: Anthony James
 **      Email: webdevelopernyc@gmail.com
 **     Client: Jeff Greenspan ~ http://www.jeffgreenspan.com (Programmed specifically for this site)
 **   Synopsis: Javascript implementation to facilitate hyperlink navigation between
 **             project-nodes as situated within corresponding project-category
 **       Date: May 2010 
 ** 
 */
 
 

galleryNav = function(gallery) {

  var listElement = null;

  listElement = document.getElementById(gallery).getElementsByTagName("LI");

  var project_link = null;
  
  var wrapper = "<div id='projects_wrapper'>";

  var x = null;

  var id = null;

  var num_iters = 9;

  var len = listElement.length;
  
  var linkstyles = new Array;
  
  for(l=0;l<len;l++) {
  	if(l==psubid) {
  		linkstyles[l]="chosen";
  	} else {
  		linkstyles[l]="hide";
  	}
  }
  
    
  var currentURL=document.URL;
  var URLarray=currentURL.split("&psubid");
  var shortenedURL=URLarray[0];
  

  if(len == 0){
	 
      project_link = "There are no projects for this category.";

    }else{

      project_link = "";

  }	

  for(x = 0; x < len; x++){		 

    id = String(listElement[x]['id']);

      if (x == num_iters){ 

	    url_prefix = "<a href='" + shortenedURL + "&psubid=" + (x+1) + "' class='" + linkstyles[x] + "' >";
	  
        project_link = project_link+url_prefix+(x+1)+"</a>&nbsp;";	 
//alert('num_iters... '+x); 	 
	  } else if(x === 0){

		//first project -- only one project
//alert('first project...'+x);		
		if(len == 1){

        project_link = ""; 
		
		} else {
		
		//first project -- more than one project	
		
	    url_prefix = "<a href='" + shortenedURL + "&psubid=" + (x+1) + "' class='" + linkstyles[x] + "'>";  
   
        project_link = project_link+url_prefix+(x+1)+"</a>&nbsp;";
		
		}
		  
     } else {
//alert('subsequent projects... '+x);		  
        //subsequent projects
			
	    url_prefix = "<a href='" + shortenedURL + "&psubid=" + (x+1) + "' class='" + linkstyles[x] + "'>";
		
		project_link = project_link+url_prefix+(x+1)+"</a>&nbsp;";

      }  

} 

//alert('project_link'+project_link);
 document.getElementById(id).innerHTML = project_link;

}
