
function openAddActivityPopup(url) {
	var vWinAct = window.open(url, 'email' ,'scrollbars=1,resizable=1,status=1,width=475px,height=422px,left=50,top=50');
	vWinAct.focus();
}

function openEditActivityPopup(url) {
	var vWinAct = window.open(url, 'email' ,'scrollbars=1,resizable=1,status=1,width=475px,height=332px,left=50,top=50');
	vWinAct.focus();
}

function openEmailWin(url) {
	var vWinEml = window.open(url, 'email' ,'scrollbars=1,resizable=1,status=1,width=475px,height=332px,left=50,top=50');
	vWinEml.focus();
}


function addEditTripValidation()
{
	var tripName = document.getElementById("TripName");
	var tripNameValue = tripName.value;
	
	var tripDate = document.getElementById("TripDate");
	var tripDateValue = tripDate.value; 
	
	if (tripNameValue == '' || tripNameValue == null || tripNameValue == undefined){
		alert("Please enter a valid trip name.");
		return false;
	}
	
	if(tripDateValue != null && tripDateValue != '' && tripDateValue != undefined && !isValidDate(tripDateValue))
	{
		alert("Please enter a valid Trip Date.");
		return false;
	}
	
	return true;
}

function validateField(field)
{
	var valid = true;
	
	if (!field || field == null || field.value == '') {
		valid = false;
	}
	
	return valid;
}
	
function getSelectedRadioValue(field)
{
	var thefield = document.getElementById(field);
	var optionChoosed = '';
	
	for (i=0;i<thefield.length;i++)
	{
		if (thefield[i].checked==true)
		{
			optionChoosed = thefield[i].value;
			break; 
		}
	}
	return optionChoosed;
}





function textCounter(field,cntfield,maxlimit) 
{
	//var txtField = document.getElementById("countBody");
	
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	}
	else
	{
		if(cntfield != null)
		{
			cntfield.value = (maxlimit - field.value.length) + " characters remaining.";
		}
	}
}

function isValidDateRange(startDate,endDate) {
   return (endDate > startDate);
}

