Hey guys, i have a really big problem!

I have to make a javascript Memory for my mommy (Birthday) and i don't know to go on.

Here's the already written code:

Code:
<script type="text/javascript">
		
			var maxfeld = 0;
			
			var Unsort = new Array();
			
			var AufgedeckteKarteId = 0;
			
			var AufgedeckteKarte = 0;
			
			var BildListe = new Array();
			BildListe[0] = "1.jpg";
			BildListe[1] = "2.jpg";
			BildListe[2] = "3.jpg";
			BildListe[3] = "4.jpg";
			BildListe[4] = "5.jpg";
			BildListe[5] = "6.jpg";
			BildListe[6] = "7.jpg";
			BildListe[7] = "8.jpg";					
			
			
					
			
			//Erstellt die Tabelle
			function zeichneFeld(s,r)
			{
				x=0;
				tab = "<table>";
				for (i=0; i < r; i++)
				{
					tab +="<tr>";
					for (j=0; j < s; j++)
						{
							tab += "<td><img id=\"f"+x+"\" src=\"images/0.jpg\" width=\"150\" height=\"150\"  onclick=\"javascript:showCard("+x+")\" /></td>";
							x++;
						}
					tab+="</tr>";		
				}
				tab +="</table>";
				
				maxfeld = x;
				
				document.getElementById("HT").innerHTML=tab;
			}
			
			
			function newGame()
			{
				//Blättchen verdeckt
				for (i = 0; i < maxfeld; i++)
					{
						document.getElementById("f"+i).src = "deck.jpg";
					}								
				
				
				var SortBildListe = new Array();
				
				// 2. Bildliste hinzufügen
				for (i = 0; i < maxfeld/2; i++)
					{
						SortBildListe.push(BildListe[i]);
						SortBildListe.push(BildListe[i]);
					}
				
				
				
				
				
				// Bilder "vermischen"		
				for (i = 0; i < maxfeld; i++)
					{
						r = Math.floor((Math.random()*SortBildListe.length));											
						Unsort.push(SortBildListe[r]);
						SortBildListe.splice(r,1);
					}
					
					
				
				/*	
				for ( i= 0; i < maxfeld; i++)
				{
					document.getElementById("f"+i).src = Unsort[i];
				}	
				*/

				
					
			}
			
			function showCard(id)
			{
				document.getElementById("f" + id).src=Unsort[id];
				
			}
			
					
		</script>
I don't know, how write the code for only two open cards, who i compare the two id's of the cards and than the pairs which are not identific should turn back and the others should stay open.

Maybe somebody can help me.

Greetings Kate