// JavaScript Document
document.observe("dom:loaded",function(){
	$('mainlogo').observe("click",function(){window.location='/';});
});

function initMap(){
	var marker;
	var map;
	var geocoder;
	var address;
	var html="<img src='images/WT_maplogo.gif'" +

         "width='138' height='42'/> <br/>" +

         "Unit 5 Universal Marina,<br/>Crableck Lane, Sarisbury Green,<br/>Southampton SO31 7ZN";
		   
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map_canvas"));
	map.addControl(new GLargeMapControl());
	map.setCenter(new GLatLng(50.876367,-1.298361), 14);
	marker = new GMarker(new GLatLng(50.874824,-1.301944));
	map.addOverlay(marker);
	map.enableContinuousZoom();
	map.enableScrollWheelZoom();
	marker.openInfoWindowHtml(html);
	GEvent.addListener(marker,"click", function(){marker.openInfoWindowHtml(html);});
	}
}
function initContact(){
	initMap();
	contactValidation = new Validation('frmContact');
	$('frmContact').observe('submit',contactSend)
}

function contactSend(e){
	if (contactValidation.validate()){
		$('btnSend').hide()
		$('contactAjaxLoader').show()
		var strBody=$F('strMessage')
		new Ajax.Request("/ajax/sendenquiry.asp",{method:'post',parameters:$('frmContact').serialize(true),
					 onSuccess: function(transport){
						 try{pageTracker._trackEvent('Contact Form','Sent',$F('strName'))}
						 catch(err){};
						 var response=transport.responseText.strip() || "no response";
						 if (response=="no response"){
							 $('frmContact').update('<h4><abbr title="(f) '+response.stripTags().strip()+'">Oops.</abbr></h4>There was a problem submitting the form. Sorry about that... you might want to <a href="mailto:sales@workingtelecoms.com">email us</a> instead.')
						 }else{
							 $('frmContact').update(response)
							 var _gaq = _gaq || [];
							 _gaq.push(['_trackEvent', 'Contact Form', 'Enquiry']);
						 }
					 },
						 onFailure: function(transport){
						 var response=transport.responseText.strip() || "no response";
							 $('frmContact').update('<h4><abbr title="(f) '+response.stripTags().strip()+'">Oops.</abbr></h4>There was a problem submitting the form. Sorry about that... you might want to <a href="mailto:sales@workingtelecoms.com?body='+encodeURI(strBody)+'">email us</a> instead.')
						 }
					});
	}
	if(e){
		Event.stop(e)
	}
}

