function crumbSetup()
{

	if( $("#breadcrumbs ul").length > 1 ) {
		// add the more and hide links
		var more_link = $("#breadcrumbs ul:first li:last").after('<li class="bcnav"> <a>(more)</a></li>');
		var hide_link = $("#breadcrumbs ul:last li:last").after('<li class="bcnav"> <a>(hide)</a></li>');

		$("#breadcrumbs ul:first li:last a").click(function() {
			crumbShowAll();
		});
		$("#breadcrumbs ul:last li:last a").click(function() {
			crumbShowFirst();
		});

		crumbShowFirst();
	}
	else {
		crumbShowAll();
	}
}

function crumbShowFirst()
{
	var all   = $("#breadcrumbs ul");
	var first = $("#breadcrumbs ul:first"); 

	$("#breadcrumbs ul").slice(1).hide();
	$("#breadcrumbs ul:first li:last").show();
	$("#breadcrumbs ul:first").show();
}

function crumbShowAll()
{
	$("#breadcrumbs ul").show();	
	if( $("#breadcrumbs ul").length > 1 ) {
		$("#breadcrumbs ul:first li:last").hide();
	}

}

function PrintPage(url)
{
	// Open the window to print this page
	var x = window.open(url, "PrintQuestion", "toolbar=1, scrollbars=1");
}

function EmailToFriend(url)
{
	xPos = screen.availWidth / 2 - 250;
	yPos = screen.availHeight / 2 - 215;

	// Open the window to email this question to a friend
	var y = window.open(url, "EmailQuestion", "width=500, height=430, toolbar=0, scrollbars=1, left=" + xPos + ", top=" + yPos);
}

function ToggleWhyTextbox(f)
{
	if (f.value == 0) {
		$('#kb_rating_why').show();
	} else {
		$('#kb_rating_why').hide();
	}
}

function ResetWhy(f)
{
	if (f.value == '') {
		f.value='Help us improve. Why was this unhelpful?';
	}
}

function ClearWhy(f)
{
	if (f.value == 'Help us improve. Why was this unhelpful?') {
		f.value='';
	}
}

function CheckFormRating()
{
	var f = document.getElementById('kb_rating_form');
	if (f.rate[1].value == 0 && f.rate[1].checked) {
		if (f.ratingmessage.value == '') {
			alert('Please tell us why you found this answer unhelpful so we can improve our system in the future.');
			return false;
		}

		if (f.ratingmessage.value == 'Help us improve. Why was this unhelpful?') {
			alert('Please tell us why you found this answer unhelpful so we can improve our system in the future.');
			return false;
		}
	}

	return true;
}