function addExternalEntryValidation()
{	
	var fields = ['ContactName', 'ContactPhone', 'ContactEmail', 'ContactAuthRep', 'EventName', 'EventType', 'OfInterestTo', 'ShortDesc', 'LongDesc', 'Neighborhood', 'SecurityCode', 'ZipCode'];

	var error = false;
	var securityCodeError = false;
	
	var invalidBGColor = "#FFFFD5";
	var validBGColor = "#FFFFFF";
	var origBGImage;
	
	// Check the Type - if we don't have this, that is a big problem
	var Type = document.getElementsByName("Type")[0].value;
	
	// Check the Image -- If Image is there, Check the AltText
	var Image = document.getElementsByName("Image")[0];
	
	// Check the EventEmail -- If it is there, Check the format
	var EventEmail = document.getElementsByName("EventEmail")[0];	
	
	// Check the Phone -- If it is there, Check the format
	var Phone = document.getElementsByName("Phone")[0];	
	
	// Check the TollFree -- If it is there, Check the format
	var TollFree = document.getElementsByName("TollFree")[0];	
	
	// Check the Fax -- If it is there, Check the format
	var Fax = document.getElementsByName("Fax")[0];		

	// Check the Location Type
	if(Type == 'Event' || Type == 'Tour')
	{
		var LocationType='';
		
		fields.push('Location');
		
		if(document.getElementsByName("LocationType")[0].checked)
		{
			LocationType = document.getElementsByName("LocationType")[0].value;
		}
		if(document.getElementsByName("LocationType")[1].checked)
		{
			LocationType = document.getElementsByName("LocationType")[1].value;
		}
		
		if(LocationType == 'Address1')
		{
			fields.push('Address1');
		}
		else
		{
			document.getElementById("Address1").style.backgroundColor = validBGColor;
			document.getElementById("Address1ErrorMessage").innerHTML = '';
		}
		
		if(LocationType == 'Intersection')
		{
			fields.push('Intersection1','Intersection2');	
		}
		else
		{
			document.getElementById("Intersection1").style.backgroundColor = validBGColor;
			document.getElementById("Intersection1ErrorMessage").innerHTML = '';
			document.getElementById("Intersection2").style.backgroundColor = validBGColor;
			document.getElementById("Intersection2ErrorMessage").innerHTML = '';		
		}
	}
	
	if(Image.value != null && Image.value != '')
	{
		fields.push('ImageAltText');
	}		
	else
	{
		document.getElementById("ImageAltText").style.backgroundColor = validBGColor;
		document.getElementById("ImageAltTextErrorMessage").innerHTML = '';
	}
	
	//Adding some non-required fields here to validate -- if they enter them, validate the format.
	if(EventEmail.value != null && EventEmail.value != '')
	{
		fields.push('EventEmail');
	}
	else
	{
		document.getElementById("EventEmail").style.backgroundColor = validBGColor;
		document.getElementById("EventEmailErrorMessage").innerHTML = '';
	}
	
	if(Phone.value != null && Phone.value != '')
	{
		fields.push('Phone');
	}
	else
	{
		document.getElementById("Phone").style.backgroundColor = validBGColor;
		document.getElementById("PhoneErrorMessage").innerHTML = '';
	}
	
	if(TollFree.value != null && TollFree.value != '')
	{
		fields.push('TollFree');
	}
	else
	{
		document.getElementById("TollFree").style.backgroundColor = validBGColor;
		document.getElementById("TollFreeErrorMessage").innerHTML = '';
	}
	
	if(Fax.value != null && Fax.value != '')
	{
		fields.push('Fax');
	}
	else
	{
		document.getElementById("Fax").style.backgroundColor = validBGColor;
		document.getElementById("FaxErrorMessage").innerHTML = '';
	}
	
	// Begin generic validation here.
	var field = document.getElementById(fields[i]);
	var focusField;
	
	var errorOccurred = false;
		
	for (var i=0; i<fields.length; i++) {
		var field = document.getElementById(fields[i]);
	
		if (field.value == '' 
				|| field.value == null 
				|| field.value == undefined 
				|| (fields[i] == 'SecurityCode' && field.value != document.addEventForm.textCheck.value)
				|| (fields[i] == 'ContactEmail' && !isValidEmail(field.value))
				|| (fields[i] == 'ContactPhone' && !isValidPhone(field.value))
				|| (fields[i] == 'ZipCode' && !isValidZipCode(field.value))
				|| (fields[i] == 'EventEmail' && !isValidEmail(field.value))
				|| (fields[i] == 'Phone' && !isValidPhone(field.value))
				|| (fields[i] == 'TollFree' && !isValidPhone(field.value))
				|| (fields[i] == 'Fax' && !isValidPhone(field.value))) {
					
			error = true;
			
			if(!errorOccurred)
			{
				focusField = field;
				errorOccurred = true;
			}
			
			
			field.style.backgroundColor = invalidBGColor;
			
			var fieldError = document.getElementById(fields[i] + 'ErrorMessage');
			
			if (fields[i] == 'SecurityCode') {
				securityCodeError = true;	
				if (fieldError != null) {
					fieldError.innerHTML = 'Please enter the correct security code.';
				}
			}			
			else if (fields[i] == 'ContactEmail' || fields[i] == 'EventEmail') {
				if (fieldError != null) {
					fieldError.innerHTML = 'Please enter a valid email address.';
				}
			}			
			else if (fields[i] == 'ContactPhone' || fields[i] == 'Phone' || fields[i] == 'TollFree' || fields[i] == 'Fax') {
				if (fieldError != null) {
					fieldError.innerHTML = 'Please enter a valid phone number.';
				}
			}		
			else if (fields[i] == 'ZipCode') {
				if (fieldError != null) {
					fieldError.innerHTML = 'Please enter a valid zip code.';
				}
			}			
			else if (fields[i] == 'EventType') {
				if (fieldError != null) {
					fieldError.innerHTML = 'Please select a type.';
				}
			}	
			else if (fields[i] == 'Neighborhood') {
				if (fieldError != null) {
					fieldError.innerHTML = 'Please select a neighborhood.';
				}
			}									
			else {
				if (fieldError != null) {
					if(field.nodeName == "SELECT") {
						fieldError.innerHTML = 'Please select a value.';
					}
					else {
						fieldError.innerHTML = 'Please enter required field.';
					}
				}
			}
			
		}
		else {
			field.style.backgroundColor = validBGColor;
			
			var fieldError = document.getElementById(fields[i] + 'ErrorMessage');
			if (fieldError != null) {
				fieldError.innerHTML = '';
			}
		}
	}
	
	var validDates = true;
	
	if(Type == 'Event' || Type == 'Tour')
	{
		validDates = dateValidation();
	}
	
	/*
	if(!error && !securityCodeError && !validDates)
	{
		//select the dates
		var field = document.getElementById('DateType')[0];
		field.focus();
		
	}
	*/
	
	if (!validDates || error || securityCodeError) {
		focusField.focus();
		return false;
	}
	
	return true;

}

