$(document).ready(function() {
	$("#subissues, .sub-menu").mouseenter(function() {
		$(this).parent().css("color", "#fff");
		$(this).parent().css("background", "#333");
	});
	$("#subissues, .sub-menu").mouseleave(function() {
		$(this).parent().css("color", "#999");
		$(this).parent().css("background", "none");
	});
	$("#youtube").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
						 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
	
		return false;
	});
	
	$(".gform_footer input").click(function() {
		var ok = true;
		if($("#input_1_9").val() == '' || $("#input_1_9").val() == 'Select State') ok = false;
		if($("#input_1_6").val() == '' || $("#input_1_6").val() == 'you@domain.com') ok = false;
		if(ok){
			return true;
		}else{
			alert("Please enter your state and email address.");
			return false;
		}
	});
	
	$("#emailsubmit").click(function() {
		var ok = true;
		if($("#input_6").val() == '' || $("#input_6").val() == 'you@domain.com') ok = false;
		if(ok){
			return true;
		}else{
			alert("Please enter your email address.");
			return false;
		}
	});
});

fixForm = function() {
	$(".gfield_required").html("[required]");
	$("#gform_1 input").each(function() {
		var inp = $(this);
		var inpid = $(this).attr('id');
		if(inpid && $(this).attr('name') !== 'group[]' && $(this).attr('name') !== 'sites[]'){
			var inpl = $('#' + inpid.replace("input", "field") + ' .gfield_description');
			if(!inpl.html()) var inpl = $("label[for=" + inp.attr("id") + "]");
			if(inpl.html()){
				var text = inpl.html();
				inpl.html('');
				inp.val(text);
				inp.attr('onBlur', "if (this.value == ''){this.value = '"+text+"';}");
				inp.attr('onFocus', "if (this.value == '"+text+"'){this.value = '';}");
			}
		}
	});
	
	$("form#gform_1").attr('action', '/get-involved/#thankyou');
	
	if($("#prefillfirstname").val()) document.getElementById('input_1_2.3').value = $("#prefillfirstname").val();
	if($("#prefilllastname").val()) document.getElementById('input_1_2.6').value = $("#prefilllastname").val();
	if($("#prefillstate").val()) document.getElementById('input_1_9').value = $("#prefillstate").val();
	if($("#prefillemail").val()) document.getElementById('input_1_6').value = $("#prefillemail").val();
	if($("#prefillphone").val()) document.getElementById('input_1_7').value = $("#prefillphone").val();
	//if($("#prefillgroup").val()) document.getElementById('input_1_2.3').value = $("#prefillgroup").val();
	//if($("#prefillsites").val()) document.getElementById('input_1_2.3').value = $("#prefillsites").val();
}

startList = function() {
if (document.all&&document.getElementById){
	navRoot = document.getElementById("leftnav");
	for (i=0; i<navRoot.childNodes.length; i++){
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				this.className+=" over";
  		}
  		node.onmouseout=function() {
  			this.className=this.className.replace(" over", "");
   		}
		}
	}
}
}
window.onload=startList;

