
function metrolandCalendarMonthChange($intMonth, $intYear, $strViewType){
	
	//alert( $strViewType + ' --> ' + $intMonth + ' of ' + $intYear );
	
	
	if( $strViewType != 'month' && $strViewType != 'day' && $strViewType == 'year' && $strViewType == 'map'){
		$strViewType  = 'month';
	}
		
	var $params = "action=GetMonth&month=" + $intMonth + '&year=' + $intYear + '&viewtype=' + $strViewType;
	
	new Ajax.Updater("divCalendar", "/ajax/front/components/Calendar_Viewer/ajax.php", { method: "get", parameters: $params, evalScripts: true  , success:'ok', failure:'sht'  });
}


function metrolandCalendarDayChange($strNextPrevious, $strViewType){
	
	if( $strNextPrevious != 'next' && $strNextPrevious != 'previous' ){
		$strNextPrevious = 'next';
	}
	
	var $params = "action=GetDay&direction=" + $strNextPrevious + '&viewtype=' + $strViewType;
	
	//alert( "-->" + $params + "<--" );
	
	new Ajax.Updater("divCalendar", "/ajax/front/components/Calendar_Viewer/ajax.php", { method: "get", parameters: $params, evalScripts: true  , success:'ok', failure:'sht'  });
}


function metrolandCalendarWeekChange($str_yyyy_m_d, $strViewType){
	var $params = "action=GetWeek&date=" + $str_yyyy_m_d + '&viewtype=' + $strViewType;
	new Ajax.Updater("divCalendar", "/ajax/front/components/Calendar_Viewer/ajax.php", { method: "get", parameters: $params, evalScripts: true  , success:'ok', failure:'sht'  });
}


function metrolandCalendarMapChange($intMonth, $intYear, $strViewType){
	var $params = "action=GetMap&month=" + $intMonth + '&year=' + $intYear + '&viewtype=' + $strViewType;
	new Ajax.Updater("divCalendar", "/ajax/front/components/Calendar_Viewer/ajax.php", { method: "get", parameters: $params, evalScripts: true  , success:'ok', failure:'sht'  });
}


function metrolandCategoryChildDDL($intCategoryID){
	var $params = "action=GetCategoryChildDDL&category_id=" + $intCategoryID;
	new Ajax.Updater("divCategoryChild", "/ajax/front/components/Calendar_Viewer/ajax.php", { method: "get", parameters: $params, evalScripts: true  });
}


function metrolandCommunityFromRegionDDL($strRegionID){
	var $params = "action=GetCommunityFromRegionDDL&region_id=" + $strRegionID;
	new Ajax.Updater("divCommunityID", "/ajax/front/components/Calendar_Viewer/ajax.php", { method: "get", parameters: $params, evalScripts: true  });
}


function fncCalendarFilter_VenueName_AutoComplete(obj){
	elm = $(obj);
	
	//This element can only have one "autocomplete" binded this way.
	if(elm._hasEvent){
		return true;
	}
	
	new Ajax.Autocompleter(elm, 'autocomplete_from_filter', '/ajax/front/components/Calendar_Viewer/ajax.php', {
			parameters         : 'action=VenueName_AutoComplete',
			minChars           : 0,
			afterUpdateElement : function(venue_name_element, list_item_element){
					$('venue_id').value = list_item_element.id;
					$('strVenueName').value = list_item_element.innerHTML;
					//alert(list_item_element.innerHTML );
			}
		}
	);

	elm._hasEvent	= true;
}




function btnSubmitSearch(){
	
	//alert( $('strKeywords').value );
	
	if( $('strKeywords').value == 'keywords' ){ 
		$('strKeywords').value = ''; 
	}
	
	//continue the search onclick
	return true;

}


function btnReset( $strRegionNameID ){
	$('strKeywords').value = 'keywords';
    
    $('venue_id').value = '';
    $('strVenueName').value = '';
    //remove: new format:    $('one_time_date').value = '';
    $('ddlPrice').value = '';

    if( $('chkMyEvents') != undefined ){
 		$('chkMyEvents').checked = false;
    }
    
    $('ddlAudience').value = '';

	if(  $('ddlDistance') ){
	    $('ddlDistance').value = '';
	}
	
    //ok, but not chkBox
    $('ddlCategory').value = '';
	$('divCategoryChild').innerHTML = '(please select a category)';
    $('ddlCommunities').value = '';
    //remove: new format:    $('ddlRegion').value = $strRegionNameID;
    
    return false;
}



function fncddlSavedSearches_onchange(){
	
	if( $F('ddlSavedSearches') != '' ){
		$('btnDelete').show();
	}
	else{
		$('btnDelete').hide();
	}
	
	//help to define if we will load search from db or not
	$('blnDidPressSearch').value = 0;
	
	$('frmCalFilter').submit();
}



function fnc_btnSaving(){

	if( $('ddlSavedSearches') ){
	    $('ddlSavedSearches').value = '';
	}
	
	if( $('btnDelete') ){
	    $('btnDelete').hide(); 
	}
	
	
	if( $('btnSaving').value == 'Save this Search' ){
		$('divSaving').show();
		$('btnSaving').value = "Cancel Save";
		$('blnDidWantSave').value = 1;
	}
	else{
		$('divSaving').hide();
		$('btnSaving').value = 'Save this Search';
		$('blnDidWantSave').value = 0;
	}
	
	return true;
}


