jQuery(function(){
	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        var address = new GLatLng(52.211465,-2.168438);
        map.setCenter(address, 15);
        //map.setMapType(G_PHYSICAL_MAP);
        
        //var icon = new GIcon();
	    //icon.image = "images/marker.png";
	    //icon.shadow = "images/shadow-marker.png";
	    //icon.iconSize = new GSize(20.0, 35.0);
	    //icon.shadowSize = new GSize(38.0, 35.0);
	   // icon.iconAnchor = new GPoint(10.0, 17.0);
	    //icon.infoWindowAnchor = new GPoint(10.0, 17.0);
	    
        var marker = new GMarker(address);
        //var address = "<span id='address-bubble'></span>";
        var showAddr = false;
        GEvent.addListener(marker, "click", function() { 
			showAddr = !showAddr; 
			if (showAddr){
				$("div.address").show();
			} else {
				$("div.address").hide();
			}
		});
        map.addOverlay(marker);
        var zoom = new GLargeMapControl();
        map.addControl(zoom);
        var controls = true;
        
        $("#toggle-controls").click(function(){
			if (controls){
				map.removeControl(zoom); 
			} else {
				map.addControl(zoom); 
			}
			controls = !controls;
		});
      }
      
    function setInlineLabel(id,label){
    	if($(id).val() === '') {
			$(id).val(label);
		}
		
		$(id).data("label",label);
		
		$(id).focus(function() {
			if($(id).val() === label) {
				$(id).val('').addClass('focused');
			}
		});
		
		$(id).blur(function() {
			if($(id).val() === '') {
				$(id).val(label).removeClass('focused');
			}
		});
	}
      
    setInlineLabel("#i-name","Your name");
	setInlineLabel("#i-email","your.mail@host.tld");
	setInlineLabel("#i-subject","Message subject");
	setInlineLabel("#i-content","Message content"); 
	
	$('.wpcf7-form').submit(function() { 
		$("#contact-form .i-text").each(function(){
			var value = $(this).val();
			var label = $(this).data("label");
			if (value == label){
				$(this).val('');
			}	
		});
    }); 

    //$("#i-name").defaultvalue("Your name");
//	$("#i-email").defaultvalue("your.mail@host.tld");
//	$("#i-subject").defaultvalue("Message subject");
//	$("#i-content").defaultvalue("Message content");
	
	/*
	var options = { 
        target: '#mail-result',   // target element(s) to be updated with server response 
        
        beforeSubmit: function(formData, jqForm, options) { 
		    for (var i=0; i < formData.length; i++) { 
		        if (!formData[i].value) { 
		            //alert('Please enter a value for both Username and Password'); 
		            //return false; 
		        } 
		    } 
		    return true;
		},  // pre-submit callback 
		
        success: function(responseText, statusText)  { 
		    //
		},  // post-submit callback 
 
        // other available options: 
        url:       "contact/mail"         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
    
	$('#cform').submit(function() { 
		$("#mail-result").html("Sending...");
        $(this).ajaxSubmit(options); 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 
    */
});
