
function bookmark() {
    var url = 'http://www.connectingmoms.com';
    var title = 'Connecting Moms';
    if((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
        window.external.AddFavorite(url,title);
    } else if (navigator.appName == "Netscape") {
        window.sidebar.addPanel(title,url,"");
    } else {
        alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
    }
}

//
// Yard Sale Categories
//
var ysBuy     = 782;
var ysCar     = 724;
var ysHouse	  = 681;
var ysJob	  = 711;
var ysService = 750;


function popIt()
{
	var url = arguments[0];
	var width  = 400;
	var height = 400;
	var windowName = 'marypopit';
	
	if (arguments.length > 1)
	{
		windowName = arguments[1];
	}
	
	if (arguments.length > 2)
	{
		width = arguments[3];
	}
	
	if (arguments.length > 3)
	{
		height = arguments[2];
	}
	
	var left = (screen.availWidth/2) - (width/2);
	var top = (screen.availHeight/2) - (height/2);
	var features = 'resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=yes';
	features = features + ',width=' + width + ',height=' + height;
	features = features + ',top=' + top + ',left=' + left;
	
	window.open(url, name, features);
}


function formRefresh()
{
	document.frmMain.Action.value = 'refresh';
	document.frmMain.submit();
}

function validateNewAccount()
{
	var s;
	var t;

	s = trim(document.frmMain.FirstName.value);
	if (s.length == 0)
	{
		alert('You must specify your first and last name.');
		return;
	}	
	
	s = trim(document.frmMain.LastName.value);
	if (s.length == 0)
	{
		alert('You must specify a login username');
		return;
	}	
	
	
	s = trim(document.frmMain.Username.value);
	if (s.length == 0)
	{
		alert('You must specify a login username');
		return;
	}	
	
	s = trim(document.frmMain.Password.value);
	if (s.length == 0)
	{
		alert('You must specify a password');
		return;
	}	
	
	if (s.length < 3)
	{
		alert('Your password must be at least three characters long');
		return;
	}

	t = trim(document.frmMain.PasswordConfirm.value);
	if (t.length == 0)
	{
		alert('You must confirm your password by entering it again');
		return;
	}	
	
	if (t != s)
	{
		alert('Your password entries do not match.  Please enter your desired password and confirm by entering again');
		return;
	}
					
	s = document.frmMain.CityID.value;
	if (s == 0)
	{
		alert('You must specify your city, state, country, and zip code');
		return;		
	}

	s = trim(document.frmMain.StateID.value);
	if (s == 0)
	{
		alert('You must specify your city, state, country, and zip code');
		return;		
	}

	s = trim(document.frmMain.CountryID.value);
	if (s == 0)
	{
		alert('You must specify your city, state, country, and zip code');
		return;		
	}

	s = trim(document.frmMain.ZipCode.value);
	if (s.length == 0)
	{
		alert('You must specify your city, state, country, and zip code');
		return;		
	}
	
	s = trim(document.frmMain.Email.value);
	if (s.length == 0)
	{
		alert('You must specify an e-mail address');
		return;
	}	

//		t = trim(document.frmMain.EmailConfirm.value);
//		if (t.length == 0)
//		{
//			alert('You must confirm your e-mail address by entering it again');
//			return;
//		}	
//		
//		if (t != s)
//		{
//			alert('Your e-mail entries do not match.  Please enter your e-mail address and confirm by entering again');
//			return;
//		}	

	if (document.frmMain.chkTerms.checked == false)
	{
		alert('You must agree to the Terms of Use and Privacy Policy of membership services at ConnectingMoms.com');
		return;
	}
	
	var s;
	var m;
	var d;
	var y;
	
	m = document.frmMain.MonthID.value;
	d = document.frmMain.DayID.value;
	y = document.frmMain.YearID.value;
	
	if (isDate(m + '/' + d + '/' + y) == false)
	{
		alert('You must enter a valid birthdate');
		return;
	}
			
	document.frmMain.Action.value = 'register';
	document.frmMain.submit();	
}

//
// Comments
//
function commentSend()
{
	document.frmMain.Action.value = 'send';
	document.frmMain.submit();		
}
	
//
// Mail functions
//

function friendInviteSend()
{

	// Sync
	document.frmMain.Action.value = 'send';
	document.frmMain.submit();
}

function friendRequest()
{
	window.location = '/members/my/friendRequest.asp';
}

function bulletinCompose()
{
	window.location = '/members/my/mail/composeBulletin.asp';
}

function mailCompose()
{
	window.location = '/members/my/mail/compose.asp';
}

function mailReply()
{
	document.frmMain.Action.value = 'reply';
	document.frmMain.submit();
}

function mailSend() 
{

	var s = trim(document.frmMain.Subject.value);
	if (s.length == 0)
	{
		alert('You must specify a subject for your message');
		return;
	}

	document.frmMain.Action.value = 'send';
	document.frmMain.submit();
}

function mailTrashSelected()
{	
	document.frmMain.Action.value = 'trash';
	document.frmMain.submit();
}


function mailSaveToSelected()
{	
	document.frmMain.Action.value = 'saveToSelected';
	document.frmMain.submit();
}

function mailSave()
{
	document.frmMain.Action.value = 'save';
	document.frmMain.submit();		
}

function mailDelete()
{
	if (confirm('Are you sure you want to delete this message') == false)
	{
		return;
	}
	document.frmMain.Action.value = 'delete';
	document.frmMain.submit();		
}

function mailForward()
{
	document.frmMain.Action.value = 'forward';
	document.frmMain.submit();		
}
	
//
// General functions
//
function checkboxToggle(chkName)
{
	var checked = document.frmMain.chkAll.checked;
	var chkRows = document.frmMain[chkName];
	
	var k;
	var m;
	
	if (chkRows.length == null)
	{
		chkRows.checked = checked;
	}
	else
	{

		m = chkRows.length;
	
		for(k = 0; k < m; k++)
		{
			chkRows[k].checked = checked;
		}		
	}
}

//
// Blog functions
//
function blogEdit(token)
{
	document.frmMain.Action.value = 'edit';
	document.frmMain.Token.value = token;
	document.frmMain.submit();
}

function blogDelete(token)
{
	if (confirm('Are you sure you want to delete the blog?') == false)
	{
		return;
	}
	
	document.frmMain.Action.value = 'delete';
	document.frmMain.Token.value = token;
	document.frmMain.submit();
}

function blogSubscriptionDelete(token)
{
	if (confirm('Are you sure you want to remove this subscription?') == false)
	{
		return;
	}
	document.frmMain.Action.value = 'subDelete';
	document.frmMain.Token.value = token;
	document.frmMain.submit();
}

function blogUnsubscribe(token)
{
	if (confirm('Are you sure you want to remove this subscription?') == false)
	{
		return;
	}
	document.frmMain.Action.value = 'unsubscribe';
	document.frmMain.Token.value = token;
	document.frmMain.submit();
}
	
function blogSubscribe(token)
{
	document.frmMain.Action.value = 'subscribe';
	document.frmMain.Token.value = token;
	document.frmMain.submit();
}	

//
//
//
function profileSave(token)
{
	document.frmMain.Action.value = 'save';
	document.frmMain.submit();
}	

function settingsSave(token)
{
	document.frmMain.Action.value = 'save';
	document.frmMain.submit();
}

//
// Buddies
//
function buddyNew()
{
	document.frmMain.Action.value = 'buddyNew';
	document.frmMain.submit();
}

function buddyDelete()
{
	if (confirm('Are you sure you want to delete the selected Mom friends?') == false)
	{
		return;
	}
	
	document.frmMain.Action.value = 'buddyDelete';
	document.frmMain.submit();
}

//
// Blocks
//
function blockNew()
{
	document.frmMain.Action.value = 'blockNew';
	document.frmMain.submit();
}

function blockDelete()
{
	document.frmMain.Action.value = 'blockDelete';
	document.frmMain.submit();
}

//
// Company
//
function companyNew(UserId)
{	
	var s = trim(document.frmMain.Company.value);
	if (s.length == 0)
	{
		alert('You must specify the name of the company');
		return;
	}
	
	document.frmMain.Action.value = 'new';
	document.frmMain.submit();
		
}

function companySave(formNumber)
{
	var theForm = eval('document.frmCompany' + formNumber);
	
	var s = trim(theForm.Company.value);
	if (s.length == 0)
	{
		alert('You must specify the name of the company');
		return;
	}
	
	theForm.Action.value = 'save';
	theForm.submit();				
	
}

function companyDelete(formNumber)
{
	var theForm = eval('document.frmCompany' + formNumber);

	var s = trim(theForm.Company.value);
	if (confirm('Are you sure you want to delete this company?') == false)
	{
		return;
	}
	
	theForm.Action.value = 'delete';
	theForm.submit();				
	
}	

//
// School
//
function loadSchool(frmName)
{
	var f = document.frmSchool;
	var frm = eval('document.' + frmName);

	f.Token.value 			= frm.Token.value;		
	f.School.value 			= frm.School.value;
	f.SchoolType.value		= frm.SchoolType.value;
	f.City.value 			= frm.City.value;
	f.State.value			= frm.State.value;
	f.Country.value			= frm.Country.value;
	f.Dates.value			= frm.Dates.value;
	f.Degree.value			= frm.Degree.value;
	f.Major.value			= frm.Major.value;

}

function loadCompany(frmName)
{
	var f = document.frmCompany;
	var frm = eval('document.' + frmName);
	
	f.Token.value 					= frm.Token.value;
	f.Company.value 				= frm.Company.value;
	f.City.value 					= frm.City.value;
	f.State.value					= frm.State.value;
	f.Country.value					= frm.Country.value;
	f.Dates.value					= frm.Dates.value;
	f.Title.value					= frm.Title.value;
	f.Responsibilities.innerHTML	= frm.Responsibilities.value;

}

function saveCompany(frm)
{
//		var s = trim(frm.Company.value);
//		if (s.length == 0)
//		{
//			alert('You must specify the company name');
//			return
//		}
//		
	frm.Action.value = 'saveCompany';
	frm.submit();
}

function saveSchool(frmName)
{
	var frm = document.frmSchool;
	
//		var s = trim(frm.School.value);
//		if (s.length == 0)
//		{
//			alert('You must specify the school name');
//			return
//		}
	
	frm.Action.value = 'saveSchool';
	frm.submit();
}

function deleteSchool(frmName)
{
	var frm = eval('document.' + frmName);
	
	if (confirm('Click OK to delete school, CANCEL to cancel') == false)
	{
		return;
	}

	frm.Action.value = 'deleteSchool';
	frm.submit();
}

function deleteCompany(frmName)
{
	var frm = eval('document.' + frmName);

	if (confirm('Click OK to delete company, CANCEL to cancel') == false)
	{
		return;
	}

	frm.Action.value = 'deleteCompany';
	frm.submit();
}

//
// Child
//
function childSave(UserId)
{	
	var f = document.frmMain;
	var s = trim(f.Child.value);
	if (s.length == 0)
	{
		alert('You must specify the name of the child');
		return;
	}
	
	f.Action.value = 'childSave';
	f.submit();
		
}

function childEdit(formNumber, m, d, y)
{
	var theForm = eval('document.frmChild' + formNumber);
	
	document.frmMain.Token.value = theForm.Token.value;
	document.frmMain.Child.value = theForm.Child.value;
	
	// Set month
	var cbx = document.frmMain.MonthID
	for(var k = 0; k < cbx.options.length; k++)
	{
		if (cbx.options[k].value == m)
		{
			cbx.selectedIndex = k;
		}
		
	}

	// Set day
	var cbx = document.frmMain.DayID
	for(var k = 0; k < cbx.options.length; k++)
	{
		if (cbx.options[k].value == d)
		{
			cbx.selectedIndex = k;
		}
		
	}

	// Set year
	var cbx = document.frmMain.YearID
	for(var k = 0; k < cbx.options.length; k++)
	{
		if (cbx.options[k].value == y)
		{
			cbx.selectedIndex = k;
		}
		
	}

	
}

function childSaveNotUsed(formNumber)
{
	var theForm = eval('document.frmChild' + formNumber);
	
	var s = trim(theForm.Child.value);
	if (s.length == 0)
	{
		alert('You must specify the name of the child');
		return;
	}
	
	theForm.Action.value = 'save';
	theForm.submit();				
	
}

function childDelete(formNumber)
{
	var theForm = eval('document.frmChild' + formNumber);

	var s = trim(theForm.Child.value);
	if (confirm('Are you sure you want to delete this child?') == false)
	{
		return;
	}
	
	theForm.Action.value = 'childDelete';
	theForm.submit();				
	
}	
	
//
// Geography
//
function stateChanged()
{
	document.frmMain.Action.value = 'stateChange';
	document.frmMain.submit();
}

function countryChanged()
{
	document.frmMain.Action.value = 'countryChange';
	document.frmMain.submit();
}

//
// Events
//
function eventNew()
{
	window.location='/members/events/edit.asp?new=y';
}

function eventSearch()
{
	var sf = document.frmMain;
	
	// They have to specify 
	if (sf.cbxDate.value == 0 && sf.EventCategoryID.value == 0 && trim(sf.ZipCode.value).length == 0)
	{
		alert('You must specify at least one search parameter');
		return;
	}

	sf.Action.value = 'search';
	sf.submit();	
}

function eventPost()
{
	var s = trim(document.frmMain.Event.value);
	if (s.length == 0)
	{
		alert('You must specify a name for your event');
		return;
	}
	
	var s = document.frmMain.PublicEventCategoryID.value;
	var t = document.frmMain.PrivateEventCategoryID.value;
	if (s == 0 && t == 0)
	{
		alert('You must specify a category for your event');
		return;
	}

	var s = trim(document.frmMain.Location.value);
	if (s.length == 0)
	{
		alert('You must specify a location for your event');
		return;
	}

	var s = trim(document.frmMain.City.value);
	if (s.length == 0)
	{
		alert('You must specify a city for your event');
		return;
	}

	var s = trim(document.frmMain.State.value);
	if (s.length == 0)
	{
		alert('You must specify a state for your event');
		return;
	}

	var s = trim(document.frmMain.ZipCode.value);
	if (s.length == 0)
	{
		alert('You must specify a location for your event');
		return;
	}

	document.frmMain.Action.value = 'post';
	document.frmMain.submit();
}

function eventInvite()
{
	var f = document.frmMain;

	document.frmMain.Action.value = 'invite';
	document.frmMain.submit();

}

//
// Groups
//
function groupSave()
{

	var s = trim(document.frmMain.GroupTitle.value);
	if (s.length == 0)
	{
		alert('You must specify a name for your group');
		return;
	}
	
	var t = document.frmMain.GroupCategoryID.value;
	if (t == 0)
	{
		alert('You must specify a category for your group');
		return;
	}
	
//		var t = document.frmMain.ZipCode.value;
//		if (t == 0)
//		{
//			alert('You must specify a zip code for your group');
//			return;
//		}		

	document.frmMain.Action.value = 'post';
	document.frmMain.submit();
}
	
function groupInvite()
{
	var f = document.frmMain;
		
	document.frmMain.Action.value = 'invite';
	document.frmMain.submit();

}		

function groupPhotoUpload()
{
	document.frmMain.Action.value = 'upload';
	document.frmMain.submit();	
}

//
// Gallery
//
function gallerySave()
{
	var s = trim(document.frmMain.Gallery);
	if (s.length == 0)
	{
		alert('You must specify a name for your photo album!');
		return;
	}
	document.frmMain.Action.value = 'save';
	document.frmMain.submit();	
}

function genericSave()
{
	document.frmMain.Action.value = 'save';
	document.frmMain.submit();		
}	

function genericSave()
{
	document.frmMain.Action.value = 'save';
	document.frmMain.submit();		
}		

function eventDelete()
{
	if (confirm('Are you sure you want to delete this event?') == false)
	{
		return;
	}
	
	document.frmMain.Action.value = 'delete';
	document.frmMain.submit();
}

function addToWishlist(resourceToken)
{
	document.frmMain.Action.value = 'add';
	document.frmMain.Token.value = 'resourceToken';
	document.frmMain.submit();
}

function movieReview()
{
	// Title
	var s = trim(document.frmReview.Title.value);
	if (s.length == 0)
	{
		alert('You must provide the title of the movie you are reviewing');
		return;
	}

	// Media Type
	var s = document.frmReview.MediaTypeID;
	
	var somethingSelected = false;
	for (var k = 0; k < s.length; k++)
	{
		if (s[k].checked)
		{
			somethingSelected = true;
		}
	}
	
	if (somethingSelected == false)
	{
		alert('You must indicate the type of movie you are reviewing');
		return;
	}
	
	// Movie Genre
	if (document.frmReview.MovieGenreID.value == 0)
	{
		alert('You must select a genre for the movie you are reviewing');
		return;
	}

	// Rating
	var s = document.frmReview.Rating;
	
	var somethingSelected = false;
	for (var k = 0; k < s.length; k++)
	{
		if (s[k].checked)
		{
			somethingSelected = true;
		}
	}
	
	if (somethingSelected == false)
	{
		alert('You must provide a rating for the movie you are reviewing');
		return;
	}
	
	// Short Description
	var s = trim(document.frmReview.Comments.value);
	if (s.length == 0)
	{
		alert('You must provide comments on the movie you are reviewing');
		return;
	}		
	
	document.frmReview.Action.value = 'review';
	document.frmReview.submit();

}


function showSearch()
{
	var s = document.frmSearch.MediaTypeID;
	
	var selected = false;
	for(var k = 0; k < s.length; k++)
	{
		if (s[k].checked)
		{
			selected = true;
		}
	}
	
	if (selected == false)
	{
		alert('You must select either movie, dvd, or television as a search option');
		return;
	}
	
	var s = trim(document.frmSearch.SearchText.value);
	if (s.length == 0)
	{
		alert('You must provide a search term to search for');
		return;
	}
	document.frmSearch.Action.value = 'search';
	document.frmSearch.submit()
}

function validateDoNotContact()
{
	var s = trim(document.frmMain.Email.value);
	if (isValidEmailAddress(s)  == false)
	{
		alert('Your e-mail address appears to be improperly formatted.  Please check and try again.');
		return;
	}
	
	document.frmMain.Action.value = "DoNotContact";
	document.frmMain.submit();
}

		