/* 
   New Perspectives on JavaScript
   Tutorial 4
   Tutorial Case

   Avalon Books
   Author: Paul Sienicki
   Date  : 3/2/09

   Function List:
   xCoord(id)
      Returns the x-coordinate of the object with id with the value id

   yCoord(id)
      Returns the y-coordinate of the object with id with the value id

   placeIt(id, x, y)
      Places the id object at the coordinates (x,y)

   shiftIt(id, dx, dy)
      Moves the id object dx pixels to the right and dy pixels down

   hideIt(id)
      Hides the id object by setting its visibility style to "hidden"

   showIt(id)
      Hides the id object by setting its visibility style to "visible"

   winWidth()
      Returns the width of the interior browser window in pixels

   winHeight()
      Returns the height of the interior browser window in pixels

   findCookie(val)
	returns cookie value

*/

function xCoord(id) {
	object=document.getElementById(id);
	xc=parseInt(object.style.left);
	return xc;
}

function yCoord(id) {
	object=document.getElementById(id);
	yc=parseInt(object.style.top);
	return yc;
} 

function placeIt(id, x, y) {
	object=document.getElementById(id);
	object.style.left=x+"px";
	object.style.top=y+"px";
}

function shiftIt(id, dx, dy) {
	object=document.getElementById(id);
	object.style.left=xCoord(id)+dx+"px";
	object.style.top=yCoord(id)+dy+"px";
}

function shiftIt2(id, dx, dy) {
	object=document.getElementById(id);
	object.style.left=dx+"px";
	object.style.top=dy+"px";
}

function hideIt(id) {
	object=document.getElementById(id);
	object.style.visibility="hidden";
}

function showIt(id) {
	object=document.getElementById(id);
	object.style.visibility="visible";
}

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;
}

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;
}

function findCookie(val){
	   var cookie = null;
	   var findVal = val + "=";
	   var dc = document.cookie;
       if (dc.length > 0)
	{
          var start = dc.indexOf(findVal);
          if (start >= 0)
		{
             		start += findVal.length;
             		lastVal = dc.indexOf(";", start);
             		if (lastVal == -1)
				{
                			lastVal = dc.length;
			 	}
             		cookie = (dc.substring(start, lastVal));
          	}
	  else
	  	{
			return cookie;
	  	}
       	}
       return cookie;
}







