// JavaScript Document
													 
	//-------------------------------------------------------------
	function Querystring(qs) { // optionally pass a querystring to parse
		this.params = {};
		
		if (qs == null) qs = location.search.substring(1, location.search.length);
		if (qs.length == 0) return;
	
	// Turn <plus> back to <space>
	// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
		qs = qs.replace(/\+/g, ' ');
		var args = qs.split('&'); // parse out name/value pairs separated via &
		
	// split out each name=value pair
		for (var i = 0; i < args.length; i++) {
			var pair = args[i].split('=');
			var name = decodeURIComponent(pair[0]);
			
			var value = (pair.length==2)
				? decodeURIComponent(pair[1])
				: name;
			
			this.params[name] = value;
		}
	}
	
	Querystring.prototype.get = function(key, default_) {
		var value = this.params[key];
		return (value != null) ? value : default_;
	}
	
	Querystring.prototype.contains = function(key) {
		var value = this.params[key];
		return (value != null);
	}
	
	
	//-------------------------------------------------------------
	var sendingtext = "<center><div class='SubTitle'>Sending... Please Wait</div><img src='/images/loading1.gif' height='32' width='32' /></center>";
	var savingtext = "<center><div class='SubTitle'>Saving... Please Wait</div><img src='/images/loading1.gif' height='32' width='32' /></center>";
	var searchingtext = "<center><div class='SubTitle'>Searching... Please Wait</div><img src='/images/loading1.gif' height='32' width='32' /></center>";
	var loadingtext = "<center><div class='SubTitle'>Loading... Please Wait</div><img src='/images/loading1.gif' height='32' width='32' /></center>";
	var loadingtextsm = "<center><div class='LineTitle'>Loading... Please Wait</div><img src='/images/loading1.gif' height='32' width='32' /></center>";
	var logintext = "<center><div class='SubTitle'>Logging In... Please Wait</div><img src='/images/loading1.gif' height='32' width='32' /></center>";
	var calendarloadtext = "<center><div class='ContentHeader'>Loading Calendar Please Wait<p><img src='images/loading3.gif' /></p></div></center>";
	var eventmapwindow = '';
	var termswindow = '';
	var helpwindow = '';
	
	function select_city() {
		var cityidx = document.getElementById("cboSelCity").selectedIndex;
		var cityid = document.getElementById("cboSelCity")[cityidx].value;
		var curstring = window.location.search.substring(1);
	
		var objqs = new Querystring(curstring);
		var qyear = objqs.get("year","");	
		var qmos = objqs.get("month","");	
		var qday = objqs.get("day","");	
		var qcat = objqs.get("cat","");	
		var qsrc = objqs.get("src","");	
		var qfrom = objqs.get("from","");	
		
		window.location = "events.php?cat="+qcat+"&year="+qyear+"&month="+qmos+"&day="+qday+"&src="+qsrc+"&from="+qfrom+"&city="+cityid;
	}
	
	function pop_terms_conditions() {
	
		if (!termswindow.closed && termswindow.location) {
			termswindow.location.href = '/include/popterms.php';
		}
		else {
			termswindow=window.open('/include/popterms.php','name','height=480,width=720,scrollbars=1');
			if (!termswindow.opener) termswindow.opener = self;
		}
				
		if (window.focus) {termswindow.focus()}
		
	}
	function pop_event_map(eventid) {
	
		if (!eventmapwindow.closed && eventmapwindow.location) {
			eventmapwindow.location.href = '/include/popmap.php?eventid'+eventid;
		}
		else {
			eventmapwindow=window.open('/include/popmap.php?eventid='+eventid,'name','height=740,width=720,scrollbars=no');
			if (!eventmapwindow.opener) eventmapwindow.opener = self;
		}
				
		if (window.focus) {eventmapwindow.focus()}
		
	}
	function pop_help_topic(helpid) {
	
		if (!helpwindow.closed && helpwindow.location) {
			helpwindow.location.href = '/include/pophelp.php?id'+helpid;
		}
		else {
			helpwindow=window.open('/include/pophelp.php?id='+helpid,'name','height=600,width=725,scrollbars=no');
			if (!helpwindow.opener) helpwindow.opener = self;
		}
				
		if (!window.focus) {helpwindow.focus()}
		
	}
	function pop_help_cat(catid) {
	
		if (!helpwindow.closed && helpwindow.location) {
			helpwindow.location.href = '/include/pophelp.php?cat='+catid;
		}
		else {
			helpwindow=window.open('/include/pophelp.php?cat='+catid,'name','height=600,width=725,scrollbars=no');
			if (!helpwindow.opener) helpwindow.opener = self;
		}
				
		if (!window.focus) {helpwindow.focus()}
		
	}
	function check_Message() {
		
		var txtName = document.getElementById('txtMName').value;
		var txtEmail = document.getElementById('txtMEmail').value;
		var txtPhone = document.getElementById('txtMPhone').value;
		
		if (txtName.trim() == "") {
			alert ("Please enter your name.");
			return;
		}
		if (txtEmail.trim() == "") {
			alert ("Please enter your email.");
			return;
		}
		if (txtPhone.trim() == "") {
			alert ("Please enter your phone.");
			return;
		}
	
		
		document.frmSendEventMsg.submit();
	}
	
	
	
	function validateEmail(elementValue){  
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
		return emailPattern.test(elementValue);  
	}   
	
	
	function eventlist_load() {
		var month = $("#eventscalendarframe").attr("month");
		var year = $("#eventscalendarframe").attr("year");
		var category = $("#eventscalendarframe").attr("cat");
		var Source = $("#eventscalendarframe").attr("src");
	
		$.get("/include/callg/calendar.php", { month: month, year: year, cat: category, from: "cal", src: Source },
					function(data) {
						$("#eventscalendarframe").fadeOut("fast", function() {
							$("#eventscalendarframe").html(data);
							$("#eventscalendarframe").fadeIn("slow");
						});
					}
		);
	}
	
	function classified_load() {
	
		var category = $("#classifiedframe").attr("cat");
		var member = $("#classifiedframe").attr("member");
		var classid = $("#classifiedframe").attr("classid");
	
		$.get("/include/classlist.php", { cat: category, member: member, id: classid },
					function(data) {
						$("#classifiedframe").fadeOut("fast", function() {
							$("#classifiedframe").html(data);
							$("#classifiedframe").fadeIn("slow");
	
							//$(".btnLoadClassMsg").click(load_class_msg);
	
						});
					}
		);
	}
	
	function mainevents_load() {
			$.get("/include/eventsmain.php", { size: "Small" },
					function(data) {
						$("#MainPageEventsList").fadeOut("normal", function() {
							$("#MainPageEventsList").html(data);
							$("#MainPageEventsList").fadeIn("normal");
						});
					}
			);
	}
	
	function printpost_load() {
		
		$("#PrintOptBox").animate({left: 0}, 750);
	}
	//------------------ Event Scroll -------------------
		var clientintervalid;
		
		function slideJump(page) {
			var $active = $('#ScrollContainer span.ScrollBoxActive');
			//var page = $(this).attr("pg");
			var $next = $('#ScrollBox'+page);
	
			if ( $next.length == 0) $next =  $('#ScrollContainer span:first'); 
	
			$(".ScrollPage span").removeClass("PageActive");
			$(".ScrollPage #page"+page).addClass("PageActive");
	
			$active.removeClass('ScrollBoxActive');	
			$next.css({opacity: 0.0});
			$next.addClass('ScrollBoxActive');
			$next.animate({opacity: 1.0}, 750);
		}
		
		function nextSlide() {
			var $active = $('#ScrollContainer span.ScrollBoxActive');
			var $next = $active.next();
			
			if ( $next.length == 0) $next =  $('#ScrollContainer span:first'); 
	
			var page = $next.attr("pg");
			$(".ScrollPage span").removeClass("PageActive");
			$(".ScrollPage #page"+page).addClass("PageActive");
	
			$active.removeClass('ScrollBoxActive');	
			$next.css({opacity: 0.0});
			$next.addClass('ScrollBoxActive');
			$next.animate({opacity: 1.0}, 750);
		}
	
		function prevSlide() {
			var $active = $('#ScrollContainer span.ScrollBoxActive');
			var $prev = $active.prev();
			
			if ( $prev.length == 0) $prev =  $('#ScrollContainer span:last'); 
	
			var page = $prev.attr("pg");
			$(".ScrollPage span").removeClass("PageActive");
			$(".ScrollPage #page"+page).addClass("PageActive");
	
			$active.removeClass('ScrollBoxActive');	
			$prev.css({opacity: 0.0});
			$prev.addClass('ScrollBoxActive');
			$prev.animate({opacity: 1.0}, 750);
		}
	
		$(function() {
				clientintervalid = setInterval( "nextSlide()", 7500 );
		});
	
	
	//****************************************************//
	//* START OF JQUERY FUNCTIONS
	//****************************************************//
	$(document).ready(function(){
	
		//--------------------------------------
		// BUGS
		//--------------------------------------
		
		function bug_load(){
			var pagename = $("#hdnPageName").attr("value");
			
			$.get("/include/enterbug.php", { page: pagename },
						function(data) {
							$("#SubmitBugBox").html(data);
							$("#SubmitBugFrame").slideDown("normal");
							$(".btnBugCancel").click(bug_cancel);
							$(".btnBugSave").click(bug_save);
						}
			); 
		};
		
		function bug_cancel(){		
			$("#SubmitBugFrame").slideUp("normal", function() {
				$("#SubmitBugBox").html("");
			});
		};
		
		function bug_save(){
			$("#SubmitBugFrame").slideUp("normal", function() {  
				$.ajax({
					type: "POST",
					url: "/include/savebug.php",
					enctype: 'multipart/form-data',
					data: $("#frmSubmitBug").serialize(),
					success: function(data) {
						$("#SubmitBugFrame").slideUp("normal", function() {					
							$("#SubmitBugBox").html(data);
							$("#SubmitBugFrame").slideDown("normal");
							
							$("#SubmitBugFrame").animate({opacity: 1.0}, 3000);
							$("#SubmitBugFrame").slideUp("normal", function() {
								$("#SubmitBugBox").html("");
							});
							
						});
						$(".btnBugCancel").click(bug_cancel);
					}  ,
					error: function(data) {
						$("#SubmitBugFrame").slideUp("normal", function() {					
							$("#SubmitBugBox").html("Error");
							$("#SubmitBugFrame").slideDown("normal");
						});
					}  
				});
			});		
		};	
	
		$(".btnBugLoad").click(bug_load);
		$(".btnBugCancel").click(bug_cancel);
		$(".btnBugSave").click(bug_save);
		
	
		//--------------------------------------
		// MAIN MENUS
		//--------------------------------------
		$("#mnuSubMenu li").hover (
			function () {
				var objlist = $(this).find("ul:first");
				
				objlist.css("display", "block");
				objlist.css("z-index", "100");
				//$(this).find("ul:first").addClass("over");
			},
			function () {
				$(this).find("ul:first").css("display","none");
				//$(this).find("ul:first").removeClass("over");
			}														 
		); 
		
		//--------------------------------------
		// CONTACT FORM
		//--------------------------------------
		$(".SubmitContact").click(function(){
			$("#ContactForm").fadeOut("fast");
			
			$.post("/include/postcontact.php",
						 $("#frmcontactus").serialize(),
						 function(data) {
								$("#ContactForm").html(data);
								$("#ContactForm").fadeIn("normal");
						 }
			);
	
		});
		
		//--------------------------------------
		// EVENT CALENDAR
		//--------------------------------------
		function category_menu_click(){
			$('#showevent').fadeOut('fast');
			
			$("#eventscalendarframe").fadeOut('fast', function(){
				$("#eventscalendarframe").html(calendarloadtext);
				$("#eventscalendarframe").fadeIn('fast');
			});
			
			var catname = $(this).html();
			var month = $(this).attr("month");
			var year = $(this).attr("year");
			var category = $(this).attr("cat");
			
			$.get("/include/callg/calendar.php", { month: month, year: year, cat: category },
					function(data) {
						$("#eventscalendarframe").html(data);
						$("#eventscalendarframe").fadeIn("normal");
						$("#CalendarSubTitle").html(catname);
						$(".btnCalNav").click(calendar_navigate);
						$(".btnCalEventCount").click(calendar_day_click);
						$("#boxCalendarShow").click(show_calendar);
						$("#boxCalendarHide").click(hide_calendar);
					}
			);
		};
		
		function calendar_navigate(){
			$("#CalendarEventsList").fadeOut("fast");
	
			$("#eventscalendarframe").fadeOut('fast', function(){
				$("#eventscalendarframe").html(calendarloadtext);
				$("#eventscalendarframe").fadeIn('fast');
			});
			
			
			var month = $(this).attr("month");
			var year = $(this).attr("year");
			var category = $(this).attr("cat");
			
			$.get("/include/callg/calendar.php", { month: month, year: year, cat: category },
						function(data) {
							$("#eventscalendarframe").html(data);
							$("#eventscalendarframe").fadeIn("normal");
							$(".btnCalNav").click(calendar_navigate);
							$(".btnCalEventCount").click(calendar_day_click);
							$("#boxCalendarShow").click(show_calendar);
							$("#boxCalendarHide").click(hide_calendar);
						}
			);
	
			$.get("/include/eventlist.php", { day: 0, month: month, year: year, cat: category, from: 'calendar' },
						function(data) {
							$("#CalendarEventsList").html(data);
							$("#CalendarEventsList").fadeIn("normal");
							$(".btnCalNav").click(calendar_navigate);
							$(".btnCalEventCount").click(calendar_day_click);
							$("#boxCalendarShow").click(show_calendar);
							$("#boxCalendarHide").click(hide_calendar);
							$(".lnkShowEvent").click(show_event);
							$(".lnkEventFBLink").click(show_event_facebook);
						}
			);
	
		};
	
		
		function calendar_day_click() {
			$("#ShowEventsFrame").slideUp("fast");
			
			var day = $(this).attr("day");
			var month = $(this).attr("month");
			var year = $(this).attr("year");
			var category = $(this).attr("cat");
			var city = $(this).attr("city");
			
			$.get("/include/eventlist.php", { day: day, month: month, year: year, cat: category, city: city, from: 'calendar', size: 'Medium' },
						function(data) {
							$("#ShowEventsFrame").html(data);
							$("#ShowEventsFrame").slideDown("normal");
							$(".btnCalNav").click(calendar_navigate);
							$(".btnCalEventCount").click(calendar_day_click);
							$(".lnkShowEvent").click(show_event);
							$(".lnkEventFBLink").click(show_event_facebook);
							$(".hideShowEvents").click(hide_calendar_day);
							$("#boxCalendarShow").click(show_calendar);
							$("#boxCalendarHide").click(hide_calendar);
							$("#EventCalBody").slideUp("normal");
						}
			);  
		};
	
		function hide_calendar_day() {
			$("#ShowEventsFrame").slideUp("fast", function() { $("#ShowEventsFrame").html(""); });
			$("#EventCalBody").slideDown("normal");
		}
		function hide_calendar() {
			$("#EventCalBody").slideUp("normal");
		}	function show_calendar() {
			$("#EventCalBody").slideDown("normal");
		}
		function calendar_load() {
			var month = $("#eventscalendarframe").attr("month");
			var year = $("#eventscalendarframe").attr("year");
			var category = $("#eventscalendarframe").attr("cat");
		
			$.get("/include/callg/calendar.php", { month: month, year: year, cat: category, from: "cal" },
						function(data) {
							$("#eventscalendarframe").fadeOut("fast", function() {
								$("#eventscalendarframe").html(data);
								$("#eventscalendarframe").fadeIn("slow");
								$(".CategoryClick").click(category_menu_click); 
								$(".btnCalNav").click(calendar_navigate);
								$(".btnCalEventCount").click(calendar_day_click);						
								$("#boxCalendarShow").click(show_calendar);
								$("#boxCalendarHide").click(hide_calendar);
							});
						}
			);
		}
		
		$(".CategoryClick").click(category_menu_click); 
		$(".btnCalNav").click(calendar_navigate);
		$(".btnCalEventCount").click(calendar_day_click);
		$("#boxCalendarShow").click(show_calendar);
		$("#boxCalendarHide").click(hide_calendar);
	
	
		
		//----------------------------------------
		// GALLERIES
		//----------------------------------------
		$(".GalleryListBox").click(function(){
	
			if ($(".GalleryListFrame").is(":animated")) { 
				return;
			}
			
			var temp = $(this).attr("id");
			var galleryid = temp.substr(1);
	
			$("#GalleryListFrame").animate({ opacity: 0.25 }, 5000 );
	
	
			$(".GalleryListBox").removeClass("GalleryActive");
			$(this).addClass("GalleryActive");
			
			$("#GalleryBox").fadeOut('fast', function(){
				$("#GalleryBox").html("<center><div class='ContentHeader'>Loading Gallery Please Wait</div><p><img src='images/loading1.gif' /></p><p>If the gallery does not load properly click <a href='/gallery.php?id="+galleryid+"'>here</a> to go directly to it.</p></center>");
				$("#GalleryBox").fadeIn('fast');
			});
			
			$.get("/include/galleryimg.php", { id: galleryid },
						function(data) {
							$("#GalleryBox").fadeOut("fast", function() {
								$("#GalleryBox").html(data);
	
								$("#GalleryListFrame").animate({ opacity: 1.0 }, 500 );
								$("#GalleryListFrame").stop();
								
								$("#GalleryBox").fadeIn("normal");
	
							});
						}
			);
		 
		});	
	
	
		//-----------------------------------------
		// MEMBER PROFILE
		//-----------------------------------------
	
		
		function load_member_events(){
			var memberid = $(this).attr("mid");
			var startat = $(this).attr("offset");
			var pastev = $(this).attr("past");
			
			$("#MemberTabContent").slideUp("fast", function() {
				$.get("/include/memberevents.php", { id: memberid, offset: startat, past: pastev},
							function(data) {
								$("#MemberTabContent").html(data);
								$("#MemberTabContent").slideDown("normal");
								$(".btnMemberEvents").click(load_member_events);
							}
				);    
			});
		};
		
	
		$(".btnMemberPast").click(function(){
			var memberid = $("#hdnMemberID").attr("value");
			$("#MemberTabContent").slideUp("fast", function() {
				$.get("/include/memberevents.php", { id: memberid, past: 1 },
							function(data) {
								$("#MemberTabContent").html(data);
								$("#MemberTabContent").slideDown("normal");
							}
				);    
			});
		});
		
		$(".btnMemberClass").click(function(){
			var memberid = $("#hdnMemberID").attr("value");
			$("#MemberTabContent").slideUp("fast", function() {
				$.get("/include/memberclass.php", { id: memberid },
							function(data) {
								$("#MemberTabContent").html(data);
								$("#MemberTabContent").slideDown("normal");
							}
				);    
			});
		});  
	
		$(".btnMemberEvents").click(load_member_events);
	
		
		
		function member_track(){
			$("#StatusMessage").fadeOut("fast");      	
			$("#btnTrack").html("Saving...");
			var memberid = $(this).attr("mid");
	
			$.get("/members/include/trackmember.php", { member: memberid },
				function(data) {
					$("#btnTrack").html("Tracking");
					$("#StatusMessage").html(data);
					$("#StatusMessage").fadeIn("normal");
					$("#StatusMessage").animate( { opacity: 1.0 } , 3000, function() { 
							$("#StatusMessage").fadeOut("fast");      	
						});
				}
			 );    
		};    
		
		function member_untrack() {
			$("#StatusMessage").fadeOut("fast");      	
			$("#btnTrack").html("Saving...");
			var memberid = $(this).attr("mid");
	
			$.get("/members/include/trackmember.php", { member: memberid, f: "del" },
				function(data) {
					$("#btnTrack").html("Tracking");
					$("#StatusMessage").html(data);
					$("#StatusMessage").fadeIn("normal");
					$("#memberrow"+memberid).fadeOut("fast");
					$("#StatusMessage").animate( { opacity: 1.0 } , 3000, function() { 
							$("#StatusMessage").fadeOut("fast");      	
						});
				}
			 );    																				
		};
																					
		
		function load_member_login(){
			$("#MemberLoginFrame").fadeOut("fast");
			$.get("/members/include/poplogin.php", { id: 0 },  function(data) {
				$("#MemberLoginBox").html(data);
				$("#MemberLoginFrame").fadeIn("normal");
				$(".btnMemberSendLogin").click(send_member_login);
			});
		};
		
		function send_member_login() {
			$.ajax({
				type: "POST",
				url: "/members/include/poplogin.php",
				enctype: 'multipart/form-data',
				data: $("#frmMemberLogin").serialize(),
				success: function(data) {
					if (data == "OK") {
						$("#MemberLoginFrame").fadeOut("fast");
						window.location.reload(true);
					} else {
						alert("Login Failed: "+data);
						$("#MemberLoginFrame").fadeOut("fast");
					}
				} 
			});		
			
		}
	
		$(".btnMemberTrack").click(member_track); 
		$(".btnMemberUnTrack").click(member_untrack);
		$(".btnMemberLogin").click(load_member_login);
		$(".btnMemberSendLogin").click(send_member_login);
		
		//-----------------------------------------
		// NEWS RELEASES
		//-----------------------------------------
		
		function news_back_link() {
			var offset = $(this).attr("offset");
			var member = $(this).attr("member");
			
			$("#NewsFrame").fadeOut("fast", function() {
				$("#NewsFrame").html(loadingtext);																					 
			});
	
			$.ajax({
				type: "GET",
				url: "/include/newslist.php",
				data: "offset="+offset+"&member="+member,
				success: function(data){
					$("#NewsFrame").html(data);
					$("#NewsFrame").fadeIn("normal");
					$(".NewsPageLink").click(news_page_link);
					$(".NewsBackLink").click(news_back_link)
					$(".NewsLink").click(news_load_link);
				},
				error: function(data, status, error) {
					$("#NewsFrame").html("<div class='boxError'>Error: "+error+"</div>"+data);
					$("#NewsFrame").fadeIn("normal");
				}
			});    
		};
		
		
		function news_page_link() {
			var offset = $(this).attr("offset");
			var member = $(this).attr("member");
			
			$("#NewsFrame").fadeOut("normal", function() {
				$("#NewsFrame").html(loadingtext);															 
	
				$.ajax({
					type: "GET",
					url: "/include/newslist.php",
					data: "offset="+offset+"&member="+member,
					success: function(data){
						$("#NewsFrame").fadeIn("normal");
						$("#NewsFrame").html(data);
						$(".NewsPageLink").click(news_page_link);
						$(".NewsBackLink").click(news_back_link)
						$(".NewsLink").click(news_load_link);
					},
					error: function(data, status, error) {
						$("#NewsFrame").html("<div class='boxError'>Error: "+error+"</div>"+data);
						$("#NewsFrame").fadeIn("normal");
					}
				});   
			});
	
		};
		
		
		function news_load_link() {
			var newsid = $(this).attr("news");
			var offset = $(this).attr("offset");
			var member = $(this).attr("member");
			
			$("#NewsFrame").fadeOut("fast", function() {
				$("#NewsFrame").html(loadingtext);																					 
			});
	
			$.ajax({
				type: "GET",
				url: "/include/newslist.php",
				data: "news="+newsid+"&offset="+offset+"&member="+member,
				success: function(data){
					$("#NewsFrame").html(data);
					$("#NewsFrame").fadeIn("normal");
					
					$(".NewsPageLink").click(news_page_link);
					$(".NewsBackLink").click(news_back_link)
					$(".NewsLink").click(news_load_link);
				},
				error: function(data, status, error) {
					$("#NewsFrame").html("<div class='boxError'>Error: "+error+"</div>"+data);
					$("#NewsFrame").fadeIn("normal");
				}
			});    
		};
	
		$(".NewsPageLink").click(news_page_link);
		$(".NewsBackLink").click(news_back_link)
		$(".NewsLink").click(news_load_link);
	
		//--------------------------------------------
		// SEND LINK TO FRIEND
		//--------------------------------------------
		function hide_friend_email(){
			$("#SendFriendEmailFrame").slideUp("fast");		
		};
		
		function hide_friend_email2(){
			var classid = $("#hdnClassID").attr("value");
			$("#SendFriendEmailFrame"+classid).slideUp("fast");		
		};
		
		function send_email_friend(){
			var classid = $("#hdnClassID").attr("value");
			var yourname = $.trim($("#txtName").attr("value"));
			var email1 = $.trim($("#txtEmail1").attr("value"));
			var email2 = $.trim($("#txtEmail2").attr("value"));
			var email3 = $.trim($("#txtEmail3").attr("value"));
			
			if (classid == "0") {
				classid = "";
			}
			
			if (yourname.length == 0) {
				alert("Please enter your name before sending.");
				return;
			}
			if (email1.length == 0) {
				alert("Please enter at least one email before sending.");
				return;
			} else {
				if (validateEmail(email1) == false) {
					alert("Please enter a valid email address for email 1.");
					return;
				 }
			}
			if (email2.length > 0) {
				if (validateEmail(email2) == false) {
					alert("Please enter a valid email address for email 2.");
					return;
				 }
			}
			if (email3.length > 0) {
				if (validateEmail(email3) == false) {
					alert("Please enter a valid email address for email 3.");
					return;
				 }
			}
			
			$("#SendFriendEmailFrame"+classid).fadeOut("fast", function() {
				$("#SendFriendEmailBox"+classid).html(sendingtext);
				$("#SendFriendEmailFrame"+classid).fadeIn("normal");
			});		
		
			$.ajax({
				type: "POST",
				url: "/include/saveemail.php",
				enctype: 'multipart/form-data',
				data: $("#frmSendFEmail").serialize(),
				success: function(data) {
					$("#SendFriendEmailFrame"+classid).fadeOut("fast", function() {
						$("#SendFriendEmailBox"+classid).html(data);
						$("#SendFriendEmailFrame"+classid).fadeIn("slow");
						
						$("#SendFriendEmailFrame"+classid).animate({opacity: 1.0}, 3000);
						$("#SendFriendEmailFrame"+classid).slideUp("normal", function() {
							$("#SendFriendEmailBox"+classid).html("");
						});
					});
	
					$(".btnHideFriendEmail2").click(hide_friend_email2);
					$(".btnHideFriendEmail").click(hide_friend_email);
				}  ,
				error: function(data) {
						$("#SendFriendEmailBox"+classid).html("Error");
						$("#SendFriendEmailFrame"+classid).fadeIn("slow");
				}  
			});
		
		};   
	
	
		
		function load_email_friend() {
			$(".SendFriendEmailFrame").fadeOut("fast");
			var eventid = $(this).attr("eventid");
			var classid = $(this).attr("classid");
			var memberid = $(this).attr("memberid");
	
		
			$.get("/include/sendemail.php", { eventid: eventid, classid: classid, memberid: memberid },
						function(data) {
							if (classid == '0') {
								$("#SendFriendEmailBox").html(data);
								$("#SendFriendEmailFrame").slideDown("normal");
							} else {
								$("#SendFriendEmailBox"+classid).html(data);
								$("#SendFriendEmailFrame"+classid).slideDown("normal");
							}
						 $("#SendFriendEmailFrame").css("display","block");
						 
							$(".btnSendEmailFriend").click(send_email_friend);
							$(".btnHideFriendEmail2").click(hide_friend_email2);
							$(".btnHideFriendEmail").click(hide_friend_email);
						}
			);  
		};
	
		$("#btnEmailFriend").click(load_email_friend);
		$(".btnEmailFriend").click(load_email_friend);
		$(".btnHideFriendEmail2").click(hide_friend_email2);
		$(".btnHideFriendEmail").click(hide_friend_email);
		$(".btnSendEmailFriend").click(send_email_friend);
		
	
		//--------------------------------------------
		// SEND EVENT MESSAGES
		//--------------------------------------------
		function hide_event_msg() {
			$("#SendEventMsgFrame").slideUp("fast");
		}
	
		function send_event_msg() {
			$("#SendEventMsgFrame").fadeOut("fast", function() {
				$("#SendEventMsgBox").html(sendingtext);
				$("#SendEventMsgFrame").fadeIn("normal");
			});				
		
			$.ajax({
				type: "POST",
				url: "/include/savemsg.php",
				enctype: 'multipart/form-data',
				data: $("#frmSendMsg").serialize(),
				success: function(data) {
					$("#SendEventMsgFrame").fadeOut("fast", function() {
						$("#SendEventMsgBox").html(data);
						$("#SendEventMsgFrame").fadeIn("slow");
						
						$("#SendEventMsgFrame").animate({opacity: 1.0}, 3000);
						$("#SendEventMsgFrame").slideUp("normal", function() {
							$("#SendEventMsgBox").html("");
						});
					});    
					
					$(".btnHideEventMsg").click(hide_event_msg);
				}  ,
				error: function(data) {
						$("#SendEventMsgBox").html("Error");
						$("#SendEventMsgFrame").fadeIn("slow");
				}  
			});
		
			
		};
	
		function load_event_msg() {
			var eventid = $(this).attr("event");
	
			$.get("/include/sendmsg.php", { id: eventid },
						function(data) {
							$("#SendEventMsgBox").html(data);
							$("#SendEventMsgFrame").slideDown("normal");
							$(".btnHideEventMsg").click(hide_event_msg); // rebind
							$(".btnSaveEventMsg").click(send_event_msg); // rebind
						}
			);    
		};
	
	
		$(".btnHideEventMsg").click(hide_event_msg); // bind
		$(".btnSaveEventMsg").click(send_event_msg); // bind
		$(".btnLoadEventMsg").click(load_event_msg); // bind
		
	
		//----------------------------------------
		// EVENTS
		//----------------------------------------	
		function show_event(){
			var EventID = $(this).attr("event");
			var CatID = $(this).attr("cat");
			var CityID = $(this).attr("city");
			var Source = $(this).attr("src");
			var From = $(this).attr("from");
			
			var eventlink = '<center><div class="ContentHeader">Loading Event Please Wait</div><p><img src="images/loading1.gif" /></p><p>If the event does not load, click <a href="/events.php?id='+EventID+'&cat='+CatID+'&from='+From+'&city='+CityID+'"><i>here</i></a> for a direct link to the event.</center>';
			
			$("#eventscalendarframe").fadeOut('fast', function(){
			$("#ShowEventsFrame").slideUp("fast", function() { $("#ShowEventsFrame").html(""); });
				$("#eventscalendarframe").html(eventlink);
				$("#eventscalendarframe").fadeIn('fast', function() {			
					$.get("/include/loadevent.php", { size: "Large", id: EventID, cat: CatID, city: CityID, src: Source, from: From },
							function(data) {
								$("#eventscalendarframe").html(data);
								$("#eventscalendarframe").fadeIn("normal");
								
								$(".btnHideEventMsg").click(hide_event_msg); // bind
								$(".btnSaveEventMsg").click(send_event_msg); // bind
								$(".btnLoadEventMsg").click(load_event_msg); // bind
								$("#btnEmailFriend").click(load_email_friend);
								$(".lnkShowEvent").click(show_event);
								$(".btnShowReminder").click(show_reminder_form);
								$(".btnFlagItem").click(show_flag_item);
								$(".lnkEventFBLink").click(show_event_facebook);
							}
					);
				});
			});
		};
	
		function jump_event_date() {
			$("#JumpDateFrame").slideDown("normal");		
		};
		function close_event_date() {
			$("#JumpDateFrame").slideUp("fast");		
		};
		
		function select_event_date() {
			var catid = $("#eventscalendarframe").attr("cat");
			var month = $("#cboJumpMonth").attr("value");
			var year = $("#cboJumpYear").attr("value");
			var source = $("#hdnSrcDate").attr("value");
			var cityid = $("#hdnCityID").attr("value");
			window.location = "/events.php?cat="+catid+"&year="+year+"&month="+month+"&src="+source+"&city="+cityid;		
		}
	
	
		function show_event_facebook() {
			var eventid = $(this).attr("eventid");		
			//var fblink = "http://www.shuswapbulletinboard.com/events.php?id="+eventid+"&from=facebook";
	
			//var showdata = '<img src="/images/icons/close.jpg" width="14" height="14" alt="close" class="btnHideEventMsg" align="right" hspace="4" />';
			//showdata = showdata + '<div style="text-align: center; font-size: 12px; line-height: 1.5em;">';
			//showdata = showdata + 'Copy and paste the below link into your favorite Social Media site, to share this<br />event with your friends. (Press CTRL-C to Copy). Change the "from" to match your site.<br />';
			//showdata = showdata + '<input type="text" size="50" maxlength="250" style="width: 90%;" id="txtCopyLink" value="'+fblink+'" /><br />';
			//showdata = showdata + 'Or click on the link below to auto post this event to your Favorite Page.<br />';
			//showdata = showdata + '<a name="fb_share" type="button_count" share_url="http://www.shuswapbulletinboard.com/events.php?id='+eventid+'&from=facebook" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript">/script></div>';
			//showdata = showdata + '<div class="boxClear"></div>';
			
			$.get("/include/socialshare.php", { eventid: eventid, classid: 0}, function(data) {
				$("#SendEventMsgBox").html(data);
				$("#SendEventMsgFrame").slideDown("normal", function() {
					$(".btnHideEventMsg").click(hide_event_msg); // rebind
					$("#txtCopyLink").select();
					$("#txtCopyLink").focus();
				});
			});
		};
	
		function show_class_facebook() {
			var classid = $(this).attr("classid");		
			//var fblink = "http://www.shuswapbulletinboard.com/classifieds.php?id="+classid+"&from=facebook";
			//var showdata = '<img src="/images/icons/close.jpg" width="14" height="14" alt="close" class="btnHideClassMsg" align="right" hspace="4" />';
			//showdata = showdata + '<div style="text-align: center; font-size: 12px; line-height: 1.5em;">';
			//showdata = showdata + 'Copy and paste the below link into your Facebook page, to share<br />this Classified with your friends. (Press CTRL-C to Copy)<br />';
			//showdata = showdata + '<input type="text" size="50" maxlength="250" style="width: 90%;" id="txtCopyLink" value="'+fblink+'" /><br />';
			//showdata = showdata + '<input type="hidden" id="hdnClassID" value="'+classid+'" />';
			//showdata = showdata + 'Or click on the link below to auto post this Classified to your Facebook Page.<br />';
			//showdata = showdata + '<a name="fb_share" type="button_count" share_url="http://www.shuswapbulletinboard.com/classifieds.php?id='+classid+'&from=facebook" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript">///script></div>';
			//showdata = showdata + '<div class="boxClear"></div>';
			
			$.get("/include/socialshare.php", { eventid: 0, classid: classid}, function(data) {
				$("#SendClassMsgBox"+classid).html(data);
				$("#SendClassMsgFrame"+classid).slideDown("normal", function() {
					$(".btnHideClassMsg").click(hide_class_msg); // rebind
					$("#txtCopyLink").select();
					$("#txtCopyLink").focus();
				});
			});
		};
		
		$(".lnkClassFBLink").click(show_class_facebook);
		$(".lnkEventFBLink").click(show_event_facebook);
		$(".btnEventDate").click(select_event_date);
		$(".btnJumpDate").click(jump_event_date);
		$(".btnCloseDate").click(close_event_date);
		$(".lnkShowEvent").click(show_event);
	
		//--------------------------------------------
		// SAVE FLAGGED
		//--------------------------------------------	
		function show_flag_item() {
			var eventid = $(this).attr("eventid");	
			var classid = $(this).attr("classid");	
			var memberid = $(this).attr("memberid");
			var flagtype = $(this).attr("typeid");
			
			$.get("/include/sendflag.php", { eventid: eventid, memberid: memberid, classid: classid, flagtype: flagtype}, function(data) {
				$("#SendFlagBox").html(data);
				$("#SendFlagFrame").slideDown("normal");
				$(".btnHideFlag").click(hide_flag_item);
				$(".btnSaveFlag").click(save_flag_item);
			});
		};
		
		function save_flag_item() {
			
			$.ajax({
				type: "POST",
				url: "/include/saveflag.php",
				enctype: 'multipart/form-data',
				data: $("#frmSendFlag").serialize(),
				success: function(data) {
						$("#SendFlagBox").html(data);
						$("#SendFlagFrame").fadeIn("slow");
						
						$("#SendFlagFrame").animate({opacity: 1.0}, 3000);
						$("#SendFlagFrame").slideUp("normal", function() {
							$("#SendFlagBox").html("");
						});
						
						$(".btnHideFlag").click(hide_flag_item);
				}  ,
				error: function(data) {
						$("#SendFlagBox").html("Error");
						$("#SendFlagFrame").fadeIn("slow");
				}  
			});
		};
		
		function hide_flag_item() { 
			$("#SendFlagFrame").slideUp("fast");
		};
		
		$(".btnFlagItem").click(show_flag_item);
		$(".btnHideFlag").click(hide_flag_item);
		$(".btnSaveFlag").click(save_flag_item);
		
		//--------------------------------------------
		// SEND CLASSIFIED MESSAGE
		//--------------------------------------------	
		function load_class_msg(){
			var cid = $(this).attr("cid");
			var mid = $(this).attr("mid");
	
			$.get("/include/sendmsg.php", { cid: cid, mid: mid },	function(data) {
					$("#SendClassMsgBox"+cid).html(data);
					$("#SendClassMsgFrame"+cid).slideDown("normal");
					
					$(".btnHideClassMsg").click(hide_class_msg);
					$(".btnSaveClassMsg").click(save_class_msg);
				}
			);    
		};  
		
		
		function hide_class_msg(){
			var cid = $("#hdnClassID").attr("value");
			$("#SendClassMsgFrame"+cid).slideUp("fast");		
		};
	
		function save_class_msg(){
			var cid = $("#hdnClassID").attr("value");
			$("#SendClassMsgFrame"+cid).fadeOut("fast");		
		
			$.ajax({
				type: "POST",
				url: "/include/savemsg.php",
				enctype: 'multipart/form-data',
				data: $("#frmSendMsg").serialize(),
				success: function(data) {
						$("#SendClassMsgBox"+cid).html(data);
						$("#SendClassMsgFrame"+cid).fadeIn("slow");
						
						$("#SendClassMsgFrame"+cid).animate({opacity: 1.0}, 3000);
						$("#SendClassMsgFrame"+cid).slideUp("normal", function() {
							$("#SendClassMsgBox"+cid).html("");
						});
						
						$(".btnHideClassMsg").click(hide_class_msg);
				}  ,
				error: function(data) {
						$("#SendClassMsgBox"+cid).html("Error");
						$("#SendClassMsgFrame"+cid).fadeIn("slow");
				}  
			});
		
		};  
		
		$(".btnLoadClassMsg").click(load_class_msg);
		$(".btnHideClassMsg").click(hide_class_msg);
		$(".btnSaveClassMsg").click(save_class_msg);
		
		
		//--------------------------------------------
		// SEND MEMBER MESSAGE
		//--------------------------------------------
		function load_member_msg(){
			$("#SendMemberMsgFrame").slideUp("fast");
			var mid = $(this).attr("mid");
			$.get("/include/sendmsg.php", { id: 0, cid: 0, mid: mid },
						function(data) {
							$("#SendMemberMsgBox").html(data);
							$("#SendMemberMsgFrame").slideDown("normal");
							$(".btnHideMemberMsg").click(hide_member_msg);
							$(".btnSaveMemberMsg").click(save_member_msg);
						}
			);    
		};    
	
	
		function hide_member_msg() {
			$("#SendMemberMsgFrame").slideUp("fast");
		}
	
		
		function save_member_msg(){
			$("#SendMemberMsgFrame").fadeOut("fast", function() {
				$("#SendMemberMsgBox").html(sendingtext);
				$("#SendMemberMsgFrame").fadeIn("normal");
			});		
		
			$.ajax({
				type: "POST",
				url: "/include/savemsg.php",
				enctype: 'multipart/form-data',
				data: $("#frmSendMsg").serialize(),
				success: function(data) {
					$("#SendMemberMsgFrame").fadeOut("fast", function() {
						$("#SendMemberMsgBox").html(data);
						$("#SendMemberMsgFrame").fadeIn("slow");
						
						$("#SendMemberMsgFrame").animate({opacity: 1.0}, 3000);
						$("#SendMemberMsgFrame").slideUp("normal", function() {
							$("#SendMemberMsgBox").html("");
						});
					});
					$(".btnHideMemberMsg").click(hide_member_msg);					
				}  ,
				error: function(data) {
						$("#SendMemberMsgBox").html("Error");
						$("#SendMemberMsgFrame").fadeIn("slow");
				}  
			});
		
		};  
	
		$(".btnLoadMemberMsg").click(load_member_msg);
		$(".btnHideMemberMsg").click(hide_member_msg);
		$(".btnSaveMemberMsg").click(save_member_msg);
	
		//--------------------------------------------
		// MEMBERS AREA
		//--------------------------------------------
		function close_info_msg() {
			$("#InfoMsgFrame").fadeOut("normal", function() {
				$(".InfoMsgBox").html("");																						
			});
		};
		
		$(".lnkUnAppMemInfo").click(function() {
			var closebtn = "<img src='/images/icons/close.png' height='24' width='24' border='0' class='btnCloseInfoMsg' alt='close' align='right' />";
			var infotext = "<div class='Title'>Un-Approved Membership</div><p>Once Events and/or Classifieds are added, they will need a final approval from an Administrator of the Bulletin Board site, before it will be visible to the general public.</p><p>If you are a frequent user, and are interested in obtaining an Approved Message, to be able to skip the step of approval, email the administrators at: admin@shuswapbulletinboard.com</p><p>Violation of the Terms of Agreement for Memberships and postings could result in Approved status being revoked.</p>";
			
			$(".InfoMsgBox").html(closebtn + infotext);
			$("#InfoMsgFrame").fadeIn("normal");
			$(".btnCloseInfoMsg").click(close_info_msg);
		});
		
		$(".lnkAppMemInfo").click(function() {
			var closebtn = "<img src='/images/icons/close.png' height='24' width='24' border='0' class='btnCloseInfoMsg' alt='close' align='right' />";
			var infotext = "<div class='Title'>Approved Membership</div><p>An Approved Member will not require an Administrator of the Bulletin Board site to review newly added Events and/or Classifieds before they are made public.</p><p>This is useful for businesses or other members who add frequent events and other postings.</p><p>Violation of the Terms of Agreement for Memberships and postings could result in Approved status being revoked.</p>";
			
			$(".InfoMsgBox").html(closebtn + infotext);
			$("#InfoMsgFrame").fadeIn("normal");
			$(".btnCloseInfoMsg").click(close_info_msg);
		});
	
		$(".btnCloseInfoMsg").click(close_info_msg);
	
	
	//----------------------------------------------------------------------
		$(".btnSectionUp").click(function() {
			var btnid = $(this).attr("sectid");
			$("#Section"+btnid).slideUp("normal");																		
		});
		$(".btnSectionDown").click(function() {
			var btnid = $(this).attr("sectid");
			$("#Section"+btnid).slideDown("normal");																		
		});
		$(".btnSectionUpAll").click(function() {
			$(".Section").slideUp("normal");
		});
		$(".btnSectionDownAll").click(function() {
			$(".Section").slideDown("normal");
		});
		
		//------------------------------------------------
		// TRACKED MEMBER FUNCTIONS
		//------------------------------------------------
		
		function load_track_member_list() {
			$("#MemberTrackList").fadeOut("fast");
			$(".MemberSmall").css("border-width", "1px");
			$(".MemberSmall").css("border-color", "#CCC");
			var memberid = $(this).attr("memberid");
			
			$.get("/include/tracklist.php", { memberid: memberid },
						function(data) {
							$("#MemberTrackList").html(data);
							$("#MemberTrackList").fadeIn("normal");
							$("#MemberBox"+memberid).css("border-width", "2px");
							$("#MemberBox"+memberid).css("border-color", "#999");
						}
			);		
		};
		
		$(".lnkTrackMemberList").click(load_track_member_list);
		
		//------------------------------------------------
		// SEARCH FUNCTIONS
		//------------------------------------------------
		
		function search_from_menu() {
			var stext = $("#txtBBSearch").attr("value");
			var stype = $("#hdnBBSearchType").attr("value");
			stext = escape(stext);
			
			window.location = "/search.php?f=menu&s="+stext+"&t="+stype+"&from=search";
		};
	
		function load_event_search_results() {
			$("#SearchFrameEvents").animate({opacity: 0.1}, "fast");
			var stext = $(this).attr("s");	
			var stype = $(this).attr("t");
			var spast = $(this).attr("p");
			var scanc = $(this).attr("c");
			var offset = $(this).attr("offset");
			var cityid = $(this).attr("ct");
			
			$.get("/include/searchevents.php", { s: stext, t: stype, p: spast, c: scanc, ct: cityid, offset: offset, from: 'search' },
						function(data) {
							$("#SearchFrameEvents").html(data);
							$("#SearchFrameEvents").animate({opacity: 1.0}, "fast");
							$(".btnSearchNextEv").click(load_event_search_results);
						}
			);    
			
		};
	
		function load_class_search_results() {
			$("#SearchFrameClass").animate({opacity: 0.1}, "fast");
			var stext = $(this).attr("s");	
			var stype = $(this).attr("t");
			var spast = $(this).attr("p");
			var scanc = $(this).attr("c");
			var offset = $(this).attr("offset");
			var cityid = $(this).attr("ct");
			
			$.get("/include/searchclass.php", { s: stext, t: stype, p: spast, c: scanc, ct: cityid, offset: offset, from: 'search' },
						function(data) {
							$("#SearchFrameClass").html(data);
							$("#SearchFrameClass").animate({opacity: 1.0}, "fast");
							$(".btnSearchNextCl").click(load_class_search_results);
						}
			);    		
		};	
	
		function load_news_search_results() {
			$("#SearchFrameNews").animate({opacity: 0.1}, "fast");
			var stext = $(this).attr("s");	
			var stype = $(this).attr("t");
			var spast = $(this).attr("p");
			var scanc = $(this).attr("c");
			var offset = $(this).attr("offset");
			
			$.get("/include/searchnews.php", { s: stext, t: stype, p: spast, c: scanc, offset: offset, from: 'search' },
						function(data) {
							$("#SearchFrameNews").html(data);
							$("#SearchFrameNews").animate({opacity: 1.0}, "fast");
							$(".btnSearchNextNs").click(load_news_search_results);
						}
			);    		
		};		
	
	
		function load_ads_search_results() {
			$("#SearchFrameAds").animate({opacity: 0.1}, "fast");
			var stext = $(this).attr("s");	
			var stype = $(this).attr("t");
			var spast = $(this).attr("p");
			var scanc = $(this).attr("c");
			var offset = $(this).attr("offset");
			
			$.get("/include/searchads.php", { s: stext, t: stype, p: spast, c: scanc, offset: offset, from: 'search' },
						function(data) {
							$("#SearchFrameAds").html(data);
							$("#SearchFrameAds").animate({opacity: 1.0}, "fast");
							$(".btnSearchNextAds").click(load_ads_search_results);
						}
			);    		
		};
	
		function load_help_search_results() {
			$("#SearchFrameHelp").animate({opacity: 0.1}, "fast");
			var stext = $(this).attr("s");	
			var stype = $(this).attr("t");
			var spast = $(this).attr("p");
			var scanc = $(this).attr("c");
			var offset = $(this).attr("offset");
			var cityid = $(this).attr("ct");
			
			$.get("/include/searchhelp.php", { s: stext, t: stype, p: spast, c: scanc, ct: cityid, offset: offset, from: 'search' },
						function(data) {
							$("#SearchFrameHelp").html(data);
							$("#SearchFrameHelp").animate({opacity: 1.0}, "fast");
							$(".btnSearchNextHp").click(load_class_search_results);
						}
			);    		
		};	
	
		function load_gallery_search_results() {
			$("#SearchFrameGallery").animate({opacity: 0.1}, "fast");
			var stext = $(this).attr("s");	
			var stype = $(this).attr("t");
			var spast = $(this).attr("p");
			var scanc = $(this).attr("c");
			var offset = $(this).attr("offset");
			
			$.get("/include/searchgallery.php", { s: stext, t: stype, p: spast, c: scanc, offset: offset, from: 'search' },
						function(data) {
							$("#SearchFrameGallery").html(data);
							$("#SearchFrameGallery").animate({opacity: 1.0}, "fast");
							$(".btnSearchNextGl").click(load_gallery_search_results);
						}
			);    		
		};		
			
		$("#txtBBSearch").keypress(function(e) {
			//alert (e.which);
			if (e.which == 13) {			
				search_from_menu();
			}																			
		});
		
		$(".btnBBSearch").click(search_from_menu);
		$(".btnSearchNextEv").click(load_event_search_results);
		$(".btnSearchNextCl").click(load_class_search_results);
		$(".btnSearchNextHp").click(load_help_search_results);
		$(".btnSearchNextNs").click(load_news_search_results);
		$(".btnSearchNextAds").click(load_news_search_results);
		$(".btnSearchNextGl").click(load_gallery_search_results);
		
		$(".lnkHelpParent").click(function() {
			var category = $(this).attr("id");
			var catid = category.substr(2);
			
			$("#Sub"+catid).slideDown("fast");
		});
		
		
		function load_help_topic() {
			var category = $(this).attr("id");
			var catid = category.substr(2);
			var parent = $(this).attr("parent");
			var parentid = parent.substr(1);
	
			$("#HelpTopicFrame").html(loadingtext);
																							
			$.get("/include/showhelp.php", { cat: catid },  function(data) {
				$("#HelpTopicFrame").fadeOut("fast", function() {
					$("#HelpTopicFrame").html(data);
					$("#HelpTopicFrame").fadeIn("fast");
					$("#Sub"+parentid).slideDown("fast");
					//alert ("Sub"+catid);
					$(".lnkHelpTopic").click(load_help_topic);
				});
			});
		};
	
		function load_help_item() {
			var helpitem = $(this).attr("id");
			var helpid = helpitem.substr(1);
			var category = $(this).attr("cat");
			var catid = category.substr(2);
			
			$("#HelpTopicFrame").html(loadingtext);
	
			$.get("/include/showhelp.php", { id: helpid },  function(data) {
				$("#HelpTopicFrame").fadeOut("fast", function() {
					$("#HelpTopicFrame").html(data);
					$("#HelpTopicFrame").fadeIn("fast");
					$("#Sub"+catid).slideDown("fast");
					//alert ("Sub"+catid);
					$(".lnkHelpTopic").click(load_help_topic);
					$(".lnkHelpItem").click(load_help_item);
				});
			});
		};
	
		function expand_all_help_cat() {
			$(".SubHelpCat").slideDown("fast");
		};
		function contract_all_help_cat() {
			$(".SubHelpCat").slideUp("fast");
		};
		
		$(".lnkHelpTopic").click(load_help_topic);
		$(".lnkHelpItem").click(load_help_item);
		$(".lnkHelpExpandAll").click(expand_all_help_cat);
		$(".lnkHelpContractAll").click(contract_all_help_cat);
		
		
		//=========================================
		// HELP
		//========================================
		function close_bulletin_help() {
			$("#HelpFrame").fadeOut("normal", function() {
				$("#HelpBox").html("");																			 
			});
		};
		function load_bulletin_help() {
			var helpid = $(this).attr("helpid");
			var helptype = $(this).attr("helptype");
			$.get("/include/gethelp.php", { id: helpid, type: helptype },  function(data) {
				$("#HelpBox").html(data);
				$("#HelpFrame").fadeIn("normal");
				$(".btnHelpClose").click(close_bulletin_help);
			});
		}
		
		$(".btnBulletinHelp").click(load_bulletin_help);
		
		//========= REFERRALS ===============//
		
		function submit_referral_form() {
			$("#ReferralFrame").fadeOut("fast");
			
			$.post("/include/postcontact.php",
						 $("#frmcontactus").serialize(),
						 function(data) {
								$("#ReferralForm").html(data);
								$("#ReferralFrame").fadeIn("normal");
								$("#ReferralFrame").animate({opacity: 1.0}, 3000, function() {
									$("#ReferralFrame").fadeOut("fast");
								});
						 }
			);		
		};
		
		function close_referral_form() {
			$("#ReferralFrame").fadeOut("fast");
		};
		function show_referral_form() {
			$.get("/include/referralform.php", { id: 0 },  function(data) {
				$("#ReferralForm").html(data);
				$("#ReferralFrame").fadeIn("normal");
				$(".lnkCloseRefer").click(close_referral_form);
				$(".lnkSubmitRefer").click(submit_referral_form);
			});
			
		};
		$(".lnkAddRefer").click(show_referral_form);
		
		//=============== REMINDERS ==================//
		
		function hide_reminder_form() {
			$("#ReminderFrame").fadeOut("fast");
		};
		
		function save_reminder() {
			$("#ReminderFrame").fadeOut("fast");
			
			$.post("/include/saveremind.php",
						 $("#frmSaveReminder").serialize(),
						 function(data) {
								$("#ReminderForm").html(data);
								$("#ReminderFrame").fadeIn("normal");
								$(".btnHideReminder").click(hide_reminder_form);
								$("#ReminderFrame").animate({opacity: 1.0}, 4000, function() {
									$("#ReminderFrame").fadeOut("fast");
								});
						 }
			);		
		};
	
		function show_reminder_form() {
			var eventid = $(this).attr("eventid");
			$.get("/include/remindme.php", { eventid: eventid },  function(data) {
				$("#ReminderForm").html(data);
				$("#ReminderFrame").fadeIn("normal");
				$(".btnHideReminder").click(hide_reminder_form);
				$(".btnSaveReminder").click(save_reminder);
			});		
		};
		
		$(".btnShowReminder").click(show_reminder_form);
		
		
		/// SEARCH MEMBERS ///
		function search_members() {
			$("#MemberFrame").fadeOut("fast", function() {
				$("#MemberFrame").html(searchingtext);
				$("#MemberFrame").fadeIn("fast", function() {
			
					$.post("/include/membersearch.php",
								 $("#frmMemberSearch").serialize(),
								 function(data) {
										$("#MemberFrame").html(data);
										$("#MemberFrame").fadeIn("normal");
										$(".lnkLoadMember").click(load_member);
								 }
					);
				});
			});			
		}
		
		function load_member() {
			var memberid = $(this).attr("memberid");
			var suser = $("#txtMSUser").attr("value");
			var sname = $("#txtMSName").attr("value");
			var semail = $("#txtMSEmail").attr("value");
			
			window.location = "/member.php?id="+memberid+"&u="+suser+"&n="+sname+"&e="+semail;
			
		}
		
		$(".lnkLoadMember").click(load_member);
		$(".lnkSearchMembers").click(search_members);
		
		//**************** SCROLL EVENTS **************************//
		
		$(".ScrollPageNext").click(function(){
			clearInterval(clientintervalid);		
			$("#lblAutoScroll").fadeOut("normal");
			nextSlide();																 
		});
	
	
		$(".ScrollPagePrev").click(function(){
			clearInterval(clientintervalid);																		 
			$("#lblAutoScroll").fadeOut("normal");
			prevSlide();																 
		});
		
		$(".ScrollPageJump").click(function(){
			clearInterval(clientintervalid);	
			$("#lblAutoScroll").fadeOut("normal");
			var pagenum = $(this).attr("pg");
			slideJump(pagenum);																 
		});	
		
		
		//=================== PRINTING ITEMS ==========================//
		
		$("#chkPrintMap").click(function() {
			var printmap = $(this).attr("value");
			
			$("#EventMapFrame").slideToggle("fast");
				
		});
		$("#chkPrintMember").click(function() {
			var printmap = $(this).attr("value");
			
			$("#EventMemberFrame").slideToggle("fast");
				
		});
		$("#chkPrintDesc").click(function() {
			var printmap = $(this).attr("value");
			
			$("#EventDescFrame").slideToggle("fast");
				
		});
		
		$("#chkPrintGroup").click(function() {
			var printmap = $(this).attr("value");
			
			$("#EventGroupFrame").slideToggle("fast");
				
		});
	
		$("#chkPrintImage").click(function() {
			var printmap = $(this).attr("value");
			
			$("#ClassImageFrame").slideToggle("fast");
				
		});
		
		//******************* POLLS ********************//
		
		function save_poll_vote(){
			var pollid = $(this).attr("pollid");
			//alert(pollid);
			$("#PollBox"+pollid).fadeOut("normal", function() {  
				$.ajax({
					type: "POST",
					url: "/include/savepoll.php",
					enctype: 'multipart/form-data',
					data: $("#frmPoll"+pollid).serialize(),
					success: function(data) {
						$("#PollBox"+pollid).html(data);
						$("#PollBox"+pollid).fadeIn("normal");		
											
						$(".btnSavePoll").click(save_poll_vote);
						$(".btnShowPoll").click(show_poll);
						$(".btnPollResults").click(show_poll_results);
					}  ,
					error: function(data) {
						$("#PollBox"+pollid).html("Error");
						$("#PollBox"+pollid).fadeIn("normal");							
					}  
				});
			});		
		};			

		function show_poll_results(){
			var pollid = $(this).attr("pollid");
			var polllg = $(this).attr("polllg");
			//alert(pollid);
			$("#PollBox"+pollid).fadeOut("normal", function() {  
				$("#PollBox"+pollid).html(loadingtextsm);
				$("#PollBox"+pollid).fadeIn("normal", function() {  
					$.get("/include/pollresults.php", { poll: pollid, large: polllg},  function(data) {
						$("#PollBox"+pollid).fadeOut("normal", function() { 
							$("#PollBox"+pollid).html(data);
							$("#PollBox"+pollid).fadeIn("normal");				
									
							$(".btnSavePoll").click(save_poll_vote);
							$(".btnShowPoll").click(show_poll);
							$(".btnPollResults").click(show_poll_results);
						});
					});
				});
			});		
		};			
		
		function show_poll(){
			var pollid = $(this).attr("pollid");
			var polllg = $(this).attr("polllg");
			//alert(pollid);
			$("#PollFrame"+pollid).fadeOut("normal", function() {  
				$("#PollFrame"+pollid).html(loadingtextsm);
				$("#PollFrame"+pollid).fadeIn("normal", function() {  
					$.get("/include/showpoll.php", { poll: pollid, large: polllg},  function(data) {
						$("#PollFrame"+pollid).fadeOut("normal", function() {  
							$("#PollFrame"+pollid).html(data);
							$("#PollFrame"+pollid).fadeIn("normal");
							
							$(".btnSavePoll").click(save_poll_vote);
							$(".btnShowPoll").click(show_poll);
							$(".btnPollResults").click(show_poll_results);
						});							
					});
				});
			});		
		};			
		
		$(".btnSavePoll").click(save_poll_vote);
		$(".btnShowPoll").click(show_poll);
		$(".btnPollResults").click(show_poll_results);
		
});
	

