	
	
																									//alert("start cftb.js load");
	
	function addAnEvent(el,type,listener,useCapture) {												//usage addAnEvent($('signin'),"click",sign_in,false);
		
		if(typeof el == 'string') {el = document.getElementById(el);}
		
		if(!el){return false;}
		
		if(document.addEventListener) {																// W3C DOM Level 2 Events - used by Mozilla, Opera and Safari
			
			if(!useCapture) {useCapture = false;} else {useCapture = true;}
			el.addEventListener(type,listener,useCapture);
		} else {																					// MS implementation - used by Internet Explorer
			el.attachEvent("on"+type, listener);
		}
	}
	
	
	function removeAnEvent(el,type,listener,useCapture) {
	 
		if(typeof el == 'string') {el = document.getElementById(el);}
		
		if(!el){return false;}
		
		if(document.removeEventListener) {															// W3C DOM Level 2 Events - used by Mozilla, Opera and Safari
			
			if(!useCapture) {useCapture = false;} else {useCapture = true;}
			el.removeEventListener(type,listener,useCapture);
		} else {																					// MS implementation - used by Internet Explorer
			el.detachEvent("on"+type, listener);
		}
	}

	
	function stopIt(ev) {
	
		if (ev.stopPropagation) {
			ev.stopPropagation();
		} else {
			ev.cancelBubble = true;
		}
		
		if (ev.preventDefault) {
			ev.preventDefault();
		} else {
			ev.returnValue = false;
		}
	}		
	
	
	function jVoid(e) {
	
		if (e.target) { 
			thetarget = e.target;
		} else {
			thetarget = e.srcElement;
		}																							//alert("we just clicked on a link with ID " + thetarget.id + ", href of *" + thetarget.href + " and onclick of " + thetarget.onclick);
		stopIt(e);
		return false;
	}


	function inject_js(js_url) {
	
		var s			= document.createElement('SCRIPT');
		s.id			= "pbjs";
		s.type			= "text/javascript";
		s.language		= "javascript";
		s.src			= js_url;
		document.body.appendChild(s);
	}
	

	function setCookie(cookieName,ID) {																//	This function creates a ONE QTR lifetime cookie with the name 
		
		var expire 		= new Date();																//	provided in the "cookieName" parameter and the value provided
		var oneMinute 	= expire.getTime() + (60 * 1000);											//	in the "ID" parameter
		var threeMin 	= expire.getTime() + (3 * 60 * 1000);
		var oneHour 	= expire.getTime() + (60 * 60 * 1000);
		var oneDay 		= expire.getTime() + (24 * 60 * 60 * 1000);
		var oneQTR 		= expire.getTime() + (91 * 24 * 60 * 60 * 1000);
		expire.setTime(oneQTR);
		var exp 		= expire.toGMTString();
		var cookie_str 	= cookieName + "=" + ID + "; expires=" + exp;
		document.cookie	= cookie_str;	
	} 


	function deleteCookie(cookieName) {																//alert('deleting ' + cookieName + ' cookie');
		
		var expire2 	= new Date();																//	in the "ID" parameter
		var dayAgo 	= expire2.getTime() - (24 * 60 * 60 * 1000);
		expire2.setTime(dayAgo);
		var exp2 		= expire2.toGMTString();
		var cookie_str 	= cookieName + "=0; " + "expires=" + exp2;									//alert('cookie_str is ' + cookie_str);
		document.cookie	= cookie_str	;
	} 

	
	function getCookieVal(offset) {																	//	This function returns the value of a cookie when given
		
		var endstr = document.cookie.indexOf(";",offset);											//	it's offset inside the cookie string.  The function
		
		if (endstr == -1) {																			//	getCookie(name) is used to find the offset inside the
			endstr = document.cookie.length;														//	cookie string for a cookie with a given name
		}									
		return unescape(document.cookie.substring(offset,endstr));
	}

	
	function getCookie(name) {																		//	This function returns the offset within the cookie string
		
		var arg 	= name + "=";																	//	for the particular cookie whose name is provided to it.										
		var alen	= arg.length;																	//	In order to get a value from a name, this function AND						
		var clen 	= document.cookie.length;														//	getCookieVal(offset) must be used.
		var i 		= 0;
		
		while (i < clen) {
			var j = i + alen;
			
			if (document.cookie.substring(i,j) == arg)
				return getCookieVal(j);
			i = document.cookie.indexOf(" ", i) + 1;
			
			if (i == 0) break;
		}
		return null;
	}

	
	function submitenter(myfield,e) {																//alert("submitenter");
		
		var keycode;
		
		if (window.event) { 
			keycode = window.event.keyCode;
		} else if (e) { 
			keycode = e.which;
		} else {
			return true;
		}
		
		if (keycode == 13) {
		  
		  if (myfield.form.name=="site_login") {													//alert("site_login form");
			validate();
		  } else {																					//alert("arbitrary form");
			myfield.form.submit();
		  }
		   return false;
		} else {
		   return true;
		}
	}
	
	
	function save_form(form_name) {
	
		inputs_array	= document.forms[form_name].elements;										//alert("the " + form_name + " form has " + inputs_array.length + " elements");
		p_string	= "";
		
		for (i=0; i<inputs_array.length; i++) {
			p_name	= inputs_array[i].name;															
			p_value	= inputs_array[i].value;														
			
			if (p_name=="real_search") { p_value = "0"; }
			
			if (i>0) { p_string += "&"; }
			p_string	+= p_name + "=" + p_value;													
		}
		save_name	= form_name;																	
		setCookie(save_name, p_string);																
	}
	
	
	function fill_form(form_name) {
	
		answer	= getCookie(form_name);																//alert("the answer for a real cookie is *" + answer +"*");
		par_arr	= answer.split("&");																/////WHAT ABOUT the case where there is only ONE form element? - not possible, because every form also has a hidden input with the form name...
		
		for (i=0; i<par_arr.length; i++) {
			p_parts	= par_arr[i].split("=");
			p_name	= p_parts[0];
			p_value	= p_parts[1];
			document.forms[form_name].elements[p_name].value = p_value;
			/// NEED special p_name convention to identify sliders, so that the slider positions can be set here too...
		}
	}
	
	function roundem() {																			//alert("roundem");
	
		var the_boxes		= $('box').getElements('div[class$=rounded]'); 							//alert("got here"); //get all div tags with class 'rounded' ////NOTE this is written in such a way that 'rounded' has to be AT THE END of the class declaration...
	
		for (i=0; i<the_boxes.length; i++) {	
			var the_length 	= the_boxes.length; 													//alert("i is now " + i + " and the_boxes.length is " + the_length);
			var the_box		= the_boxes[i];
			var the_class	= the_box.className;													//alert("the classname name of this box is " + the_class);
			var the_id		= the_box.id;
			var rnd_params	= "";
			var par_list	= "";
			
			if (the_class.indexOf('rnd_')!= -1) {													//alert("we found a rnd_ in the className"); // the rnd box params are specified
				the_classes	= the_class.split(" ");
				
				for (j=0; j<the_classes.length; j++) {												//alert("j is now " + j);
					this_cls	= the_classes[j];													//alert("this_cls = " + this_cls);
					
					if (this_cls.indexOf('rnd_')!= -1) {
			//			rnd_params	= this_cls + "_div";											//alert("the div is named *" + rnd_params + "*");
			//			par_list	= $(rnd_params).getComputedStyle('font-family');	
			//			par_list	= $('rnd_1_div').getComputedStyle('font-family');	
			//			par_list	= "0,15,#d8d8ff,#e8e8e8,#cccccc";
			//			par_list	= "0,15,#d8d8d8,#e8e8e8,#ccccff";
						
						if (this_cls.indexOf('rnd_1')!= -1) {
							par_list	= "0,15,#ffffff,#ffffd0,#aaaaff";							//"0,15,#ffffff,#ffffe8,#ccccff"
						} else if (this_cls.indexOf('rnd_2')!= -1) {
							par_list	= "0,15,#ffffff,#ffffe8,#EB7C33";
						} else if (this_cls.indexOf('rnd_3')!= -1) {
							par_list	= "0,10,#88FF88,#008800,#EB7C33";
						}
					}
				}
			} else {																				//alert("default parameters");
				par_list	= "0,13,#ffffff,#ffffff,#C0C0C0";
			}																						//alert("par_list for the div with id " + the_id + " is " + par_list);
			var box_id		= the_box.id;
			var the_height	= the_box.offsetHeight;													//alert("the the_height of this box is " + the_height);
			var the_width	= the_box.offsetWidth;													//alert("the the_width of this box is " + the_width);
//			var the_index	= the_box.style.zIndex;														alert("the z-index of this box is " + the_index);
//      		var the_pos		= the_box.style.position;
			
			//here we should delete the prior canvas element, if there is one...
			if ($(box_id + "_cn")) {
				var old_cn_box	= $(box_id + "_cn");												//alert("before delete");
				old_cn_box.parentNode.removeChild(old_cn_box);										//alert("after delete");
			}
			
			//this section is for use with google excanvas
			var s = document.createElement('CANVAS');
			the_box.appendChild(s);
			
			if (typeof window.G_vmlCanvasManager!="undefined") { 									//alert("we are emulating canvas"); //a friendlier way to check to see if we're in IE emulating Canvas
				G_vmlCanvasManager.initElement(s);
				s.style.width	= the_width;
				s.style.height	= the_height;
			} else {				
				s.width			= the_width;
				s.height		= the_height;
			}
			s.id 				= box_id + "_cn";													//here we create a new canvas element

/*
			//this section is for use with the mootools canvas library by Olmo Maldonado, <http://ibolmo.com/>
			if (ie) { 																				//alert("we are emulating canvas"); //a friendlier way to check to see if we're in IE emulating Canvas
				var s = new Canvas({
					id: box_id + "_cn",
					width: the_width,
					height: the_height
				});
			} else {
				var s = document.createElement('CANVAS');
			s.id			= box_id + "_cn";														//here we create a new canvas element
			s.width			= the_width;
			s.height		= the_height;
			}
*/

///			s.id				= box_id + "_cn";													//here we create a new canvas element
			s.style.position	= "absolute";
//			s.style.position	= the_pos";
			s.style.top		= "0px";
			s.style.left	= "0px";
			s.style.zIndex	= -1;
//			s.style.zIndex	= the_index -1;
			
///			the_box.appendChild(s);																	//alert("got past the_box.appendChild(s)");
			var ctx				= s.getContext('2d');												//alert("s.getContext");
			par_list		= par_list.replace(/\"/g,'');
			var all_params	= the_width + "," + the_height + "," + par_list;						//alert("all_params for the div with id " + the_id + " is " + all_params);
			roundedRect2(ctx,all_params);
		}
	}

	
	function roundedRect2(ctx,par_list) {															//alert("roundedRect2 - the par_list is: " + par_list);  //par_list: bx_wd,bx_ht,mgn,rd_r,rd_g1,rd_g2,rd_s		//width, height, margin, radius, gradient_color_1, gradient_color_2, stroke_color
																									// what about an opacity parameter?	
		var rnd_params	= par_list.split(',');
					
		x		= parseFloat(0.5 + parseFloat(rnd_params[2]));					//alert("x = " + x);			
		y		= parseFloat(0.5 + parseFloat(rnd_params[2]));					//alert("y = " + y);					
		width	= parseFloat(parseFloat(rnd_params[0])-1-2*parseFloat(rnd_params[2]));		
		height	= parseFloat(parseFloat(rnd_params[1])-1-2*parseFloat(rnd_params[2]));		
		radius	= parseFloat(rnd_params[3]);						
		rd_g1	= rnd_params[4];					//gradient color 1					
		rd_g2	= rnd_params[5];					//gradient color 2					
		rd_s	= rnd_params[6];					//outline stroke					
			
		ctx.lineWidth	= 1;
		
		ctx.beginPath();
		ctx.moveTo(x,y+radius);
		ctx.lineTo(x,y+height-radius);
		ctx.quadraticCurveTo(x,y+height,x+radius,y+height);
		ctx.lineTo(x+width-radius,y+height);
		ctx.quadraticCurveTo(x+width,y+height,x+width,y+height-radius);
		ctx.lineTo(x+width,y+radius);
		ctx.quadraticCurveTo(x+width,y,x+width-radius,y);
		ctx.lineTo(x+radius,y);
		ctx.quadraticCurveTo(x,y,x,y+radius);

		var lingrad = ctx.createLinearGradient(0,0,0,height);										// Create gradient
		lingrad.addColorStop(0, rd_g1);
		lingrad.addColorStop(1, rd_g2);
		
		ctx.fillStyle = lingrad;																	// assign gradient to fill style - or use a solid color? (just using identc
		ctx.strokeStyle = rd_s;																		// assign color to stroke style
		ctx.stroke();
		ctx.fill();
	}
	
	// getPageScroll()
	// Returns array with x,y page scroll values.
	// Core code from - quirksmode.org
	//
	function getPageScroll() {
	
		var yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 				// Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {																	// all other Explorers
			yScroll = document.body.scrollTop;
		}
	
		arrayPageScroll = new Array('',yScroll) 
		return arrayPageScroll;
	}
	
	
	//
	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.org
	// Edit for Firefox by pHaez
	//
	function getPageSize() {
		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 						// all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 																					// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {																		// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 			// Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 																// other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		if (yScroll < windowHeight){																// for small pages with total height less then height of the viewport
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}	
		
		if(xScroll < windowWidth){																	// for small pages with total width less then width of the viewport
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}
	
	
	function shade_it() {
		
		var arrayPageSize = getPageSize();															// this function was loaded with lightbox_cf.js
		var arrayPageScroll = getPageScroll();														// this function was loaded with lightbox_cf.js
		
		$('shade').style.height = (arrayPageSize[1] + 'px');										//alert("shadeObj.style.height is " + shadeObj.style.height + "px"); // set height of Overlay to take up whole page and show
		
		if (arrayPageScroll[1]>0) {
			$('shade').style.height	= (arrayPageSize[1] + arrayPageScroll[1] + 'px');
		}
		
		$('shade').style.display = 'block';
		$('shade').style.visibility = 'visible';
    
    	var opacityChange = new Fx.Morph('shade', { 'duration': 500 });
		opacityChange.start({ 'opacity': 0.8 });
	}
 
	
	function un_shade() {
		
    	var opacityChange = new Fx.Morph('shade', { 'duration': 500 });
		opacityChange.start({ 'opacity': 0.0 });
		
		setTimeout(shade_off,600);
	}
	
	
	function shade_off() {
	
		$('shade').style.visibility = 'hidden';
		$('shade').style.display = 'none';
	}


	var signin_btn	= "Sign In";
	
	
	function sign_in() {																			//alert("sign_in");											
	
		inject_js("js/md5.js");
		
		tgt_ht	= 225;
		tgt_wd	= 400;

		new MUI.Modal({
			id: 'sign-in_box',
			title: 'Sign-in to CharityFusion Donation Toolbars',
			loadMethod: 'xhr',
			contentURL: 'includes/signin.php',
			type: 'modal',
			minimizable:false,
			
			width: tgt_wd,
			height: tgt_ht,
			
			onContentLoaded: function() {
				var currentInstance 	= MochaUI.Windows.instances.get('sign-in_box');				//alert("after currentInstance");
				var contentWrapperEl 	= currentInstance.contentWrapperEl;
				var contentEl 			= currentInstance.contentEl;
				
				if (contentEl.offsetHeight > tgt_ht) {
					contentWrapperEl.setStyle('height', contentEl.offsetHeight+24);					//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
				}
				
				if (contentEl.offsetWidth > tgt_wd) {
					contentWrapperEl.setStyle('width', contentEl.offsetWidth+24);					//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
				}
				currentInstance.drawWindow($('sign-in_box'));											
			}
		});
	}
	
	
	function sign_out() {
	
		sendata	= "logout=now";
		logout	= a_call("includes/access_jacks.php", sendata, spill_it, true, false);
	}
	
	
	function join_sp(e) {																			
	
		inject_js("js/md5.js");
//		new Event(e).stop();																		//alert("after stop");
		
		tgt_ht	= 280;
		tgt_wd	= 600;

		new MUI.Modal({
			id: 'join_box',
			title: 'Apply to Create a Donation Toolbar',
			loadMethod: 'xhr',
			contentURL: 'includes/join.php',
			type: 'modal',
			minimizable:false,
			width: tgt_wd,
			height: tgt_ht,
			
			onContentLoaded: function() {
				var currentInstance 	= MochaUI.Windows.instances.get('join_box');				//alert("after currentInstance");
				var contentWrapperEl 	= currentInstance.contentWrapperEl;
				var contentEl 			= currentInstance.contentEl;
				
				if (contentEl.offsetHeight > tgt_ht) {
					contentWrapperEl.setStyle('height', contentEl.offsetHeight+24);					//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
				}
				
				if (contentEl.offsetWidth > tgt_wd) {
					contentWrapperEl.setStyle('width', contentEl.offsetWidth+24);					//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
				}
				currentInstance.drawWindow($('join_box'));											
			}
		});
	}

	
	function sleep(delay) {
	
		var start = new Date().getTime();
		while (new Date().getTime() < start + delay);
	}	
	
	
	function thanks_delay(delay_msec) {
	
		sleep(delay_msec);
		MochaUI.alert(thanks_msg);
	}
	
	
	//sho_page function - this function allows for simple instantiation of mochaui windows from links, or programmatically in javascript
	//this assumes a link with an id of the form id="theName_lnk" where "includes/theName.php" is the relative address of the file to be loaded
	//optionally the title to the link, if there is one, will be used as the title for the window
	//also optionally, the class for the link, if there is one, can contain the pagebox width and height in the form class="WWWxHHH" where WWW is the width and HHH is the height (in pixels) 
	//
	function sho_page(e) {																			//alert("shopage");										
	
		if (e.target) { 
			thetarget = e.target;
		} else {
			thetarget = e.srcElement;
		}																							//alert("we just clicked on a link with ID " + thetarget.id + ", href of *" + thetarget.href + " and onclick of " + thetarget.onclick);
		
		var lnk_tgt	= false;																		//this section was created with the goal of having onclick sho_page actions for elements that were not anchor tags...
		
		while (!lnk_tgt) {																			// it works great for the contact me! image link on the tutor_profile page :-)
			
			if (thetarget.tagName!="A") {
				thetarget	= thetarget.parentNode;
			} else {
				lnk_tgt	= true;
			}
		}
		
		var tgt_id	= thetarget.id;
		var pg_name	= tgt_id.substring(0,tgt_id.length-4);											//the link id should be of the form xxxxx_lnk or xxxxx_img, where xxxxx is the page name found for this page in the `pages` table
		var aTitle	= thetarget.title;
		var sz_str	= "300x300";

		if (thetarget.className && thetarget.className.indexOf("x") != -1) {
			
			if (thetarget.className.indexOf(" ") != -1) {											//there is at least one space in the class parameter, there are multiple classes!
				var allcstrs = thetarget.className.split(" ");										//alert("multiple classes! - the first class is " + allcstrs[0]);
				
				for (i=0; i<allcstrs.length; i++) {													//alert("this className is " + allcstrs[i]);
					
					if (allcstrs[i].indexOf("x") != -1) {	
						sz_str = allcstrs[i];														//alert("the size className is " + sz_str);
					}
				}
			} else {
				sz_str	= thetarget.className;														//alert("sz_str is now " + sz_str);
			}
			var szParts	= sz_str.split("x");														//alert("after split");
			aWidth	= parseInt(szParts[0]);															//alert("aWidth is now " + aWidth);
			aHeight	= parseInt(szParts[1]);
		} else { 
			aWidth	= 600;
			aHeight	= 400;
		}
		
		if (thetarget.href.indexOf("?")!=-1) {														//alert("there was a query string!");
			url_pts	= thetarget.href.split("?");
			q_pts	= url_pts[1].split("&");														//alert("there was a query string, containing " + q_pts.length + " parameters");
			q_str	= "";
			
			for (i=0; i<q_pts.length; i++) {
				
				if (q_str != "") { q_str += ";"; }
				p_pts	= q_pts[i].split("=");
				q_str += p_pts[0] + ":" + p_pts[1];
			}
			a_query	= "&a_query=" + q_str;															//alert("the a_query fragment is " + a_query);
		} else {
			a_query	= "";
		}
		
		//consider performing an AJAX access here to check for Title and size info from `pages` for pg_name=pg_name... 
		//IF ACCESS IS OF THE FORM url='includes/get_pb_info.php' sendata='pg_name=XXXX' AND THE RESPONSE IS OF THE FORM 'OK title:A Great PageBox Title;width:350;height:250', THEN WE ARE PRETTY SAFE...
		
		new Event(e).stop();
		new MochaUI.Window({
			id: tgt_id + '_box',
			title: aTitle,
			loadMethod: 'xhr',

			contentURL: '../includes/pageboxes.php?tgt=' + tgt_id + a_query,						//////////////////NOTE THIS IS HARD-CODED TO EXPECT *NOT* TO BE IN THE ROOT DIRECTORY...			
/*
			onContentLoaded: function() {															//this actually happens *before* the page morphs into visibility...
				var html_content 		= $(tgt_id + '_box_content').innerHTML;
				var dimensions			= content_size(html_content);
				
				if (dimensions[0]>=10 && dimensions[0]<=1000) {
					autoWidth				= dimensions[0] + 40;										//alert("content width is " + autoWidth);
					autoHeight				= dimensions[1];											//alert("content height is " + autoHeight);
				} else {
					autoWidth				= 675 + 40;
					autoHeight				= 600;
				}
															
				var currentInstance 	= MochaUI.Windows.instances.get(tgt_id + '_box');
				var contentWrapperEl 	= currentInstance.contentWrapperEl;
				var contentEl 			= currentInstance.contentEl;
				
				if (ie) {
					contentWrapperEl.setStyle('height', contentEl.offsetHeight + 40);				//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
				} else {
					contentWrapperEl.setStyle('height', contentEl.offsetHeight);					//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
				}

//				contentWrapperEl.setStyle('width', contentEl.offsetWidth);
				contentWrapperEl.setStyle('width', autoWidth);
				contentWrapperEl.setStyle('height', autoHeight);
//				currentInstance.drawWindow(windowEl);			
				currentInstance.drawWindow($(tgt_id + '_box'));
			},
*/
			minimizable: false,
			maximizable: false,
			resizable: false,

			width: aWidth,
			height: aHeight
		});
	}	

	
	function toggle_div(div_id,off_text,on_text) {													//typically off_text is something like 'more...' and off_text is something like 'less...'
	
		if (document.getElementById(div_id).style.display=="none") {
			document.getElementById(div_id).style.display	= "block";
			link_text	= on_text;
		} else {
			document.getElementById(div_id).style.display	= "none";
			link_text	= off_text;
		}
		
		if (off_text && on_text) {
			return link_text;
		} else {
			return false;
		}
	}
	
	
	function spill_it(xhr_data) {														

		if (xhr_data.indexOf("OK")==-1) {
			alert(xhr_data);																		// responseText did not contain "OK" - throw alert with error message
			return false;
		} else {																					// parse response data for what to do next
			
			if (xhr_data.indexOf("eval(")!=-1) {													// successful remote operation means parameters can be returned in the responseText, as can function calls...
				var params = xhr_data.substr(xhr_data.indexOf("eval(")); 							////// modify the php pages so that the string returned and checked for is NOT the normal "eval(" that might be part of the returned page...	
				eval(params.substr(5));
			} else if (xhr_data.indexOf("data|:")!=-1) {											// for this situation, where list.php is providing a list of files to make a menu, we will use synchronous requests?
				var list_str 	= xhr_data.substr(xhr_data.indexOf("data|:") + 6); 		
				
				if (list_str === "") { list_str = false; }
				return list_str;
			} else {
				return xhr_data;																	// responseText contained "OK" - return response data (to program that called ajax request) for further processing							
			}
		}
	}


	function a_call(url, send_data, callback_function, isAsync, return_xml) {					//alert("a_call - url is "+ url);	// usage: results = a_call(url, send_data, spill_it, isAsync, false); or just results = a_call(url, send_data);

		if (send_data!="") { send_data = encodeURI(send_data); }

		var HR 		= false;															
		
		if (window.XMLHttpRequest) { 				// Mozilla, Safari,...								
			HR = new XMLHttpRequest();													
			
			if (HR.overrideMimeType) {
				HR.overrideMimeType('text/html');	
		   }
		} else if (window.ActiveXObject) { 			// IE
			try {
				HR = new ActiveXObject("Msxml2.XMLHTTP");								
			} catch (e) {
				try {
					HR = new ActiveXObject("Microsoft.XMLHTTP");						
				} catch (e) {}
			}
		}
		
		if (!HR) {
			alert("Unfortunately your browser doesn't support this feature.");
			return false;
		}
		
		if (isAsync) {																				// this section is skipped when the XHR is synchronous, because the readystatechage action is not needed then
			HR.onreadystatechange = function() {	

			  	if (HR.readyState == 4) {															
					
					if (HR.status == 200) {													
						
						if (return_xml) {													
							eval(callback_function(HR.responseXML));						
						} else {															
							eval(callback_function(HR.responseText));						
						}
					} else {
						
						if (HR.status != 0) {
							alert('There was a problem with the request.(Code: ' + HR.status + ')');
						}
					}
				}
			};
		}
		
		if (send_data === "") {																		// no send_data means this is a GET request, where the data is all in a url query string
			HR.open('GET', url, isAsync);												
			HR.send(null);																
		} else {																		
			HR.open('POST', url, isAsync);												
			HR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			HR.send(send_data);															
		}
		
		if (!isAsync) { if (return_xml) { return HR.responseXML; } else { return HR.responseText; } }
	}
	

	function entsub(event,ourform) {
  
		if (event && event.which == 13) {
			ourform.submit();
		} else {
			return true;	
		}
	}
		
	
	var fading	= null;
	
	
	function fade_out(div_id) {																		//MochaUI.notification("fade_out");			
	
		fading	= div_id;
		setTimeout(fade_it,200);
	}
	
	
	function fade_it() {																			//MochaUI.notification("fade_it");
	
    	var opacityChange = new Fx.Morph(fading, { 'duration': 500 });
		opacityChange.start({ 'opacity': 0.0 });
		var reset	= setTimeout(hide_it,600);
	}
	
	
	function hide_it() {
	
		$(fading).style.visibility	= "hidden";
	}

	
	function aa_form(form_element) {								//alert("form_element name is "+ form_element.name);								//the div to be populated with the returned html should be specified in the form 'return_elm' input 
		
		var the_list	= "";																	
		var send_data	= "";
		var result_div	= "";
		var the_action	= form_element.action;
		var the_elmts	= form_element.elements;
		
		if (form_element.cf_password && form_element.salt && form_element.hash) {					//passwords will be hashed & submitted automatically if using the inputs 'cf_password', 'salt' and 'hash'
			inject_js("js/md5.js");
			var the_salt	= form_element.salt.value;
			var pwd_input	= form_element.cf_password.value;
			var pwd_hash	= hex_md5(pwd_input);
			var uid			= this_user;
			var new_hash	= hex_md5(the_salt+pwd_hash+uid); 
			form_element.hash.value			= new_hash;			
			form_element.cf_password.value 	= "sorry, no password here!";
		}
		
		var e_ct		= the_elmts.length;														
		
		for (i=0; i<e_ct; i++) {
			var elmt	= the_elmts[i];
			the_name	= elmt.name;
			
			if (the_name.length > 2 && the_name!="pt1_user_pwd_hash" && the_name!="pt2_user_pwd_hash") {		//create an array of 'never sent' fieldnames and check that list here?
				the_type	= elmt.type;
				
				if (the_type!="checkbox" || elmt.checked) {
		//			the_value	= elmt.value;
					the_value	= encodeURIComponent(elmt.value);
					
					if (send_data!="") { send_data += "&"; }
					send_data += the_name + "=" + the_value;
				}
			}
			
			if (the_list!="") { the_list += ", \n\n"; }
			the_list += "the element named *" + the_name + "* is of type " + the_type + " and has a value of *" + the_value + "*";
		}
///			send_data	= somefunction(send_data); //////NEED A WAY OF URL ENCODING send_data HERE!!
		
		the_list +=	"\n\n the form will be submitted to *" + the_action + "* using AJAX";
		the_list +=	"\n\n send_data is *" + send_data + "*";										//alert(the_list);
		sent = a_call(the_action, send_data, aa_return, true, false);												
	}
	
	
	function aa_return(xhr_data) {		//callback function for aa_form inserts returned text/html content in an element that can be speciifed in the return text/html itself, or inserts it into a MochaUI notification or alert

		if ($("mocha_loading")) {
			MochaUI.closeWindow($("mocha_loading"));
		}
		
		if (xhr_data.indexOf("eval(")!=-1) {													
			var params = xhr_data.substr(xhr_data.indexOf("eval(")); 								////// modify the php pages so that the string returned and checked for is NOT the normal "eval(" that might be part of the returned page...	
			eval(params.substr(5));
		} else if (xhr_data.indexOf("data|:")!=-1) {												// for this situation, where list.php is providing a list of files to make a menu, we will use synchronous requests?
			var list_str 	= xhr_data.substr(xhr_data.indexOf("data|:") + 6); 		

			if (list_str === "") { list_str = false; }
			return list_str;
		} else if (xhr_data.indexOf("return|:")!=-1) {												//alert("return");
			var return_str 	= xhr_data.substr(xhr_data.indexOf("return|:") + 8); 		

			if (return_str === "") { return_str = false; }
			str_pts	= return_str.split(":");
			return_elm	= str_pts[0];
			$(return_elm).innerHTML = return_str.substr(return_elm.length+1);
			rndbox	= setTimeout(roundem,"10");
		} else if (xhr_data.indexOf("notice|:")!=-1) {												//alert("notice");		the string returned from the AJAX page will have the form "notice|:" + the string to be noticed, OR "notice|:" + "wxh:WWWxHHH:" + string	
			var notice_str 	= xhr_data.substr(xhr_data.indexOf("notice|:") + 8); 		

			if (notice_str.substr(0,4)=="wxh:") {
				notice_str 		= notice_str.substr(notice_str.indexOf("wxh:") + 4);				//MochaUI.alert("notice_str is " + notice_str);
				var wxh			= notice_str.substr(0,notice_str.indexOf(":"));						//MochaUI.alert("wxh is " + wxh);
				notice_str 		= notice_str.substr(notice_str.indexOf(":") + 1);					//MochaUI.alert("notice_str is " + notice_str);
				MochaUI.notification(notice_str,wxh);
			} else {
				MochaUI.notification(notice_str);
			}
		} else if (xhr_data.indexOf("alert|:")!=-1) {												//alert("alert");						
			var alert_str 	= xhr_data.substr(xhr_data.indexOf("alert|:") + 7); 		

			if (alert_str.substr(0,4)=="wxh:") {
				alert_str 		= alert_str.substr(alert_str.indexOf("wxh:") + 4);					//MochaUI.alert("alert_str is " + alert_str);
				var wxh			= alert_str.substr(0,alert_str.indexOf(":"));						//MochaUI.alert("wxh is " + wxh);
				alert_str 		= alert_str.substr(alert_str.indexOf(":") + 1);						//MochaUI.alert("alert_str is " + alert_str);
				MochaUI.alert(alert_str,wxh);
			} else {
				MochaUI.alert(alert_str);
			}
		} else if (xhr_data.indexOf("edit|:")!=-1) {												//alert("edit");			//usage: edit|:wxh:WWWxHHH:pos:TTTxLLL:[html code for form] where WWW is width, HHH is height, TTT is top and LLL is left (all in px)
			var wxh	= false;
			var pos	= false;
			var edit_str 	= xhr_data.substr(xhr_data.indexOf("edit|:") + 6); 		

			if (edit_str.substr(0,4)=="wxh:") {
				edit_str 	= edit_str.substr(edit_str.indexOf("wxh:") + 4);						//MochaUI.alert("edit_str is " + edit_str);
				wxh			= edit_str.substr(0,edit_str.indexOf(":"));								//MochaUI.alert("wxh is " + wxh);
				edit_str 	= edit_str.substr(edit_str.indexOf(":") + 1);							//MochaUI.alert("edit_str is " + edit_str);
			}

			if (edit_str.substr(0,4)=="pos:") {
				edit_str 	= edit_str.substr(edit_str.indexOf("pos:") + 4);						//MochaUI.alert("edit_str is " + edit_str);
				pos			= edit_str.substr(0,edit_str.indexOf(":"));								//MochaUI.alert("pos is " + pos);
				edit_str 	= edit_str.substr(edit_str.indexOf(":") + 1);							//MochaUI.alert("edit_str is " + edit_str);
			}
			MochaUI.sp_edit(edit_str,wxh,pos);

/*		//add this later to facilitate multiple separate updates
		} else if (xhr_data.indexOf("update|:")!=-1) {												//alert("update");			//usage: do_updates("elem_id:innerHTML;elem_id:innerHTML;elem_id:innerHTML;elem_id:innerHTML")					
			var update_str 	= xhr_data.substr(xhr_data.indexOf("update|:") + 8); 		
			do_updates(update_str);		
*/		
		} else {
			return xhr_data;																					
		}
	}
	
