// JavaScript Document
//--------------------------------------- city page date -------------------------------------------------------
function SetDateControls(ctlName, newDate)
{
	//alert("I am Here...1");
	var monthCtl;
	monthCtl = eval('window.document.mscitysearch1.' + ctlName + '_month');
	var dateCtl = eval('window.document.mscitysearch1.' + ctlName + '_day');
	var yearCtl = eval('window.document.mscitysearch1.' + ctlName + '_year');
	monthCtl.selectedIndex = newDate.getMonth() + 1;
	dateCtl.selectedIndex = newDate.getDate();
	yearCtl.selectedIndex = newDate.getYear() - (new Date()).getYear() + 1;
}
// It took some Experimentation, but this will return true , if the Date given is valid, false if not.
function IsValidDate(year, month, day)
{
	//alert("I am Here...2");
	month = month - 1;
	var tmpDate = new Date(year, month, day);
	var yearOkay = (tmpDate.getFullYear() == year);
	var monthOkay = (tmpDate.getMonth() == month);
	var dayOkay = (tmpDate.getDate() == day);
	return (yearOkay && monthOkay && dayOkay);
}
// When a date is submitted, we have to first check its validity,
//	and then we can create the new href & redirect to it.
function SubmitDate(useSingle)
{
	//alert("I am Here...3");
	var startDate ="";
	var endDate = "";
	var excDays = "";
	// User is only looking for a single date, not a range
/*	if (useSingle)
	{
		// Check the validity
		if (!IsValidDate(frmDateSearch.single_year.value, frmDateSearch.single_month.value, frmDateSearch.single_date.value))
		{
			alert('The date you have chosen is not a valid date.');
			return;
		}
		// We can create only the start date, and then just copy to the end date
		startDate = frmDateSearch.single_month.value + '/' + frmDateSearch.single_date.value + '/' + frmDateSearch.single_year.value;
		endDate = startDate;
	} */
	// Here, the user want's a date range, so we have to check & include both
	//else
if (useSingle)
	{
		// Check the start date validity
		if (!IsValidDate(fdatesearch.start_year.value, fdatesearch.start_month.value, fdatesearch.start_day.value))
		{
			alert('The starting date you have chosen is not a valid date.');
			return false;
		}
		// Create the start date
		startDate = fdatesearch.start_month.value + '/' + fdatesearch.start_day.value + '/' + fdatesearch.start_year.value;
		
		// Check the end date validity
		if (!IsValidDate(fdatesearch.end_year.value, fdatesearch.end_month.value, fdatesearch.end_day.value))
		{
			alert('The ending date you have chosen is not a valid date.');
			return false;
		}
		//Create the end date
		endDate = fdatesearch.end_month.value + '/' + fdatesearch.end_day.value + '/' + fdatesearch.end_year.value;
		
		// Make sure it's a legit range (i.e. start <= end)
		if ((new Date(startDate)) > (new Date(endDate)))
		{
			alert('The starting date you have chosen is after the ending date.');
			return false;
		}
		// We want to pass the excluded days of the week, so we add the character
		//	only if the checkbox is NOT checked
		if (fdatesearch.chkMon.checked) excDays += 'M';
		if (fdatesearch.chkTue.checked) excDays += 'T';
		if (fdatesearch.chkWed.checked) excDays += 'W';
		if (fdatesearch.chkThu.checked) excDays += 'H';
		if (fdatesearch.chkFri.checked) excDays += 'F';
		if (fdatesearch.chkSat.checked) excDays += 'S';
		if (fdatesearch.chkSun.checked) excDays += 'U';
		//alert(excDays);
	}
	// Redirect, using the start, end & excluded dates
	document.fdatesearch.action='city-date-tickets.asp?sdate=' + startDate + '&edate=' + endDate + '&excdays=' + excDays;
	document.fdatesearch.submit();
	//location.href = 'city-date-tickets.asp?sdate=' + startDate + '&edate=' + endDate + '&excdays=' + excDays;
	return;
}

