function toDate() {
	today = new Date();

	vToday = new Date();
	vTomorrow = new Date();
	vEightDays = new Date();

	vTomorrow.setDate(vTomorrow.getDate()+1);
	vEightDays.setDate(vEightDays.getDate()+9);
	
	d = vTomorrow.getDate();
	m = vTomorrow.getMonth();
	y = vTomorrow.getFullYear();
	
	document.getElementById("arrivalday").value = d;
	document.getElementById("arrivalmonthyear").value = m+1 + "/" + y;
	
	d = vEightDays.getDate();
	m = vEightDays.getMonth();
	y = vEightDays.getFullYear();
	
	document.getElementById("returnday").value = d;
	document.getElementById("returnmonthyear").value = m+1 + "/" + y;
	
		
	
}

function LoadingQuote() {
	
	// Validate First
	
	if (document.getElementById("parkingdisplay").value != "none") {
	
		var arrivalday = document.getElementById("arrivalday").value;
		var arrivalmonthyear = document.getElementById("arrivalmonthyear").value;
		var arrivalmonthyear = arrivalmonthyear.split("/");
		var arrivalmonth = arrivalmonthyear[0]-1;
		var arrivalyear = arrivalmonthyear[1];
		
		var arrivaldate = new Date();
		arrivaldate.setFullYear(arrivalyear, arrivalmonth, arrivalday);
	
		var returnday = document.getElementById("returnday").value;
		var returnmonthyear = document.getElementById("returnmonthyear").value;
		var returnmonthyear = returnmonthyear.split("/");
		var returnmonth = returnmonthyear[0]-1;
		var returnyear = returnmonthyear[1];
		
		var returndate = new Date();
		returndate.setFullYear(returnyear, returnmonth, returnday);
					
		if (returndate < arrivaldate) {
			alert("If you require holiday parking BEFORE your hotel stay, please call reservations on 0871 360 2592.");
			return false;
		}else{
			// Load Quote
		
			return true;
		}
	
	}else{
		return true;
	}
	
	//$('#main').css('display','none')
	//$('#quotecontainer').css('display','block')	
	//setTimeout('document.images["loadinggif"].src = "https://images.essentialtravel.co.uk/et/loading.gif"', 200); 
	
	
	///document.getElementById("loadinggifcontainer").innerHTML = "<img src=\"http://images-essentialtravel-co-uk/et/loading.gif\" id=\"loadinggif\" width=\"100\" height=\"100\" alt=\"Loading Quote...\"/>";
	//$('#loadinggifcontainer').css('background-image','url(http://images-essentialtravel-co-uk/et/loading.gif)')	
	//document.getElementById("loadinggifcontainer").style.backgroundImage = "url(http://images-essentialtravel-co-uk/et/loading.gif)";
	//$('#loadinggif').css(' visibility','visible')	
	//document.getElementById("main").style.display = "none";
	//document.getElementById("quotecontainer").style.display = "block";
	
}
function StopLoadingQuote() {
	
	try {document.execCommand("Stop");}
	catch(err){}
	
	try {window.stop()	;}
	catch(err){}
	
	$('#quotecontainer').css('display','none')
	$('#main').css('display','block')
	
	setTimeout('document.images["loadinggif"].src = "https://images.essentialtravel.co.uk/et/loading.gif"', 200); 
	

	//document.getElementById("quotecontainer").style.display = "none";
	//document.getElementById("main").style.display = "block";
}


function hideFlash() {
	if (document.getElementById('salesmessage')) {
		document.getElementById('flashmovie').style.display = "none";
		document.getElementById('flashReplace').style.display = "block";
	}
}

function showFlash() {
	if (document.getElementById('salesmessage')) {
		document.getElementById('flashmovie').style.display = "block";
		document.getElementById('flashReplace').style.display = "none";
	}
}


function Left(str, n){
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
		return String(str).substring(0,n);
}


function parkingDisplay() {
	parkingType = document.getElementById("parkingdisplay").value;

	if (parkingType == 'none') {
		document.getElementById("returnday-row").style.display = "none";
	}
	else {
		document.getElementById("returnday-row").style.display = "block";
	}
	
}


//////////////////// scroll ////////////////////////////////////////////////////////////////////////////
jQuery.getPos = function (e)
{
	var l = 0;
	var t  = 0;
	var w = jQuery.intval(jQuery.css(e,'width'));
	var h = jQuery.intval(jQuery.css(e,'height'));
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
};
jQuery.getClient = function(e)
{
	if (e) {
		w = e.clientWidth;
		h = e.clientHeight;
	} else {
		w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
		h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
	}
	return {w:w,h:h};
};
jQuery.getScroll = function (e) 
{
	if (e) {
		t = e.scrollTop;
		l = e.scrollLeft;
		w = e.scrollWidth;
		h = e.scrollHeight;
	} else  {
		if (document.documentElement && document.documentElement.scrollTop) {
			t = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
			w = document.documentElement.scrollWidth;
			h = document.documentElement.scrollHeight;
		} else if (document.body) {
			t = document.body.scrollTop;
			l = document.body.scrollLeft;
			w = document.body.scrollWidth;
			h = document.body.scrollHeight;
		}
	}
	return { t: t, l: l, w: w, h: h };
};

jQuery.intval = function (v)
{
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
};

jQuery.fn.ScrollTo = function(s) {
	o = jQuery.speed(s);
	return this.each(function(){
		new jQuery.fx.ScrollTo(this, o);
	});
};

jQuery.fx.ScrollTo = function (e, o)
{
	var z = this;
	z.o = o;
	z.e = e;
	z.p = jQuery.getPos(e);
	z.s = jQuery.getScroll();
	z.clear = function(){clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / z.o.duration;
		if (t >= z.o.duration+z.t) {
			z.clear();
			setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer=setInterval(function(){z.step();},13);
};