/*
	vScroll - Javascript Vertical Scroller
	
	Based on the "Cross Browser Marquee II" script at Dynamic Drive
	
	Modifications made by: Kevin Southworth <southwo8@msu.edu> http://portal.ksouthworth.net
	Changes:
		2004-07-16:
			- Moved/converted the scroller functions into a Class
			- Added ability to specify CSS classes for the 
			  outer DIV (container) and the inner DIV (scrolled content)
			- Added some setter functions to set things like width, height, speed, content, etc.

	USAGE:
		// include the JS file either in your <HEAD> or <BODY>
		<script src="vscroll.js" type="text/javascript"></script>
		// Create a new scroller object
		// specify the name of the variable you're creating (e.g. 'scroll1', it MUST be unique)
		// the name of the DIV to scroll ->
		// (this is the name vScroll will use to create your scroller, it MUST be unique)
		var scroll1 = new vScroll('scroll1','kigBoxDiv');
		// Set the width and height (optional)
		scroll1.setWidth("150px");	// CSS style syntax, px or %
		scroll1.setHeight("200px");
		// Set whatever content you want to be scrolled...
		scroll1.setContent('Here is come test content.<br>You can use any HTML content, like images<br><img src="img1.gif">');
		// Write the DIVs to the page and start the scroller
		scroll1.writeDiv('outerClass','innerClass');
		// (the CSS classes are optional)
		scroll1.writeDiv();		
*/

/*
Cross browser Marquee II-  Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and TOS, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

// constructor
function vScroll( p_objName, p_divName )
{
	/* Properties */
	this.objName = p_objName;
	this.divName = p_divName;
	this.marqueewidth = "240px";
	this.marqueeheight = "440px";
	this.marqueespeed = 1;
	this.pauseit = 1;
	this.marqueecontent = "";
	
	this.marqueespeed = (document.all)? this.marqueespeed : Math.max(1, this.marqueespeed-1); //slow speed down by 1 for NS
	this.copyspeed = this.marqueespeed;
	this.pausespeed = (this.pauseit==0)? this.copyspeed: 0;
	this.iedom = document.all||document.getElementById;
	this.actualheight = '';
	this.cross_marquee = '';
	this.ns_marquee = '';
	
	/* Public Methods */
	this.scroll = vs_scrollmarquee;
	this.setContent = vs_setcontent;
	this.setSpeed = vs_setcopyspeed;
	this.setWidth = vs_setwidth;
	this.setHeight = vs_setheight;
	this.writeDiv = vs_writediv;
	
	/* Private Methods */
	this._getDiv = vs_getdiv;
	this._populate = vs_populate;
this.setContent('<h3>Vacancy for rural consultant</h3><p class="news-smaller-text">For more details visit <a href="vacancies.html">Vacancies.</a></p><h3>Budget cuts and agri-environment &ndash; how will you be affected?</h3><p class="news-smaller-text">Many farmers now see agri-environment (AE) monies as an important income stream to their business and many are in the process of applying for HLS as their old ESA or CSS agreements are coming to an end. The coalition government is reducing public sector spending as we speak and the rural development funding pot (RDPE) and the Defra/Natural England AE budget is not immune. There is some good news and some bad news, however farmers would be wise to make their HLS applications sooner rather than later. <a href="news.html#0610">Read the rest of this story.</a></p><h3>Wilden Marsh &ndash; bringing land managers and environmental bodies together to  restore SSSI condition</h3><p class="news-smaller-text">A bold project to restore groundwater levels at  Wilden Marsh and Meadows SSSI, near Kidderminster, Worcestershire has just been  completed by the Environment Agency working with partners including Natural  England, Worcestershire Wildlife Trust, private landowners and tenants. Cumulus is delighted to have played an  integral role in the project liaising with landowners and tenants during the  planning and implementation of the project, negotiating compensation  settlements and scoping future environment enhancement via co-ordinated Higher  Level Stewardship agreements. <a href="news.html#0510">Read the rest of this story.</a></p><h3>Common Agricultural Policy reform &ndash; what can we expect after 2013? </h3><p class="news-smaller-text">&ldquo;An extensive public debate&rdquo; on the  future of the Common Agricultural Policy (CAP) beyond 2013 has recently been  called for by Dacian Ciolo&#351;, the new European Commissioner for Agriculture  and Rural Development. This follows the publication of a range of policy  visions and position statements from different organisations over the past few  months. Later this year, the Commission will produce a policy paper setting out  different options for public consultation. What can we expect from the next  round of CAP reform and how should we prepare? <a href="news.html#0410">Read the rest of this story.</a></p><h3>SEEDA Launches its Farm Resource Improvement Programme (FRIP)</h3><p class="news-smaller-text">The South East England Development Agency (SEEDA) has just announced the launch of the Farm Resource Improvement Programme (FRIP) in South East England and London. The aim of this programme of support is to improve competitiveness through resource efficiency and animal health and welfare practices. Grants of up to £25,000, maximum 50% grant, are available to farmers and horticultural businesses across 4 funding areas which aim to improve the profitability of farms through sustainable farming practices. <a href="news.html#feb10">Read the rest of this story.</a></p>');
}

