$(document).ready(function() {

/* Main Navigation hover */
$('#nav>ul>li').hover(function() {
$(this).addClass('over').find('div.show_me').stop().css('height', '').slideDown();
$('div.info', this).equalHeights();
return;
},
function() {
$(this).removeClass('over').find('div.show_me').stop().slideUp();
return;
});

/* Country Selector hover */
$('li#country_selector').hover(function() {
$('ul', this).fadeIn('fast');
},
function() {
$('ul', this).fadeOut('fast');
});

});

$(document).ready(function() {
//Init the table controller
var dtable = $('table#datatable').dataTable({
"bLengthChange": false,
"bFilter": false,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"fnInitComplete": function() {
$('div.fg-toolbar').addClass('clearfix');
$('div.fg-toolbar:empty').hide();
}
});

//Resource filter
$('select.resource_filter').change(function() {
var a = $('select.resource_filter :selected').val();
if (a != "All Resource Types") {
dtable.fnFilter(a, 1);
} else {
dtable.fnFilter('', 1);
}
})

//Product filter
$('select.product_filter').change(function() {
var a = $('select.product_filter :selected').val();
if (a != "All Products") {
dtable.fnFilter(a, 2);
} else {
dtable.fnFilter('', 2);
}
})

//Keyword search on the Name table
$('.submit_btn .send').click(function() {
var filter = $('#keyword_filter input').val();
dtable.fnFilter(filter, 0);
return false;
})

//Clear the keyword search and reset the form
$('.submit_btn .reset').click(function() {
$('#keyword_filter input').val('keyword');
dtable.fnFilter('', 0);
return false;
})
});
