// JavaScript Document

  

        // wait for the DOM to be loaded 
        $(document).ready(function() {
        
          $("#list").load("php/botr.php", function(){checkFontSize();}); 
		$("#tagcloud").load("php/tagcloud.php");
      
        
        //----------------
        
        
        
        
        
        //this is the floating content
	var $floatingbox = $('#floating-box');
 
	if($('#list').length > 0){
 
	  var bodyY = parseInt($('#list').offset().top) - 2;
	  var originalX = $floatingbox.css('margin-left');
 
	  $(window).scroll(function () { 
 
	   var scrollY = $(window).scrollTop();
	   var isfixed = $floatingbox.css('position') == 'fixed';
 
	   if($floatingbox.length > 0){
 
	      /*
$floatingbox.html("srollY : " + scrollY + ", bodyY : " 
                                    + bodyY + ", isfixed : " + isfixed);
*/
 
	      if ( scrollY > bodyY && !isfixed ) {
			$floatingbox.stop().css({                 /* $floatingbox.stop().css({ */
			  position: 'fixed',
			  left: '50%',
			  top: 20,
			  marginLeft: -480
			});
		} else if ( scrollY < bodyY && isfixed ) {
		 	  $floatingbox.css({
			  position: 'relative',
			  left: 0,
			  top: 0,
			  marginLeft: originalX
		});
	     }		
	   }
       });
        
        
        }
        
        
        
        
        
        
        
        //-----------------
        
        
        
        
        
        
        
        
        $('#zoeklabel').click(function(){$(this).hide();$('#zoekveldje').show().focus();});
	
		$('#zoekveldje').blur(function(){$(this).hide().val('');$('#zoeklabel').show();$('.zoekbericht').hide();});
       
        
        
        
        
        
        
  /*
      
        
        // changer links when clicked
        $("a.changer").click(function() {
            //set the div with class mainText as a var called $mainText 
            var $mainText = $('.menuKnop,.resizeme');
            // set the current font size of .mainText as a var called currentSize
            var currentSize = $mainText.css('font-size');
            // parse the number value out of the font size value, set as a var called 'num'
            var num = parseFloat(currentSize, 10);
            // make sure current size is 2 digit number, save as var called 'unit'
            var unit = currentSize.slice(-2);
            // javascript lets us choose which link was clicked, by ID
            if (this.id == 'linkLarge') {
                num = 20; //num = num * 1.4;
            } else if (this.id == 'linkSmall') {
                num = 14; //num = num / 1.4;
            } else if (this.id == 'linkNormal') {
                num = 16;
                }
            // jQuery lets us set the font Size value of the mainText div
            $mainText.css('font-size', num + unit);
            berekenMenu();
            menuhoogte();
           // $("#footer_menu").pinFooter();
            return false;
        });
        
        
        
*/
        
        
        $("a.changer").click(function() {
            
            var num;
            var $mainText = $('.resizeme');
           
            if (this.id == 'linkNormal') {
                num = 14; 
            } else if (this.id == 'linkLarge') {
                num = 16; 
            } else if (this.id == 'linkXLarge') {
                num = 20;
                }
           
            $mainText.css('font-size', num);
            $(".menuKnop").css('font-size', num + 2);
            $("#logo2").css('font-size', num + 2);
            $(".resizeme2").css('font-size', num + 2);           
            
            
            $.cookie('font-size', num);
            $('.changer').css('text-decoration', 'none'); 
            $(this).css('text-decoration', 'underline');  
            
            
            $.post("../log.php", { info: "font="+num } );
            
            berekenMenu();
            menuhoogte();
          
            return false;
        });

             
             
             
             
             checkFontSize();
         
       
        
        
              
        
        
        
        
        
        
        
        
        
        
        
        $(function() {
		$("a:contains(Disclaimer)[rel]").overlay({mask: 'darkred',fixed: false, top: 130});
		$("a:contains(Contact)[rel]").overlay({mask: 'darkred',fixed: false, top: 130}); /*  , effect: 'apple' */
		$("a:contains(Gezocht)[rel]").overlay({mask: 'darkred',fixed: false, top: 130});
		$("a:contains(Partners)[rel]").overlay({mask: 'darkred',fixed: false, top: 130});
		$("a:contains(Pers)[rel]").overlay({mask: 'darkred',fixed: false, top: 130});
		$("a:contains(Embed)[rel]").overlay({mask: 'darkred',fixed: false, top: 130});
		
});
        
        
        
       
        
   
        
        
        jQuery(function(){
        
        $(".img_swap").hover(
        					function(){this.src = this.src.replace("_off","_on");},
        					function(){this.src = this.src.replace("_on","_off");});
						});

        
        
        
       /*
 
        	$(window).resize(function() {
        	
  berekenMenu();
  });

*/
								   
								   externalLinks();
								   
								    if (window.location.hash == "#meldjeaan"){$("a:contains(Gezocht)[rel]").trigger('click');}  
								    if (window.location.hash == "#pers"){$("a:contains(Pers)[rel]").trigger('click');}
								    if (window.location.hash == "#embed"){$("a:contains(Embed)[rel]").trigger('click');}
								    if (window.location.hash == "#partners"){$("a:contains(Partners)[rel]").trigger('click');}
									
									
								   
								 								   
								   
								
								   
								$('#zoekForm').ajaxForm({target: '#list' ,beforeSubmit: geduldaub,success: function() {
										var mnresultaat = $('.message').text();
										
																		
										$('.zoekbericht').text(mnresultaat);
										
										
										
										setTimeout("$('.zoekbericht').hide();$('#zoeklabel').show();",2000);

										/* hier if visible dan niet nogmaals show voor zoeklabel */
																				
										}
										});  
	
	
	
	
		

								   menuhoogte();
								   berekenMenu();
								    
								    
								    
								    
								    
								    
								    
								   
	
	
	
	
							   
								   
								   
								  
								   
								   
								   
								   
								    /* $('#melding_container').delay(3000).slideDown(500).delay(3000).slideUp(500);  */
	 
	 
		 
	 
	 
	
function meetHoogteFooter(){
	
	 var hoogteFooter = $(window).height() - ($("#container").height() + $("#menuContainer").height()+ 30); 	
	
		
	 $("#footer_menu").height(hoogteFooter);

	
	}
	
	

	
	
	
	
	//-------
	
	var options = {
        //target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 

}; 
 
    // bind form using 'ajaxForm' 
    $('#myform').ajaxForm(options); 

 });
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    //var queryString = $.param(formData); 

    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 	
	
	var human = $('input[name=proof_u_r_human]').fieldValue(); 
  
 
    // usernameValue and passwordValue are arrays but we can do simple 
    // "not" tests to see if the arrays are empty 
    if (human[0] == 2 | human[0] == "twee" | human[0] == "Twee" | human[0] == "TWEE") { 
        //alert('ok'); 
        return true; 
    } 
    
 
    alert('Het antwoord op de vraag één erbij één is onjuist.'); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return false; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
   // alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
     //   '\n\nThe output div should have already been updated with the responseText.'); 
	
	
	
	 $('#aanmelden_container').slideUp(1000);
	
	$('#dank_container').delay(1100).slideDown(500);
	
} 
	
	
	
	
    
	
    var sURL = unescape(window.location.pathname);

	function refresh(tag){
	tag=tag.replace(/\s/g,"%20");
	
	$("#list").load("php/botr.php?search="+tag);
	
}




function menuhoogte(){

 $(".menu").height($(".menuKnop").height());


}


function geduldaub(){



$("#zoeklabel").hide();
$("#zoekveldje").hide();
$(".zoekbericht").show().text('even geduld a.u.b.');



}








function berekenMenu(){							    
	var sum=80;
	$('.menuKnop').each( function(){ sum += $(this).width(); });
	$('#menuKnoppenContainer').width( sum );
	}
	
	
	
	
	
	
	
	
function checkFontSize(){


       
             
         if ($.cookie('font-size')) {
         
          var koek = $.cookie('font-size');
    
	if (koek == '20') {$("a:#linkXLarge").trigger('click');};
	if (koek == '16') {$("a:#linkLarge").trigger('click');};
	if (koek == '14') {$("a:#linkNormal").trigger('click');};
         
         
         }   else {
         
         
          $("a:#linkNormal").css('text-decoration', 'underline'); 
         
         
         }
            


}	
