// last updated by david 11/11/2009

$(document).ready(function(){
	
	// add target="_blank" attribute to all links not on same domain
	
/*	$("a").filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).attr('target', '_blank');
*/	
	// add website tools to div
	if ( $("#websiteTools").length > 0 ) {
		
		$("#websiteTools").html("<ul class=\"horizontal\"><li><a href=\"javascript:void(0)\" onclick=\"increaseFontSize(); return false\">A<sup>+</sup></a></li><li><a href=\"javascript:void(0)\" onclick=\"decreaseFontSize(); return false\">A<sup>-</sup></a></li><li>|</li><li><a href=\"javascript:void(0)\" onclick=\"window.print(); return false\" class=\"printLink\">Print</a></li></ul>");
		
	}
	
	// if not IE6 (IE6 isn't good at overlays)
	if (typeof document.body.style.maxHeight !== "undefined") { 
	
		// change links to non-branded pages for use by overlay script
		$("a.iframe.tour_home").attr("href", "interactive-tour/tour.html"); // need separate links for top-level index
		$("a.iframe.tour").attr("href", "../interactive-tour/tour.html"); 
		$("a.iframe.testimonial_ben").attr("href", "ben.html");
		$("a.iframe.testimonial_alex").attr("href", "alex.html");
	
	     // jquery overlay script for swf display (interactive tour link from home page)
		$("a.iframe.tour_home").fancybox({

			frameWidth: 746,
			frameHeight: 562

		});
	
	     // jquery overlay script for swf display (interactive tour link)
		$("a.iframe.tour").fancybox({

			frameWidth: 746,
			frameHeight: 562

		}); 

		// jquery overlay script for swf display (testimonials videos)
		$("a.iframe.testimonial_ben").fancybox({

			frameWidth: 500,
			frameHeight: 333

		});  
	
		// jquery overlay script for swf display (testimonials videos)
		$("a.iframe.testimonial_alex").fancybox({

			frameWidth: 500,
			frameHeight: 333

		});
	
	} 
	
	// validate form#enquiry_form on keyup and submit	
	if ( $("#enquiry_form").length > 0 ) {
	
		$("#enquiry_form").validate({

			// rules for field names
			rules: {
			
				first_name: "required", 
				last_name: "required", 
				phone_number: "required", 
				email_address: { required: true, email: true }, 
				contact_method: "required", 
				comments: "required" // no comma on last var or IE cracks it
			
			},

			// inline error messages for fields above
			messages: {

				first_name: "required", 
				last_name: "required", 
				phone_number: "required", 
				email_address: { required: "required", email: "email format" }, 
				contact_method: "required", 
				comments: "required" // no comma on last var or IE cracks it

			}

		});
		
	}
	
});