jQuery.fn.insertFlash = function(swf, height, width, flashvars) { if ($.hasFlashPlayer) $(this).html('').flash({ swf: swf, flashvars: flashvars, height: height, width: width, params: { scale: "noScale", wmode: "transparent" } }); }
jQuery.fn.exists = function() { return (this.is('*')) }
$(function() {
	$('body').addClass('js');
	if ($('.js').exists()) {
		if ($.hasFlashPlayer) $('body').addClass('flash');
		//js used on each page
		alisonshints();
		$('#foursteps div').hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); });

		if ($('.flavourscope').exists()) {
			if ($.hasFlashPlayer) {
				$('body').css({ background: 'none', overflow: 'hidden' });
				$('.flavourscope').html('').flash({
					swf: '/Content/Flash/flavourscope.swf',
					flashvars: {},
					height: '100%',
					width: '100%',
					params: { scale: "noScale" }
				});
				$('.flavourscope object').attr({id : "flashcontent"});
			} else {
				$('#nonflashcontent').show();
				$('body').css({ background: 'transparent url(/Content/Img/backgrounds/body-bg.gif) repeat-x scroll left top' });
			}
		}

		//check browser width for stylesheet
		checkBrowserWidth();
		$(window).resize(function() { checkBrowserWidth(); });
		$('a[rel="external"]').click(function() { window.open($(this).attr('href')); return false; });
	}
});

//Check browesr width and apply stylesheet appropriately
function checkBrowserWidth() {
    //store width as a var
    var width = $(window).width();
    //Change width dependant on window.width
    if (width < 990) { $('#footer').width(980); }
    else if (width > 990) { $('#footer').width('auto'); }
}

//Page - Alison's Tips
function alisonshints() {
	//store default hints text
	var hintstext = $('#hints-text').html();
	//add onclick to change out hints text
	$('dl#hints dt').hover(function(){
		$(this).addClass('hover');
		//store the new hint
		var newhint = $(this).next('dd').html();
		//change out hint
		$('#hints-text').html('<p>'+newhint+'</p>');						
	}, function() {
		//change hint back to default	
		$('#hints-text').html(hintstext);
		$(this).removeClass('hover');		
	});
	
	//Roll over for showing alison's bio
	$('#alisons-tips #alisons-bio').hover(function(){
		$('#content #tip').hide();
		$('#content .carousel-case').hide();
		$('#content .next').hide();
		$('#content .prev').hide();
		$('#content #blurb').show();
		$('#content #bio').show();
	},function(){
		$('#content #blurb').hide();
		$('#content #bio').hide();
		$('#content #tip').show();
		$('#content .carousel-case').show();
		$('#content .next').show();
		$('#content .prev').show();
	});
}

var formSubmitted = false;
function submitForm() {
  if (formSubmitted == false) formSubmitted = true;
	return formSubmitted;
}