$(document).ready(function()
{
	$("a[rel='lightbox']").colorbox({
        width: '800px',
        height: '600px'	   
	});
    
    $('.innerfade').innerfade({
		speed: 750,
		timeout: 5000,
		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");
		}
    });
    
    jQuery(document).ready(function() {
        jQuery('#carrousel').jcarousel({
        });
    });
    
    $("#huurkoop").change(function() {
        alert('test');
        $('#huurofkoop').submit();
    });
    
    $(".huurkoop").change(function() {
        $('#huurofkoop').submit();
    });
    
    $('#submitZoekenHome').click(function() {
        $('#zoekFormHome').submit();
    });
    
    if($("#currentLanguage").val() == 'nl')
    {
       // var melding = 'Dit veld is verplicht';
    }
    else
    {
        //var melding = 'This field is required';
    }
    
    
    //jQuery.validator.messages.required = '<span style="color:red;">'+melding+'</span> <br/>';
    jQuery.validator.messages.required = "";
    jQuery.validator.messages.email = "";
    $("#signupForm").validate({
    });
    $("#intresseForm").validate({
    });
    $("#contactForm").validate({
    });
     
    $('#plaatsnaamSale').change(function() {
        $.getJSON("controllers/woningen.php",{id: $(this).val(), ajax: true}, function(j){
            var options = '';
            for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i].value + '">' + j[i].display + '</option>';
            }
            $("#urbanisation").html(options);
        });
    });
    
    $('#urbanisation').change(function() {
        $.getJSON("controllers/woningen.php",{id: $(this).val(), ajaxVolledig: true}, function(j){
            var options = '';
            for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i].value + '">' + j[i].display + '</option>';
            }
            $("#urbanisationVolledig").html(options);
        });
    });
});


function handleNoFlash(errorCode) {
      if (errorCode == 603) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
      }
    }  

function showAddress(map,geocoder,address,html, postalcode, i) {
	geocoder.getLatLng(
	address,
	function(point) {
		if (!point && i < 1) {
			showAddress(map, geocoder, postalcode, html, postalcode, 1);
		} else {
			map.setCenter(point, 15);
			map.addControl(new GMapTypeControl());
			map.addControl(new GLargeMapControl());
		}
	});
}