function dateValidation()
{
	// Check the Date Type
	var DateType = '';
	var StartDate = '';
	var EndDate = '';
	var DayOptions = '';

	document.getElementById("StartDateErrorMessage").innerHTML = '';

	if(document.getElementsByName("DateType")[0].checked)
	{
		DateType = document.getElementsByName("DateType")[0].value;
	}
	if(document.getElementsByName("DateType")[1].checked)
	{
		DateType = document.getElementsByName("DateType")[1].value;
	}	
	if(document.getElementsByName("DateType")[2].checked)
	{
		DateType = document.getElementsByName("DateType")[2].value;
	}		
	
	if(DateType == 'DateRange')
	{
		StartDate = document.getElementsByName("StartDate")[0].value;
		EndDate = document.getElementsByName("EndDate")[0].value;
		
		if(!isValidDateRange(StartDate,EndDate))
		{
			var fieldError = document.getElementById('StartDateErrorMessage');
			if(fieldError != null)
			{
				fieldError.innerHTML = 'End Date must be greater than Start Date.  For events that start and end on the same date, please select the "One or More Dates" option.';
			}
			return false;
		}
		else
		{
			document.getElementById("StartDateErrorMessage").innerHTML = '';
			return true;
		}
	}
	
	if(DateType == 'RecurringDates')
	{
		StartDate = document.getElementsByName("RecurStartDate")[0].value;
		EndDate = document.getElementsByName("RecurEndDate")[0].value;
		DayOptions = document.getElementsByName("DayOfWeek")[0].value;
		var returnVal= true;
	
		if(DayOptions == null || DayOptions == '') 
		{
			var fieldError = document.getElementById('StartDateErrorMessage');
			if(fieldError != null)
			{
				fieldError.innerHTML = 'Please select at least one value from Day Of Week.';
			}
			returnVal = false;
		}
		
		if(!isValidDateRange(StartDate,EndDate))
		{
			var fieldError = document.getElementById('StartDateErrorMessage');
			if(fieldError != null)
			{
				fieldError.innerHTML += '<br><br>End Date must be greater than Start Date.  For events that start and end on the same date, please select "One or More Dates" option below.';
			}
			returnVal = false;
		}
		
		return returnVal;
	}
	
	return true;
}


