function initAccordian() {
	window.addEvent('domready', function() {
		//create our Accordion instance
		var myAccordion = new Accordion($('accordianArea'), 'div.toggler', 'div.element', {
			display: -1,
			opacity: false,
			alwaysHide: true,
			onActive: function(toggler, element){
				//toggler.setStyle('color', '#e58e1a');
			},
			onBackground: function(toggler, element){
				//toggler.setStyle('color', '#0070ad');
			}
		});
	});
}

window.addEvent('domready', function(){
	if($("mapper")) {
		Google.createMap('mapper', {'zoom': 12, 'controls':{'large':false,'small':true} } , function(){
			var marker = {
				'address': 'Fox Lane, Wakefield, WF1 2AJ',			
				'options': {
					'center': true					
				},
				'icon': {
					'top': 68,
					'left': 43,					
					'image': {
						'src': rooturl + 'webapp/templates/images/map-marker.gif',
						'width': 132,
						'height': 91
					}
				}
			};
			
			//Google.addEvent("markerDragged",function(a,b){console.log(a,b)});
			Google.addMapMarker('mapper', marker);
		});
	
		$('frmSubmitDirections').addEvent('submit', function(e){
		
				e.preventDefault();
		
				var postcode = $('texboxDirections').value;
				Google.postcodeSearch(postcode, 'UK', function(result){
					Google.getDirections('mapper', $('googleDirections'), 
							postcode + '@' + result.y + ',' + result.x, 'TS Booker', 
							function(){
								$('googleDirections').empty();
							}, 
							function(){
							}, 3, {
								'lat':function(){return 53.69401}, 
								'lng':function(){return -1.51408}
							}, true);
				});
		
				return false;
		
		});
	}
	
});	




// Validation for Contact Form
function validateContactFrm(theForm) {
	with (theForm) {
		if (title.value.length < 1) {
			alert('Please enter a title/salutation');
			title.focus();
			return false;
		}
		if (forename.value.length < 1) {
			alert('Please enter your forename');
			forename.focus();
			return false;
		}
		if (surname.value.length < 1) {
			alert('Please enter your surname');
			surname.focus();
			return false;
		}		
		var stripped = tel.value.replace(/[\(\)\.\-\ ]/g, '');    
		if (tel.value.length < 1 ) {
			alert('Please tell us a contact number');
			tel.focus();
			return false;
		} else if (isNaN(parseInt(stripped))) {
	        alert('Please ensure the contact number contains only 0-9, characters.');
	       	tel.focus();
			return false;
		}
		if (email.value.length < 1) {
			alert('Please enter your email address');
			email.focus();
			return false;
		}		
		if (echeck(email.value) == false){
			email.focus();
			return false;
		}	
	}// end WITH
	
	return true;
}// end function


function trim(s) {
  return s.replace(/^\s+|\s+$/, '');
}

function echeck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){
	   alert('Please enter a valid email address');
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert('Please enter a valid email address');
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert('Please enter a valid email address');
	    return false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert('Please enter a valid email address');
	    return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert('Please enter a valid email address');
	    return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert('Please enter a valid email address');
	    return false;
	 }
	
	 if (str.indexOf(" ")!=-1){
	    alert('Please enter a valid email address');
	    return false;
	 }

	 return true;					
}





	
