// JavaScript Document

function submitFindForm(buttonValue)
{
	document.eventSearchForm.submitButton.value=buttonValue;
	if(document.eventSearchForm.locationZipCode.value!="")
	{
		document.eventSearchForm.metroZipCode.value="Z";
	}
	document.eventSearchForm.submit();
}

function clearDate(dt,iframeName,url,loc)
{	
	dt.value="";
	loadFrame(iframeName, url, loc)
}

function checkDate(dt)
{
	if(dt.value=="")
		dt.value="YYYY-MM-DD";
}

function loadFrame(iframeName, url, loc)
 {	 
	if(loc=="date1" || loc == "date2")
	{
		document.eventSearchForm.dateType.value=loc;
		if ( window.frames[iframeName] ) 
			{			
				window.frames[iframeName].location = url;
			}
			//setTimeout('calenderShow()',1000);
			calenderShow();		
	}
 }
 
 //This function is used to open the Calendar Frame
function calenderShow()
{
	if(document.eventSearchForm.dateType.value=="date1")
	{
		document.getElementById("CalFrame").style.visibility = 'visible';
		document.getElementById("CalFrame").style.position = 'absolute';
		document.getElementById("CalFrame").style.display='inline';
	}
	if(document.eventSearchForm.dateType.value=="date2")
	{
		document.getElementById("CalFrame1").style.visibility = 'visible';
		document.getElementById("CalFrame1").style.position = 'absolute';
		document.getElementById("CalFrame1").style.display='inline';
	}
}

//Closes all the frames in the page
function CloseCal()
{
	if(GetCalFrame()!=null)
	{
		GetCalFrame().style.visibility='hidden';
		GetCalFrame().style.display = 'none';	
	}	
	if(GetCalFrame1()!=null)
	{
		GetCalFrame1().style.visibility='hidden';
		GetCalFrame1().style.display = 'none';	
	}		
}

//This function is used to store date in text box from date picker and this will call from date picker.
function datevalue(x,y,z)
{	
	if(x<10)
		x="0" + x;
	if(y<10)
		y="0" + y
	if(document.eventSearchForm.dateType.value=="date1")
		document.eventSearchForm.startDate.value=z+"-"+x+"-"+y;
		
	if(document.eventSearchForm.dateType.value=="date2")
		document.eventSearchForm.endDate.value=z+"-"+x+"-"+y;
	CloseCal();
}

// This code for hadling NewCity and Date Picker frames
var wp=window.parent;
var calFrame=null;
var calFrame1=null;

var cityframe=null;
var cityframe1=null;

function GetCalFrame(){if (!calFrame)calFrame=wp.getObj('CalFrame');return calFrame;}
function GetCalFrame1(){if (!calFrame1)calFrame1=wp.getObj('CalFrame1');return calFrame1;}

function GetCityFrame(){if (!cityframe)cityframe=wp.getObj('CityFrame');return cityframe;}
function GetCityFrame1(){if (!cityframe1)cityframe1=wp.getObj('CityFrame1');return cityframe1;}

function getObj(objID)
{
	if (document.getElementById) {return document.getElementById(objID);}
	else if (document.all) {return document.all[objID];}
	else if (document.layers) {return document.layers[objID];}
}

function showEventCalendar(month,year)
{
	var requestParameters = null;	
	var url = "/EventCalendarDisplay.ads";
	
	requestParameters = "changedMonth=" + month + "&changedYear=" + year;
	var ajax = new Ajax.Request(
	url, {
		method: "post",
		parameters: requestParameters,
		onFailure: reportError,
		onSuccess: function(request) {
		var obj = eval('(' + ajax.transport.responseText + ')');
		
		document.getElementById("eventCalendar").innerHTML=obj.resultData;
	}
	});
}

function reportError()
{
}

function submitDateSearchForm(x,y,z)
{
	if(x<10)
		x="0" + x;
	if(y<10)
		y="0" + y
	document.eventSearchForm.startDate.value=z+"-"+x+"-"+y;
	document.eventSearchForm.submitButton.value="Find Events";
	document.eventSearchForm.submit();
}