function getEventsForDate(){
	__results__ = [];
	var todaysDate = new Date();
	$('event', __eventsXML__).each(function(r){
		var tempDates = [];
		var tempTimes = [];
		$(this).find('showing').each(function(){
			var eventDate = new Date($(this).find('eventDate').text());
			//if(todaysDate <= eventDate){
					tempDates.push($(this).find('eventDate').text());
					//tempTimes.push(formatTime(tempXML.event[e].showings.showing[t].startTimes));
			//	}
			});
			if(tempDates.length>0){
				__results__.push({'EventTitle':$(this).find('eventTitle').text(),'EventID':$(this).find('eventID').text(),'EventImage':$(this).find('imagePath').text(),'EventVenue':$(this).find('venue').text(),'EventPrice':$(this).find('price').text(),'EventTickets':$(this).find('reservationLink').text(),'EventShortDescription':$(this).find('shortDescription').text(),'EventDates':tempDates});
			}
		});
}


/* XML Search */

Global.listEvent = function(Type,Search){
	__results__ = [];
	var todaysDate = new Date();
	$('event', __eventsXML__).each(function(r){
		var tempDates = [];
		var tempTimes = [];
		var tempTypes = [];

		$(this).find('showing').each(function(){
			var tempSession = [];
			var eventDate = new Date($(this).find('eventDate').text());
			//if(todaysDate <= eventDate){
					$(this).parent().parent().find('eventType').each(function(){
						tempTypes.push($(this).text());				
					});
					//tempArray.push({'EventDate':new Date($(this).find('eventDate').text()),'StartTime':$(this).find('startTime').text(),'EndTime':$(this).find('endTime').text(),'Price':$(this).find('price').text(),'SoldOut':$(this).find('soldOut').text()});
					$(this).find('session').each(function(){
						//tempSession.push({'StartTime':$(this).find('startTime').text(),'EndTime':$(this).find('endTime').text(),'Tickets':$(this).find('ticketLink').text(),'SoldOut':$(this).find('soldOut').text()});
						tempSession.push({'StartTime':$(this).find('startTime').text(),'EndTime':$(this).find('endTime').text(),'Tickets':$(this).find('ticketLink').text(),'Price':$(this).find('price').text(),'SoldOut':$(this).find('soldOut').text()});
					});
					tempDates.push({'EventDate':new Date($(this).attr('eventDate')),'Sessions':tempSession});
			//	}
			});
		
	if(tempDates.length>0){
		switch(Type){
			case "eventDate":
				var tempArray = [];
				for (j in tempDates){
					tempArray.push(tempDates[j]['EventDate']);
				}
				
				if(Search in Global.oc(tempArray)){
				var dateArray = String(tempDates[0]['EventDate']).split(' ');
				if($.browser.msie){
						tempDates[0]['EventDate'] = new Date(dateArray[1]+' '+dateArray[2]+', '+dateArray[5]+' '+to_military(tempDates[0]['Sessions'][0]['StartTime']));
					}else{
						tempDates[0]['EventDate'] = new Date(String(tempDates[0]['EventDate']).split('00:00:00')[0]+' '+to_military(tempDates[0]['Sessions'][0]['StartTime']));
					}
					__results__.push({'PropCode':$(this).find('propertyCode').text(),'EventTitle':$(this).find('eventTitle').text(),'EventID':$(this).find('eventID').text(),'EventImage':$(this).find('imagePath').text(),'EventVenue':$(this).find('venue').text(),'EventTickets':$(this).find('reservationLink').text(),'EventShortDescription':$(this).find('shortDescription').text(),'EventDates':tempDates[0],'EventTypes':tempTypes});
				}
			break;
			case "eventType":
				var tempArray = [];
				for (j in tempDates){
					tempArray.push(tempDates[j]['EventDate']);
				}
				if(Search in Global.oc(tempTypes)){var dateArray = String(tempDates[0]['EventDate']).split(' ');
				if($.browser.msie){
						tempDates[0]['EventDate'] = new Date(dateArray[1]+' '+dateArray[2]+', '+dateArray[5]+' '+to_military(tempDates[0]['Sessions'][0]['StartTime']));
					}else{
						tempDates[0]['EventDate'] = new Date(String(tempDates[0]['EventDate']).split('00:00:00')[0]+' '+to_military(tempDates[0]['Sessions'][0]['StartTime']));
					}
				__results__.push({'PropCode':$(this).find('propertyCode').text(),'EventTitle':$(this).find('eventTitle').text(),'EventID':$(this).find('eventID').text(),'EventImage':$(this).find('imagePath').text(),'EventVenue':$(this).find('venue').text(),'EventTickets':$(this).find('reservationLink').text(),'EventShortDescription':$(this).find('shortDescription').text(),'EventDates':tempDates[0],'EventTypes':tempTypes});
				}
			break;
			case "Featured":
				if($(this).find('featured').text() == 'true'){
				__results__.push({'PropCode':$(this).find('propertyCode').text(),'EventTitle':$(this).find('eventTitle').text(),'EventID':$(this).find('eventID').text(),'EventImage':$(this).find('imagePath').text(),'EventVenue':$(this).find('venue').text(),'EventTickets':$(this).find('reservationLink').text(),'EventShortDescription':$(this).find('shortDescription').text(),'EventDates':tempDates,'EventTypes':tempTypes});
				}
			break;
			case "Personality":
				var $ParentNode = $(this);
				$ParentNode.find('personalityID').each(function(){
					if($(this).text()==Search){
						__results__.push({'PropCode':$(this).find('propertyCode').text(),'EventTitle':$ParentNode.find('eventTitle').text(),'EventID':$ParentNode.find('eventID').text()});
					}
				});
			break;
			default:
				var personalities = [];
				var sponsors = [];
				if($(this).find('eventID').text() == Type){
					$(this).find('personalityID').each(function(){
						personalities.push($(this).text());
					});
					$(this).find('sponsorID').each(function(){
						sponsors.push($(this).text());
					});
				__results__.push({'PropCode':$(this).find('propertyCode').text(),'EventTitle':$(this).find('eventTitle').text(),'EventID':$(this).find('eventID').text(),'EventImage':$(this).find('imagePath').text(),'EventVenue':$(this).find('venue').text(),'EventPrice':$(this).find('price').text(),'EventTickets':$(this).find('reservationLink').text(),'EventShortDescription':$(this).find('shortDescription').text(),'EventLongDescription':$(this).find('longDescription').text(),'EventDates':tempDates,'EventTypes':tempTypes,'Personalities':personalities,'Sponsors':sponsors});
				}
			break;
			}
		}
		});
	return __results__;
}

