(function($){$.fn.autofill=function(options){var defaults={value:'First Name',defaultTextColor:"#b2adad",activeTextColor:"#333"};var options=$.extend(defaults,options);return this.each(function(){var obj=$(this);obj.css({color:options.defaultTextColor}).val(options.value).focus(function(){if(obj.val()==options.value){obj.val("").css({color:options.activeTextColor});}}).blur(function(){if(obj.val()==""){obj.css({color:options.defaultTextColor}).val(options.value);}});});};})(jQuery);

$(document).ready(function() {
	$(".faq-question .faq-answer").hide();
	
	$(".faq-question").eq(0).addClass("active");
	$(".faq-question .faq-answer").eq(0).show();
	
	$(".faq-question h3").click(function() {
		if($(this).closest(".faq-question").hasClass("active")) {
			$(this).closest(".faq-question").children(".faq-answer").slideUp();
			$(this).closest(".faq-question").removeClass("active");
			return;
		} else {
			$(this).closest(".faq-question").addClass("active");
			$(this).closest(".faq-question").children(".faq-answer").slideDown();	
		}					
	});
	
	$(".faq-question .minimize span").click(function() {
		$(this).closest(".faq-question").children(".faq-answer").slideUp();
		$(this).closest(".faq-question").removeClass("active");
	});

	$('#homepageCycle').cycle()
	$('.showReceiveUpdates, #closeUpdate').click(function(){
	   $('#receiveUpdates').toggle();
	   return false;
	});
	$('#fullName').autofill({
	   value: 'your name and last name',
	   defaultTextColor: '#aaa',
	   activeTextColor: '#000'
	});
	$('#creditUnion').autofill({
	   value: 'your credit union',
	   defaultTextColor: '#aaa',
	   activeTextColor: '#000'
	});
	$('#email').autofill({
	   value: 'yourname@domain.com',
	   defaultTextColor: '#aaa',
	   activeTextColor: '#000'
	});
	$('#xreceiveUpdates input:submit').click(function(){
	   $('#receiveUpdates label').css({'color':'#ffffff'});
	   $('#receiveUpdates label span').css({'visibility':'visible'});
	   $('#receiveUpdates label strong').css({'color':'#fc2800'});
	   return false;
	});
	$("#xreceiveUpdates form").submit(function () { return false; });
	$('input:submit, input:button').hover(function(){
		$(this).css({'cursor':'pointer'});
	});
	$('.truncate').truncate({max_length: 200});
	$('.truncateSmall').truncate({max_length: 0});
	$('.truncateSession').truncate({max_length: 180});
	$('#schedule dt:first, #day dt:first').css({'padding':'0'});
	$('#schedule .reveal, #day .reveal').click(function(){
	   $(this).parent().next().show();
	   return false;
	});
	$('#schedule .minimize, #day .minimize').click(function(){
	   $(this).parent().hide();
	   return false;
	});
	
	$(".video").fancybox({
			'hideOnContentClick': false,
			'frameWidth': 750,
			'frameHeight': 459,
			'overlayOpacity': 0.7
		});
	
	// countdown
	var dayof = new Date();
	dayof = new Date(2010, 3, 18,0,0,0);
	$('#daysLeftnumber').countdown({until: dayof, format: 'd'});
	
	$(".speaker .profile").hide();
	
	$(".speaker h3").click(function() {
		if($(this).closest(".speaker").hasClass("active")) {
			return;
		}
		
		$(".speaker").removeClass("active");
		$(".speaker .profile").slideUp();
		
		$(this).closest(".speaker").addClass("active");
		$(this).closest(".speaker").children(".profile").slideDown();						
	});
	
	$(".speaker .minimize span").click(function() {
		$(this).closest(".speaker").children(".profile").slideUp();
		$(this).closest(".speaker").removeClass("active");
	});

	var maxwords = new Array();
	maxwords['ctl00_ctl00_ctl00_ContentPlaceHolderDefault_RunwayMasterContentPlaceHolder_ctl03_ed_form_4_edFormElementTextBox1432'] = 200;
	maxwords['ctl00_ctl00_ctl00_ContentPlaceHolderDefault_RunwayMasterContentPlaceHolder_ctl03_ed_form_4_edFormElementTextBox1433'] = 50;
	maxwords['ctl00_ctl00_ctl00_ContentPlaceHolderDefault_RunwayMasterContentPlaceHolder_ctl03_ed_form_4_edFormElementTextBox1434'] = 50;
	maxwords['ctl00_ctl00_ctl00_ContentPlaceHolderDefault_RunwayMasterContentPlaceHolder_ctl03_ed_form_4_edFormElementTextBox1435'] = 100;
	maxwords['ctl00_ctl00_ctl00_ContentPlaceHolderDefault_RunwayMasterContentPlaceHolder_ctl03_ed_form_4_edFormElementTextBox1436'] = 200;
	maxwords['ctl00_ctl00_ctl00_ContentPlaceHolderDefault_RunwayMasterContentPlaceHolder_ctl03_ed_form_4_edFormElementTextBox1437'] = 100;
	
	$(document).ready(function() {
		for(var i in maxwords) {
			eval("$('#" + i + "').blur(function() { checkWordCount('" + i + "', maxwords['" + i + "']); });");
		}
	});
	function checkWordCount(id, maxwords) {
		value = $('#' + id).val();
		value = jQuery.trim(value);
		wordarray = value.split(' ');
		if(wordarray.length > maxwords) {
			alert("Max length is " + maxwords + " words");
			temp = "$('#" + id + "').focus();";
			setTimeout(temp, 100);
//	$('#ctl00_ctl00_ctl00_ContentPlaceHolderDefault_RunwayMasterContentPlaceHolder_ctl03_ed_form_4_edFormElementTextBox1432').focus();
//eval (temp);
//	var myField = document.getElementById(id);
//	setTimeout('myField.select()',50);
return 1;
//			eval("$('" + id + "').focus();");
		}
		else {	return 1; }
	}



});