<!-- Hide from old browsers

<!-- Earthquake cartoon script by Dean Liu -->

<!-- Modified fade in/out script from Brainerror.com -->
<!-- found here: http://www.brainerror.net/scripts_js_blendtrans.php -->

<!-- Global Variables -->
<!-- What can be changed: -->
<!-- intensity: strength of earthquake -->
<!-- speed: how long the earthquake lasts. -->
var intensity = 30;
var speed = 3500;

<!-- variables used for images -->
<!-- images are 600 x 450 -->
<!-- change if you want, i.e. if you have housefineowner.jpg in another directory -->
<!-- let's say images, then change it to images/housefineowner.jpg -->

var houseFine = 'housefineowner.jpg';
var houseNotFine = 'housenotfineowner.jpg';

<!-- Blank.jpg transitions the fade away -->
var blank = 'blank.jpg';



<!-- What should NOT be changed: -->
<!-- clicked : flag to see if button has been clicked to disable or not disable earthquake -->
<!-- firstQuake : flag to determine to fix offset of window caused by earthquake. -->
<!-- choice: flag for button text change. -->
<!-- count: used for switch statement in earthquake -->

var clicked=0;
var firstQuake=0;
var choice = 0;
var count = 0;


<!--Pre-load the images-->

if (document.images)
{
  pic1 = new Image(600,450); 
  pic1.src = houseFine; 

  pic2 = new Image(600,450);
  pic2.src = houseNotFine; 
}




<!-- Shaking function -->
function earthquake() {

  <!-- correct offset at the end of the quake -->
  if(firstQuake==0) {
    parent.moveBy(0, intensity*-1);
    firstQuake=1;
  }

  if(clicked==0){
    switch (count){
    	  case 0:
	 	  parent.moveBy(0,intensity);
		  count++;
		  break;
	  case 1:
		  parent.moveBy(intensity,0);
		  count++;
	          break;
 	  case 2:
		  parent.moveBy(0,intensity*-1);
		  count++;
		  break;
	  case 3:
		  parent.moveBy(intensity*-1,0);
		  count=0;
		  break;

	  default : ;
    }
  }  
}
// End -->


<!-- changing opacity of images occurs here -->
function changeOpac(opacity, id) {     
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
    earthquake();

}

<!-- fading current image into another images occurs here -->
function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //first image as bg
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //change to invis
    changeOpac(0, imageid);
    
    //get new image to fade in
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 99; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
}

<!-- Fade in to houseNotFine here -->

function blendimage2(){
	
	if(choice == 0) {
          changeButton(1);
	  blendimage('blenddiv','blendimage', blank, speed);
	  setTimeout("clicked=1",speed);
	  setTimeout("blendimage('blenddiv', 'blendimage', houseNotFine, 1000)",speed);
	  choice = 1;
	}
	else if(choice == 1){
          changeButton(2);
	  blendimage('blenddiv','blendimage', houseFine , 700);
	  choice = 0;
	  setTimeout("clicked = 0", 1000);

	}
	
}

<!-- button text handling occurs here -->
function changeButton(x){
	if(x == 1) {
	  document.getElementById("button").value="Reset";

	  <!--temporarily disables button until the earthquake finishes. -->

	  document.getElementById("button").disabled = true;
          setTimeout('document.getElementById("button").disabled = false', speed);
	}
	else if(x == 2)
	  document.getElementById("button").value="Watch Earthquake";
}

-->
