$(document).ready(function(){
	
	$("ul.nav").superfish({
		hoverClass		: "sfHover",
		delay			: 0,
		speed			: "5000"
	});

	/*var qInput = $("input#q");
	var optionsBox = $("#options-box");
	
	qInput.focus(
        function(){
        $(this).css("background-position","right");
  		});

	qInput.blur(
        function(){
        $(this).css("background-position","left");
  		});*/
		
	$("#page-options").toggle(function() {
		$(optionsBox).slideDown("normal");
	}, function() {
		$(optionsBox).slideUp("normal");
 	});
	
$(':input').focus(function() { $(this).addClass('inputselected'); }).blur(function() { $(this).removeClass('inputselected'); });

$('.forwardarrow').hover(function() {$(this).addClass('forwardarrow_hover');}, function() {$(this).removeClass('forwardarrow_hover');});
$('.backarrow').hover(function() {$(this).addClass('backarrow_hover');}, function() {$(this).removeClass('backarrow_hover');});

// Testing Start
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////

checkstate()

$("input[value='Yes']").click(function(event){
	checkstate();
})

$("input[value='No']").click(function(event){
	checkstate();
})

$("#conditional input").click(function(event){
	checkstate();
});

function checkstate() {
	var yesChecked = $("input[value='Yes']").attr("checked");
	var assistChecked = $("#conditional input[name='reopen']").attr("checked");
	var otherChecked = $("#unresolved-reason input[name='_fid_24']:checked").val();
	
	if (yesChecked){
		$("div#conditional").hide();
		$("div#exitQ").show();
	}
	else {
		if(otherChecked == 'Other (Please explain below)') {
			$("#unresolved-reason textarea[name='_fid_25']").show();	
		} else {
			$("#unresolved-reason textarea[name='_fid_25']").hide();	
		}
		
		if (assistChecked){

			$("div#exitQ").hide();
			$("div#conditional").show();
			$("#conditional textarea[name='activity_detail']").show();	
			$("#conditional label:last").show();
		}
		else {
			$("div#exitQ").show();
			$("div#conditional").show();
			$("#conditional textarea[name='activity_detail']").hide();
			$("#conditional label:last").hide();		
		}
	}
}

/*$("#unresolved-reason input[@name='_fid_7']").change(
	function() {
		var value = $("#unresolved-reason input[name='_fid_7']:checked").val();
		
		
		alert(value);
	}
);*/

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Testing End

});

		$(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();
			
			$('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('div.tabs ul.tabNavigation a').removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});


function CheckForOther (item, origlen)
	{
	var sitem = item.options[item.selectedIndex];

	if (item.selectedIndex == (item.length - 1))
		{
		var val = prompt ("ADD A NEW CHOICE:", "");

		if (val == null)
			item.selectedIndex = 0;
		else	
			{
			var slen = item.length;

			if (slen == origlen+1){
				item.options[slen] = new Option (sitem.text, sitem.value);
                        }
			
			item.options[item.length-2].text = val;
			item.options[item.length-2].value = val;
			item.selectedIndex = item.length-2;
			}
		}
	}

