// JavaScript Document
   var casenum = 1
   var maxcase = 14
   var imgpath = 'images/cases/'
   var timer_active = 1

   function off_dig(num)
   {
      if (num != casenum)
         document.getElementById('dig'+num).style.color = '#bb7e16'
   }


   function show_before()
   {
      timer_active = 0 
      padnum = casenum
      if (casenum < 10)
         padnum = '0' + casenum
      document.images.face.src = imgpath + 'case_' + padnum + '_face_before.jpg'
      document.images.before.src = 'graphics/before_on.gif'
      document.images.after.src = 'graphics/after_off.gif'
   }


   function show_after()
   {
      timer_active = 0 
      padnum = casenum
      if (casenum < 10)
         padnum = '0' + casenum
      document.images.face.src = imgpath + 'case_' + padnum + '_face_after.jpg'
	  
	  var crossFadeDuration = 2;
	  document.images.face.style.filter="blendTrans(duration=crossFadeDuration)";
	  document.images.face.filters.blendTrans.Apply();
	  document.images.face.filters.blendTrans.Play();

	  
	  
      document.images.after.src = 'graphics/after_on.gif'
      document.images.before.src = 'graphics/before_off.gif'
   }


   function sel_num(num)
   {
      timer_active = 0 

      if (num != casenum)
      {
         document.getElementById('dig'+casenum).style.color = '#bb7e16'

         casenum = num

         document.getElementById('dig' + casenum).style.color = '#ffffff'
      }

      padnum = casenum
      if (casenum < 10)
         padnum = '0' + casenum

      document.images.face.src = imgpath + 'case_' + padnum + '_face_before.jpg'
      document.images.teeth.src = imgpath + 'case_' + padnum + '_teeth.jpg'
      document.images.before.src = 'graphics/before_on.gif'
      document.images.after.src = 'graphics/after_off.gif'

      timer_active = 1
      setTimeout("before2after()", 4000)
   }
   

   function next_case()
   {
      timer_active = 0 

      document.getElementById('dig'+casenum).style.color = '#bb7e16'

      ++casenum
      if (casenum > maxcase)
         casenum = 1

      document.getElementById('dig' + casenum).style.color = '#ffffff'

      padnum = casenum
      if (casenum < 10)
         padnum = '0' + casenum

      document.images.face.src = imgpath + 'case_' + padnum + '_face_before.jpg'
      document.images.teeth.src = imgpath + 'case_' + padnum + '_teeth.jpg'
      document.images.before.src = 'graphics/before_on.gif'
      document.images.after.src = 'graphics/after_off.gif'
	  
      timer_active = 1
      setTimeout("before2after()", 4000)
   }


   function before2after()
   {
      if (timer_active > 0)
         show_after()
   }
   
   setTimeout("before2after()", 4000)


   function domRollover()
   {
      if (navigator.userAgent.match(/Opera (\S+)/))
         var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1])

      if (!document.getElementById||operaVersion <7)
         return;

      var imgarr=document.getElementsByTagName('img')
      var imgPreload=new Array()
      var imgSrc=new Array()
      var imgClass=new Array()

      for (i=0; i<imgarr.length; i++)
      {
         if (imgarr[i].className.indexOf('domroll') != -1)
         {
            imgSrc[i]=imgarr[i].getAttribute('src')
            imgClass[i]=imgarr[i].className
            imgPreload[i]=new Image()

            if (imgClass[i].match(/domroll (\S+)/))
               imgPreload[i].src = imgClass[i].match(/domroll (\S+)/)[1]

            imgarr[i].setAttribute('xsrc', imgSrc[i])
            imgarr[i].onmouseover=function(){this.setAttribute('src',this.className.match(/domroll (\S+)/)[1])}
            imgarr[i].onmouseout=function(){this.setAttribute('src',this.getAttribute('xsrc'))}
         }
      }
   }

   domRollover();

