function ChangeDate(todate)
{
	YAHOO.calendar.cal1.selectDate(todate);
	SearchEvents(todate);
	mytabs.activeTab=mytabs.getTab(1);
}

function SearchEvents()
{
	var calID = YAHOO.util.Dom.get('hdnCalendar').value;
	var div = YAHOO.util.Dom.get('search-results');
	var sURL = "index.php";
	var postData = "a=search&q=" + YAHOO.util.Dom.get('txtSearch').value;
	if(calID != "")
		postData += "&calid=" + calID;
		
	var handleSuccess = function(o)
	{ 
		if(o.responseText !== undefined) div.innerHTML = o.responseText; 
		else div.innerHTML = "Search failed, please try again.<br />If this continues, please contact support.";
	}
	var handleFailure = function(o)
	{
		div.innerHTML = "Search failed, please try again.<br />If this continues, please contact support.";
	}
	 
	var callback = 
	{ 
		success: handleSuccess, 
		failure: handleFailure, 
		argument: ['foo','bar'] 
	}; 
	var request = YAHOO.util.Connect.asyncRequest('POST', sURL, callback, postData);
	
}

function DownloadICal(event_id,web_id,web_name)
{
	var url = "http://"+web_name+".usachamber.com/virtualDir/calendar/index.php?a=download&wid="+web_id+"&wn="+web_name+"&eid="+event_id;
	var win = window.open(url,"iCal_Download","width=800,height=300,scrollbars=no,menubar=no,status=no");
}

function ChangeCalendar(element)
{
/*	var div = YAHOO.util.Dom.get('upcoming-events-list');
	var sURL = "index.php";
	var selectbox = YAHOO.util.Dom.get(element);
	var postData = "a=update&calid=" + selectbox.options[selectbox.selectedIndex].value;
	var handleSuccess = function(o)
	{ 
		if(o.responseText !== undefined) div.innerHTML = o.responseText; 
		else div.innerHTML = "Failed to change calendars, please try again.<br />If this continues, please contact support.";
	}
	var handleFailure = function(o)
	{
		div.innerHTML = "Failed to change calendars, please try again.<br />If this continues, please contact support.";
	}
	 
	var callback = 
	{ 
		success: handleSuccess, 
		failure: handleFailure, 
		argument: ['foo','bar'] 
	}; 
	var request = YAHOO.util.Connect.asyncRequest('POST', sURL, callback, postData);
*/
	//update the search
//	rexp = /[\s\t\r\n]*/gi;
//	if(YAHOO.util.Dom.get("txtSearch").value.replace(rexp,"") != "")
//	{
//		YAHOO.util.Dom.get("hdnCalendar").value = selectbox.options[selectbox.selectedIndex].value;
//		SearchEvents();
//	}
	if(window.location.search != "")
	{
		rexp = /calid\=\w*\d*/gi;
		url = window.location.search.replace(rexp, "");
		window.location.search = url+"calid=" + YAHOO.util.Dom.get("cboCalendar").options[YAHOO.util.Dom.get("cboCalendar").selectedIndex].value;
	} else window.location.search += "?calid=" + YAHOO.util.Dom.get("cboCalendar").options[YAHOO.util.Dom.get("cboCalendar").selectedIndex].value;
}

/*function UpdateEvents(query)
{
	var div = YAHOO.util.Dom.get('search-results');
	var sURL = "index.php";
 	var postData = "a=search&q=" + query;
	var handleSuccess = function(o)
	{ 
		if(o.responseText !== undefined) div.innerHTML = o.responseText; 
		else div.innerHTML = "Failed to perform search, please try again.<br />If this continues, please contact support.";
	}
	var handleFailure = function(o)
	{
		div.innerHTML = "Failed to perform search, please try again.<br />If this continues, please contact support.";
	}
	 
	var callback = 
	{ 
		success: handleSuccess, 
		failure: handleFailure, 
		argument: ['foo','bar'] 
	}; 
	var request = YAHOO.util.Connect.asyncRequest('POST', sURL, callback, postData);
	
}*/

