
PEPS = {};
PEPS.rollover = {
   init: function(){
	  this.preload();
	  
	  $(".ro").hover(
		 function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); }, 
		 function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
	  );
   },

   preload: function(){
	  $(window).bind('load', function() {
		 $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
	  });
   },
   
   newimage: function( src ){ 
	  return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0]; 
   },

   oldimage: function( src ){ 
	  return src.replace(/_o\./, '.'); 
   }
};


function ajax_func(f,d,dv){
	$.ajax({
		type: "POST",
		url: f,
		data: d,
		contentType: "application/x-www-form-urlencoded, application/x-www-form-urlencoded;charset=utf-8",
		dataType: 'text',
		async:false,					
		
		success: function(txt){
			$(dv).html(txt)
		}
	});
	
	// Track pages and clicks via ajax and google Analitics
	if (_gaq) _gaq.push(['_trackEvent', f]);
}

function validateForm() {
	var okSoFar=true
	alert("Disabled by Simon")
	return
	
	
	with (document.phpformmailer){
		var foundAt = email.value.indexOf("@",0)
		if (foundAt < 1 && okSoFar)
	{
	
	okSoFar = false
	alert ("Please enter a valid email address.")
	
	email.focus()}
		var e1 = email.value
		var e2 = email2.value
		
		if (name.value=="" && okSoFar){
			okSoFar=false
			alert("Please enter your name.")
			thesubject.focus()
		}
		if (!(e1==e2) && okSoFar){
			okSoFar = false
			alert ("Email addresses you entered do not match.  Please re-enter.")
			email.focus()
		}
		if (tel.value=="" && okSoFar){
			okSoFar=false
			alert("Please enter your telephone number.")
			thesubject.focus()
		}
		if (thesubject.value=="" && okSoFar){
			okSoFar=false
			alert("Please enter the subject.")
			thesubject.focus()
		}
		if (themessage.value=="" && okSoFar){
			okSoFar=false
			alert("Please enter the details for your enquiry.")
			themessage.focus()
		}
		if (okSoFar==true){
			query = "name=" + name.value
			query += "&email=" + email.value
			query += "&tel=" + tel.value
			query += "&thesubject=" + thesubject.value
			query += "&themessage=" + themessage.value
			emailer(query);	 
		} 
	}
}

function callOverlay(){
	$(".triggers img[rel]").overlay({effect		: 'apple',	   
									mask		: {	color: '#aaa',	// you might also consider a "transparent" color for the mask
													loadSpeed	: 200,		// load mask a little faster
													opacity		: 0.5		// very transparent
	  								}
	 });	
}
