
/**
 * 
 * To use this put the following in the <head> tage
 * 
 * <script type="text/javascript" src="curl/cvi_curl_lib.js"></script>
 * <script type="text/javascript" src="curl/curl.js"></script> 
 * <script type="text/javascript" src="curl/curlUp.js"></script> 
 * 
 * Then each image you do must be classed as:
 * 
 * <img class="curlUp" id="<your id>" .... />
 * 
 * You must also id your image.
 * 
 */

var tmp = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
if(tmp) var isIE = document.namespaces ? 1 : 0;


function addCurlUp()
  {
	
  var theimages = getImages('curlUp');
  for(var i=0;i<theimages.length;i++) 
    {
	
	var image = theimages[i];
	
	var theCanvas = cvi_curl.add(image,{size: 0.1});
	
	theCanvas.onmouseover = function() { increaseCurl(theCanvas) };
	theCanvas.onmouseout  = function() { decreaseCurl(theCanvas) };
	
    }	
  }

var curlTiming = 80;
var max = 20;
var size = 0;

var increaseInterval = null;
function increaseCurl(obj) 
  {// from MouseEnter

  //alert("mouseoenter: " + event); //.contains(event.fromElement) ));
  if ( (typeof event == "undefined")       ||  // hack for firefox
	   (! obj.contains(event.fromElement))  )  
    {
	  
    if ( decreaseInterval != null )
	  {
	  clearInterval(decreaseInterval);
	  decreaseInterval = null;
	  }
	 
    if ( (increaseInterval == null) && ( size < max ) )
      {
      increaseInterval = setInterval(function() {increase(obj);},curlTiming);
      }
      
    }
  }	

function increase(obj)
  {		
  
  if (obj.tagName.toUpperCase() != 'IMG') 
    {
	  
	if ( size < max )
	  {
	  size += 5;
	  if ( size >= max ) 
	    {
        clearInterval(increaseInterval);
        increaseInterval = null;
	    size = max;	  
	    }
	
	  cvi_curl.modify(obj, {size: size});
	  }
    }
  }

var decreaseInterval = null;
function decreaseCurl(obj)
  {// Mouse Exit 
  //alert("MouseExit: " + event.fromElement.id + " : " + obj.id + " : " + event.toElement.id);  
  if ( (typeof event == "undefined") ||  // hack for firefox
	   ( ( (! isIE) || (event.fromElement.id != obj.id) ) &&     // hack for IE
	     (! obj.contains(event.toElement))  ))  // hack for IE
    {
	  
      if ( increaseInterval != null )
        {
        clearInterval(increaseInterval);
        increaseInterval = null;
        }
  
      if ( (decreaseInterval == null) && ( size > 0.1 ) )
        {
        decreaseInterval = setInterval(function(){decrease(obj);},curlTiming);	
        } 

    }
  }

function decrease(obj) 
  {

  if (obj.tagName.toUpperCase() != 'IMG') 
    {
	  
	if ( size > 0.1 )
	  {
      size -= 5;
	  if ( size <= 0.1 ) 
	    {
        clearInterval(decreaseInterval);
        decreaseInterval = null;
	    size = 0.1;
	    }
	
	  cvi_curl.modify(obj, {size: size});
	  }
    }
  }

var curlUpOnload = window.onload;
window.onload = function () { if(curlUpOnload) curlUpOnload(); addCurlUp();};
					