function Register(event_id)
{
	var sURL = "https://www.secure-submission.com/SecureEventRegV2/default.asp?intID="+event_id;
	var sOptions = "";
	window.open(sURL,"Event Registration", sOptions);
}

function SubmitForm()
{
	///this should be garbage now.  Replaced by checksubmission() - Mar 15th - JM
	var div = YAHOO.util.Dom.get('divSubmitMsg');
	var form = YAHOO.util.Dom.get('frmEventSubmission');
	var sURL = "index.php";
	var selectbox = YAHOO.util.Dom.get('cboCalendar');
	var postData = "a=submitsubmission&calid=" + selectbox.options[selectbox.selectedIndex].value;
	for(var i=0;i<form.elements.length;i++)
		postData += "&" + form.elements[i].name + "=" + form.elements[i].value;
	var handleSuccess = function(o)
	{ 
		if(o.responseText !== undefined)
		{
			div.innerHTML = o.responseText;
			//alert(o.responseText);
			if(o.responseText == "<span style=\"color: green;font-weight: bold;padding:12px;\">Your event has been successfully submitted.</span>")
				for(var i=0;i<form.elements.length;i++)
				{
					if(form.elements[i].name == "cboStartHour") form.elements[i].selectedIndex = 7;
					else if(form.elements[i].name == "cboStartMinute") form.elements[i].selectedIndex = 0;
					else if(form.elements[i].name == "cboStartAMPM") form.elements[i].selectedIndex = 0;
					else if(form.elements[i].name == "cboEndHour") form.elements[i].selectedIndex = 7;
					else if(form.elements[i].name == "cboEndMinute") form.elements[i].selectedIndex = 0;
					else if(form.elements[i].name == "cboEndAMPM") form.elements[i].selectedIndex = 0;
					else if(form.elements[i].name != "btnSubmit") form.elements[i].value = "";
				}
		} else div.innerHTML = "Failed to submit event, please try again.<br />If this continues, please contact support.";
	}
	var handleFailure = function(o)
	{
		div.innerHTML = "Failed to submit event, please try again.<br />If this continues, please contact support.";
	}
	 
	var callback = 
	{ 
		success: handleSuccess, 
		failure: handleFailure, 
		argument: ['foo','bar'] 
	}; 
	var request = YAHOO.util.Connect.asyncRequest('POST', sURL, callback, postData);
}

function CheckSubmission()
{
	if (document.getElementById("txtContactName").value == '')
		{
			document.getElementById("txtContactName").focus();
			alert('You must enter a Contact Name');
			return false;
		}
	if (document.getElementById("txtContactPhone").value == '')
		{
			document.getElementById("txtContactPhone").focus();
			alert('You must enter a Contact Phone Number');
			return false;
		}		
	if (document.getElementById("txtContactEmail").value == '')
		{
			document.getElementById("txtContactEmail").focus();
			alert('You must enter a Contact Email Address');
			return false;
		}		
	if (document.getElementById("txtEventTitle").value == '')
		{
			document.getElementById("txtEventTitle").focus();
			alert('You must enter an Event Title');
			return false;
		}	
	if (document.getElementById("txtEventStartDate").value == '')
		{
			document.getElementById("txtEventStartDate").focus();
			alert('You must enter an Event Start Date');
			return false;
		}
	if (document.getElementById("txaEventDescription").value == '')
		{
			document.getElementById("txaEventDescription").focus();
			alert('You must enter an Event Description');
			return false;
		}				
	if (document.getElementById("txaEventLocation").value == '')
		{
			document.getElementById("txaEventLocation").focus();
			alert('You must enter the Event Location');
			return false;
		}
	if (document.getElementById("txaAdmissionInfo").value == '')
		{
			document.getElementById("txaAdmissionInfo").focus();
			alert('You must enter the Admission and Pricing information');
			return false;
		}
	if (document.getElementById("txtConfirmation").value != 'chamber')
		{
			document.getElementById("txtConfirmation").focus();
			alert('You must enter the word in the image.');
			return false;
		}		
	document.frmEventSubmission.submit();
}
