/******************************************************************************
Copyright 1999 - 2007 EPIware, Inc.,  2550 Huntington Ave. Suite 300,
Alexandria, VA., 22304, U.S.A.  All rights reserved.

This work (and included software, both binary and source, or
documentation such as READMEs, or other related items) published by
Epiware, Inc. (hereafter, work or Software) is copyrighted by Epiware,
Inc. (hereafter, Epiware) and ownership of all right, title and interest
in and to the Software remains with Epiware. By obtaining, using and/or
copying this work, you (the Licensee) agree that you have read,
understood, and will comply with the following terms and conditions.

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY
DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY
USE OF THE SOFTWARE OR DOCUMENTATION.

NON-COMMERCIAL USE: By downloading, installing, using, or implementing
this Software,  Licensee acknowledges the validity and enforceability of
Epiware's copyright in the underlying software and code. The Software and
the accompanying materials are licensed, not sold, to Licensee. Epiware
maintains ownership of all copyright interests in the Software, including
any derivative works based upon the Software. 
Unauthorized copying of the Software or accompanying materials even if modified,
merged, or included with other software, or of the written materials, is
expressly forbidden.  Licensee may be held legally responsible for any
infringement of intellectual property rights that is caused or
encouraged by Licensees failure to abide by the terms of this Agreement.
The name and trademarks of copyright holders may NOT be used in advertising
or publicity pertaining to the software without specific, written prior permission.


COMMERCIAL USE: Any User wishing to make a commercial use of the
Software must contact Epiware at sales@epiware to arrange an appropriate
license. Commercial use includes (1) integrating or incorporating all or
part of the source code into a product for sale or license by, or on
behalf of, User to third parties, or (2) distribution of the binary or
source code to third parties for use with a commercial product sold or
licensed by, or on behalf of, User.
*****************************************************************************/
var shakeIntervals = new Array();
var shakeOrigin = new Array();
var shakeDone = new Array();

function shakeObject(shake_elem_id){
	if(typeof(shakeDone[shake_elem_id])=="undefined")
		shakeDone[shake_elem_id] = true;
	if(shakeDone[shake_elem_id]){
		shakeDone[shake_elem_id]=false;

		var shake_elem = document.getElementById(shake_elem_id);
		var shake_step = 5;
		var shake_time = 50;
		var total_shake_time = 500;

		shakeOrigin[shake_elem_id] = parseInt(shake_elem.style.left);
		shakeIntervals[shake_elem_id] = setInterval("intervalShake('"+shake_elem_id+"', '"+shake_step+"','"+shake_time+"','"+total_shake_time+"')", shake_time);
	}
}

function intervalShake(shake_elem_id, shake_step, shake_time, total_shake_time){
	var shake_elem = document.getElementById(shake_elem_id);
	var current_pos = parseInt(document.getElementById(shake_elem_id).style.left);
	var newPos = shakeOrigin[shake_elem.id];

	shakeDone[shake_elem.id]*=1;
	shakeDone[shake_elem.id]+=(shake_time*1);
	if(shakeDone[shake_elem.id] >= total_shake_time) {
		shake_elem.style.left = shakeOrigin[shake_elem.id] + 'px';
		clearInterval(shakeIntervals[shake_elem.id]);
		shakeDone[shake_elem.id] = true;
	} else {
		if((current_pos*1) > (shakeOrigin[shake_elem.id]*1))
			newPos = (shakeOrigin[shake_elem.id]*1) - (shake_step*1);
		else 
			newPos = (shakeOrigin[shake_elem.id]*1) + (shake_step*1);

		shake_elem.style.left = newPos + 'px';
	}	
}