<script type="text/javascript">
	$(document).ready(function(){
		$('#dv30').click(function(e){
			e.preventDefault();
			$('#graphwrapper').addClass("dataloading");
			$('.dataview a').removeClass("dataviewsellink");
			$(this).addClass("dataviewsellink");
		    $('#graphdiv').fadeOut('slow', function(){
				setTimeout(function(){
					$('#graphdiv').html('');
					$('#graphdiv').fadeIn('slow', function(){
						datG30();
						$('#graphwrapper').removeClass("dataloading");
					});
				},1500);
			});
		});
		$('#dv60').click(function(e){
			e.preventDefault();
			$('#graphwrapper').addClass("dataloading");
			$('.dataview a').removeClass("dataviewsellink");
			$(this).addClass("dataviewsellink");
		    $('#graphdiv').fadeOut('slow', function(){
				setTimeout(function(){
					$('#graphdiv').html('');
					$('#graphdiv').fadeIn('slow', function(){
						datG60();
						$('#graphwrapper').removeClass("dataloading");
					});
				},1500);
			});
		});
		$('#dv90').click(function(e){
			e.preventDefault();
			$('#graphwrapper').addClass("dataloading");
			$('.dataview a').removeClass("dataviewsellink");
			$(this).addClass("dataviewsellink");
		    $('#graphdiv').fadeOut('slow', function(){
				setTimeout(function(){
					$('#graphdiv').html('');
					$('#graphdiv').fadeIn('slow', function(){
						datG90();
						$('#graphwrapper').removeClass("dataloading");
					});
				},1500);
			});
		});
		<%=fetchbt("30",str_company_id)%>
		$('#btfp').html('&pound;' + btG30);
		$('#bafp').html('&pound;' + baG30);
		g = new Dygraph(
	    	document.getElementById("graphdiv"),
		    "Date,Total Sales\n" +
	    	<%=fetchDataViewData("30",str_company_id)%>
	
	  		);
	});
	 		

	  function datG30(){
		 g = new Dygraph(
	      document.getElementById("graphdiv"),
	      "Date,Total Sales\n" +
	      <%=fetchDataViewData("30",str_company_id)%>
	     );
	    <%=fetchbt("30",str_company_id)%>
		$('#btfp').html('&pound;' + btG30);
		$('#bafp').html('&pound;' + baG30);
		$('#tndaysdisplay').html('30');
	 }
	function datG60(){
	   g = new Dygraph(
	     document.getElementById("graphdiv"),
	    "Date,Total Sales\n" +
	    <%=fetchDataViewData("60",str_company_id)%>
	  );
	  <%=fetchbt("60",str_company_id)%>
	  $('#btfp').html('&pound;' + btG60);
	  $('#bafp').html('&pound;' + baG60);
	  $('#tndaysdisplay').html('60');
	 }
	function datG90(){
		 g = new Dygraph(
	      document.getElementById("graphdiv"),
	      "Date,Total Sales\n" +
	      <%=fetchDataViewData("90",str_company_id)%>
	    );
	  <%=fetchbt("90",str_company_id)%>
	  $('#btfp').html('&pound;' + btG90);
	  $('#bafp').html('&pound;' + baG90);
	  $('#tndaysdisplay').html('90');
	 }
</script>
