/* 
   New Perspectives on JavaScript
   Tutorial 4
   Tutorial Case

   Avalon Books
   Author: Jack Grigsby
   Date  : January 31, 2008

   Function List:
   xCoord(id)
      Returns the x-coordinate of the object with id with the value id*/
      function xCoord(id) {
	      object=document.getElementById(id);
	      xc=parseInt(object.style.left);
	      return xc;
      }
      
 /*  yCoord(id)
      Returns the y-coordinate of the object with id with the value id*/
      function yCoord(id) {
	      object=document.getElementById(id);
	      yc=parseInt(object.style.top);
	      return yc;
      }

/*   placeIt(id, x, y)
      Places the id object at the coordinates (x,y)*/
      function placeIt(id,x,y) {
	      object=document.getElementById(id);
	      object.style.left=x+"px";
	      object.style.top=y+"px";
	      
      }

/*   shiftIt(id, dx, dy)
      Moves the id object dx pixels to the right and dy pixels down*/
      function shiftIt(id,dx,dy) {
	      object=document.getElementById(id);
	      object.style.left=xCoord(id)+dx+"px";
	      object.style.top=yCoord(id)+dy+"px";
      }

/*   hideIt(id)
      Hides the id object by setting its visibility style to "hidden"*/
      function hideIt(id) {
	      object=document.getElementById(id);
	      object.style.visibility = "hidden";
      }

/*   showIt(id)
      Hides the id object by setting its visibility style to "visible"*/
      function showIt(id) {
	      object=document.getElementById(id);
	      object.style.visibility = "visible";
      }
     
	      /*   winWidth()
      Returns the width of the interior browser window in pixels*/
      function winWidth() {
	      if (window.innerWidth) return window.innerWidth;
	      else if (document.documentElement) return document.documentElement.offsetWidth;
	      else if (document.body.clientWidth) return document.body.clientWidth;
      }

/*   winHeight()
      Returns the height of the interior browser window in pixels*/
      function winHeight() {
	      if (window.innerHeight) return window.innerHeight;
	      else if (document.documentElement) return document.documentElement.offsetHeight;
	      else if (document.body.clientHeight) return document.body.clientHeight;
      }
/*	setZ() sets the z-index of an image*/      
      function setZ(id,z) {
	object=document.getElementById(id);
	object.style.zIndex = z;
}

/*	swapIt()
	makes id images visible in rotation by changing their z-index values*/
	
	function swapIt(id1, id2, id3, id4) {
		object1 = document.getElementById(id1);
		object2 = document.getElementById(id2);
		object3 = document.getElementById(id3);
		object4 = document.getElementById(id4);
		
		var z1 = object1.style.zIndex;
		var z2 = object2.style.zIndex;
		var z3 = object3.style.zIndex;
		var z4 = object4.style.zIndex;
	
		object1.style.zIndex = z4;
		object2.style.zIndex = z1;
		object3.style.zIndex = z2;
		object4.style.zIndex = z3;
		//alert("The x indeces are "+z3);
}