Global.listPersonalities = function(Type,Search){
	__results__ = [];
	$('personality', __personalitiesXML__).each(function(r){
		var tempTypes = [];
		$(this).find('personalityType').each(function(){
					tempTypes.push($(this).text());
			});
	
	switch(Type){
		case "personalityType":
				if(Search in Global.oc(tempTypes)){
				__results__.push({'PersonalityID':$(this).find('personalityID').text(),'Name':$(this).find('name').text(),'MainImage':$(this).find('mainImage').text(),'FeaturedImage':$(this).find('featuredImage').text(),'PersonalityTypes':tempTypes});
				}
		break;
		case "Featured":
			if($(this).find('featured').text() == 'true'){
				__results__.push({'PersonalityID':$(this).find('personalityID').text(),'Name':$(this).find('name').text(),'MainImage':$(this).find('mainImage').text(),'FeaturedImage':$(this).find('featuredImage').text()});
			}
		break;
		case "All":
				__results__.push({'PersonalityID':$(this).find('personalityID').text(),'Name':$(this).find('name').text(),'MainImage':$(this).find('mainImage').text(),'FeaturedImage':$(this).find('featuredImage').text()});
		break;
		default:
			if($(this).find('personalityID').text() == Type){
				__results__.push({'PersonalityID':$(this).find('personalityID').text(),'Name':$(this).find('name').text(),'MainImage':$(this).find('mainImage').text(),'FeaturedImage':$(this).find('featuredImage').text(),'LongDiscription':$(this).find('longDiscription').text()});
			}
		break;
		}
	});
	return __results__;
}

Global.listSponsors = function(Type,Search){
	__results__ = [];
	$('sponsor', __sponsorsXML__).each(function(r){
/*
	var tempTypes = [];
		$(this).find('tier').each(function(){
				tempTypes.push($(this).attr('name'));
			});	
*/

	//console.log($(this).parent().attr('name'));
	
	switch(Type){
		case "Featured":
			if($(this).find('featured').text() == 'true'){
				//console.log($(this).find('mainImage').text());
				__results__.push({'SponsorImage':$(this).find('mainImage').text(),'SponsorLink':$(this).find('link').text(),'Size':$(this).parent().attr('size')});
			}
		break;
		case "All":
			if(Search == $(this).parent().attr('name')){
				__results__.push({'SponsorImage':$(this).find('mainImage').text(),'SponsorLink':$(this).find('link').text(),'Size':$(this).parent().attr('size')});
			}
			//console.log($(this).find('bannerImage').text());
		break;s
		default:
			if($(this).find('sponsorID').text() == Type){
				__results__.push({'SponsorImage':$(this).find('mainImage').text(),'SponsorLink':$(this).find('link').text(),'Size':$(this).parent().attr('size')});
			}
		break;
		}
	});
	return __results__;
}