function addTourismMediaValidation()
{	
	var fields = ['JournalistProjDirector', 'PublOutlet', 'PhoneNumber', 'Email', 'ArrivalDateTime', 'DepartureDateTime', 'SecurityCode'];

	var error = false;
	var securityCodeError = false;
	
	var invalidBGColor = "#FFFFD5";
	var validBGColor = "#FFFFFF";
	var origBGImage;
	
		
	var field = document.getElementById(fields[i]);
		
	for (var i=0; i<fields.length; i++) {
		var field = document.getElementById(fields[i]);
	
		if (field.value == '' 
				|| field.value == null 
				|| field.value == undefined 
				|| (fields[i] == 'SecurityCode' && field.value != document.tourismMediaForm.textCheck.value)) {
					
			error = true;
			
			field.style.backgroundColor = invalidBGColor;
			
			var fieldError = document.getElementById(fields[i] + 'ErrorMessage');
			
			if (fields[i] == 'SecurityCode') {
				securityCodeError = true;	
				if (fieldError != null) {
					fieldError.innerHTML = 'Please enter the correct security code';
				}
			}
			else {
				if (fieldError != null) {
					fieldError.innerHTML = 'Please enter required field';
				}
			}
			
		}
		else {
			field.style.backgroundColor = validBGColor;
			
			var fieldError = document.getElementById(fields[i] + 'ErrorMessage');
			if (fieldError != null) {
				fieldError.innerHTML = '';
			}
		}
	}
	
	
	var radioButtons = document.tourismMediaForm.HotelNeeded
	var isRadioSelected = false;

	for (var i=0; i<radioButtons.length; i++)  {
	    if (radioButtons[i].checked)  {
    		isRadioSelected = true;
	    } 
	}
	
	if (!isRadioSelected) {
		var fieldError = document.getElementById('HotelNeededErrorMessage');
			if (fieldError != null) {
				fieldError.innerHTML = 'Please select required value';
			}
		error = true;
	}
	else {
		var fieldError = document.getElementById('HotelNeededErrorMessage');
			if (fieldError != null) {
				fieldError.innerHTML = '';
			}
	}
	
	if (error || securityCodeError) {
		return false;
	}
	
	/*
	var errorMessage = document.getElementById('errorMessage');
	
	if (error) {		
		errorMessage.innerHTML = '<br />All required fields must be completed.';
		
		if (securityCodeError) {
			errorMessage.innerHTML += '<br />Please enter the correct security code.';
		}
		
		return false;
	}
	
	errorMessage.innerHTML = '';
	*/
	
	return true;

}

function addMOSEMediaValidation()
{	
	var fields = ['EventName', 'FirstName', 'LastName', 'Email', 'PhoneNumber', 'MediaOutlet', 'Market', 'MediaType', 'CredentialType', 'EditorProducer', 'MarketEmail', 'MarketPhoneNumber', 'SecurityCode'];

	var error = false;
	var securityCodeError = false;
	
	var invalidBGColor = "#FFFFD5";
	var validBGColor = "#FFFFFF";
	var origBGImage;
	
		
	var field = document.getElementById(fields[i]);
		
	for (var i=0; i<fields.length; i++) {
		var field = document.getElementById(fields[i]);
	
		if (field.value == '' 
				|| field.value == null 
				|| field.value == undefined 
				|| (fields[i] == 'SecurityCode' && field.value != document.moseMediaForm.textCheck.value)) {
					
			error = true;
			
			field.style.backgroundColor = invalidBGColor;
			
			var fieldError = document.getElementById(fields[i] + 'ErrorMessage');
			
			if (fields[i] == 'SecurityCode') {
				securityCodeError = true;	
				if (fieldError != null) {
					fieldError.innerHTML = 'Please enter the correct security code';
				}
			}
			else {
				if (fieldError != null) {
					if(field.nodeName == "SELECT") {
						fieldError.innerHTML = 'Please select a value';
					}
					else {
						fieldError.innerHTML = 'Please enter required field';
					}
				}
			}
			
		}
		else {
			field.style.backgroundColor = validBGColor;
			
			var fieldError = document.getElementById(fields[i] + 'ErrorMessage');
			if (fieldError != null) {
				fieldError.innerHTML = '';
			}
		}
	}
	
	if (error || securityCodeError) {
		return false;
	}
	
	return true;

}

function redirectFromPopup(url) {
	opener.location.href = url;
	window.close();
}

function addToFavorite() {
	if(browser == 'Safari')
		alert ('Please press clt+D for BookMarking this page');
	else if(document.all)
		window.external.AddFavorite(window.location.href, window.document.title);
	else if(window.sidebar)
		window.sidebar.addPanel(window.document.title,window.location.href,'');
}

function addLinkToFavorite() {
	var mailLink   =  document.getElementById("linkemail").value;
	var mailTitle  =  document.getElementById("emailtitle").value;
	if(browser == 'Safari'){
		alert ('Please press clt+D for BookMarking this page');
	}else if(document.all){
	 	window.external.AddFavorite(mailLink, mailTitle);
	}else if(window.sidebar){	
	 	window.sidebar.addPanel(mailTitle,mailLink,'');
	}
}

