

// gebruik $j als jquery variabele zodat deze niet conflicteerd met de scripts uit de smartsite formulieren generator
var $j = jQuery.noConflict();  



function doHighlight(bodyText, searchTerm){
if(searchTerm!="" && searchTerm.length > 2){
StartTag="<font class='highlight'>";EndTag="</font>";var newText = "";
var i = -1;var lcBodyText = bodyText.toLowerCase();while (bodyText.length > 0){i = lcBodyText.indexOf(searchTerm, i+1);
if (i < 0) {newText += bodyText;bodyText = "";} else {
if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)){
if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
newText += bodyText.substring(0, i) + StartTag + bodyText.substr(i, searchTerm.length) + EndTag; bodyText = bodyText.substr(i + searchTerm.length);
lcBodyText = bodyText.toLowerCase();i = -1;}}}}return newText;}else{return bodyText;}}


$j(document).ready(function(){
try{
var arr =$j.query.get('q').split(" ");

$j(arr).each(function(i, n) {

if(n.length>2){
try{
if($j("#fldTermszoek").val().length<1){
$j("#content").html(doHighlight($j("#content").html(), n.toLowerCase()));
}
}catch(e){
$j("#content").html(doHighlight($j("#content").html(), n.toLowerCase()));
}
}
});
}catch(e){}



try{
if($j("#fldTermszoek").val().length>1){
var arr =$j("#fldTermszoek").val().split(" ");
$j(arr).each(function(i, n) {
if(n.length>2){
// $j("#content").html(doHighlight($j("#content").html(), n.toLowerCase()));

}
});}
}catch(e){}
});

$j(document).ready(function(){
try{   
$j('#fromdate').datepicker({  
	//altField: "#fromdate", 
        showOn: "button",   
        buttonImage: "images/calendar.png",   
        buttonImageOnly: true,
	dateFormat: "dd-mm-yy",
	//altFormat: 'yy/mm/dd',
	dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
	dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr','Za'],
	//defaultDate: -61,
	//maxDate: '+14',
        //setDate: -14, 
	monthNames: ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December']
}); 
$j('#todate').datepicker({  
	//altField: "#todate", 
        showOn: "button",   
        buttonImage: "images/calendar.png",   
        buttonImageOnly: true,
	dateFormat: "dd-mm-yy",
	//altFormat: 'yy/mm/dd',
	dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
	dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr','Za'],
	//defaultDate: -61,
	//maxDate: '+14',
	monthNames: ['January','February','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December']
});  




if($j("ul li").size()==1){$j("ul li").children("div").show("normal")}else{$j("ul li").children("div").hide(); 

$j("ul li").children("div").each(function(){_fnLoadState($j(this).attr("id"))});


}





if($j("ul li").size()==1){$j("ul li").children("ul li").show("normal");$j("ul li span.cat").html($j("ul li span.cat").html().replace("+","-"));}else{$j("ul li ul li").hide();}


    $j("ul li span.cat").click(function () {
if ($j(this).parent().children("div").is(":hidden")) {
$j(this).html($j(this).html().replace("+","-"));
$j(this).parent().children("div").show("normal");

_fnSaveState($j(this).parent().children("div").attr("id"),$j(this).parent().children("div").attr("id"),1)

}
else{
$j(this).html($j(this).html().replace("-","+"));
$j(this).parent().children("div").hide("normal");
_fnSaveState($j(this).parent().children("div").attr("id"),$j(this).parent().children("div").attr("id"),0)
}


if ($j(this).parent().children("ul").children("li").is(":hidden")) {

$j(this).parent().children("ul").children("li").show("normal");
}
else{
$j(this).parent().children("ul").children("li").hide("normal");
}




    });


   	$j("a.soundx").click(function(){
      	var page = $j(this).attr("href");
	$j("#fldTermszoek").val($j(this).html());
	$j("#frmsearch").submit();
      	return false;
   	});
    }catch(e){}



   	$j("#optionlist").click(function(){
      	$j("#checkboxen").toggle();
   	});
try{
$j("#fldTermszoek").focus();
}catch(e){}
$j('.dataTables').dataTable({
		"sPaginationType": "full_numbers",
		"bLengthChange": true,
		"iDisplayLength": 6,
		"bFilter": false,
		"bSort": false,
		"bInfo": true,
		"bStateSave":true,
	"bAutoWidth": false,
	"oLanguage": {
                        "sProcessing": "Bezig met verwerken...",
                        "sZeroRecords": "Geen resultaten gevonden",
                        "sInfoEmpty": "0 tot 0 van 0 resultaten",
                        "sInfoFiltered": "(gefilterd uit _MAX_ resultaten)",
	                "sInfoPostFix": "",
	                "sSearch": "Zoek:",
			"sLengthMenu": 'Toon <select>'+
				'<option value="6">6</option>'+
				'<option value="10">10</option>'+
				'<option value="20">20</option>'+
				'<option value="30">30</option>'+
				'<option value="40">40</option>'+
				'<option value="50">50</option>'+
				'<option value="-1">All</option>'+
				'</select> resultaten', 
			"sInfo": "_START_ tot _END_ van _TOTAL_ resultaten", 
			"oPaginate": {"sFirst":    "Eerste",
				      "sPrevious": "Vorige", 
                                      "sNext":     "Volgende", 
                                      "sLast":     "Laatste"
                                     }
			
		    }

});
  
 
});

		function _fnLoadState (id)
		{

			var sData = _fnReadCookie( "swdsearch"+id );
			if ( sData !== null && sData !== '' )
			{
				oData = eval( '('+sData+')' );
if(oData.divname==$j("#"+id).attr("id")){
if(oData.value==1){
$j("#"+id).show("normal");
}
}
			}
		}
		
		function _fnSaveState (id,name,value)
		{

			
			/* Store the interesting variables */
			var sValue = "{";
			sValue += '"divid":"'+id+'",';
			sValue += '"divname":"'+name+'",';
			sValue += '"value": '+value+'';
 			sValue += "}";

 			_fnCreateCookie( "swdsearch"+id, sValue, 
				60 * 60 * 2 );
		}
		function _fnCreateCookie ( sName, sValue, iSecs )
		{
			var date = new Date();
			date.setTime( date.getTime()+(iSecs*1000) );
			
			/* 
			 * Shocking but true - it would appear IE has major issues with having the path being
			 * set to anything but root. We need the cookie to be available based on the path, so we
			 * have to append the pathname to the cookie name. Appalling.
			 */
			sName += '_'+window.location.pathname.replace(/[\/:]/g,"");
			
			document.cookie = sName+"="+sValue+"; expires="+date.toGMTString()+"; path=/";
		}
		function _fnReadCookie ( sName )
		{
			var sNameEQ = sName +'_'+ window.location.pathname.replace(/[\/:]/g,"") + "=";
			var sCookieContents = document.cookie.split(';');
			
			for( var i=0 ; i<sCookieContents.length ; i++ )
			{
				var c = sCookieContents[i];
				
				while (c.charAt(0)==' ')
				{
					c = c.substring(1,c.length);
				}
				
				if (c.indexOf(sNameEQ) === 0)
				{
					return c.substring(sNameEQ.length,c.length);
				}
			}
			return null;
		}
		