


/* /js/ajaxem.js */

/**
	Flip 'Em - by Marcus AT noveis.net
	http://noveis.net/em/flipem
	Version 1.0.4
	Changelog:
	1.0.4	- Changed from adding/removing text-decoration, to adding/removing class name in variable currentClass. Variables to change fading speeds.
		- Ability to have current link, send you to url. Moved to play and pause text to variables for customaziation. If not automatic, make sure text says play.
	1.0.3	- Fixing a few obivious mistakes. Improves preformance.
	1.0.2	- Will now only start if .flipem exists, paving the way for multiple instances, though not tried and probably won't work.
	1.0.1	- Will now only start if div#flipem exists
	1.0	- Initial
*/
/* Things to touch */
var ajTotal			= 3; // This should be done better - like automatically - but it's not for now.
var displaytime		= 5; // Time in seconds before switching
var startRotating	= true; // false if not starting automatically 
var useControls		= true; // false if not using controls
var currentClass	= 'currentLink';
var fadeDuration	= 0.3;	// in seconds
var appearDuration	= 0.8;	// in seconds
var changeToLink	= true;
var PauseHTML		= '<img src="/style/images/pause.png" alt="pause">';
var PlayHTML		= '<img src="/style/images/play.png" alt="play">';
/* Things not to touch */
var ajCurrent = 1;
var number = 1;
var pause = false;

flipemprocess = function(num, cur)
{
	Effect.Fade('flipem-'+cur, { duration:  fadeDuration });
	Effect.Appear('flipem-'+num, { duration: appearDuration });
	if(useControls == true)
	{
		$('flipem-control-'+num).addClassName(currentClass);
		$('flipem-control-'+cur).removeClassName(currentClass);
	}
}
flipem = function(number, link)
{
	if(number != ajCurrent)
	{
		flipemprocess(number, ajCurrent);
		ajCurrent = number;
		pause = true;
		if(useControls == true)
		{
			$('flipem-control').update(PlayHTML);
		}
		return false;
	}
	else if(number == ajCurrent && changeToLink == true)
	{
		return true;
	}
}
flipemplay = function()
{
	if(pause == true)
	{
		pause = false;
		flipemstart();
		if(useControls == true)
		{
			$('flipem-control').update(PauseHTML);
		}
	}
	else
	{
		pause = true;
		if(useControls == true)
		{
			$('flipem-control').update(PlayHTML);
		}
	}
}
flipemauto = function()
{
	if(pause != true)
	{
		if(ajCurrent >= ajTotal)
		{
			number = 1;
		}
		else
		{
			number = ajCurrent+1;
		}
		if(number != ajCurrent)
		{
			flipemprocess(number, ajCurrent);
			ajCurrent = number;
		}
	}
}
flipemstart = function()
{
	var flipemElements = $$('.flipem');
	if(flipemElements != '')
	{
		new PeriodicalExecuter(function(pe) {
			if(pause == true)
			pe.stop();
			else
			flipemauto();
		}, displaytime);
	}
}
flipemnotstart = function()
{
	pause	= true;
	$('flipem-control').update(PlayHTML);
}

if(startRotating == true)
{
	Event.observe(window, 'load', flipemstart, false);
}
else
{
	Event.observe(window, 'load', flipemnotstart, false);
}


/* /js/pollem.js */

/* Poll 'Em - by Marcus @ Noveis.net */
/* You can change these: */
var pollemUrl = '/index.php?page=poll&no_html=true'; // The URL to send data.
var pollemTarget = 'pollemResponse';
var pollemMethod = 'post';
/* Don't change below if you know what's good for ya. */
pollem = function(id, task)
{
	if(task == 'back')
	{
		Effect.Fade(pollemTarget, { duration: 0.1 });
		$(pollemTarget).hide();
		Effect.Appear('pollemForm', { duration: 0.4 });
	}
	else
	{
		Effect.Fade('pollemForm', { duration: 0.1 });
		$('pollemForm').hide();
		if(task == 'results')
		{
			var values = 'nologo=true&results='+id;
			pollemMethod = 'get';
		}
		else
		{
			var values = Form.serializeElements( $('pollemForm').getInputs('radio') );
			values = values+'&poll='+id+'&nologo=true';
		}
		new Ajax.Updater(pollemTarget, pollemUrl, {method: pollemMethod, parameters: values});
		Effect.Appear(pollemTarget, { duration: 0.4 });
	}
}