function bookmarkDel() {
	window.open('http://del.icio.us/post?v=2&url='+encodeURIComponent(location.href)+'&notes=&tags=&title='+encodeURIComponent(document.title));
}

function bookmarkDigg() {
	// Format - http://digg.com/submit?url=example.com&title=TITLE&bodytext=DESCRIPTION&media=MEDIA&topic=TOPIC
	// For more details, see - http://digg.com/tools/integrate#1
	//window.open('http://digg.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title) + '&bodytext=&media=&topic=');
	window.open('http://digg.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title) + '&bodytext=&media=&topic=');
}

function emailValidation()
{
	// Validate Mail From
	var mailfrom = document.getElementById("SiteSearch0");
	var mailfromValue = mailfrom.value;
	
	if (mailfromValue == '' || mailfromValue == null || mailfromValue == undefined){
		alert("Please enter a valid email address in the From field.");
		mailfrom.focus();
		return false;
	}
	else if (!isValidEmail(mailfromValue)) {
		alert("The value entered in the From field is not a valid email address");
		mailfrom.focus();
		return false;
	}
	
	// Validate Mail To
	var mailto = document.getElementById("SiteSearch1");
	var mailtoValue = mailto.value;
	
	if (mailtoValue == '' || mailtoValue == null || mailtoValue == undefined){
		alert("Please enter a valid email address in the To field.");
		mailto.focus();
		return false;
	}
	else if (!isValidEmail(mailtoValue)) {
		alert("The value entered in the To field is not a valid email address");
		mailto.focus();
		return false;
	}
	
	// Validate CC
	var mailcc = document.getElementById("SiteSearch2");
	var mailccValue = mailcc.value;
	
	if (mailccValue == '' || mailccValue == null || mailccValue == undefined){
		// Optional Field - Continue
	}
	else if (!isValidEmail(mailccValue)) {
		alert("The value entered in the CC field is not a valid email address");
		mailcc.focus();
		return false;
	}
	
	// Send Email
	document.getElementById("BtnHolder").style.display ="none" ;
	document.getElementById("submitBtnHolder").innerHTML = "Sending...";
	document.getElementById("emailForm").submit();
}

function prefillPrintValues() {
				
	var fields = ['JournalistProjDirector', 'PublOutlet', 'Address', 'City', 
					'State', 'ZipCode', 'Country', 'PhoneNumber', 'FaxNumber', 'Email', 
					'ArrivalDateTime', 'DepartureDateTime',
					'NumberOfRooms', 'NumberOfNights', 'HotelBudgetPerNight', 'PastArticles',
					'EventName', 'FirstName', 'LastName', 'JobTitle', 'MediaOutlet', 'MediaOutletCity',
					'MediaOutletState', 'MediaOutletZipCode', 'CMediaOutletountry', 'Market',
					'MediaType', 'RadioFrequency', 'CirculationRatings', 'EditorProducer',
					'MarketPhoneNumber', 'MarketEmail'];

	if (window.opener 
			&& !window.opener.closed) {
		var tourismDocument = window.opener.document;	
				
		if (tourismDocument && tourismDocument != null) {
			for (var i=0; i<fields.length; i++) {
				var openerField = tourismDocument.getElementById(fields[i]);
				var printField = document.getElementById(fields[i]);
				
				if (openerField != null) {
					printField.value = openerField.value;
				}
			}
			
			var hotelNeededButtons = tourismDocument.tourismMediaForm.HotelNeeded;
			for (var i=0; i<hotelNeededButtons.length; i++)  {
			    if (hotelNeededButtons[i].checked)  {
					document.tourismMediaForm.HotelNeeded[i].checked = true;
			    } 
			}
			
			var englishButtons = tourismDocument.tourismMediaForm.EnglishLevel;
			for (var i=0; i<englishButtons.length; i++)  {
			    if (englishButtons[i].checked)  {
					document.tourismMediaForm.EnglishLevel[i].checked = true;
			    } 
			}
		}
	}
}

function prefillMOSEPrintValues() {
				
	var fields = 	['EventName', 'FirstName', 'LastName', 'JobTitle', 'Address', 'City', 
					'State', 'ZipCode', 'Country', 'PhoneNumber', 'FaxNumber', 'Email', 
					'MediaOutlet', 'MediaOutletAddress', 'MediaOutletCity',
					'MediaOutletState', 'MediaOutletZipCode', 'MediaOutletCountry', 'Market',
					'MediaType', 'CredentialType', 'RadioFrequency', 'CirculationRatings', 
					'EditorProducer', 'MarketPhoneNumber', 'MarketEmail'];

	if (window.opener 
			&& !window.opener.closed) {
		var tourismDocument = window.opener.document;	
				
		if (tourismDocument && tourismDocument != null) {
			for (var i=0; i<fields.length; i++) {
				var openerField = tourismDocument.getElementById(fields[i]);
				var printField = document.getElementById(fields[i]);
				
				if (openerField != null) {
					printField.value = openerField.value;
				}
			}
		}
	}
}

function emailHideValidation()
{
	// Validate Mail From
	var mailfrom = document.getElementById("SiteSearch0");
	var mailfromValue = mailfrom.value;
	
	if (mailfromValue == '' || mailfromValue == null || mailfromValue == undefined){
		alert("Please enter a valid email address in the From field.");
		mailfrom.focus();
		return false;
	}
	else if (!isValidEmail(mailfromValue)) {
		alert("The value entered in the From field is not a valid email address");
		mailfrom.focus();
		return false;
	}
	
	// Validate CC
	var mailcc = document.getElementById("SiteSearch2");
	var mailccValue = mailcc.value;
	
	if (mailccValue == '' || mailccValue == null || mailccValue == undefined){
		// Optional Field - Continue
	}
	else if (!isValidEmail(mailccValue)) {
		alert("The value entered in the CC field is not a valid email address");
		mailcc.focus();
		return false;
	}
	
	// Send Email
	document.getElementById("BtnHolder").style.display ="none" ;
	document.getElementById("submitBtnHolder").innerHTML = "Sending...";
	document.getElementById("emailForm").submit();
}

function emailTripValidation()
{
	// Validate Mail To
	var mailto = document.getElementById("SiteSearch1");
	var mailtoValue = mailto.value;
	
	if (mailtoValue == '' || mailtoValue == null || mailtoValue == undefined){
		alert("Please enter a valid email address in the To field.");
		mailto.focus();
		return false;
	}
	else if (!isValidEmail(mailtoValue)) {
		alert("The value entered in the To field is not a valid email address");
		mailto.focus();
		return false;
	}
	
	// Validate CC
	var mailcc = document.getElementById("SiteSearch2");
	var mailccValue = mailcc.value;
	
	if (mailccValue == '' || mailccValue == null || mailccValue == undefined){
		// Optional Field - Continue
	}
	else if (!isValidEmail(mailccValue)) {
		alert("The value entered in the CC field is not a valid email address");
		mailcc.focus();
		return false;
	}
	
	// Send Email
	document.getElementById("BtnHolder").style.display ="none" ;
	document.getElementById("submitBtnHolder").innerHTML = "Sending...";
	document.getElementById("emailForm").submit();
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function isValidPhone(str) {
   return (str.search(/\d{3}\.\d{3}\.\d{4}$/)!=-1);
}

function isValidZipCode(str) {
   return (str.search(/(^\d{5}$)|(^\d{5}-\d{4}$)/)!=-1);
}

function isValidDate(str) {
	//(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d
	return (str.search(/^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/) != -1);
}

function getWindowCenter() {
} 

function removetext(varid)
{
	if (document.getElementById(varid).value == document.getElementById(varid).defaultValue)
    	document.getElementById(varid).select();
}

function restoretext(boxid)
{ 
    if(document.getElementById(boxid).value=="")
       document.getElementById(boxid).value="Search Chicago";        

}

function isEnterPressed(e) {
		var code;
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		if (code == 13){
			validateKeyWord();
		}
} 

function doDestinations()
{
		var e;
		var strOriginCityCode = document.getElementById('ctlAvailCriteria_cboOrigin').value;
		if ( strOriginCityCode == '' )
		{
			return;
		}
		ClearDestinationList();
		if (strOriginCityCode == "all") 
		{
			for (j=0; j < area_array.length; j++) 
			{
			  		CreateOptionInDestinationList(neighborhood_handle_array[j],neighborhood_array[j],false);
				  
			} 
		} else 
		{
			for (j=0; j < area_array.length; j++) 
			{
			  	if (strOriginCityCode == area_array[j])
				{
						CreateOptionInDestinationList(neighborhood_handle_array[j],neighborhood_array[j],false);
				}  
			} 
		}
}


function ClearDestinationList()
{
	//alert("ClearDestinationList Begin ");
	var e;
	try
	{
		var nlength = document.getElementById('ctlAvailCriteria_cboDest').options.length;
		//alert("ClearDestinationList nlength = " + nlength);

		while (document.getElementById('ctlAvailCriteria_cboDest').options.length > 0)
		{
			var deleteIndex=document.getElementById('ctlAvailCriteria_cboDest').options.length-1;
			document.getElementById('ctlAvailCriteria_cboDest').options[deleteIndex]=null;
		}
		return true;
	}
	catch(e)
	{
		alert("Error in function ClearDestinationList. Error = " + e.description );
		return false;
	}
}

function CreateOptionInDestinationList(strVal,strName,blnIsSelected)
{
	//alert("CreateOptionInDestinationList return value = " + sResult);

			
		var myOption=new Option();
		var insertIndex;
		myOption.text=strName;
		myOption.value=strVal;
	//	alert("CreateOptionInDestinationList before IF.");
		if (document.getElementById('ctlAvailCriteria_cboDest').selectedIndex > 0)
			insertIndex=document.getElementById('ctlAvailCriteria_cboDest').selectedIndex;
		else
			insertIndex=document.getElementById('ctlAvailCriteria_cboDest').options.length;

	//	alert("CreateOptionInDestinationList after IF.");
		document.getElementById('ctlAvailCriteria_cboDest').options[insertIndex]=myOption;	


}

function populateAreaDropDown()
{
	//alert("CreateOptionInDestinationList return value = " + sResult);

			
		var myOption=new Option();
		var insertIndex;
		myOption.text=strName;
		myOption.value=strVal;
	//	alert("CreateOptionInDestinationList before IF.");
		if (document.getElementById('ctlAvailCriteria_cboDest').selectedIndex > 0)
			insertIndex=document.getElementById('ctlAvailCriteria_cboDest').selectedIndex;
		else
			insertIndex=document.getElementById('ctlAvailCriteria_cboDest').options.length;

	//	alert("CreateOptionInDestinationList after IF.");
		document.getElementById('ctlAvailCriteria_cboDest').options[insertIndex]=myOption;	


}

function check_selected_neighborhood() {
	var neighborhoodhandle = document.getElementById("ctlAvailCriteria_cboDest").value;
	if (neighborhoodhandle == "all") {
		alert ("Please select a neighborhood from the list.");
		return false;
	} else if( neighborhoodhandle==null || neighborhoodhandle=="")  {
		alert ("Please select a neighborhood from the list.");
		return false;
	} else {
		submitneighborhood(neighborhoodhandle);
	}
}

function submitneighborhood(neighborhoodhandle) {
	var formAction = document.getElementById("neighborhoodsearch");
	formAction.action=neighborhoodhandle+".html";
	formAction.submit();
}
 
function filterInputMaxlength(maxlength)
{
	if(eval(event))
	{
		if (event.srcElement.value.length == maxlength) 
		{
			event.returnValue=false;
			return false;
		}
		else if(event.srcElement.value.length > maxlength)
		{
			event.srcElement.value = event.srcElement.value.substring(0, maxlength);
		}
		// need to take custom action if the event was onPaste because data
		// coming from the clipboard must be modified.
		else if(event.type=='paste')
		{
			// no return value - manually set the srcElement value
			event.returnValue = false;
			// check for how many remaining characters and substring the text in the clipboard
			// to fill available space.  Then set it on the source element.vv
			var remainingLength = maxlength - event.srcElement.value.length;
			event.srcElement.value =  event.srcElement.value + window.clipboardData.getData('text').substring(0,remainingLength);
		}
		return true;
	}
	return false;
}