/* Class Methods */

function vs_setcontent( p_content )
{
	this.marqueecontent = p_content;
}

function vs_setcopyspeed( p_speed )
{
	this.copyspeed = p_speed;
}

function vs_setwidth( p_w )
{
	this.marqueewidth = p_w;
}

function vs_setheight( p_h )
{
	this.marqueeheight = p_h;
}

function vs_writediv( p_outerCSS, p_innerCSS )
{
	document.write( this._getDiv(p_outerCSS,p_innerCSS) );
	this._populate();
}

function vs_getdiv( p_outerCSS, p_innerCSS )
{
	var outerClass = '';
	var innerClass = '';
	if( p_outerCSS )
		outerClass = "class='" + p_outerCSS + "'";
	if( p_innerCSS )
		innerClass = "class='" + p_innerCSS + "'";
	
	var mouseover = this.objName + ".setSpeed('" + this.pausespeed + "')";
	var mouseout = this.objName + ".setSpeed('" + this.marqueespeed + "')";
	var outerDiv = "<div "+outerClass+" style=\"position:relative; width:"+this.marqueewidth+"; height:"+this.marqueeheight+"; overflow:hidden;\" onmouseover=\""+mouseover+"\" onmouseout=\""+mouseout+"\">";
	var innerDiv = "<div id=\"" + this.divName + "\" "+innerClass+" style=\"position:absolute; left:0px; top:0px; width: 100%;\"></div>";
	outerDiv += (innerDiv + "</div>");
	
	return outerDiv;
}

function vs_populate(){
	if(this.iedom)
	{
		if( document.getElementById )
		{
			this.cross_marquee = document.getElementById(this.divName);
		}
		else
		{
			//alert('document.all');
			this.cross_marquee = eval('document.all.'+this.divName);
		}
		this.cross_marquee.style.top = parseInt(this.marqueeheight)+8+"px";
		this.cross_marquee.innerHTML = this.marqueecontent;
		this.actualheight = this.cross_marquee.offsetHeight;
	}
	else if(document.layers)
	{
		this.ns_marquee = document.ns_marquee.document.ns_marquee2;
		this.ns_marquee.top = parseInt(this.marqueeheight)+8;
		this.ns_marquee.document.write(this.marqueecontent);
		this.ns_marquee.document.close();
		this.actualheight = this.ns_marquee.document.height;
	}
	lefttime=setInterval(this.objName+".scroll()",20)
}

function vs_scrollmarquee(){
	if (this.iedom)
	{
		if (parseInt(this.cross_marquee.style.top)>(this.actualheight*(-1)+8))
			this.cross_marquee.style.top = parseInt(this.cross_marquee.style.top)-this.copyspeed+"px";
		else
			this.cross_marquee.style.top = parseInt(this.marqueeheight)+8+"px";
	}
	else if (document.layers){
		if(this.ns_marquee.top > (this.actualheight*(-1)+8))
			this.ns_marquee.top -= this.copyspeed;
		else
			this.ns_marquee.top = parseInt(this.marqueeheight)+8;
	}
}

/*if (iedom||document.layers){
with (document){
if (iedom){
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden" onmouseover="copyspeed=pausespeed" onmouseout="copyspeed=marqueespeed">')
write('<div id="iemarquee" style="position:absolute;left:0px;top:0px;width:100%;">')
write('</div></div>')
}
}
}*/