		function in_array(needle,haystack){
	var haystack_length=haystack.length;
	
	for(var i=0;i<haystack_length;i++){
		if(needle==haystack[i]){
			return true;
		}
	}
	
	return false;
}
	   
function getBooks(){
	var urls=new Array('http://tinyurl.com/yvopz5',
			       'http://tinyurl.com/289ql6',
				   'http://tinyurl.com/2dnh98',
				   'http://tinyurl.com/ysjc84',
				   'http://tinyurl.com/238s8n',
				   'http://tinyurl.com/39nupe',
				   'http://tinyurl.com/38n6ez',
				   'http://tinyurl.com/3cq4p2',
				   'http://tinyurl.com/ys3snl',
				   'http://tinyurl.com/2t3zf5',
				   'http://tinyurl.com/2opdua',
				   'http://tinyurl.com/2rqnqw',
				   'http://tinyurl.com/3av7c9',
				   'http://tinyurl.com/3akkkv',
				   'http://tinyurl.com/2wpsxh',
				   'http://tinyurl.com/3xumop');
	
	var books=new Array('Visions',
				    'The Heinle Picture Dictionary for Children',
					'Gateway to Science - Vocabulary and Concepts',
					'Grammar in Context',
					'The Heinle Reading Library: Academic Content Collection',
					'The Heinle Reading Library: Biography Collection',
					'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
					'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
					'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
					'Step-By-Step Writing Book 1',
					'Foundations Reading Library',
					'Destinations 2 - Writing for Academic Success',
					'Far From Home - Reading and Word Study',
					'At Home in Two Lands',
					'Concepts and Comments',
					'Strategies for Test-Taking Success');
	
	var imgs=new Array('<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000116_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1413022561_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1424003318_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000421_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000682_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000762_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000464_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000465_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000463_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1424004004_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000742_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1413019366_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/0838448526_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/141302730X_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/0155997181_th.gif" border="0">',
				   '<img src="http://eltmedia.thomsonlearning.com/prod_images/thumbnails/1000000662_th.gif" border="0">');
				   
						 					  
	var k=new Array('The Heinle Picture Dictionary for Children');
	
	var one=new Array('The Heinle Picture Dictionary for Children');
	
	var two=new Array('The Heinle Picture Dictionary for Children');
	
	var three=new Array('The Heinle Picture Dictionary for Children');
							   
	var four=new Array('The Heinle Picture Dictionary for Children');
	
	var five=new Array('The Heinle Picture Dictionary for Children');
	
	var six=new Array('The Heinle Picture Dictionary for Children',
					  'Visions',
					'Gateway to Science - Vocabulary and Concepts',
					'Grammar in Context',
					'The Heinle Reading Library: Academic Content Collection',
					'The Heinle Reading Library: Biography Collection',
					'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
					'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
					'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
					'Step-By-Step Writing Book 1',
					'Foundations Reading Library',
					'Destinations 2 - Writing for Academic Success',
					'Far From Home - Reading and Word Study',
					'At Home in Two Lands - Intermediate Reading and Word Study',
					'Concepts and Comments',
					'Strategies for Test-Taking Success');
					  
	var seven=new Array('Visions',					
					'Gateway to Science - Vocabulary and Concepts',
					'Grammar in Context',
					'The Heinle Reading Library: Academic Content Collection',
					'The Heinle Reading Library: Biography Collection',
					'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
					'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
					'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
					'Step-By-Step Writing Book 1',
					'Foundations Reading Library',
					'Destinations 2 - Writing for Academic Success',
					'Far From Home - Reading and Word Study',
					'At Home in Two Lands - Intermediate Reading and Word Study',
					'Concepts and Comments',
					'Strategies for Test-Taking Success');
						
	var eight=new Array('Visions',					
					'Gateway to Science - Vocabulary and Concepts',
					'Grammar in Context',
					'The Heinle Reading Library: Academic Content Collection',
					'The Heinle Reading Library: Biography Collection',
					'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
					'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
					'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
					'Step-By-Step Writing Book 1',
					'Foundations Reading Library',
					'Destinations 2 - Writing for Academic Success',
					'Far From Home - Reading and Word Study',
					'At Home in Two Lands - Intermediate Reading and Word Study',
					'Concepts and Comments',
					'Strategies for Test-Taking Success');
	
	var nine=new Array('Visions',					
					'Gateway to Science - Vocabulary and Concepts',
					'Grammar in Context',
					'The Heinle Reading Library: Academic Content Collection',
					'The Heinle Reading Library: Biography Collection',
					'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
					'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
					'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
					'Step-By-Step Writing Book 1',
					'Foundations Reading Library',
					'Destinations 2 - Writing for Academic Success',
					'Far From Home - Reading and Word Study',
					'At Home in Two Lands - Intermediate Reading and Word Study',
					'Concepts and Comments',
					'Strategies for Test-Taking Success');
	
	var ten=new Array('Visions',					
					'Gateway to Science - Vocabulary and Concepts',
					'Grammar in Context',
					'The Heinle Reading Library: Academic Content Collection',
					'The Heinle Reading Library: Biography Collection',
					'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
					'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
					'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
					'Step-By-Step Writing Book 1',
					'Foundations Reading Library',
					'Destinations 2 - Writing for Academic Success',
					'Far From Home - Reading and Word Study',
					'At Home in Two Lands - Intermediate Reading and Word Study',
					'Concepts and Comments',
					'Strategies for Test-Taking Success');
	
	var eleven=new Array('Visions',					
					'Gateway to Science - Vocabulary and Concepts',
					'Grammar in Context',
					'The Heinle Reading Library: Academic Content Collection',
					'The Heinle Reading Library: Biography Collection',
					'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
					'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
					'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
					'Step-By-Step Writing Book 1',
					'Foundations Reading Library',
					'Destinations 2 - Writing for Academic Success',
					'Far From Home - Reading and Word Study',
					'At Home in Two Lands - Intermediate Reading and Word Study',
					'Concepts and Comments',
					'Strategies for Test-Taking Success');
	
	var twelve=new Array('Visions',
						'Gateway to Science - Vocabulary and Concepts',
						'Grammar in Context',
						'The Heinle Reading Library: Academic Content Collection',
						'The Heinle Reading Library: Biography Collection',
						'The Heinle Reading Library: Illustrated Classics Collection - Beginning',
						'The Heinle Reading Library: Illustrated Classics Collection - Intermediate',
						'The Heinle Reading Library: Illustrated Classics Collection - Advanced',
						'Step-By-Step Writing Book 1',
						'Foundations Reading Library',
						'Destinations 2 - Writing for Academic Success',
						'Far From Home - Reading and Word Study',
						'At Home in Two Lands - Intermediate Reading and Word Study',
						'Concepts and Comments',
						'Strategies for Test-Taking Success');
	
	
	var grades=document.getElementsByName("grades");


	var grades_length=grades.length;
	
	var books_k=new Array();
	var books_one=new Array();
	var books_two=new Array();
	var books_three=new Array()
	var books_four=new Array();	
	var books_five=new Array();	
	var books_six=new Array();	
	var books_seven=new Array();	
	var books_eight=new Array();	
	var books_nine=new Array();	
	var books_ten=new Array();	
	var books_eleven=new Array();	
	var books_twelve=new Array();
	
	var grade_vals=new Array();
	
	var grades_length=grades.length;
	var b=document.getElementById('books');
	
	for(var i=0;i<grades_length;i++){
		if(grades[i].checked){
			grade_vals[i]=grades[i].value;
		}
	}
	
	//if nothing on the page is checked
	if(!grade_vals.length){
		var empty=true;
		b.innerHTML="";
	}else{
		var empty=false;
	}

	if(!empty){
		//if none of the grades are checked but one of the subjects are	
		
		for(var i=0;i<grade_vals.length;i++){
			//alert("outer i: "+i);
			//alert(typeof(grade_vals[i]));
			//if(grades[i].checked){
				//alert(grades[i].value);
				switch(grade_vals[i]){
					
					case "k":
					var k_length=k.length;
					//alert('yay');
					
					for(var j=0;j<k_length;j++){
						//alert(k[j]);
						if(!in_array(k[j],books_k)){
							//alert(k[j]);
							books_k.push(k[j]);
						}
											
					}									
														
					break;
					
					case "1":
					var one_length=one.length;
					//alert('yay');
					
					for(var j=0;j<one_length;j++){
						if(in_array(one[j],books)){
							if(!in_array(one[j],books_one)){
								books_one.push(one[j]);
							}
						}						
					}									
														
					break;
					
					case "2":
					var two_length=two.length;
					//alert('yay');
					
					for(var j=0;j<two_length;j++){
						if(in_array(two[j],books)){
							if(!in_array(two[j],books_two)){
								books_two.push(two[j]);
							}
						}						
					}									
														
					break;	
					
					case "3":
					var three_length=three.length;
					//alert('yay');
					
					for(var j=0;j<three_length;j++){
						if(in_array(three[j],books)){
							if(!in_array(three[j],books_three)){
								books_three.push(three[j]);
							}
						}						
					}									
														
					break;				
					
					case "4":
					var four_length=four.length;
					//alert('yay');
					
					for(var j=0;j<four_length;j++){
						if(in_array(four[j],books)){
							if(!in_array(four[j],books_four)){
								books_four.push(four[j]);
							}
						}						
					}									
														
					break;
					
					case "5":
					
					var five_length=five.length;
					
					for(var j=0;j<five_length;j++){
						if(in_array(five[j],books)){
							if(!in_array(five[j],books_five)){
								books_five.push(five[j]);
							}
						}						
					}									
										
					break;
					
					case "6":
					
					var six_length=six.length;
					
					//if just books books are checked
					
					for(var j=0;j<six_length;j++){
						if(in_array(six[j],books)){
							if(!in_array(six[j],books_six)){
								books_six.push(six[j]);
							}
						}						
					}									
										
					break;
					
					case "7":
					
					var seven_length=seven.length;
										
					for(var j=0;j<seven_length;j++){
						if(in_array(seven[j],books)){
							if(!in_array(seven[j],books_seven)){
								books_seven.push(seven[j]);
							}
						}						
					}									
					
					break;
					
					case "8":
					
					var eight_length=eight.length;
										
					for(var j=0;j<eight_length;j++){
						if(in_array(eight[j],books)){
							if(!in_array(eight[j],books_eight)){
								books_eight.push(eight[j]);
							}
						}						
					}									
										
					break;
					
					case "9":
					
					var nine_length=nine.length;
										
					for(var j=0;j<nine_length;j++){
						if(in_array(nine[j],books)){
							if(!in_array(nine[j],books_nine)){
								books_nine.push(nine[j]);
							}
						}						
					}									
										
					break;
					
					case "10":
					
					var ten_length=ten.length;
					
					for(var j=0;j<ten_length;j++){
						if(in_array(ten[j],books)){
							if(!in_array(ten[j],books_ten)){
								books_ten.push(ten[j]);
							}
						}						
					}									
										
					break;
					
					case "11":
					
					var eleven_length=eleven.length;
					//alert(eleven_length);
					//if just books books are checked
					
					for(var j=0;j<eleven_length;j++){
						if(in_array(eleven[j],books)){
							if(!in_array(eleven[j],books_eleven)){
								books_eleven.push(eleven[j]);
							}
						}						
					}									
										
					break;
					
					case "12":
					
					var twelve_length=twelve.length;
					//alert(twelve_length);
					//if just books books are checked
					
					for(var j=0;j<twelve_length;j++){
						if(in_array(twelve[j],books)){
							if(!in_array(twelve[j],books_twelve)){
								books_twelve.push(twelve[j]);
							}
						}						
					}									
														
					break;
					
					
				}
				
				
			//}
		}
		
		
		var html_str="";
		
		//outputs books books in table format
		
		html_str+='<table border="1" widtd="450" cellpadding="4" cellspacing="0"><tr bgcolor="#003399"><td colspan="14" class="dicipHEAD">books</td></tr><tr>';
		html_str+='<td width="180" rowspan="2" class="bold12" align="center">Title</td><td width="270" colspan="13" class="bold12" align="center">Grade Levels</td></tr><tr>';
		html_str+='<td class="bold12" align="center">K</td><td class="bold12" align="center">1</td><td class="bold12" align="center">2</td><td class="bold12" align="center">3</td><td class="bold12" align="center">4</td><td class="bold12" align="center">5</td><td class="bold12" align="center">6</td><td class="bold12" align="center">7</td><td class="bold12" align="center">8</td><td class="bold12" align="center">9</td><td class="bold12" align="center">10</td><td class="bold12" align="center">11</td><td class="bold12" align="center">12</td></tr>';
		
		for(var i=0;i<books.length;i++){
			
			if(in_array(books[i],books_k) || in_array(books[i],books_one) || in_array(books[i],books_two) || in_array(books[i],books_three) || in_array(books[i],books_four) || in_array(books[i],books_five) || in_array(books[i],books_six) || in_array(books[i],books_seven) || in_array(books[i],books_eight) || in_array(books[i],books_nine) || in_array(books[i],books_ten) || in_array(books[i],books_eleven) || in_array(books[i],books_twelve)){
				//alert('you are here');
				
				html_str+='<tr><td><a href="'+urls[i]+'">'+imgs[i]+'</a><br><a href="'+urls[i]+'">'+books[i]+'</a></td>';					

				if(in_array(books[i],books_k)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
				
				if(in_array(books[i],books_one)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
				
				if(in_array(books[i],books_two)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
				
				if(in_array(books[i],books_three)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
								
				if(in_array(books[i],books_four)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
				
				if(in_array(books[i],books_five)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
				
				if(in_array(books[i],books_six)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
		
				if(in_array(books[i],books_seven)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}	
				
				if(in_array(books[i],books_eight)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
		
				if(in_array(books[i],books_nine)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
				
				if(in_array(books[i],books_ten)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}
				
				if(in_array(books[i],books_eleven)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}	
				
				if(in_array(books[i],books_twelve)){
					html_str+='<td><img src="checked-icon.gif" /></td>';
				}else{
					html_str+='<td>&nbsp;</td>';
				}	
			
				html_str+='</tr>';
			}
			
		}
		
		html_str+='</table><br><br>';		
	
	
		b.innerHTML=html_str;
		
		//var debug=document.getElementById('debug');
		//debug.innerHTML='books: '+books_four.toString()+'<br />';
		
		
	}	
}