// JavaScript Document
//Start of Curling Corner
 
                cnr= new Array()
                cnr[1]= new Image(67,45)
                cnr[1].src ='../i/polaC1.gif'
                cnr[2]= new Image(67,45)
                cnr[2].src ='../i/polaC2.gif'
                cnr[3]= new Image(67,45)
                cnr[3].src ='../i/polaC3.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(0);
		var eek=document.getElementById(cnr_id);
		
        eek.src = cnr[showthis].src; return true; 
     
                }


function uncurl(a1) {  
		var cnr_id=a1.id.substr(0);
		var eek=document.getElementById(cnr_id);
		eek.src = "../i/polaC.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('pola_'+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 
            var crn1=document.getElementById('crn_'+polaID); // grabs first corner
		      var crn2=document.getElementById('crnb_'+polaID); // grabs replacement corner
			    var footer=document.getElementById('btm_'+polaID); // grabs polaroid name image image  
	
	tmp.innerHTML=flpf.innerHTML;  // copies whole polaroid to names temporary span element
	img.innerHTML=txt.innerHTML; // replaces image with text
	crn1.innerHTML=crn2.innerHTML; // replaces front corner with rear corner
	footer.src='../i/polaB.gif'; // changes source of polaroid name image
}
	
function flipback(C2) {
  var polaID=C2.id.substr(4); // gets id or polaroid from corner ID
    var tmp=document.getElementById('tmp_'+polaID); // grabs the temp location of polaroid
	  var flpf=document.getElementById('pola_'+polaID); // grabs the whole polaroid to flip

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