function displayGoogleMapByAddress(addr,title)
{
//		alert(addr,title);
	jQuery("#map").gMap({ markers: [
	  
	  { address: addr,
	    html: title}],
	address: addr,
	zoom: 15 });
}

  

function displayGoogleMapByCoord(x,y,title)
{
//		alert(addr,title);
	jQuery("#map").gMap({ markers: [
	  { 
	  	latitude: x, longitude: y,
	    html: title}],
	
	zoom: 15 });
}

jQuery(function ()
{
	
	 jQuery('#ec-more-dates-close').click(function() {
    	jQuery('#ec_seq_more').hide('slow', function() {});
    	jQuery('#ec-more-dates-close').hide('fast', function() {});
    	jQuery('#ec-more-dates-open').show('fast', function() {});
    	return false;
    });
    
     jQuery('#ec-more-dates-open').click(function() {
    	jQuery('#ec_seq_more').show('slow', function() {});
    	jQuery('#ec-more-dates-open').hide('fast', function() {});
    	jQuery('#ec-more-dates-close').show('fast', function() {});
    	return false;
    });
	
	
	
	jQuery('.default-value').each(function() {

		  var default_value = this.value;
		  
		 jQuery(this).focus(function() {
	          if(this.value == default_value) {
	              this.value = '';
	          }
	      });
		 jQuery(this).blur(function() {
	          if(this.value == '') {
		       
	              this.value = default_value;
	          }
	      });
	  });
	
	jQuery('#eventcopia_start_date').datepicker({
		duration: '',
    	showTime: false,
    	constrainInput: false
 	});
	jQuery('#eventcopia_end_date').datepicker({
		duration: '',
    	showTime: false,
    	constrainInput: false
 	});	
	
	jQuery('#eventcopia_search').click(function()
	{
		Title = jQuery('#eventcopia_title').val();
		var StartDate = FixTime(jQuery('#eventcopia_start_date').val());
		var EndDate = FixTime(jQuery('#eventcopia_end_date').val());
		var Venue = jQuery('#eventcopia_venue').val();
		var Category = jQuery('#eventcopia_category').val();
		var newHTML = searchEvents(Title,Category,Venue,StartDate,EndDate);
		var tab =".eventcopia-event-list";
		jQuery(tab).html(newHTML);	
		return false;
	});
	jQuery('.sort_type').change(function()
		{
			SortID = jQuery(this).val();
			
			var tab = jQuery('div.tabs ul.tabNavigation li a.selected').attr('href');
		tabID = tab.substr(5);
		var newHTML = getEvents(Date2,tabID,SortID);
		tab = tab + " .eventcopia-event-list";
		
		jQuery(tab).html(newHTML);
			
			
			return false;
		});


	jQuery('.logintest').click(function()
	{
		//alert($('#weekof', window.parent.document).html());
		win = window.open('http://dev.freshcoasthosting.com/eventnexus/widgets/login/login.php?url=http://tailgategazette.com/calendar/','login_window','width=300,height=400');
		//	alert('fsa');	
		return false;
	});
	
	
	var tabContainers = jQuery('div.tabs > div');
    
    jQuery('#eventcopia div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        jQuery('#eventcopia div.tabs ul.tabNavigation a').removeClass('selected');
        jQuery(this).addClass('selected');
		jQuery(".calDay span.selected").click();
        
        return false;
    }).filter(':first').click();  

    var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

var Date2;
/*var calendarPicker1 = jQuery("#dsel1").calendarPicker({
    monthNames:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    //useWheel:true,
    //callbackDelay:500,
    years:0,
    months:0,
    callbackDelay:1,
    //days:4,
    //showDayArrows:false,
    callback:function(cal) {
	//alert('fdas');
//	location.href = location.href + '?date=' + cal.currentDate;
	
	 
	//	dt = getMonday(new Date(cal.currentDate));
		var calDate = new Date(cal.currentDate);
		var day = calDate.getDate();
		var month = calDate.getMonth() + 1;
		if(month < 10)
		{
			month = "0" + month;
		}
		if(day < 10)
		{
			day = "0" + day;
		}
		var year = calDate.getFullYear();
		Date2 = year + ":" + month + ":" + day + " 23:59:59";

		
	//	var newHTML = getEvents(Date2,'');
		
		
//		jQuery(".eventcopia-event-list").html(newHTML);

	jQuery("#weekof").html(monthname[calDate.getMonth()]);
		//make ajax call get Most Popular events by RSVP count and draw
    }});*/
    




function getMonday(date){
	var day = date.getDay() || 7;
	if (day !== 1) 
		date.setHours(-24 * (day - 1));
	return date;
}});
