// subpages
h=1;

while(h<=pgs)
  {
		pgloop=h;
    	  c=1;
    	  s=1;
    	  subpgs=0;
          while(s<=20)
          {
          
            subpgnum=window['page'+pgloop+'_'+s];
            
            if(subpgnum!=undefined){
             subpgs=subpgs+1;
        
        	}
          
          s++;
          }
    	  if(subpgs>0){
		  
    	  document.write('<div id="dropmenu'+pgloop+'" class="dropmenudiv" align="left">');
    	  }
    	  while(c<=subpgs)
            {
            
            subpgnum=window['page'+pgloop+'_'+c];
			subpglink=window['page'+pgloop+'_'+c+'link'];
			subisgallery=window['page'+pgloop+'_'+c+'gallery'];
           	
    		if(subpgnum!=undefined){
				if(subisgallery){
					g=window['page'+pgloop+'_'+c+'galnum'];
					document.write('<a href="gallery.html?pg='+pgloop+'&sub='+c+'&gal='+g+'">'+subpgnum+'</a>');
				}
				else {
    			 	document.write('<a href="'+subpglink+'">'+subpgnum+'</a>');
				 }
    		}
    		
    		c++;
          	}
    	  if(subpgs>0){
    	  	document.write('</div>');
    	  }
h++;
}
    	// end subpages code
