var mobile = false;

var psize = 1.3;
var h1size = 2.8;
var h3size = 1.5;


function onload() {

	mobileAdjust();

	$('html, body').animate({scrollTop:0}, 100);

	$('#t1').fadeTo(1000,1);
	setTimeout(function() {$('#t2').fadeTo(1000,1);},300);
	setTimeout(function() {$('#t3').fadeTo(1000,1);},600);
	setTimeout(function() {$('#t4').fadeTo(1000,1);},800);

	$('#powered').fadeTo(1000,1);

	setTimeout(function() {
		$('.content').fadeTo(1000,1);
		$('#loaddiv').fadeTo(1000,1);
		$('#bar').fadeTo(1000,0.85);
		$('#powered').fadeTo(1000,0);
	},1500);

	$('.welcomediv').click(welcome);
	$('.testimdiv').click(testimonials);
	$('.faqdiv').click(faq);
	$('.aboutdiv').click(about);
	
	$('#font1').click(fontLarger);
	$('#font2').click(fontSmaller);
	$('#fonts a').click(fontDefault);

	$('#whiskylink').click(whisky);


	onscroll();
}


function openbar() {

	$('#sidebar').stop().animate({width: '33%'});
	$('.sidebar').stop().fadeTo(500, 1);
	$('.content').stop().fadeTo(500, 0.2);
	$('#more').click(closebar);
}

function closebar() {

	$('.sidebar').stop().hide();
	$('#sidebar').stop().animate({width: '10%'});
	$('.sidebar').stop().hide();
	$('.content').stop().fadeTo(500, 1);
	$('#more').click(openbar);
}

function mobileAdjust() {

	if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
		$('#csslink').attr("href", "css/mobile.css");
		mobile = true;

		fontLarger();
		fontLarger();

		
		$('.narrowL').css('font-size', '2.7vw');
		$('.narrowR').css('font-size', '2.7vw');

		$('.button').hide();
		$('#sidebar').show();
		$('.sidebar').hide();
		$('#more').click(openbar);
	}
}

function onscroll() {

	if ($(window).scrollTop() >= $(window).height()) {
			$('#title_div').css('position', 'fixed');
			$('#title_div').css('top', '0vw');
		}

	if ($(window).scrollTop() < ($(window).height())) {
	}
}

function fontLarger() {

	if(psize>1.6) {
		alert("The font size is already at it's largest.");
	} else {

		psize += 0.1;
		h1size += 0.1;
		h3size += 0.1;

		$('p').stop().css('font-size', psize + 'vw');
		$('h1').stop().css('font-size', h1size + 'vw');
		$('h3').stop().css('font-size', h3size + 'vw');
	}
}

function fontSmaller() {

	if(psize<0.8) {
		alert("The font size is already at it's smallest.");
	} else {

		psize -= 0.1;
		h1size -= 0.1;
		h3size -= 0.1;

		$('p').css('font-size', psize + 'vw');
		$('h1').stop().css('font-size', h1size + 'vw');
		$('h3').stop().css('font-size', h3size + 'vw');
	}
}

function fontDefault() {

	psize = 1.3;
	h1size = 2.8;
	h3size = 1.7;

	$('p').css('font-size', psize + 'vw');
	$('h1').css('font-size', h1size + 'vw');
	$('h3').css('font-size', h3size + 'vw');
}


function inTouch() {
	$('.content').stop().fadeTo(500,0.2);
	$('#intouchdiv').stop().animate({height: '20vw'});
	$('#intouchdiv').css('border', '1px solid grey');
	$('#intouchdiv').css('background-color', 'rgba(0,0,0,0.8');
	$('#intouch').stop().show();
	$('#intouchdiv').click(inTouchClose);
}

function inTouchClose() {
	$('.content').stop().fadeTo(500,1);
	$('#intouchdiv').stop().animate({height: '4vw'});
	$('#intouchdiv').css('border', 'none');
	$('#intouchdiv').css('background-color', 'rgba(0,0,0,0');
	$('#intouch').stop().hide();
	$('#intouchdiv').click(inTouch);
}

function welcome() {$("#p1").get(0).scrollIntoView();closebar();}

function about() {$("#p2").get(0).scrollIntoView();closebar();}

function faq() {$("#p3").get(0).scrollIntoView();closebar();}

function testimonials() {$("#p4").get(0).scrollIntoView();closebar();}



function whisky() {window.location="http://whiskytastings.co.uk";}
