﻿$(function() {
/* Menu's */
if ($.fn.superfish)
{
$("#navigatie ul.sf-menu").superfish(
{
pathClass: 'current',
pathLevels: 1,
delay: 1000,
// speed: 1,
autoArrows: false
});
}
$('ul.sf-menu').addClass('visible');
$("#sitemap0").children().appendTo($("#sitemap"));
$("#sitemap0").remove();
$("#sitemapButton").click(function() {
$("#sitemap").toggle();
this.className = this.className == 'opened' ? '' : 'opened';
return false;
});

$(".pulldown select").change(function() {

var selected = $(".pulldown option:selected");
if (selected.val() != 0) {
window.location = selected.val();
}
});

$("#document_tree").treeview(
{
collapsed: true,
animated: false
});

/* Zoekformulier */

$('.zoekSubmitClass').click(function() {
searchSubmit($(this));
return false;
}
);

var searchSubmit = function(sNode) {
var theForm = $(sNode).parent();
var searchInputText = $(theForm).find('input:text');
var searchInputHidden = $(theForm).find('input:hidden');

searchTerm = encodeURIComponent(searchInputText.val());

if (searchTerm.length > 1) {
$("form").submit(function() { return false });
var searchUrl = searchInputHidden.val();
searchUrl += searchTerm;
window.location = searchUrl;
} else {
alert('Please fill in a search term of at least two characters');
return false;
}
}
$("input:radio").addClass("noBorder");
$("input:checkbox").addClass("noBorder");
$(".formbuilder_errormessagemarker").css("display", "inline");
$(".zoekformulier input:text").each(function() {
$(this).keydown(
function(e) {
if (e.keyCode == 13) {
searchSubmit($(this));
return false;
}
}
);

$(this).focus(
function() {
this.value = '';
this.className = 'active';
}
);
$(this).blur(
function() {
if (this.value == '') {
this.value = 'Search CANSO website';
this.className = 'zoekTekstClass';
}
}
)
}
);
$("#btnAddToBasket").click(function() {
$("#itemAdded, #basketLink").css('display', 'block');
$.cookie('showBasket', '1', { path: '/' });
$(this).css('display','none');

});
if ($.cookie('showBasket') == '1') {
$("#basketLink").css('display', 'block');
}
document.forms[0].reset();
}
);