/*function ValidCity()
{
	if(document.mscitysearch1.listcity1.value == 'select')
	{
		alert("Please Select Any City....");
		document.mscitysearch1.listcity1.focus();
		return false;
	}
}*/
//--------------------------------------------------------------------------------------------------------------

function chk_form()
{
 
	if (document.frm3.name.value == "")
		{
			alert("Please enter Name");
			document.frm3.name.focus();
			return false;
		}

	if (document.frm3.email.value == "" || document.frm3.email.value.indexOf('@',0) == -1 || document.frm3.email.value.indexOf('.',0) == -1) 
	 {
	   alert ("Please enter a valid E-mail Address") ;
	   document.frm3.email.focus() ;
	   return false ;
	 }
	 return true;

}

function datesub()
{
	if (document.frmdate.searchdate[document.frmdate.searchdate.selectedIndex].value == "")
		{
			alert("Please select the Days");
			document.frmdate.searchdate.focus();
			return false;
		}
}


function citysub()
{
 
	if (document.frmcity.citySelect[document.frmcity.citySelect.selectedIndex].value == "")
		{
			alert("Please select the City");
			document.frmcity.citySelect.focus();
			return false;
		}
}

function emailvali()
{
	if (document.frm3.email.value == "" || document.frm3.email.value.indexOf('@',0) == -1 || document.frm3.email.value.indexOf('.',0) == -1) 
	 {
	   alert ("Please enter a valid E-mail Address") ;
	   document.frm3.email.focus() ;
	   return false ;
	 }
	 return true;
}

function ValidateNewsLetter()
{
//alert("h : "+document.newsletter.elements[0].name);
if(document.newsletter.elements[0].name == "email")
{
	//alert("gg");
	if (newsletter.email.value == "")
		{
			alert("Please Enter Email Address");
			newsletter.email.focus();
			return false;
		}

	if (newsletter.email.value == "" || newsletter.email.value.indexOf('@',0) == -1 || newsletter.email.value.indexOf('.',0) == -1) 
		 {
		   alert ("Please enter a valid E-mail Address") ;
		   newsletter.email.focus() ;
		   return false ;
		 }
}
else
{
	if (newsletter.name.value == "")
		{
			alert("Please Enter Your Name");
			newsletter.name.focus();
			return false;
		}

	if (newsletter.phone.value == "")
		{
			alert("Please Enter Your Phone");
			newsletter.phone.focus();
			return false;
		}
	if (newsletter.address.value == "")
		{
			alert("Please Enter Your address");
			newsletter.address.focus();
			return false;
		}
}
	 return true;
}

function newslettertextempty()
{
	//alert("hi...");
	document.newsletter.email.value = "";
	//return true;
}

function newslettertextcopy()
{
	//alert("hi...");
	document.newsletter.email.value = "email address";
	//return true;
}


