﻿/* menu functie in document ready */
$(document).ready(function(){
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);

	if ((document.all) && !(window.opera)) {
		$("#nav-one li").hoverClass ("sfHover");
	}

});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};
/* einde menu functie! */



/* begin alle JS on document ready */
$(document).ready(function() {		
    			  
    			    $("#pijl_talen_sub").click(function () { showhide_talen(); } );
    			    $("#pijl_talen").click(function () { showhide_talen(); } );
    			        			    
    			    $("div.taal").click(function () { showhide_talen(); } );
                    $('#popup_content').hover(function() {}, function() {hide_talen(); });
                     
                    function hide_talen () {
                                $("#pijl_talen").attr({src : "grfx/pijl.gif"});
                                $("#pijl_talen_sub").attr({src : "../grfx/pijl.gif"});
                                
                                $('#popup_content').hide();
                                $('#talen').css("visibility","hidden"); 
                      }	
                      
				    function showhide_talen() {
                        var visibleState = $('#talen').css("visibility"); 
                            if (visibleState =="hidden") 
                            {  
                                $("#pijl_talen").attr({src : "grfx/pijl_hover.gif"});
                                $("#pijl_talen_sub").attr({src : "../grfx/pijl_hover.gif"});
                                
                                $('#popup_content').show();    
                                $('#talen').css("visibility","visible");                                 
                            }
                            else  { hide_talen(); }
                        }

 
          
			//HOVER OVER PRODUCT BOX
				$('.product_blok').hover(function() {
				  $(this).addClass('product_hover');
				}, function() {
				  $(this).removeClass('product_hover');
				}); 

                
                // CUSTOM STYLE VOOR CHECKBOXES UITGEZET 
	            // check for what is/isn't already checked and match it on the fake ones
	            /*
	            $("input:checkbox").each( function() {
		            (this.checked) ? $("#fake"+this.id).addClass('fakechecked') : $("#fake"+this.id).removeClass('fakechecked');
	            });
	            // function to 'check' the fake ones and their matching checkboxes
	            $(".fakecheck").click(function(){
		            ($(this).hasClass('fakechecked')) ? $(this).removeClass('fakechecked') : $(this).addClass('fakechecked');
		            $(this.hash).trigger("click");
		            return false;
	            });
	            */
	            
	            
	           //zoekveldje!!	           
	           var standaardtext;
	           var gewijzigd = false;
	           
               $('.zoekbox_textfield').focus(function() {
				   $(this).addClass('zoekbox_active');
				   if (!standaardtext) { standaardtext = this.value; }
				   this.value = '';
				   gewijzigd = true;
				} );
				 
                //zoekveldje onblur 
                $('.zoekbox_textfield').blur(function() {
                $(this).removeClass('zoekbox_active');
                    if (this.value =="") { this.value = standaardtext; gewijzigd=false;} 
                } );
                
                //als er gezocht wordt zonder iets in te vullen; zoek dan niet
                $('.zoekbox_button').click(function() {
                if (gewijzigd == false) { return false; } else {return true}
                });
                //EINDE ZOEKVELDJE


            //ACCORDION!!!!!
	            $("p.acc_head").click(function()
                {               
                    //als deze al geselecteerd is doe nix
                    if ($(this).hasClass('acc_head_active')) {
                     /*doe nix*/  
                     }else {
                        $(this).siblings().removeClass('acc_head_active');                   
    	                $(this).next("div.acc_body").slideToggle("normal").siblings("div.acc_body").slideUp("normal");
      	                $(this).addClass('acc_head_active');
                       
       	            }
	            });
	          

    
    
		});



// ***		
//niet on READY maar "gewone" JS functies hier	                
                
  
                
                function show_detail_pic(locatie,mijn_id) {
                      //is al niet geselecteerd?
                      var gadoor = 1;
                      if ($(mijn_id).hasClass('detail_thumb_active')) { gadoor = 0; return false } 
                      
                      if (gadoor == 1) { 
                                      //wijzig class van kader om thumbs
                                      if ($('.detail_thumb').hasClass('detail_thumb_active')) { $('.detail_thumb').removeClass('detail_thumb_active') }
                                      $(mijn_id).addClass('detail_thumb_active');    
                                      
                                      //begin wisseling van afbeelding     
                                      $('#product_image_big').fadeOut("fast",function() 
                                                    {
                                                    $('#product_image_big').attr({src : locatie }); 
                                                    //console.log("src");
                                                   });
                                                                                       
                                      
                                      $('#product_image_big').load (function() 
                                                    { 
                                                    $('#product_image_big').fadeIn("fast");
                                                    //console.log("loaded");
                                                     });
                                      
                                      }
                     }
    
    
    
                   function open_accordion(id) {
                    if ( $('#acc'+ id).hasClass('acc_head_active')) { } else {
                        $('#acc'+ id).siblings().removeClass('acc_head_active');                   
    	                $('#acc'+ id).next("div.acc_body").slideToggle("normal").siblings("div.acc_body").slideUp("normal");
      	                $('#acc'+ id).addClass('acc_head_active');
                    }
                     
       	            }
       	            
          
                    function dealers_loading() {
                         $('#google_maps_container').fadeTo("slow", 0.22);
                         $('#dealers_loading').show();
                    }
                    
                    function venster(URL,width,height) {
                        var left = (screen.width/2)-(width/2); 
                        var top = (screen.height/2)-(height/2); 
                        window.open(URL, 'popup', 'width='+width+', height='+height+', resizable=no, menubar=no, scrollbars=no, status=no, toolbar=no,top = '+top+', left='+left);
                        return false;
                    }

				function goto(url) { 
					window.location.href = url;
					return false;
	}

	function vragenvenster() {
	    $('#overlay').toggle();
	    $('#vragenvenster').toggle();
	}
