

jQuery(document).ready(function() {	
	// H1 Replace
	$('.default h1').flash(
		{ 
			src: basepath+'interface/flash/jfr-optimusprincepssemibold.swf',  
			flashvars: { 
				css: [
					'* { color: #111111; }',
					'a { color: #515151; text-decoration: none; }',
					'a:hover { text-decoration: underline; }'
				].join(' ')
			},
			wmode: "transparent"
		},
		{ version: 7 },
		function(htmlOptions) {
			htmlOptions.flashvars.txt = this.innerHTML;
			this.innerHTML = '<span>'+this.innerHTML+'</span>';
			var $alt = $(this.firstChild);
			htmlOptions.height = $alt.height();
			htmlOptions.width = $alt.width();
			$alt.addClass('alt');
			$(this)
				.addClass('flash-replaced')
				.prepend($.fn.flash.transform(htmlOptions));						
		}
	);
	
	// Menu
	$("#header li").hoverIntent({
		sensitivity: 1, 
		interval: 1, 
		over: function() {
			$(this).addClass("selected");
			$(".sub", this).removeClass("hide").animate({opacity: .9}, 100);
		}, 
		timeout: 50, 
		out: function() {
			$(this).removeClass("selected");
			$(".sub", this).addClass("hide").animate({opacity: .0}, 100);
		}
	});
	$("#header .sub").addClass("hide");
	
	// Flash
	$("#mainFeature").flash({
	    src: 'interface/flash/main-feature.swf',
	    width: 651,
	    height: 240
	},
	{
		expressInstall: true,
		version: '9'
	});	
	
	// Forms	
	$("#frmLead").prepend('<input type="hidden" name="_type" value="newlead" />');
	$("#frmLead").validate({
		rules: {
			txtName: { required: true },
			txtPhone: { required: true },
			txtEmail: { required: true, email: true }
		},
		messages: {
			txtName: 'Please enter and check your Name',
			txtPhone: 'Please enter and check your Phone Number',
			txtEmail: 'Please enter and check your Email'
		}
	});	
	$("#frmEnquiry").prepend('<input type="hidden" name="_type" value="enquiry" />');
	$("#frmEnquiry").validate({
		rules: {
			txtName: { required: true },
			txtEmail: { required: true, email: true },
			txtEnquiry: { required: true }
		},
		messages: {
			txtName: 'Please enter and check your Name',
			txtEmail: 'Please enter and check your Email',
			txtEnquiry: 'Please enter and check your Message'
		}
	});

	
	//  Print header image
	$(".header").before('<div class="print"><img src="'+basepath+'interface/images/print-header.gif" alt="" /></div>');
	
	// Accessible Target links
	$(".newwindow").click( function(e) {
		// Abort if a modifier key is pressed
		if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
			return true;
		} else {
			// Change "_blank" to something like "newWindow" to load all links in the same new window
		    var newWindow = window.open(this.getAttribute('href'), '_blank');
			if (newWindow) {
				if (newWindow.focus) {
					newWindow.focus();
				}
				return false;
			}
			return true;
		}
		
	});
	$(".newwindow").each(
		function() {
			$(this).attr("title", "Link opens in an external window");
			if($(this).attr("href").match("pdf")) $(this).addClass("pdf");
		}
	);
	
	// Fancybox
	$(".fancybox").fancybox({
		hideOnContentClick: false,
		frameWidth: 465,
		frameHeight: 250
	});
});

function printPage() {
	if (window.print) {
		window.print() ;
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
	}
}
