jQuery(document).ready(function() {
	jQuery(".labelize input:text").clearingInput();
});


     Cufon.replace('.frank-book', {hover: true, fontFamily: 'ITC Franklin Gothic Book'})('.frank-demi', {hover: true, fontFamily: 'ITC Franklin Gothic Demi'})('.generika', {hover: true, fontFamily: 'Generika MG'});  // removed ('.synchro', {hover: true, fontFamily: 'Synchro LET'}) on 2013-12-06, a monumental day!




function side_nav(){

  var path = location.pathname;
  var pathWithoutTrailingSlash = path.replace(/\/$/, "");

  if (path == '/') {
    jQuery('#section-nav a[href$="' + location + '"]').parent().addClass('nav_active'); // check path as typed exactly
    jQuery('#section-nav a[href$="' + location + '/"]').parent().addClass('nav_active'); // check path with an extra trailing slash added
  } else {
    jQuery('#section-nav a[href$="' + path + '"]').parent().addClass('nav_active'); // check path as typed exactly
    jQuery('#section-nav a[href$="' + pathWithoutTrailingSlash + '"]').parent().addClass('nav_active'); // check path as typed exactly
    jQuery('#section-nav a[href$="' + path + '/"]').parent().addClass('nav_active'); // check path with an extra trailing slash added
  }
  // Hide all subnavigation
  jQuery('#section-nav ul ul').hide();
  // show all parent sibling
  jQuery('#section-nav li.nav_active').parent().show();
  // show child
  jQuery('#section-nav li.nav_active').children('ul').show();
  // when subnavigation active, show parent and its children
  jQuery('#section-nav li.nav_active').parent().parent().parent().show();


  var here = jQuery('#section-nav li.nav_active a:first').addClass('current-page');
}

jQuery(function($j) {side_nav();});

function toggleCollapsible(id)
{
	if (document.getElementById(id).style.display == 'none' || document.getElementById(id).style.display == '') {
		document.getElementById(id).style.display = 'block';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}

searchIndex = 0;

function navigateSearchDown() {
	if (document.getElementById("search-suggestion" + (searchIndex + 1))) {
		if (document.getElementById("search-suggestion" + searchIndex)) {
			document.getElementById("search-suggestion" + searchIndex).className = '';
		}
		searchIndex++;
		document.getElementById("search-suggestion" + searchIndex).focus();
		document.getElementById("search-suggestion" + searchIndex).className = 'active';
	}
}

function navigateSearchUp() {
	if (document.getElementById("search-suggestion" + (searchIndex - 1))) {
		if (document.getElementById("search-suggestion" + searchIndex)) {
			document.getElementById("search-suggestion" + searchIndex).className = '';
		}
		searchIndex--;
		document.getElementById("search-suggestion" + searchIndex).focus();
		document.getElementById("search-suggestion" + searchIndex).className = 'active';
	}
}

function lookup(string, e)
{	
	if (string.length == 0) {jQuery('#search-suggestions').fadeOut();} else {
		jQuery.post('/search.php', {query: string}, function(data) {
			jQuery('#search-suggestions').fadeIn();
			jQuery('#search-suggestions').html(data);
			searchIndex = 0;
		});
	}
}
