/******** CUFON ********/

$(document).ready(function(){
	Cufon.replace('h1,h2,h3');
	Cufon.replace('#affiliations address strong');
	Cufon.replace('dl.faq dt');
	Cufon.replace('blockquote span');
});


/******** ACCORDION SCRIPT ********/

$(document).ready(function(){
						   
$('#directions dt').click(function() {
	movedIndex = qIndex;	
	$('#directions dd.desc:eq('+movedIndex+')').slideUp('fast');
	$('dt:eq('+movedIndex+')').removeClass("open");
	$(this).addClass("open");
	qIndex = this.id.slice(2,3)-1;
	$('#directions dd.desc:eq('+qIndex+')').slideDown('slow');	
});

qIndex = 0;
movedIndex = null;

$('#directions dd.desc').hide();
$('#directions dt:eq(0)').addClass("open");
$('#directions dd.desc:eq(0)').show();

});


/*********** CONTACT FORM ************/

$(document).ready(function(){

var shownPanel;						   
						   
$('select').change(function(){
	var str = "";
	var val = "";
	$("select option:selected").each(function () {
		str += $(this).text() + " ";
		val += $(this).val();
	});
	if(shownPanel) {
		shownPanel.slideUp();
	}
	$("#"+val).slideDown('slow');
	shownPanel=$("#"+val);
	
	$("input#switch").attr('value', val);
});	

$('#contact div.hidden').hide();
$('#maintenance').show();
shownPanel=$("#maintenance");

if($("input#switch").attr('value')!="default") {
	$("#"+$("input#switch").attr('value')).show();
	shownPanel=$("#"+$("input#switch").attr('value'));
}

$('input[type="text"]').focus(function() {
	$(this).removeClass("idleField").addClass("focusField");									   
});

$('input[type="text"]').blur(function() {
	$(this).removeClass("focusField").addClass("idleField");									   
});

$('select').focus(function() {
	$(this).removeClass("idleField").addClass("focusField");									   
});

$('select').blur(function() {
	$(this).removeClass("focusField").addClass("idleField");									   
});

$('textarea').focus(function() {
	$(this).removeClass("idleField").addClass("focusField");									   
});

$('textarea').blur(function() {
	$(this).removeClass("focusField").addClass("idleField");									   
});

});


/*********** OVERLAY PANEL ************/

$(document).ready(function () {
	$('a#login').click(function (e) {
		e.preventDefault();
		$('#overlay-content').modal();
		$('p.error').hide();
		$('input#login-btn').click(function () {
			$('#overlay-content h3').html("the details provided do not match our records");
			$('#overlay-content h3').addClass("error");
			 Cufon.replace('#overlay-content h3'); 
		});
		$('input#user').focus(function() {  
			$('#overlay-content h3').html("client login");
			$('#overlay-content h3').removeClass("error");
			Cufon.replace('#overlay-content h3'); 
		});
		$('input#password').focus(function() {  
			$('#overlay-content h3').html("client login");
			$('#overlay-content h3').removeClass("error");
			Cufon.replace('#overlay-content h3'); 
		});
		$('input[type="text"]').focus(function() {
			$(this).removeClass("idleField").addClass("focusField");									   
		});
		
		$('input[type="text"]').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");									   
		});
		$('input#user').addClass("focusField");
		
	});
	$('a#out-of-hours').click(function (e) {
		$('#overlay2-content').modal();
	});
});




