/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 *	Copyright 2007 BOSS Logics, a division of Set Your Site, Inc.
 *	
 *	USE OR MANIPULATION OF THIS CODE IS PROHIBITED WITHOUT EXPRESS WRITTEN PERMISSION.
 *
 * 	Any use of the code written here-in belongs to the developer
 * 	and is hereby the owner.  If used, one must have strict
 * 	approval by the developer of the code written here-in.
 *
 * 	The developer may at anytime change, modify, add, or delete
 * 	any content contained within. 
 *	
 * 	This content may not be used on any server 12outside of the boss32.com maintained 
 *	servers.  Any such use will be considered a copyright infringement and will be 
 *	prosecuted to the full extent of the law.
 *
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 
function driveInTractor() {
	var truck = $('truckHolder');
	removeBlankChildren(truck);

	// make it move
	var startX = (Left(truck)+truck.offsetWidth)*-1;
	truck.style.marginLeft = startX+'px';
	truck.style.position = 'absolute';
	truckMotionTw = new Tween(truck, 'marginLeft', 'out.xstrong', startX, 0, 6, true, 50);
	truck.className = '';

	function addMovement(targ, bounceMax, rotateMax) {
		if(!targ.id)	targ.id = 'anonymous|'+(unique_counter++);

		truckMotionAry[targ.id] = new Array();

		// make it bounce
		truckMotionAry[targ.id]['bounce'] = new Tween(targ, 'marginTop', '', -1*bounceMax/2, bounceMax/2, .2, true);
		truckMotionAry[targ.id]['bounce'].onstop = function() { 
			var to = Math.random() * bounceMax;
			if(isNeg(truckMotionAry[targ.id]['bounce'].finish))	to = to*-1;
			truckMotionAry[targ.id]['bounce'].begin = to;
			truckMotionAry[targ.id]['bounceTimeout'] = window.setTimeout('if(truckMotionTw) truckMotionAry[\''+targ.id+'\'][\'bounce\'].reverse();', Math.random()*50);
		};
	}
	setTimeout(function() {
		truckMotionTw = false;
		for(var i in truckMotionAry) {
			window.clearTimeout(truckMotionAry[i]['bounceTimeout']);
			truckMotionAry[i]['bounce'].stop(false, true);
			//truckMotionAry[i]['bounce'].isPlaying = true;
			truckMotionAry[i]['bounce'].setProperty(0);
			window.clearTimeout(truckMotionAry[i]['rotateTimeout']);
		}
	}, 3000);

	/*
	for(var i in truck.childNodes) {
		if(truck.childNodes[i] && truck.childNodes[i].nodeName && truck.childNodes[i].nodeName.toLowerCase() == 'div') {
			addMovement(truck.childNodes[i], 2, .5);
		}
	}
	*/
	addMovement(truck.childNodes[0], 2, 1);		// tractor
	addMovement(truck.childNodes[1], 2, .1);	// first trailer
	addMovement(truck.childNodes[2], 2, .1);	// second trailer
}

function logout() {
	load('/b32/dyn/data/account.xml.php?fn=logout', false, false, true);
	window.location = window.location;
}
function passwordReset(email) {
	var holder = document.createElement('div');
	holder.className = 'msg passwordReset';

	var heading = addChild(holder, 'h1', '', '', 'Forgot your password');
	var frm = addChild(holder, 'form', '', 'resetForm');
	addHiddenInput(frm, 'fn', 'passwordReset');
	var message = addChild(frm, 'div', 'notice', '', 'To reset your password, please enter your email address and a new password you would like to use.');
	var errHolder = addChild(frm, 'div', 'err transparent');

	var inpHolder = addChild(frm, 'div', 'inpHolder');
	var emailInp = addChild(inpHolder, 'input', 'txt');
	emailInp.type = 'text';
	emailInp.name = 'email';
	if(email) emailInp.value = email;
	setDefaultText(emailInp, 'Email Address');
	addClearDv(frm);

	var inpHolder = addChild(frm, 'div', 'inpHolder');
	var passwordInp = addChild(inpHolder, 'input', 'txt');
	passwordInp.name = 'password';
	passwordInp.type = 'password';
	setDefaultText(passwordInp, 'New Password');
	addClearDv(frm);

	var inpHolder = addChild(frm, 'div', 'inpHolder');
	var passwordInp = addChild(inpHolder, 'input', 'txt');
	passwordInp.type = 'password';
	passwordInp.name = 'password2';
	setDefaultText(passwordInp, 'Confirm Password');
	addClearDv(frm);

	var submitInp = addChild(frm, 'input', 'sbmt');
	submitInp.style.float = 'right';
	submitInp.style.marginRight = '4px';
	submitInp.type = 'submit';
	submitInp.value = 'Reset';

	frm.action = 'javascript:;';
	frm.onsubmit = function() {
		var res = postForm('/b32/dyn/data/account.xml.php', $('resetForm'), true, false); 
		if(parseXML(res,'success')==1) {
			frm.innerHTML = '<div class="notice">Your password reset confirmation email has been sent to "'+emailInp.value+'".'
					+'<br /><br />Follow the instructions in your email to complete the process.';
		} else {
			var e = false;
			while(e=parseXML(res, 'e')) {
				errHolder.innerHTML = parseXML(e, 'msg')+"<br />";
				res = eatXML(res, 'e');
			}
			fade_in(errHolder);
		}
		return false;
	}
	addClearDv(frm);
	addClearDv(holder);
	lightbox(holder, 400, 'obj');
}

