function expandDescription(li, highlight)
{
	var active = (li.className == "active");
	var prices = document.getElementById('Prices').getElementsByTagName('tr');
	var section = new RegExp((highlight) ? highlight : "full");
	if(active)
	{
		li.className = "";
		for(var i=0; i<prices.length;i++)
		{
			if(prices[i].className.match(section)) prices[i].className = prices[i].className.replace(/active/g,'');
		}
	}
	else
	{
		li.className = "active";
		for(var i=0; i<prices.length;i++)
		{
			if(prices[i].className.match(section) && !prices[i].className.match(/active/)) prices[i].className += " active";
		}
	}
}

var Slides =
{	
	frames: [],
	interval: 50,
	speed: 25,
	length: 8000,
	currentframe: 0,
	opacity: 0,
	ie: false,
	
	node: undefined,
	
	addframe: function(text)
	{
		Slides.frames.push(text);
	},
	setid: function(id)
	{ 
		Slides.node = document.getElementById(id);
		if(typeof document.body.style.filter != "undefined") Slides.ie = true;
	},
	pause: function() { Slides.timer = setInterval(Slides.fadeout, Slides.interval); },
	start: function()
	{
		Slides.setopacity(0);
		Slides.node.innerHTML = Slides.frames[Slides.currentframe];
		Slides.timer = setInterval(Slides.fadein, Slides.interval);
	},
	
	nextframe: function()
	{
		Slides.currentframe = (Slides.currentframe+1) % Slides.frames.length;
		Slides.node.innerHTML = Slides.frames[Slides.currentframe];
		Slides.timer = setInterval(Slides.fadein, Slides.interval);
	},
	
	fadein: function()
	{
		Slides.setopacity(Slides.opacity + (1/Slides.speed));
		if (Slides.opacity > 1)
		{
			clearInterval(Slides.timer);
			setTimeout(Slides.pause, Slides.length);
		}
	},
	
	fadeout: function()
	{
		
		Slides.setopacity(Slides.opacity - (1/Slides.speed));
		if (Slides.opacity < 0)
		{
			clearInterval(Slides.timer);
			Slides.nextframe();
		}
	},
	setopacity: function(o)
	{
		Slides.opacity = o;
		if(o < 0) o = 0;
		if(o > 1) o = 1;
		Slides.node.style.opacity = o+"";
		if(Slides.ie) Slides.node.filters.item("DXImageTransform.Microsoft.Alpha").Opacity=o*100;
	}
}
	
function LoadSlides()
{
	Slides.setid('Slide');
	Slides.addframe("There's nothing like wielding a weighted balance bar like a spear as you lunge your way across the length of the studio, with the Spartan 300 soundtrack pushing you forward... I highly recommend it! <span>- Lisa Hamm</span>");
	Slides.addframe("In the past I started and stopped exercising a number of times. Training with Dave has proved to be the difference. His functional training techniques are simple to understand as well as practical in the real world. Thanks Dave! <span>- John C. Kearney</span>");
	Slides.addframe("I've worked with trainers on and off since I was in college – none of them lasted for more than a few months and I experienced few results. The results that I've gotten through [Dave's] programs have been so successful that it has motivated me to really incorporate physical fitness into my life daily. <span>- Andrew Lipman</span>");
	Slides.addframe("With 25 years of competitive swimming experience and 2 years of intense triathlon training under my belt, I thought there were no physical challenges left that could test me to my limits. That all changed the day David Kawior put me through my first 300 workout. <span>- Matthew Davie</span>");
	Slides.addframe("We've been training for the past year and i really notice a difference in my body. David finds the right balance of of being tough and being supportive that's helping me reach my fullest potential. <span>- Trevor Hebertson</span>");
	Slides.start();

}

function checkForm(frm) {
	var required = [];
	var emails = [];
	var complete = true;
	var error_field = '';
	var error_field2 = '';
	var error = document.getElementById('error')
	var error2 = document.getElementById('error2')
	error.innerHTML = '';
	for (i = 0; i < frm.elements.length; i++) //scan all elements to clear error border and load required array and products table
	{
		oElem = frm.elements[i];
		if (oElem.type != "submit") {
			oElem.style.borderColor='';
			oElem.style.backgroundColor='';
		}
		if(frm.elements[i].name) var span = document.getElementById(frm.elements[i].name.replace(/\[\]/,''));
		if(span)
		{
			span.style.borderStyle='';
		}
		if(oElem.className.match(/required/) && !oElem.disabled) required.push(oElem);
		if(oElem.className.match(/email/) && oElem.value) emails.push(oElem);
	}
	for(var i=0;i<required.length;i++) //scan all required fields
	{
		
		if(required[i].value == '') //check for empty value
		{
			required[i].style.borderColor='red';
			/*required[i].focus();*/
			complete = false;
		}
		if(required[i].value == '' && required[i].type == 'select-one') //for select fields
		{
			required[i].style.backgroundColor='pink';
		}
		
		if(required[i].type == 'radio' || required[i].type == 'checkbox') // for radio and checkbox fields fields
		{
			var name = required[i].name;
			span = document.getElementById(name.replace(/\[\]/,''));
			if(!span) continue;
			var c = false;
			for(var j=0;j<frm[name].length;j++)
			{
				if(frm[name][j].checked) c = true ;
			}
			if(!frm[name].length)
			{
				var checkboxes = span.getElementsByTagName('input');
				for(var j=0;j<checkboxes.length;j++)
				{
					if(checkboxes[j].checked) c = true ;
				}
			}
			if(!c)
			{
				span.style.borderColor='red';
				span.style.borderWidth='1px';
				span.style.borderStyle='solid';
				complete = false;
			} else { span.style.borderStyle=''; }
		}
		if(required[i].type == 'file') // for file upload fields
		{
			var name = required[i].name;
			span = document.getElementById(name.replace(/\[\]/,''));
			if(!span) continue;
			if(required[i].value == '')
			{
				span.style.borderColor='red';
				span.style.borderWidth='1px';
				span.style.borderStyle='solid';
				error_field2 += '<br />Please select a file to upload.';
				complete = false;
			} else { span.style.borderStyle=''; }
		}
		
	}
	
	if(!complete) error_field = 'Please complete required fields.';
	
	for(i=0;i<emails.length;i++)//email address validation
	{
		if(!(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9\-\.]+\.[A-Za-z]{2,4}$/.test(emails[i].value)))
		{
			emails[i].style.borderColor='red';
			error_field2 += '<br />Please enter a valid e-mail address.';
			complete = false;
		}
	}

	error.innerHTML = error_field;
	error2.innerHTML = error_field2;
	return complete;
}

function enableRequired(obj)
{
	if(!obj.className.match(/required/)) obj.className += ' required';
}
function disableRequired(obj)
{
	obj.value = '';
	obj.className = obj.className.replace(/required/g,'');
}

function checkNum(obj, max, dec)
{
	var regexp = (dec) ? /[^0-9\.]/g : /[^0-9]/g;
	obj.value = obj.value.replace(regexp,'') // numbers only
	if(max && obj.value > max) obj.value = max;
}	