
var IsScrolling = 0; // do not change
var ScrollSpeed = 7; // speed of the scroll, smaller numbers = faster. 
var LastMoved = 0;

function ScrollMove(objid)
{
	if (IsScrolling != 0)
	{
		obj=document.getElementById(objid);
		
		var n = new Date(); 
		Now = n.getTime();
		
		if ((Now - LastMoved) >= ScrollSpeed)
		{
			obj.scrollTop = obj.scrollTop + IsScrolling;
			LastMoved = Now;
		}

		setTimeout('ScrollMove("'+objid+'")', ScrollSpeed);
	}
}

function StartScrolling(objid, direction)
{
	var WasScrolling = IsScrolling;
	
	if (direction == 'down')
	{
		IsScrolling = 1;
	}
	if (direction == 'up')
	{
		IsScrolling = -1;
	}
	
	if (WasScrolling == 0)
	{
		ScrollMove(objid);
	}
}

function StopScrolling()
{
	IsScrolling = 0;
}

function AddToNewsletter()
{
	var emailAddress = document.getElementById('news_email').value;
	var zipCode = document.getElementById('news_zip').value;
	
	if (zipCode.length != 5)
	{
		alert('Please enter a valid zip code');
		return;
	}
	// verify
	
	var emailRegex = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;
	
	if (emailAddress.match(emailRegex) == null)
	{
		alert('Please enter a valid E-mail address');
	}
	else
	{
		document.getElementById('cl_b').innerHTML = 'Submitting your request, please wait...';
		
		url = '/plugins/newsletter/remote.php';
		
		new Ajax.Request(url, {
		  parameters: 'OILB_FIRSTNAME=&OILB_LASTNAME=&OILB_EMAIL='+emailAddress+'&OILB_694914='+zipCode+'&OILB_MAIL_PREF=both html and text&commitcontact=true&builderType=paid',
		  method: 'post',
		  onComplete: function(transport) {
		  },
		  onSuccess: function(transport) {
			document.getElementById('cl_b').innerHTML = 'Thank you!';
		  }
		});

	}
}

function NewsletterCompleted()
{
	document.getElementById('cl_b').innerHTML = 'Thank you!';
}

function ShowEventDate(date)
{
	var url = '/plugins/eventlist/eventdetails.php?date='+date;
	new Ajax.Updater('event_showWin', url);
}