function in_array (needle, haystack, argStrict) {
    var key = '',
        strict = !! argStrict;

    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }

    return false;
}

$(document).ready(function ()
{
        /// Contact openingstijden 
        $("#openingstijden-click").live("mouseover",function(){
            $(this).next("span#openingstijden-content").fadeIn();
        }).live("mouseout",function(){
            $(this).next("span#openingstijden-content").fadeOut();
        });
    
        // Showroom slider
    $("li#showroom-navi:first").css("background","#ed008e");
    $("#showroom-navi").live("click",function(){
        var $$index = $(this).index();
        $(".showroom-ul").stop().animate({marginLeft:'-'+($$index * 900)+'px'},800);
        $(this).css("background-color","#ed008e");
        $("#showroom-navi").not(this).each(function(){
            $(this).css("background-color","#C0C0C0");
        });
    });
    /// Last showroom
    $("#showroom-last li").live("mouseover",function(){
        $(this).children("#item-background").stop().animate({opacity:1});
        $("#showroom-cont li").not(this).each(function(){
            $(this).children("#item-background").stop().animate({opacity:0});
        });
    }).live("mouseout",function(){
        $("#showroom-last li").each(function(){
            $(this).children("#item-background").stop().animate({opacity:0});
        });
    })
    /// ShareBox
    $("#share-buttons li").hover(function(){
        $(this).stop().animate({marginLeft:"60px"});
        $("#share-buttons li").not(this).each(function(){
            $(this).stop().animate({marginLeft:"0px"});
        });
    },function(){
        $("#share-buttons li").each(function(){
            $(this).stop().animate({marginLeft:"0px"});
        });
    });
    /// Alert function
    var newAlert = function(msg){
        $("#darkBackground").fadeIn(200);
        $("#alert").html(msg).delay(200).fadeIn();
    }
    $("#darkBackground,#alert").click(function(){
        $("#darkBackground,#alert").fadeOut();
    });
///// Contact send : ajax

$(" #contactgegevens form").submit(function(){
    var error;
    var $this = $(this);
    var $standardValues = new Array;
    $standardValues = ("Uw naam","Uw email","Uw telefoon nummer","Uw bericht");

    //if(error < 1){
        $.ajax({
            url:"ajax.php",
            type:"POST",
            data:$this.serialize(),
            complete:function(){
                newAlert("Uw bericht is verzonden");
            }
        });
    //}
    return false;
});
///// Contact input
    var $thisAlt;
    var $thisVal;
    $(".contactUnit #contactgegevens input[type=text],.contactUnit #contactgegevens textarea").focus(function(){
        $thisAlt = $(this).attr("alt");
        $thisVal = $(this).val();
        if($thisVal == $thisAlt){$(this).val("").css({"color":"gray","font-style":"normal"});}
    });
    $(".contactUnit #contactgegevens input[type=text],.contactUnit #contactgegevens textarea").blur(function(){
        $thisAlt = $(this).attr("alt");
        $thisVal = $(this).val();
        if($thisVal==""){$(this).val($thisAlt).css({"color":"silver","font-style":"italic"});}
    });
    $(".contactUnit #contactgegevens textarea").click(function(){
        $(this).animate({width:400+"px",height:300+"px"});
    });
    $(".contactUnit #contactgegevens textarea").blur(function(){
        $(this).animate({width:250+"px",height:100+"px"});
    });
///// Contact tabs
    /// Start orders
    $("#contactBar ul li").each(function(){$(this).animate({opacity:0.5});});
    $("#contactBar ul li:first").animate({opacity:1});
   // $(".contactUnit:first").fadeIn();
    //$("#contactBar ul li:first").animate({opacity:1,fontWeight:"bold"});
     
    /// Click function
    var $thisName;
    $("#contactBar ul li").click(function(){
        $thisName = $(this).attr("class");
        $(".contactUnit").not("#"+$thisName).each(function(){
            $(this).fadeOut(500);
        });
        $("#"+$thisName).delay(500).fadeIn();
        ///
        
        $("#contactBar ul li").not(this).each(function(){
            $(this).stop().animate({opacity:0.5});
        }); 
        $(this).stop().animate({opacity:1});  

        
    });

///// HEADER ARROW EFX
    var $thisUrl = "?page=";
    var $space = (($("#headerLinks a[href='"+$thisUrl+page+"']").attr("id"))*90)+"px";;
      $("#efxLine").stop().animate({left:$space});  
      
    $("#headerLinks a").hover(
    function(){
        var $thisID = $(this).attr("id");
        var $space = ($thisID*90)+"px";
        //alert($space);
        $("#efxLine").stop().animate({left:$space});
    },function(){
        var $thisUrl = "?page=";
        var $space = (($("#headerLinks a[href='"+$thisUrl+page+"']").attr("id"))*90)+"px";;
        $("#efxArea").hover(
        function(){
            $("#efxLine").stop();
        },function(){
          $("#efxLine").stop().animate({left:$space});  
        });
       // alert($space);
    });    
//////////////////////////////////////////////////////////////////////////////////////////    
//// ALERTBOX
    
    $("#alertBox_bg").fadeIn();
    $("#alertBox_bg").click(function ()
    {
        $(this).fadeOut("fast");
    });

///////////////////////////////////////////////////////////////////////////////////////////
  // Homepage slider
  var speed = 800;
  var $Position = 0;
  $("#newsBar-navigation-buttons li").each(function(){
            $(this).animate({opacity:0.5});
        });
  $("#newsBar-navigation-buttons li:first").css("background","#ed008e").animate({opacity:1});
  $("#newsBar-navigation-buttons li").hover(function(){
        $("#newsBar-navigation-buttons li").not(this).each(function(){
            $(this).animate({opacity:0.5});
        });
        $(this).animate({opacity:1});
        clearInterval(NewsSliderTimer);
  },function(){
    $("#newsBar-navigation-buttons li").not($(".clicked")).each(function(){
            $(this).animate({opacity:0.5});
        });
  });
  
  $("#newsBar-navigation-buttons li").click(function(){
    $Position = $(this).index();
    $(".sliderHome_news #slider-list").stop().animate({marginLeft:"-"+($Position*430)+"px"},speed);
    $(this).css("background","#ed008e").animate({opacity:1}).addClass("clicked");
    
    $("#newsBar-navigation-buttons li").not(this).each(function(){
            $(this).css("background","silver").animate({opacity:0.5});
        });
    
  });
  
/*
   // time
   var $button = 0;
    var $thisPosition = $(".sliderHome_news #slider-list").css("margin-left").replace("px","");
     $thisPosition = Math.abs(parseInt($thisPosition));
   var NewsSliderTimer = setInterval(function(){   
     if($thisPosition < 900){
         $(".sliderHome_news").animate({marginLeft:"-"+$thisPosition+"px"}); 
         // Buttons efx
         $("#newsBar-navigation-buttons li").each(function(){
             $(this).css("background-color","silver");
         });
         var $index = $thisPosition / 430;
         $("#newsBar-navigation-buttons li").eq($index).css("background-color","#ED008E");
         $thisPosition = $thisPosition + 430;
         
     }else{
         $(".sliderHome_news").animate({marginLeft:"0px"});
         $thisPosition = 0;
         $index = 0;
     }
     
 
    
    
  },1000);
  */
});
