var Map = {
    init: function() {
        // Create the map.
        var map = new VEMap('Map');
        // Hide controls.
        map.HideDashboard();

        // Set credentials.
        map.SetCredentials("AmZ3cUe5 - Doo_fmvM6QDbMQ7KvPhoKibhGly6P1sRV9H1o6Axi - LU75VzqoKSuDN");

        // Create map and set position.
        var position = new VELatLong(51.446308, 5.614867);
        map.LoadMap(position, 16, VEMapStyle.Road, false, VEMapMode.Mode2D, false, 0);
        map.HideScalebar();

        // Set point on adres.
        pinPoint = map.GetCenter();
        pinPixel = map.LatLongToPixel(pinPoint);
        map.AddPushpin(pinPoint);
    }
}

$j().ready(function () {
   Map.init();

   $j(".LoginField").focus(function () {
	if (this.value == this.title)
		this.value = "";
   });

   $j(".LoginField").blur(function () {
	if (this.value == "")
		this.value = this.title;
   });

    $j(".ContactFormButton").click(function () {
        var valid = true;
        $j("input,textarea").each(function () {
            if (this.className.indexOf("Required") >= 0) {

                $j(this).removeClass("Error");

                var current = true;

                if (this.value.length == 0)
                    current = false;

                if (this.className.indexOf("Email") >= 0) {
                    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                    if (reg.test(this.value) == false)
                        current = false;
                }

                if (!current) {
                    $j(this).addClass("Error");
                    valid = false;
                }
            }
        });

        return valid;
    });
});