/*	
	function do_updates(update_list) {																//alert("do_updates - update_list is " + update_list);
	
		var updates_arr	= update_list.split(";");
		var updates_ct	= 0;
		var errors		= "";
		for (i=0; i<updates_arr.length; i++) {
			update_pts	= updates_arr[i].split(":");
			update_id	= update_pts[0];
			update_val	= update_pts[1];
			if ($(update_id)) {
				$(update_id).innerHTML	= update_val;
				updates_ct	+= 1;
			} else {
				MochaUI.alert("There was a problem :-( <br><br>No element was found with ID " + update_id);
				errors		+= "<br>- no element was found with ID " + update_id;
			}
		}
		if (errors=="") {
			MochaUI.notification("Local updates completed successfully!");
		} else {
			MochaUI.alert("Updates were made, but... " + errors);
		}
	}
*/	

	function getStyle(el,styleProp) {

		var x = document.getElementById(el);
		if (x.currentStyle) {
			var y = x.currentStyle[styleProp];
		} else if (window.getComputedStyle) {
			var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
		}
		return y;
	}
	
	
	function findPos(obj) {

		var curleft = curtop = 0;

		if (obj.offsetParent) {

			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		}
		return [curleft,curtop];
	}
	

	function findPos2(obj,refEl) {

		var curleft = curtop = 0;
		
		if (obj.offsetParent) {

			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
				if (obj.offsetParent==refEl) { break; }
			} while (obj = obj.offsetParent);
		}
		return [curleft,curtop];
	}


	function goTo2(subpage,params) {			///NOTE: in this implementation params can start with "&", or not... 	//alert("this would have used AJAX to load the subpage *" + subpage + "*");
	
		if (subpage) {
			get_url		= "includes/sub_pgs/" + subpage + ".php";									//alert("get_url was *" + get_url + "*");
			
			if (params) {
				the_params	= params;
				
				if (the_params.substring(0,1)!="&"){
					the_params	= "&"+ the_params;
				}
			} else {
				the_params	= "";
			}
//			send_data	= "uid="+ this_user +"&tid="+ this_user + the_params; 						//alert("send_data was *" + send_data + "*");
			send_data	= "uid="+ this_user + the_params; 											//alert("send_data was *" + send_data + "*");
			new_sub	= a_call(get_url,send_data,sub_return,true,false);
		}
	}	


	function sub_return(xhr_data) {
	
		if (xhr_data.substring(0,20)=="return|:profile_div:") {
			xhr_data = xhr_data.substring(20);
		}
		$('profile_div').innerHTML	= xhr_data;														//alert("after a_call()");
		rndbox	= setTimeout(roundem,50);
		rndbox2	= setTimeout(roundem,1050);
		goto_sub	= false;
		goto_pars	= "";
	}
	

	function goPost(url_plus_qstr) {
	
		if ($('post_div')) {
			document.body.removeChild($('post_div'));
		}
		
		url_pts			= url_plus_qstr.split("?");
		params			= url_pts[1];																
		par_pairs		= params.split("&");
		
		the_form		= 	'<form name="postit" method="post" action="'+ url_pts[0] +'">';
	
		for (i=0; i<par_pairs.length; i++) {
			pair_pts	= par_pairs[i].split("=");
			p_name		= pair_pts[0];
			p_value		= pair_pts[1];
			the_form	+= '<input type="hidden" name="'+ p_name +'" value="'+ p_value +'">';
		}	
		the_form		+= '</form>';
		d				= document.createElement('DIV');
		d.id			= "post_div";
		d.style.left	= "-2000px";
		d.innerHTML		= the_form;
		document.body.appendChild(d);
		document.postit.submit();
	}


	function content_size(html_content) {															//what about taking formcode and loading into a div element id="edit_size" style="position:absolute; top:20; left:20; z-index:-1; visibility:hidden;"
	
		var d				= document.createElement('DIV');
		d.id				= "content_wxh";
		d.className			= "temp_div";
		d.style.position	= "absolute";
		d.style.top			= "20px";
		d.style.left		= "20px";
		d.style.display		= "block";		
		d.style.visibility	= "hidden";
		d.style.zIndex		= -1;
		d.innerHTML			= html_content;
		document.body.appendChild(d);
		dimensions 			= new Array();
		dimensions[0]		= d.offsetWidth;
		dimensions[1]		= d.offsetHeight;														//alert("width is "+ dimensions[0] +", and height is "+ dimensions[1]);
		
		if (ie) {
//			dimensions[0] = dimensions[0] + 40;
			dimensions[1] = dimensions[1] + 0;
		}
		document.body.removeChild(d);
		return dimensions;
	}
	
	
	
	if (typeof(MochaUI)!="undefined" && typeof(MochaUI)!="unknown" && MochaUI) {
		
		MochaUI.extend({
	
			notification: function(message,wxh){
				
				win_content	= '<table><tr><td width="200" valign="middle" align="center" class="alert" nowrap>' + message + '</td></tr></table>';
				
				if(!wxh || wxh=="auto") {
					the_dims	= content_size(win_content);
					the_width	= the_dims[0] + 24;
					the_height	= the_dims[1] + 20;
				} else {
					size_pts	= wxh.split("x");
					the_width	= parseInt(size_pts[0]);
					the_height	= parseInt(size_pts[1]);
				}
				div_height	= the_height - 20;
				new MochaUI.Window({
					loadMethod: 'html',
					content: win_content,
					type: 'notification',
					addClass: 'notification',
		//			addClass: 'notice_test',
					width: the_width,
					height: the_height,
		//			y: 120,
					padding: { top: 10, right: 12, bottom: 10, left: 12 },
					shadowBlur: 5,
					closeAfter:1500,
					bodyBgColor: [255, 189, 110]
				});
			},
		
			alert: function(message,wxh){
			
				win_content	= '<table><tr><td valign="middle" class="alert" nowrap>' + message + '</td></tr></table>';
				
				if(!wxh || wxh=="auto") {
					the_dims	= content_size(win_content);
					the_width	= the_dims[0] + 24;
					the_height	= the_dims[1] + 20;
				} else {
					size_pts	= wxh.split("x");
					the_width	= parseInt(size_pts[0]);
					the_height	= parseInt(size_pts[1]);
				}
				new MochaUI.Window({
					id: "mocha_alert",
					title: "",
					loadMethod: 'html',
					content: win_content,
					width: the_width,
					height: the_height,
					footerHeight: 10,
					padding: { top: 10, right: 12, bottom: 10, left: 12 },
					shadowBlur: 5,
					statusBar: false,
					scrollbars: false,
					resizable: false,
					maximizable: false,
					minimizable: false,
					collapsible: false,
					contentBgColor: '#FFF',
					headerStartColor:  [255, 189, 110],
					headerStopColor:   [255, 145, 70],
					bodyBgColor: [255, 255, 255]
				});
			},
			
			loading: function(message,wxh){
			
				win_content	= '<table><tr><td width="15">&nbsp;</td><td valign="middle" class="loading_td" nowrap>' + message + '</td></tr></table>';
	
				if(!wxh || wxh=="auto") {
					the_dims	= content_size(win_content);
					the_width	= the_dims[0] + 24;
					the_height	= the_dims[1] + 20;
				} else {
					size_pts	= wxh.split("x");
					the_width	= parseInt(size_pts[0]);
					the_height	= parseInt(size_pts[1]);
				}
	
				new MochaUI.Window({
					id: "mocha_loading",
					title: "",
					loadMethod: 'html',
					content: win_content,
					width: the_width,																
					height: the_height,															
					footerHeight: 10,
					headerHeight: 10,
					padding: { top: 10, right: 12, bottom: 10, left: 12 },
					shadowBlur: 5,
	//				statusBar: false,
					scrollbars: false,
					resizable: false,
					maximizable: false,
					minimizable: false,
					closable:false,
					collapsible: false,
					draggable: true,
					container: document.body,
					contentBgColor: 'transparent',
					headerStartColor:  [255, 189, 110],
					headerStopColor:   [255, 145, 70],
					bodyBgColor: [255, 255, 255]
				});
			},
	
			sp_edit: function(formcode,wxh,pos){
			
				if(!wxh || wxh=="auto") {																//alert("wxh is "+ wxh);
					the_dims	= content_size(formcode);
					the_width	= the_dims[0] + 24 + 40;												//alert("the_width is "+ the_width);
					the_height	= the_dims[1] + 20 + 5;													//alert("the_height is "+ the_height);
				} else {
					size_pts	= wxh.split("x");
					the_width	= parseInt(size_pts[0]);
					the_height	= parseInt(size_pts[1]);												//alert("the_width is " + the_width + " and the_height is " + the_height);
				}
			
				div_height		= the_height - 20;
				if(!pos) {
					the_top		= 300;
					the_left	= 300;
				} else {
					pos_pts		= pos.split("x");														//alert("the window outer width is " + document.window.outerWidth);
					the_top		= parseInt(pos_pts[0]);													//alert("the_top is " + the_top + " and document.html.scrollTop is " + document.html.scrollTop);
					the_top		= parseInt(pos_pts[0]) - document.html.scrollTop;						//alert("the_top after scrollTop subtracted is " + the_top);
					the_left	= parseInt(pos_pts[1]);													//alert("the_left is " + the_left + " and document.html.scrollLeft is " + document.html.scrollLeft);
					the_left	= parseInt(pos_pts[1]) - document.html.scrollLeft;						//alert("the_left after scrollLeft subtracted is " + the_left);
					
					if (the_left + the_width > document.window.outerWidth) { the_left = the_left - the_width; }
				}
				
				
				tgt_wd	= the_width;
				tgt_ht	= the_height;
	
				
				new MochaUI.Window({
					id: "mocha_edit",
					title: '<span style="color:#FFFFFF;">Changes will be implemented immediately</span>',
					loadMethod: 'html',
					content: formcode,
	//				width: the_width,
	//				height: the_height,
					y: the_top,
					x: the_left,
					footerHeight: 10,
					padding: { top: 10, right: 12, bottom: 10, left: 12 },
					shadowBlur: 5,
					statusBar: false,
					scrollbars: false,
					resizable: false,
					maximizable: false,
					minimizable: false,
					collapsible: false,
					width: the_width,
					height: the_height,
					
					onContentLoaded: function() {
						var currentInstance 	= MochaUI.Windows.instances.get('mocha_edit');				
						var contentWrapperEl 	= currentInstance.contentWrapperEl;
						var contentEl 			= currentInstance.contentEl;								
						
						if (contentEl.offsetHeight > tgt_ht) {
							contentWrapperEl.setStyle('height', contentEl.offsetHeight+24);					//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
						}
						
						if (contentEl.offsetWidth > tgt_wd) {
							contentWrapperEl.setStyle('width', contentEl.offsetWidth+24);					//alert("offsetHeight is " + contentEl.offsetHeight + ", offsetWidth is " + contentEl.offsetWidth);
						}
						currentInstance.drawWindow($('mocha_edit'));											
					},				
					
					contentBgColor: '#FFF',
					headerStartColor:  [255, 159, 255],			//want D7D [208, 112, 208]
					headerStopColor:   [208, 112, 208],			//want 939 [144, 48, 144]
					bodyBgColor: [255, 255, 255]
				});
			
			}	
			
		});
	}


	window.addEvent('domready',start_up);															//this uses the addEvent() function from mootools - maybe we should try using *our* addAnEvent() ???
	
//	addAnEvent('window','domready',start_up,false);													//usage addAnEvent($('signin'),"click",sign_in,false);
	
	
	function start_up() {																													
	
		var rndbox	= setTimeout(roundem,"10");														
		var dimit	= setTimeout(un_shade,"100");													

		addAnEvent($('join_lnk'),"click",join_sp,false);											//alert("after signin");// WAS onclick="sign_in(); return false;" >>> NOTE: this event handler is added BEFORE the jVoid event handler <<<

		the_links	= document.getElementsByTagName("a");											// this prevents the default action (i.e. location = href) for any links with rel="j-void", *IF* javascript is working...	
		
		for (i=0; i<the_links.length; i++) {
			var linkObj	= the_links[i];
		
			if (linkObj.rel.indexOf("j-void")!=-1) {
				addAnEvent(linkObj,"click",jVoid,false);
			}
		
			if (linkObj.rel.indexOf("shopage")!=-1) {
				addAnEvent(linkObj,"click",sho_page,false);
			}
		}																								
	}		


