
function styleLoader() {
	jQuery.easing.def = "easeInOutCirc";
	$(document.body).css("display", "block").css("visibility", "visible");
	$("#wrap").hide();
	$("#topDiv").hide();
	$("#hardHat").hide();
	$("#services div").hide();
	$("#recent").hide();
	$("#footer").hide();
	$("#wrap").fadeIn(1000);
	$("#hardHat").fadeIn(600, function(){
		$("#topDiv").fadeIn(600, function(){
			$("#services div:first").slideDown(600, function(){
				$("#services div:odd").slideDown(600, function(){ 
					$("#services div:last").slideDown(600, function(){
						$("#recent").fadeIn(300, function(){
							$("#footer").fadeIn(300);
						});
					});
				});
			});
		});								
	});


$('#navlist').before('<div id="hoverGuy"></div>');
$('#navlist').prepend('<div id="lastHoverGuy"></div>');
$('#navlist').prepend('<div id="lastLastHoverGuy"></div>');

var x = 0;
var l0 = 1;
var l1 = 1;

$('#navbar li').mouseover(function() {	
	if (this.id == 'webLi') {x = 170;}
	if (this.id == 'avLi') {x = 345;}
	if (this.id == 'freeLi') {x = 520;}
	if (this.id == 'newsLi') {x = 760;}

	$('#hoverGuy').animate({width: x+'px'}, 350, 'easeOutQuad', function() {
		/*
		$('#lastLastHoverGuy').animate({width: l1+'px'}, 350, 'easeOutQuad', function() {
			l1 = l0;
		});
		
		$('#lastHoverGuy').animate({width: l0+'px'}, 350, 'easeOutQuad', function() {
			l0 = x;
		});
		*/
	});
});

}

var openDiv='accEl0'; /*set this to the div that you are keeping open or the phantom div if you have them all closed*/
var count = 0;
var lastImg = 'img0'; /*set this to the beginning openDiv image if there is one*/

function firstBlind() {
	$("#accordian").find("h4").each(function(i) {
					var theImg = 'img'+i;
					$(this).prepend("<div class='bullet "+theImg+" closed'></div>");
    					$(this).addClass("point");
    					var theDiv = 'accEl'+i;
    					$(this).click(function () {
    						bUp(openDiv);bDown(theDiv, theImg);
    						});
     				});
     				
	$("#accordian").find("div:odd").each(function(i) {
    					$(this).addClass("accEl"+i);
    					if (i == 0) {$('.img0').removeClass('closed').addClass('open'); return;}
    					$(this).slideUp(300);
     				});
     				
    lastImg = 'img0'; /*init lastImg incase an accordian was already manipulated on a previous page*/
    openDiv='accEl0'; /*same as above*/
}

function bDown(bDiv, img) {
	if (openDiv == bDiv) { /*if you are clicking the tab that is already open*/
		count ++;
			if (count == 2) { /*if you click the same tab three times you want it to bDown again and not bUp at the same time*/
				$("."+bDiv).slideDown(300);
				$("."+img).removeClass('closed').addClass('open');
				count = 0;
			}
	}
	
	if (openDiv != bDiv) { /*if you aren't clicking the tab that is already open*/
		$("."+bDiv).slideDown(300);
		$("."+img).removeClass('closed').addClass('open');
		openDiv=bDiv;	/*set current bDdiv to 'open' so it will bUp next time*/
		lastImg = img;
		count = 0;
	}
}

function bUp(openDiv) {
	if (count == 0) { /*count value for bUp is one less than the count for bDown*/
		$("."+openDiv).slideUp(300);
		$("."+lastImg).removeClass('open').addClass('closed');
	}
}


function formInit() {
	$("form > #noJS").hide();/*hide noJS warning for fools without JS*/
	$("form > #spamcheck").hide(); $("#checkspam").attr('value', 'notspam'); // hide the spam checker and add the right variable if they have js on
	
	$("form").find("div").each(function() { /*hide conditional sections*/
							$(this).hide();
						});
	$("form").find("input").each(function() { /*add classes and spans to highlight radio selections on hover*/
							if (this.type == 'radio' || 'checkbox') {
								$(this).addClass('point');
								}
						});
}

function expandForm(id) {
	$("#"+id).slideDown("fast");
}

function dexpandForm(id) {
	$("#"+id).slideUp("fast");
}

function toggleForm(id) {
	me = document.getElementById(id).toggle;
	if (me == null) {me = 0}
		
		if (me == 0) {
			expandForm(id);
			me = 1;
			document.getElementById(id).toggle = me;
			return;
		}
		
		if (me == 1) {
			dexpandForm(id);
			me = 0;
			document.getElementById(id).toggle = me;
		}
}

function tableInit() {
	$("tr:even").addClass('color2');
}
