/******* double drop-down **************/

var oTable;

$(document).ready(function() {
	
	oTable = $('#schoolslist').dataTable({
        "bPaginate": false,
		"aaSorting": [[ 1, "asc" ]],
		"aoColumns": [
			/* Id */  {"bVisible": false},
			/* Test */ { "sType": "html" },
			/* Stakeholder */ {"bVisible": false},
			/* Interest */ {"bVisible": false},
			/* Type */ null
		]
	});
	$('#se').change( fnTwoWayFilter );
	$('#be').change( fnTwoWayFilter );

function fnTwoWayFilter()
{
	/* Get the filter values */
	var filter1 = $('#se').val();
	var filter2 = $('#be').val();
	var filter = "";
	
	/* Concat them together */
	if ( filter1 != "" )
	{
		filter += filter1+" ";
	}
	
	if ( filter2 != "" )
	{
		filter += filter2+" ";
	}
	
	/* Drop the last space */
	if ( filter != "" )
	{
		filter = filter.replace(/ $/, "");
	}
	
	oTable.fnFilter( filter );
}

} ); 
/******* all tests table **************/
$(document).ready(function() {
	$('#alltests').dataTable( {
        "bPaginate": false,
		"aoColumns": [
			{ "sType": "html" },
            null,
            null
		]
	} );
} );

/******* social media table **************/
$(document).ready(function() {
	$('#socialmedia').dataTable( {
        "bPaginate": false,
        "aaSorting": [[ 1, "asc" ]],
		"aoColumns": [
                        null,
			{ "sType": "html" },
                        null
		]
	} );
} );

/******* participating schools table school country **************/
$(document).ready(function() {
	$('#ps-sc').dataTable( {
        "bPaginate": false,
		"aoColumns": [
			{ "sType": "html" },
            null
		]
	} );
} );

/******* scholarship schools table **************/
$(document).ready(function() {
	$('#scholarshipschools').dataTable( {
        "bPaginate": false,
		"aoColumns": [
			{ "sType": "html" },
                        null,
                        null,
                        { "sWidth": "10%" },
                        { "sWidth": "5%" }]} );
} );

/******* projects table **************/
$(function(){
    pTable = $('#projects').dataTable({
        "bPaginate": false,
        "iDisplayLength": 20,
            "aoColumns": [
		{ "sType": "html" },
                null,
                { "sType": "html" }
		]
        });
});

/******* staff list **************/
$(document).ready(function() {
	$('#staff-all').dataTable( {
        "bPaginate": false,
	"bLengthChange": false,
        "iDisplayLength": 50,
        "aoColumns": [
            { "sType": "html" },
            { "sWidth": "35%" },
            { "sWidth": "35%" }
        ]
	} );
} );

/******* staff list **************/
$(document).ready(function() {
	$('#staff').dataTable( {
        "bPaginate": false,
		"bLengthChange": false,
        "iDisplayLength": 50,
        "aoColumns": [
            { "sWidth": "15%", "sType":"html" },
            { "sWidth": "15%" },
            { "sWidth": "25%" },
            { "sWidth": "35%" },
            { "sWidth": "10%" }]
	} );
} );

$(document).ready(function() {
    $('#featureprofile').before('<div id="featuresnav">')
                   .cycle({ 
        fx:     'fade', 
        speed:   2000, 
        timeout: 2000, 
        pause: 1,
        pager:  '#featuresnav' 
});
});
$(document).ready(function() {
    $('#features').before('<div id="featuresnav">')
                   .cycle({ 
        fx:     'fade', 
        speed:   2000, 
        timeout: 2000, 
        pause: 1,
        pager:  '#featuresnav' 
});
});
$(document).ready(function() {
    $('#features-wide').before('<div id="featuresnav-wide">')
                   .cycle({ 
        fx:     'fade', 
        speed:   1000, 
        timeout: 8000,
        pause: 1,
        pager:  '#featuresnav-wide' 
});
});
$(document).ready(function() {
    $('#bannerslides').before('<div id="bannerwrapper">')
                   .cycle({ 
        fx:     'fade', 
        speed:   1000, 
        timeout: 8000,
        pause: 1
});
});


$(document).ready(function(){
	
	/** Demo 1 **************************/

	$('.collapsetext').collapser({
		target: 'next',
		targetOnly: 'div',
		expandHtml: '+ Expand Text',
		collapseHtml: '- Collapse Text'
	});		
});

/******* school tests table **************/
$(document).ready(function() {
	$('#schooltests').dataTable( {
        "bPaginate": false,
		"aoColumns": [
			/* name */      { "sWidth": "50%", "sType":"html" },
			/* focus */      { "sWidth": "10%", "sType":"html" },
			/* cat    */       { "sWidth": "5%", "sType":"html" },
			/* level */       { "sWidth": "10%", "sType":"html" },
			/* delivery */  { "sWidth": "5%", "sType":"html" },
			/* report */     { "sWidth": "20%", "sType":"html" }
		]
	} );
} );

/********* FAQs **************/
$(document).ready(function() {
		$('.faqs dd').hide(); // Hide all DDs inside .faqs
		$('.faqs dt').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')}).click(function(){ // Add class "hover" on dt when hover
		$(this).next().slideToggle('normal'); // Toggle dd when the respective dt is clicked
		}); 
});
