// JavaScript Document
//Start of Curling Corner
 
                cnr= new Array()
                cnr[1]= new Image(167,167)
                cnr[1].src = '../i/p2.gif'
                cnr[2]= new Image(167,167)
                cnr[2].src = '../i/p3.gif'
                cnr[3]= new Image(167,167)
                cnr[3].src = '../i/p4.gif'
                                
                showthis=0                 //prepares the repeat-preventing variable
          
function curl(a1) {        
                                          //the next three lines help prevent repeating images

               oldcnr = new Array()
               oldcnr[2] = oldcnr[1]
               oldcnr[1] = showthis
                        
                                        //the next line chooses the number to use in selecting the image
                        
               showthis = parseInt((Math.random()*(cnr.length-1))+1);    
                        
                                        //the next two lines help prevent repeating images
                        
         //      if (showthis == oldcnr[1]) {RandomSwapOut();}
        //       if (showthis == oldcnr[2]) {RandomSwapOut();}
                        
                                        //the next line replaces the image with the new, random image
              
//			  var img=document.getElementById(id);
	//		  img.src=cnr[showthis].src; 
		//	  return true; 
		var cnr_id=a1.id.substr(5);
		var eek=document.getElementById(cnr_id);
			
			eek.style.backgroundImage = "url("+cnr[showthis].src+")"; return true;
        }


function uncurl(a1) {  
		var cnr_id=a1.id.substr(5);
		var eek=document.getElementById(cnr_id);
		eek.style.backgroundImage = "url(../i/p1.gif)"; return true;  
	             }

//start of flip
function flip(C1) { 
  var polaID=C1.id.substr(5);   // gets id of polaroid from corner ID
	var flpf=document.getElementById(polaID); // grabs the whole polaroid to flip
	  var img=document.getElementById('img_'+polaID); // grabs the image to replace
	    var tmp=document.getElementById('tmp_'+polaID); // grabs the relevent div to store the image
	      var txt=document.getElementById('txt_'+polaID); // grabs the text 
	
	tmp.innerHTML=flpf.innerHTML;  // copies whole polaroid to names temporary span element
	flpf.innerHTML=txt.innerHTML; // replaces image with text
}
	
function flipback(C2) {
  var polaID=C2.id.substr(5); // gets id or polaroid from corner ID
    var tmp=document.getElementById('tmp_'+polaID); // grabs the temp location of polaroid
	  var flpf=document.getElementById(polaID); // grabs the whole polaroid to flip

	flpf.innerHTML=tmp.innerHTML;
	tmp.innerHTML='';
}
