﻿/* 
Quick Animations
----------------
Requires:
	yahoo-dom-event.js
	animation-min.js
	generic_lib.js
*/

/*
Function: $anim
Version: 1
Arguments:
	string id, Element id
	string prop, Style property
	int from, starting value
	int to, ending value
	int duration, how many secodns to annimate for
	int delay, how long to wait bfore t starts
	obj easing, a Yahoo easing object (or null)
	callback onComplete, a callback funtion for when the animation completes
ToDo: bad input tests
*/

function $anim(id, prop, from, to, duration, delay, easing, onComplete) {
	if (id && prop && to != undefined) {
		var obj, anim, attributes = {};
		obj = $get(id);
		if (obj) {
			if (!duration) duration = 1;
			if (!delay) delay = 0;
			if (!easing) easing = YAHOO.util.Easing.easeNone;
			if (from) attributes[prop] = { 'from': from, 'to': to};
			else attributes[prop] = { 'to': to };
			anim = new YAHOO.util.Anim(obj.id, attributes, duration, easing);
			if (onComplete) anim.onComplete.subscribe(onComplete);
			setTimeout(function() {
				anim.animate();
			}, delay * 1000);
		}
	}
}

function $animProp(obj, prop, from, to, interval) {
	if (parseFloat(document.body.style.opacity) < 1) {
		document.body.style.opacity = parseFloat(document.body.style.opacity) + delta;
		//$debug(delta)
		setTimeout(function() { fadeIn(delta, delay) }, delay);
	}
}
