var $browser;
var $version;
$(document).ready(function()
{
    $k = 1;
    jQuery.each(jQuery.browser, function(i, val) {
        if ($k == 1)
        {
            $browser = i;
        }
        else
        {
            $version = val;
        }
        $k++;
    });
    
	$("a[rel='lightbox']").colorbox({maxHeight:"90%", maxWidth:"90%"});
    
    $(".lightbox").colorbox({width:'500px', height:'270px'});
    $(".formbox").colorbox({iframe:true, width:'500px', height:'360px'});
    $(".verkoophuis").colorbox({iframe:true, innerWidth:500, width:'500px', height:'530px'});
    $(".slideFotos").colorbox({iframe:true, width:'900px', height:'800px'});

    $('.innerfade').innerfade({
		speed: 2000,
		timeout: 12000,
		type: 'random'
	});
    
    $(".validateForm").validate({
        errorPlacement: function(error, element) {
			error.prependTo( element.parent().next() );
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
    });
    
    $('.orderType').change( function() {
        $('#orderTypeForm').submit();
    });
    
    $('.woningItem').mouseover(function(){
        $(this).children('div').children('div').children('a').show();
    });
    
    $('.woningItem').mouseout(function(){
        $(this).children('div').children('div').children('a').hide();
    });
    
    $('.detailContact').mouseover(function(){
        $(this).attr('src','images/detailContactHover.png'); 
    });
    
    $('.detailContact').mouseout(function(){
        $(this).attr('src','images/detailContact.png'); 
    });
    
    $('.detailRoute').mouseover(function(){
        $(this).attr('src','images/detailRouteHover.png'); 
    });
    
    $('.detailRoute').mouseout(function(){
        $(this).attr('src','images/detailRoute.png'); 
    });
    
    $('.detailBrochure').mouseover(function(){
        $(this).attr('src','images/detailBrochureHover.png'); 
    });
    
    $('.detailBrochure').mouseout(function(){
        $(this).attr('src','images/detailBrochure.png'); 
    });
    
    $('.detailMail').mouseover(function(){
        $(this).attr('src','images/detailMailHover.png'); 
    });
    
    $('.detailMail').mouseout(function(){
        $(this).attr('src','images/detailMail.png'); 
    });
    
    $('.leesMeer').mouseover(function(){
        $(this).attr('src','images/leesMeerHover.png'); 
    });
    
    $('.leesMeer').mouseout(function(){
        $(this).attr('src','images/leesMeer.png'); 
    });
    
    $('.meerTweets').mouseover(function(){
        $(this).attr('src','images/meerTweetsHover.png'); 
    });
    
    $('.meerTweets').mouseout(function(){
        $(this).attr('src','images/meerTweets.png'); 
    });
    
        $('.verzenden').mouseover(function(){
        $(this).attr('src','images/verzendenHover.png'); 
    });
    
    $('.verzenden').mouseout(function(){
        $(this).attr('src','images/verzenden.png'); 
    });
    
    $('.meerFotos').mouseover(function(){
        $(this).attr('src','images/meerFotosHover.png'); 
    });
    
    $('.meerFotos').mouseout(function(){
        $(this).attr('src','images/meerFotos.png'); 
    });
    
    $('.zoekenB').mouseover(function(){
        $(this).attr('src','images/zoekenHover.png'); 
    });
    
    $('.zoekenB').mouseout(function(){
        $(this).attr('src','images/zoeken.png'); 
    });
    
    $('.belmij').mouseover(function(){
        $(this).attr('src','images/belmijHover.png'); 
    });
    
    $('.belmij').mouseout(function(){
        $(this).attr('src','images/belmij.png'); 
    });
    
    $('.meerinformatie').mouseover(function(){
        $(this).attr('src','images/meerinformatieHover.png'); 
    });
    
    $('.meerinformatie').mouseout(function(){
        $(this).attr('src','images/meerinformatie.png'); 
    });
    
    $('.afspraakmaken').mouseover(function(){
        $(this).attr('src','images/afspraakmakenHover.png'); 
    });
    
    $('.afspraakmaken').mouseout(function(){
        $(this).attr('src','images/afspraakmaken.png'); 
    });
    
    $('.tex').mouseover(function(){
        $(this).attr('src','images/texHover.png'); 
    });
    
    $('.tex').mouseout(function(){
        $(this).attr('src','images/tex.png'); 
    });
    
    $('.verkoop').mouseover(function(){
        $(this).attr('src','images/verkoopHover.png'); 
    });
    
    $('.verkoop').mouseout(function(){
        $(this).attr('src','images/verkoop.png'); 
    });
    
    
    
    $('.menuItem').mouseover(function(){
        $(this).children('div').toggle();
        height = 0;
        $.each($(this).children('div').children('ul').children('li'), function() {
            height += 30;
        });
        
        if ($browser == 'msie' && parseFloat($version) < 8)
        {
            $width = $(this).width();
            $(this).children('div').css('margin-left', '-' + $width + 'px');
        }
        
        $('.submenuDefault').css('height',height);
        $('.submenuDefault').toggle();
    });
    
    $('.menuItem').mouseout(function(){
        $('.submenuDefault').toggle(); 
        $(this).children('div').toggle();
        
    });
});
