function DKSite()
{
	this.testimonialScrollPause=6000;
	this.tempHeaderSearchGlassBg='';
	this.page='';
	this.lang='';
}

DKSite.prototype.initialise = function()
{
	setInterval(dkSiteScrollTestimonials, this.testimonialScrollPause);
}

DKSite.prototype.applyHeaderSearchEvents = function()
{
	$("a.headerSearchGlass").click(function()
	{
		document.forms['gSearchForm'].submit();
	});
	
	$("input.headerSearchField").focusin(function()
	{
		$('.headerSearchArea').css('border', '#5b92d5 solid 2px');
		$('.headerSearchField').css('color', '#1c58ae');
		$('.headerSearchGlassBg').css('background', 'url("/site/img/search_glass_blue.png")');
		
		if ($('input.headerSearchField').val() == 'SEARCH ...')
			$('input.headerSearchField').val('');
	});
	
	$("input.headerSearchField").focusout(function()
	{
		$(".headerSearchArea").css("border", "#82210c solid 2px");
		$(".headerSearchField").css("color", "#82210c");
		$('.headerSearchGlassBg').css('background', 'url("/site/img/search_glass_red.png")');
		
		if ($('input.headerSearchField').val() == '')
			$('input.headerSearchField').val('SEARCH ...');
	});
	
	$(".headerSearchGlassBg").hover(function()
	{
		_WDF.site.tempHeaderSearchGlassBg = $('.headerSearchGlassBg').css('background');
		$('.headerSearchGlassBg').css('background', 'url("/site/img/search_glass_grey.png")');
	}, 
	function()
	{
		$('.headerSearchGlassBg').css('background', _WDF.site.tempHeaderSearchGlassBg);
	});	
}

DKSite.prototype.showHeaderSlides = function()
{
	$('.headerSlideShow').cycle(
	{
		fx: 'fade',
		pause:  5,
		speed: 2500 
	});
}

DKSite.prototype.makeFAQPage = function()
{
	$('#faq').makeFAQ(
	{
		displayIndex: false,
		faqHeader: "h4"
	});
}

DKSite.prototype.applyContactEmailFormEvents = function()
{
	// validate contact form on keyup and submit
	$("#contactEmailForm").validate(
	{
		rules:
		{
			contactName: 
			{
				required: true,
				minlength: 2
			},
			telNum: {
				required: true,
				minlength: 6
			},
			emailAddr: {
				required: true,
				email: true
			},
			emailSubject: {
				required: true,
				minlength: 2
			},
			emailMsg: 
			{
				required: true,
				minlength: 5
			},
		},
		
		messages: 
		{
			contactName: 
			{
				required: "Please enter your contact name.",
				minlength: "Must consist of at least 2 characters."
			},
			telNum: 
			{
				required: "Please enter your telephone number.",
				minlength: "Must consist of at least 6 characters."
			},				
			emailAddr: "Please enter a valid email address.",
			emailSubject: 
			{
				required: "Please enter a subject.",
				minlength: "Must consist of at least 2 characters."
			},				
			emailMsg: 
			{
				required: "Please enter a message to be emailed to Davies Khan.",
				minlength: "Your message must consist of at least 5 characters."
			}
		},
		
		errorPlacement: function(error, element)
		{
			error.insertBefore(element);
		},			
		
		submitHandler: function() 
		{
			document.forms['contactEmailForm'].submit();
			//alert("submitted!");
		}			
	});
	
	$('textarea#emailMsg').autoResize({
			// On resize:
			onResize : function() {
					$(this).css({opacity:0.8});
			},
			// After resize:
			animateCallback : function() {
					$(this).css({opacity:1});
			},
			// Quite slow animation:
			animateDuration : 300,
			// More extra space:
			extraSpace : 40
	});		
	
	$("#contactEmailForm input[type=submit]").hover(function()
	{
		$('#contactEmailForm input[type=submit]').css('border', '1px solid #1c58ae');
		$('#contactEmailForm input[type=submit]').css('color', '#1c58ae');
	}, 
	function()
	{
		$('#contactEmailForm input[type=submit]').css('border', '1px solid #82210c');
		$('#contactEmailForm input[type=submit]').css('color', '#82210c');
	});
}
