var buttons = new Array();
buttons[1] = "button1";
buttons[2] = "button2";
buttons[3] = "button3";
buttons[4] = "button4";
buttons[5] = "button5";
buttons[6] = "button6";
buttons[7] = "button7";

var color = new Array();
color[1] = "#770000";	//dark red
color[2] = "#FF0000";	//red
color[3] = "#FF9900";	//orange
color[4] = "#FFFF00";	//yellow
color[5] = "#00FF00";	//light green
color[6] = "#009900";	//green
color[7] = "#003300";	//dark green

var max=7;

function linkmeter()
{
	var x;
	var rnum = Math.ceil(Math.random() * max);
	
	for (x=1; x<rnum; x++)
	{
		document.getElementById(buttons[x]).style.backgroundColor='#FFFFFF';
	}
	
	for (x=max; x>=rnum; x--)
	{
		document.getElementById(buttons[x]).style.backgroundColor=color[x];
	}
	
	rnum = 0;
	
	var t=setTimeout("linkmeter()",750);
}

function checknumber(id)
{
	var input = document.getElementById(id).value;
	
	if (input != "")
	{
		if (isNaN(input))
		{
			alert("Entry is not a number");
			document.getElementById(id).value = "";
			document.getElementById(id).focus();
		}
		else
		{
			var num = new Number(input);
			num = num.toFixed(0);
			document.getElementById(id).value = num;
		}
	}
}

function checkcontactform()
{
	var firstname=document.getElementById('firstname').value;
	var lastname=document.getElementById('lastname').value;
	var address=document.getElementById('address').value;
	var city=document.getElementById('city').value;
	var state=document.getElementById('state').value;
	var zip=document.getElementById('zip').value;
	var phone1=document.getElementById('phone1').value;
	var phone2=document.getElementById('phone2').value;
	var phone3=document.getElementById('phone3').value;
	var email=document.getElementById('email').value;
	var message=document.getElementById('comments').value;
	
	var name_ok = true;
	if (firstname == "")
	{
		name_ok = false;
	}
	else
	{
		if (firstname.match("@") == "@" || firstname.match("href") == "href" || firstname.match("http://") == "http://" || firstname.match("https://") == "https://")
		{
			name_ok = false;
		}
	}
	
	if (lastname == "")
	{
		name_ok = false;
	}
	else
	{
		if (lastname.match("@") == "@" || lastname.match("href") == "href" || lastname.match("http://") == "http://" || lastname.match("https://") == "https://")
		{
			name_ok = false;
		}
	}
	
	var address_ok = true;
	if (address == "") 
	{
		address_ok = false;
	}
	else
	{
		if (address.match("@") == "@" || address.match("a href") == "a href" || address.match("http://") == "http://" || address.match("https://") == "https://")
		{
			address_ok = false;
		}
	}
	
	if (city == "") 
	{
		address_ok = false;
	}
	else
	{
		if (city.match("@") == "@" || city.match("a href") == "a href" || city.match("http://") == "http://" || city.match("https://") == "https://")
		{
			address_ok = false;
		}
	}
	
	if (state == "") 
	{
		address_ok = false;
	}
	else
	{
		if (state.length != 2)
		{
			address_ok = false;
		}
	}
	
	if (zip == "") 
	{
		address_ok = false;
	}
	else
	{
		if (zip.length != 5)
		{
			address_ok = false;
		}
	}
	
	var phone_ok = true;
	if (document.getElementById('nophone').checked == false)
	{
		if (phone1 == "" && phone2 == "" && phone3 == "") 
		{
			phone_ok = false;
		}
		else
		{
			if (phone1 == "" || phone2 == "" || phone3 == "") 
			{
				phone_ok = false;
			}
			else
			{
				if (phone1.length != 3 || phone2.length != 3 || phone3.length != 4)
				{
					phone_ok = false;
				}
			}
		}
	}
	
	var email_ok = true;
	if (email == "") 
	{
		email_ok = false;
	}
	else
	{
		if (email.match("href") == "href" || email.match("http://") == "http://" || email.match("https://") == "https://") 
		{
			email_ok = false;
		}
		else
		{
			var apos = email.indexOf("@");
			var dotpos = email.lastIndexOf(".");
			if (apos < 1 || dotpos-apos < 2)
			{
				email_ok = false;
			}
		}
	}
	
	message_ok = true;
	if (message == "") 
	{
		message_ok = false;
	}
	else
	{
		if (message.match("href") == "href" || message.match("@") == "@" || message.match("http://") == "http://" || message.match("https://") == "https://") 
		{
			message_ok = false;
		}
	}

	form_ok = (name_ok && address_ok && phone_ok && email_ok && message_ok);

	if (!form_ok) 
	{
		if (!name_ok) 
		{
			alert("Please enter your complete name");
		}
		else
		{
			if (!address_ok) 
			{
				alert("Please enter a valid address");
			}
			else
			{
				if (!phone_ok) 
				{
					alert("Please enter a valid phone number");
				}
				else
				{
					if (!email_ok) 
					{
						alert("Please enter a valid email address");
					}
					else
					{
						if (!message_ok) 
						{
							alert("Please enter your message");
						}
					}
				}
			}
		}
	}
	
	return form_ok;
}

function clearphone()
{
	if (document.getElementById('nophone').checked == true)
	{
		document.getElementById('phone1').value = "";
		document.getElementById('phone2').value = "";
		document.getElementById('phone3').value = "";
		
		document.getElementById('phone1').disabled = true;
		document.getElementById('phone2').disabled = true;
		document.getElementById('phone3').disabled = true;
	}
	else
	{
		document.getElementById('phone1').disabled = false;
		document.getElementById('phone2').disabled = false;
		document.getElementById('phone3').disabled = false;
		
		document.getElementById('phone1').focus();	
	}
}

function getshowbydate(month, year)
{
	month++;
	
	document.getElementById('showlist').innerHTML = '';
	
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();	// code for IE7+, Firefox, Chrome, Opera, Safari
	}
	else
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");		// code for IE6, IE5
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			document.getElementById("showlist").innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open("GET", "showlist.php?month="+month+"&year="+year, true);
	xmlhttp.send();
}

function getshowbycategory(category)
{	
	document.getElementById('showlist').innerHTML = "";
	
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();	// code for IE7+, Firefox, Chrome, Opera, Safari
	}
	else
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");		// code for IE6, IE5
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			document.getElementById("showlist").innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open("GET", "showlist.php?category="+category, true);
	xmlhttp.send();
	
}

function getintro()
{
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		document.getElementById('intro').innerHTML = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab" width="0" height="0"><param name="URL" value="commercials/lawtalkintro.mp3"><param name="AutoStart" value="true"><param name="ShowTracker" value="false"><param name="ShowControls" value="false"><param name="ShowGotoBar" value="false"><param name="ShowDisplay" value="false"><param name="ShowStatusBar" value="false"><param name="AutoSize" value="false"><embed src="commercials/lawtalkintro.wma" autostart="true" showtracker="false" showcontrols="false"  showgotobar="false" showdisplay="false" showstatusbar="false" autosize="false" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/" width="0" height="0"></embed></object>';
	}
	else
	{
		document.getElementById('intro').innerHTML = '<object width="0" height="0" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="commercials/lawtalkintro.mp3"><param name="autoplay" value="true"><param name="controller" value="false"><embed src="commercials/lawtalkintro.mp3" width="0" height="0" autoplay="true" controller="false" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';
	}
}