function ValidateGiftCertificates()
{
var success = true;
if (GiftCertificates.first_name.value == "")
	{
		alert("Please Enter Your First Name");
		GiftCertificates.first_name.focus();
		success = false;
		return false;
	}
if (GiftCertificates.last_name.value == "")
	{
		alert("Please Enter Your Last Name");
		GiftCertificates.last_name.focus();
		success = false;
		return false;
	}

if (GiftCertificates.sender_phone.value == "")
	{
		alert("Please Enter Your Phone");
		GiftCertificates.phone.focus();
		success = false;
		return false;
	}

if (GiftCertificates.sender_email.value == "")
	{
		alert("Please Enter Email Address");
		GiftCertificates.email.focus();
		success = false;
		return false;
	}

if (GiftCertificates.sender_email.value == "" || GiftCertificates.sender_email.value.indexOf('@',0) == -1 || GiftCertificates.sender_email.value.indexOf('.',0) == -1) 
	 {
	   alert ("Please enter a valid E-mail Address") ;
	   GiftCertificates.email.focus() ;
		success = false;
		return false;
	 }


if (GiftCertificates.card_number.value == "")
	{
		alert("Please Enter Your credit card number");
		GiftCertificates.card_number.focus();
		success = false;
		return false;
	}

if (GiftCertificates.expiration_date.value == "")
	{
		alert("Please Enter Your credit card expiration date");
		GiftCertificates.expiration_date.focus();
		success = false;
		return false;
	}
if (GiftCertificates.cvs_number.value == "")
	{
		alert("Please Enter Your cvs number");
		GiftCertificates.cvs_number.focus();
		success = false;
		return false;
	}


if (GiftCertificates.billing_address.value == "")
	{
		alert("Please Enter Your billing address");
		GiftCertificates.billing_address.focus();
		success = false;
		return false;
	}
if (GiftCertificates.billing_city.value == "")
	{
		alert("Please Enter Your billing city");
		GiftCertificates.billing_address.focus();
		success = false;
		return false;
	}
if (GiftCertificates.billing_zip.value == "")
	{
		alert("Please Enter Your billing zip");
		GiftCertificates.address.focus();
		success = false;
		return false;
	}
if (GiftCertificates.tbxImageCode.value != "AGT3Y")
	{
		alert("Please Enter The Text In The Image.");
		GiftCertificates.address.focus();
		success = false;
		return false;
	}


	if (success == true) {
		GiftCertificates.submit();
	} 
}


function ValidateCorporateForm()
{
var success = true;
if (CorporateForm.first_name.value == "")
	{
		alert("Please Enter Your First Name");
		CorporateForm.first_name.focus();
		success = false;
		return false;
	}
if (CorporateForm.last_name.value == "")
	{
		alert("Please Enter Your Last Name");
		CorporateForm.last_name.focus();
		success = false;
		return false;
	}

if (CorporateForm.sender_phone.value == "")
	{
		alert("Please Enter Your Phone");
		CorporateForm.phone.focus();
		success = false;
		return false;
	}

if (CorporateForm.sender_email.value == "")
	{
		alert("Please Enter Email Address");
		CorporateForm.email.focus();
		success = false;
		return false;
	}

if (CorporateForm.sender_email.value == "" || CorporateForm.sender_email.value.indexOf('@',0) == -1 || CorporateForm.sender_email.value.indexOf('.',0) == -1) 
	 {
	   alert ("Please enter a valid E-mail Address") ;
	   CorporateForm.email.focus() ;
		success = false;
		return false;
	 }

if (CorporateForm.company_name.value == "")
	{
		alert("Please Enter Your company name");
		CorporateForm.company_name.focus();
		success = false;
		return false;
	}
if (CorporateForm.employee_number.value == "")
	{
		alert("Please Enter the number of employees");
		CorporateForm.employee_number.focus();
		success = false;
		return false;
	}


if (CorporateForm.company_address.value == "")
	{
		alert("Please Enter Your company address");
		CorporateForm.company_address.focus();
		success = false;
		return false;
	}
if (CorporateForm.company_city.value == "")
	{
		alert("Please Enter Your city");
		CorporateForm.company_city.focus();
		success = false;
		return false;
	}
if (CorporateForm.company_zip.value == "")
	{
		alert("Please Enter Your zip");
		CorporateForm.address.focus();
		success = false;
		return false;
	}
if (CorporateForm.tbxImageCode.value != "AGT3Y")
	{
		alert("Please Enter The Text In The Image.");
		CorporateForm.address.focus();
		success = false;
		return false;
	}


	if (success == true) {
		CorporateForm.submit();
	} 
}



function NavigateSearch() 
{
	var kwds = document.srch.SearchBox.value;

	//alert(kwds);

	if (kwds == "" || kwds == "Search Events" || kwds == "Search" || kwds == "Events")
	{
		alert("Please Enter Events...");
		return false;
	}
	//else
	//{
	//	window.location.href = "/" + escape(kwds) + "/buy.asp" ;
	//}
}

function KeyPressedSearch()
{
	if (window.event.keyCode == 13)
		NavigateSearch();
}