/* /js/form.js */

/* By Marcus for BF.com */
checkForm = function(fields)
{
	var len = fields.length - 1;
	var n;
	var c=0;
	var missing	= Array();
	var value;
	var ignore	= false;
	var form	= $('application_form');
	var input;
	for (n=0; n<=len; n++) 
	{
		if (fields[n] == undefined)
		{
			input	= false;
			value	= false;
			ignore	= true;
		}
		else
		{
			input	= form[fields[n]];
			value	= $F(input);
			ignore	= false;
		}
		
		if (value == undefined || value == '' || value == ' ' || value == null || value == 'Please select')
		{
			$(fields[n]).addClassName('emptyfield')
			missing[c] = fields[n];
			c++;
		}
		else if(ignore == false)
		{
			$(fields[n]).removeClassName('emptyfield');
		}
	}
	if (c > 0)
	{
		alert('You did not fill in all the required fields.');
		confirmBefore = true;
		return false;
	}
	else
	{
		return true;
	}
}

confirmBefore	= false;
window.onbeforeunload = confirmExit;

function confirmExit()
{
	if (confirmBefore == true)
	{
		return 'You will have to restart the application proccess if you do.';
	}
}


/* /js/bfjs.js */

doClear = function(theText)
{
	if(theText.value == theText.defaultValue)
	{
		theText.value = "";
	}
}

toggleLayer = function(whichLayer)
{
	$(whichLayer).toggle();
}

outside = function(url)
{
	$('overlay_content').update('<div class="top"><\/div><h2>Leaving Bravofleet.com<\/h2><p>You are about to leave bravofleet.com for a site that is no controlled by Bravo Fleet. We take no reponsibility of the content on the site. However if you do object to content on the site please report it and the link may be removed.<br><a href="'+url+'">Continue to site<\/a> or <a href="javascript:fade(\'overlay\');">cancel<\/a>.<\/p><div class="bottom"><\/div>');
	Effect.Appear('overlay', { duration: 0.2 });
}

loadpageToggle = Array();
loadpage = function(id, content, vars)
{
	if(loadpageToggle[id] == true)
	{
		Effect.Fade(id, { duration: 0.1 });
		loadpageToggle[id] = false;
	}
	else
	{
		$(id).update('<p class="loading"><img class="center" src="/style/images/loading.gif" alt="Loading"><br>Loading...<\/p>');
		new Ajax.Updater(id, content, {
						parameters: { 'no_html': true },
						method: 'get' });
		Effect.Appear(id, { duration: 0.2 });
		loadpageToggle[id] = true;
	}
}

overlay = function(content, vars)
{
	$('overlay_content').update('<div class="top"><\/div><p class="loading"><img class="center" src="/style/images/loading.gif" alt="Loading"><br>Loading...<\/p><div class="bottom"><\/div>');
	new Ajax.Updater('overlay_content', content, {
					parameters: { more: vars },
					method: 'get' });
	Effect.Appear('overlay', { duration: 0.2 });
}

togfaToggle = Array();
togfa = function(id)
{
	if(togfaToggle[id] == true)
	{
		Effect.Fade(id, { duration: 0.3 });
		togfaToggle[id] = false;
	}
	else
	{
		Effect.Appear(id, { duration: 0.3 });
		togfaToggle[id] = true;
	}
}

fade = function(id)
{
	Effect.Fade(id, { duration: 0.1 });
}

function updateFields(text, li)
{
	$('output_id').value = li.id;
}