function addLoadEvent ( func ) {
	var oldonload = window.onload;
	if ( typeof window.onload != 'function' ) {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		};
	};
};


var resources = {
	preload : function () {
	    // global variables as file handles
	    source_handle = Array();      // subarray position 0=img, 1= <a> tag
	    swapout_handle = Array();
	    folder_directory = "t150x300";
	    
	    // get all of the UL lists on the page
        var item_count = 0;

		var content_handle = document.getElementById("content");
		var rsrc_handle = content_handle.getElementsByTagName("li");
        var test_class_01 = "js_indiv_item";
	    var test_class_02 = "js_source";
	    var test_class_03 = "js_swapout";
		
		//Find the items to scan for and park them in the arrays
		//First find the individual items and make sure you increment just before you escape the if....
		for (var i=0; i < rsrc_handle.length; i++) {
		  if (rsrc_handle[i].getAttribute("class") == test_class_01 || rsrc_handle[i].getAttribute("className") == test_class_01) {		      
		      var local_src_handle = Array();  // position 0=img, 1= <a> tag
		      var local_swap_handle = Array(); 

		      
		      // get all of the image tags and use the first one
		      var image_get = rsrc_handle[i].getElementsByTagName("img");
		      local_src_handle[0] = image_get[0];		      
		      
		      // set counter for a tags
		      // get all of the a tags and use all of the ones that have the right stuff
		      // when we get the other source a tag and put it in local_src_handle[1] then we set the source_handle based on the i - count
		      // to = local_src_handle
		      xtra_pics = 0; //counter for actual found pics
		      var atag_get = rsrc_handle[i].getElementsByTagName("a");
		      for (var j=0; j < atag_get.length; j++) {		          
		          if (atag_get[j].getAttribute("class") == test_class_02 || atag_get[j].getAttribute("className") == test_class_02) {
		              // set the other source variable
		              local_src_handle[1] = atag_get[j];       		      
		          } else if (atag_get[j].getAttribute("class") == test_class_03 || atag_get[j].getAttribute("className") == test_class_03) {
		              // start setting the swapout array
		              local_swap_handle[xtra_pics] = atag_get[j];
		              xtra_pics ++;
		          };
		      };
		      
		      source_handle[item_count] = local_src_handle;
		      swapout_handle[item_count] = local_swap_handle;
		      item_count ++;
		  }; // end if when complete working inside of individual resource
		}; // end i-loop
		
		
		// iterate back through the arrays and using global variables and reassign values
        for (var i=0; i < source_handle.length; i++) {
            //set onclick for <a> of the source (pos 1) to function "L" below. 
            source_handle[i][1].onclick = new Function ( "resources.l ( 'larger.php?img=' + this.href ); return false;" );

            // get each swapout
            for (var j=0; j < swapout_handle[i].length; j++) {
                // swapout_handle[i][j]
                // get the href from each swapout
                // on a click on the swapout handle set the href for the source <a> (i-loop) tag to the swapout href
                swapout_handle[i][j].onclick = new Function ( "resources.chHref ( " + i + ", " + j + " ); return false;" );                
            };            
        }; // end new i-loop
        
        // check the UL lists - 
        // end preload
	},
	l : function ( iid ) {
		// iid is the full URL, including the image URl in a http://currentsite/larger.php?img=IMGURL
		window.open( iid, "larger", "width=400,height=400,resizable=yes,scrollbars=yes" );
		return false;
	},
	chHref : function ( i, j ) {
	    // needs i and j positions to modify global variables, as well as current href
	    // i loop defines current resource
	    // j loop defines current "additional photo" being used
	    // raw href is used for swapping in href for source_handle[i][1]	    
	    
	    // uses following globals: 
	        // source_handle = Array();      // subarray position 0=img, 1= <a> tag
	        // swapout_handle = Array();
	        // folder_directory = "t150x300";

        // insert the folder directory to the swapout
	    base_href = swapout_handle[i][j].getAttribute("href");    	    
	    source_handle[i][1].setAttribute("href",base_href);

        //  set the src of the src image to the modded url
        small_img = base_href.replace(/resources\//, "resources/" + folder_directory + "/" );
  	    source_handle[i][0].setAttribute("src",small_img);

		return false;	    
	}
};

var about = {
	preload : function () {
		el = document.getElementById("content");
		var blocks = el.getElementsByTagName("li");
		
		for ( i=0; i<blocks.length; i++ ) {
			//get "a" tag children of each list item			
			// The first "a" tag will always be the image.
			var imgTag = blocks[i].getElementsByTagName("a");
						
			//and onclick we run "l" to open a new window wih the href of the image tag
			imgTag[0].onclick = new Function ( "about.l ( 'larger.php?img=' + this.href ); return false;" );
		}
	},
	l : function ( iid ) {
		// iid is the full URL, including the image URl in a http://currentsite/larger.php?img=IMGURL
		window.open( iid, "larger", "width=400,height=400,resizable=yes,scrollbars=yes" );
		return false;
	}
};

var team = {
	preload : function () {
	    search_class = "abt_image";
		el = document.getElementById("content");
		var blocks = el.getElementsByTagName("div");
		
		// get divs - searc for class "abt_image", then get all "a"'s
		
		for ( i=0; i<blocks.length; i++ ) {
            if (blocks[i].getAttribute("class") == search_class || blocks[i].getAttribute("className") == search_class) {
    			//get "a" tag children of each list item			
    			// The first "a" tag will always be the image.
    			var imgTag = blocks[i].getElementsByTagName("a");


    			//and onclick we run "l" to open a new window wih the href of the image tag
    			imgTag[0].onclick = new Function ( "team.l ( 'larger.php?img=' + this.href ); return false;" );

            }


		}
	},
	l : function ( iid ) {
		// iid is the full URL, including the image URl in a http://currentsite/larger.php?img=IMGURL
		window.open( iid, "larger", "width=600,height=600,resizable=yes,scrollbars=yes" );
		return false;
	}
};

var index = {
	preload : function () {

        test_href = "jpg";
        
        //diagnostic
		//alert(test_href);
        

	    // global variables as file handles
		content_handle = document.getElementById("content");
		content_a_handle = content_handle.getElementsByTagName("a");
		
		//Find the items to scan for and park them in the arrays
		//First find the individual items and make sure you increment just before you escape the if....
		for (i=0; i < content_a_handle.length; i++) {
		    
            handle_href = content_a_handle[i].href;
            is_jpg_result = handle_href.search(test_href);
            //diagnostic
    		//alert("HELP!!" + is_jpg_result);
		    //alert(content_a_handle[i].href);
		  if (is_jpg_result >= 0) {		      
		      //set onclick for <a> of the source (pos 1) to function "L" below. 
              content_a_handle[i].onclick = new Function ( "index.l ( 'larger.php?img=' + this.href ); return false;" );             	      

		  }; // end if when complete working inside of individual resource
		}; // end i-loop
		

	    // global variables as file handles
		content_handle = document.getElementById("right");
		content_a_handle = content_handle.getElementsByTagName("a");
		
		//Find the items to scan for and park them in the arrays
		//First find the individual items and make sure you increment just before you escape the if....
		for (i=0; i < content_a_handle.length; i++) {
		    
            handle_href = content_a_handle[i].href;
            is_jpg_result = handle_href.search(test_href);
            //diagnostic
    		//alert("HELP!! Side! " + is_jpg_result);
		    //alert(content_a_handle[i].href);
		    
  		  if (is_jpg_result != 0) {		      
      		  //alert("HELP!! Side! " + is_jpg_result);
		      //set onclick for <a> of the source (pos 1) to function "L" below. 
              content_a_handle[i].onclick = new Function ( "index.l ( 'larger.php?img=' + this.href ); return false;" );             	      

		  }; // end if when complete working inside of individual resource
		}; // end i-loop
	},
	l : function ( iid ) {
		// iid is the full URL, including the image URl in a http://currentsite/larger.php?img=IMGURL
		window.open( iid, "larger", "width=400,height=400,resizable=yes,scrollbars=yes" );
		return false;
	}
};

var news = {
	preload : function () {

        test_href = "jpg";
        
        //diagnostic
		//alert(test_href);
        

	    // global variables as file handles
		content_handle = document.getElementById("content");
		content_a_handle = content_handle.getElementsByTagName("a");
		
		//Find the items to scan for and park them in the arrays
		//First find the individual items and make sure you increment just before you escape the if....
		for (i=0; i < content_a_handle.length; i++) {
		    
            handle_href = content_a_handle[i].href;
            is_jpg_result = handle_href.search(test_href);
            //diagnostic
    		//alert("HELP!!" + is_jpg_result);
		    //alert(content_a_handle[i].href);
		  if (is_jpg_result >= 0) {		      
		      //set onclick for <a> of the source (pos 1) to function "L" below. 
              content_a_handle[i].onclick = new Function ( "news.l ( 'larger.php?img=' + this.href ); return false;" );             	      

		  }; // end if when complete working inside of individual resource
		}; // end i-loop
		

	    // global variables as file handles
		content_handle = document.getElementById("right");
		content_a_handle = content_handle.getElementsByTagName("a");
		
		//Find the items to scan for and park them in the arrays
		//First find the individual items and make sure you increment just before you escape the if....
		for (i=0; i < content_a_handle.length; i++) {
		    
            handle_href = content_a_handle[i].href;
            is_jpg_result = handle_href.search(test_href);
            //diagnostic
    		//alert("HELP!! Side! " + is_jpg_result);
		    //alert(content_a_handle[i].href);
		    
  		  if (is_jpg_result != 0) {		      
      		  //alert("HELP!! Side! " + is_jpg_result);
		      //set onclick for <a> of the source (pos 1) to function "L" below. 
              content_a_handle[i].onclick = new Function ( "news.l ( 'larger.php?img=' + this.href ); return false;" );             	      

		  }; // end if when complete working inside of individual resource
		}; // end i-loop
	},
	l : function ( iid ) {
		// iid is the full URL, including the image URl in a http://currentsite/larger.php?img=IMGURL
		window.open( iid, "larger", "width=400,height=400,resizable=yes,scrollbars=yes" );
		return false;
	}
};


var pl = {
	checkBody : function ( ) {
		bd = document.body;
		if ( bd.id == "resources" ) {
			resources.preload();
		}
		if ( bd.id == "team" ) {
			team.preload();
		}
		if ( bd.id == "index" ) {
			index.preload();
		}
		if ( bd.id == "news" ) {
			news.preload();
		}
	}
};

if ( document.getElementById && document.getElementsByTagName ) { 
	addLoadEvent(pl.checkBody);
};



