var name = navigator.userAgent.toLowerCase()
var ie = (name.indexOf("msie")>-1)
var netscape = (name.indexOf("mozilla") >=-1 && name.indexOf("msie")==-1 && name.indexOf("opera") == -1)
var op_out_ie = 100;
var op_in_ie = 0; 
var op_out_ne = 1.0;
var op_in_ne = 0.0;  
var box1 = null; 
var box2 = null;
var obj_out = null; 
var obj_in  = null;
var index = 0;   
var bPause = false;
var bZoomIn = false; 
var bZoomOut = false;  

function slideShow() {
  box1 = document.getElementById('img_box_1');
  box2 = document.getElementById('img_box_2');
  
  obj_out = box1; 
  obj_in = box2; 
  
  
  op_out_ie = 100; 
  op_out_ne = 1.0; 
  op_in_ie = 0; 
  op_in_ne = 0.0;
  
  if (netscape)
    obj_in.style.opacity = 0.0;
  else
    obj_in.style.filter = 'alpha(opacity=' + 0 + ')';
  
  fadeOut();
  fadeIn();
  
  setTimeout("engine()", 5000);
}

function pause() {
  bPause = true; 
  bZoomIn = true; 
  zoomIn(); 
}

function restart() {
  bZoomOut = true; 
  zoomOut(); 
  bPause = false;
}

function zoomIn() {
  if (bZoomOut)
    return; 

  if (box1) {
    var width = box1.offsetWidth;
    if (width < 312) {
      width += 1; 
      box1.style.width = width+'px';
      box1.style.height = width+'px';
      box2.style.width = width+'px';
      box2.style.height = width+'px';
      setTimeout("zoomIn()", 1);
    }
    else
      bZoomIn = false; 
  }
}

function zoomOut() {
  if (box1) {
    var width = box1.offsetWidth;
    if (width > 206) {
      width -= 1; 
      box1.style.width = width+'px';
      box1.style.height = width+'px';
      box2.style.width = width+'px';
      box2.style.height = width+'px';
      setTimeout("zoomOut()", 1);
    }
    else 
      bZoomOut = false; 
  }
}

function engine() {
  if (!bPause) {
    var tmp = obj_out;
    obj_out = obj_in;
    obj_in = tmp;
 
    index++; 
    if (index > files.length-1)
      index = 0; 
    obj_in.src = files[index];
    
    op_out_ie = 100; 
    op_out_ne = 1.0; 
    op_in_ie = 0; 
    op_in_ne = 0.0; 
    
    setTimeout("fader()", 1000);
    setTimeout("engine()", 5000);
  }
  else
    setTimeout("engine()", 500);
}

function fader() {
  fadeOut(); 
  fadeIn();
}

function fadeOut() {
	if (netscape) {
		if (op_out_ne > -0.05) {
			op_out_ne -= .05
			obj_out.style.opacity = op_out_ne;
			setTimeout("fadeOut()", 40);
		}
	}
	if (ie) {
	  if (op_out_ie > 0) {
	    op_out_ie -= 5;
			obj_out.style.filter = 'alpha(opacity=' + op_out_ie + ')';
			setTimeout("fadeOut()", 40);
		}
	}
}

function fadeIn(obj) {
	if (netscape) {
		if (op_in_ne < 1.00) {
			op_in_ne += .10
			obj_in.style.opacity = op_in_ne;
			setTimeout("fadeIn()", 40);
		}
	}
	if (ie) {
	  if (op_in_ie < 100) {
	    op_in_ie += 5;
			obj_in.style.filter = 'alpha(opacity=' + op_in_ie + ')';
			setTimeout("fadeIn()", 40);
		}
	}
}

