/*  GLOBAL OBJECT TO TRACK OBE STATE  */
// set some global info from PHP
var OBEInfo = {
	OBEBar: {
		expanded: false
		,height_closed: 23
		,height_open: 478
	}
	// set some info about the obe_actions div
	,OBEActionsBar: {
		last_clicked: null
	}
	// set some info about the stats bar
	,OBEStatsBar: {
		last_clicked: null
	}
	// set some info about the user stats detail
	,OBEStatsBarDetail: {
		expanded: false
		,height_closed: 1
		,height_open_1: ((OBE_num_active_satellites*20) + 20)
		,height_open_2: 305
		,current_campaign: null
	}
	// cart stuff
	,OBECart: {
		height_closed: 107
		,height_open: 260
	}
	// content stuff
	,OBEContent: {
		current_content: null
	}
	// form stuff
	,OBEFormElementStuff: {
		select_country: null
		,select_state: null
		,address_p: null
	}
	// page info
	,PageInfo: {
		url: _obe_satellite_this_page_url
	}
	// order stuff
	,OrderInfo: {
		ord_id: null
		,ord_added_string: null
	}
	// user stuff
	,UserInfo: {
		user_id: null
	}
	// login form stuff
	,LoginInfo: {
		login_form: new Object()
	}

	// autologin user stuff
	,AutologinInfo: {
		user_username: null
	}


};
/*  END GLOBAL OBJECT TO TRACK OBE STATE  */
/*  ANIMATION-RELATED FUNCTIONS  */
var OBEBarExpanded = function(){
	OBEInfo.OBEBar.expanded = true;
};
var OBEBarCollapsed = function(){
	OBEInfo.OBEBar.expanded = false;
};
/*  END ANIMATION-RELATED FUNCTIONS  */




/*  GENERIC FUNCTIONS  */
var toggleOBEBar = function(e, cont, act) {
	if( !e.tagName ){
		var e_obj = YAHOO.util.Event.getTarget(e);
	}
	else{
		var e_obj = document.getElementById(e.id);
	}
	// the attributes for the animation
	var attributes = {
	  height: { to: OBEInfo.OBEBar.height_closed }
	};
	// will hold animation object
	var anim = null;
	// the stats to load
	stats_to_load = ( e_obj.id=='obe_action_my_karmas_link' && OBEInfo.UserInfo.user_id ) ? 'stats_user_points' : 'stats_total_members';
	// set the background image properly
	if( OBEInfo.OBEBar.expanded && OBEInfo.OBEActionsBar.last_clicked==e_obj ){
		attributes.height.to = OBEInfo.OBEBar.height_closed;
		anim = new YAHOO.util.Anim('obe_bar', attributes, 0.5, YAHOO.util.Easing.easeOut);
		anim.onComplete.subscribe(OBEBarCollapsed);
		anim.onComplete.subscribe(OBERemoveCurrentContent);
	}
	else if( OBEInfo.OBEBar.expanded ){
		//alert( 'hello...' );
		if( act ){
			OBEContentLoad(cont,act);
		}
		else{
			OBEContentLoad(cont);
		}
		OBELoadStatsBar( stats_to_load );
		OBECollapseStatsDetail();
	}
	else{
		attributes.height.to = OBEInfo.OBEBar.height_open;
		anim = new YAHOO.util.Anim('obe_bar', attributes, 0.5, YAHOO.util.Easing.easeOut);
		anim.onComplete.subscribe(OBEBarExpanded);
		if( act ){
			OBEContentLoad(cont,act);
		}
		else{
			OBEContentLoad(cont);
		}
		OBELoadStatsBar( stats_to_load );
		OBECollapseStatsDetail();
/*
		if( act ){
			anim.onComplete.subscribe(act);
		}
*/
	}
	// store a reference to the last clicked object
	OBEInfo.OBEActionsBar.last_clicked = e_obj;
	toggleSpecialActionButtons( e );
	if( anim!==null ){
		anim.animate();
	}
};
var toggleSpecialActionButtons = function(e){
	var e_obj = YAHOO.util.Event.getTarget(e);
/*
	if( OBEInfo.UserInfo.user_id && (e_obj != document.getElementById('obe_action_view_my_account')) ){
		// set the clicked property for the other like icon
		document.getElementById('obe_action_view_my_account').clicked = false;
		YAHOO.util.Dom.setStyle( 'obe_action_view_my_account', 'backgroundImage', 'url(http://69.56.220.155/_gr/_obe_bar/btn_view_my_account_off.png)' );
	}
	if( e_obj != document.getElementById('obe_action_view_campaigns') ){
		// set the clicked property for the other like icon
		document.getElementById('obe_action_view_campaigns').clicked = false;
		YAHOO.util.Dom.setStyle( 'obe_action_view_campaigns', 'backgroundImage', 'url(http://69.56.220.155/_gr/_obe_bar/btn_view_campaigns_off.png)' );
	}
*/
};
var OBEBarGenericCollapse = function(){
	// animate the close
	var attributes = {
	  height: { to: OBEInfo.OBEBar.height_closed }
	};
	anim = new YAHOO.util.Anim('obe_bar', attributes, 0.5, YAHOO.util.Easing.easeOut);
	anim.onComplete.subscribe(OBEBarCollapsed);
	anim.onComplete.subscribe(OBERemoveCurrentContent);
	anim.animate();
};

/*  END GENERIC FUNCTIONS  */


/*  CONTENT-RELATED FUNCTIONS  */

// get rid of the current content
var OBERemoveCurrentContent = function(){
	// get all the nodes in the content area
	var the_el = document.getElementById('obe_bar_content_holder');
	the_el.innerHTML = '<div></div>'
	return true;
};
// display "loading" progress
var OBEDisplayContentLoading = function(){
	var the_el = document.getElementById('obe_bar_content_holder');
	
	// put a loading panel in the div
	the_el.innerHTML = '<img src="http://69.56.220.155/_gr/_obe_bar/loading.gif" style="position: absolute; left: 350px; top: 174px;" border="0" />';
	//alert( the_el );	
};
// load in the content
var OBEContentLoad = function( cont, act ){
	if( typeof(act)==undefined ){
		act = null;
	}
	// step 1: empty out the content container
	if( OBERemoveCurrentContent() ){
		OBEDisplayContentLoading();
		
		// note the content that is loading
		OBEInfo.OBEContent.current_content = cont;
		// build the URL to the script
		var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php?c=' + cont;
		//alert( the_url );
		// now, load the proper content
		var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandler, argument: act, failure:OBEAjaxFailureHandler });
	}


};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandler = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	//alert( the_contents );
	////var the_contents = root.getElementsByTagName('title')[0].firstChild.nodeValue;
	//var oDateTime = root.getElementsByTagName('lastBuildDate')[0].firstChild.nodeValue;
	//var descriptionNode = root.getElementsByTagName('description')[1].firstChild.nodeValue;
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.appendChild( root );
	the_el.innerHTML = the_contents;
	// if this is the my account section, then we need to handle displaying the cart
	if( OBEInfo.OBEContent.current_content=='product_list' ){
		OBECart.setCheckoutStep( 'product_list' );
		OBEProductListCartRedraw();
	}
	if( o.argument ){
		//alert( o.argument );
		o.argument();
	}
	//SSParseXHTMLNode( root, the_el );
	//div.innerHTML = "<p>" + oTitle + "</p>" + "<p>" + oDateTime + "</p>" + descriptionNode;
}
var OBEAjaxFailureHandler = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	the_el.innerHTML = o.status + " " + o.statusText;
}
// load in the stats bar
var OBELoadStatsBar = function( c ){
	// kw that tells us which stats to retrieve
	//var c = (OBEInfo.OBEActionsBar.last_clicked==document.getElementById('obe_action_view_campaigns')) ? 'stats_total_members' : 'stats_user_points';
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php?c=' + c;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerStats, failure:OBEAjaxFailureHandlerStats });
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerStats = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	var the_el = document.getElementById('obe_bar_stats_holder');
	//alert( the_el );
	the_el.innerHTML = the_contents;

};
var OBEAjaxFailureHandlerStats = function(o){
	var the_el = document.getElementById('obe_bar_stats_holder');
	the_el.innerHTML = o.status + " " + o.statusText;
};
/*  END CONTENT-RELATED FUNCTIONS  */
/*  OBE TEMP CART  */


// THIS OBJECT WILL MAINTAIN THE CART IN JAVASCRIPT UNTIL IT'S TIME TO PASS IT OFF THE THE CORE
// constructor function
var OBETempCart = function(){
	
	// PROPERTIES
	
	// an numbered array of objects
	this.items = new Array();
	// the current subtotal
	this.subtotal = 0;
	// the checkout step
	this.checkout_step = '';
	// the shipping address array
	this.shipping_address = new Object();
	
	// METHODS
	
	// function to add an item to the cart
	this.addItem = OBETCAddItem;
	// function to remove an item from the cart
	this.removeItem = OBETCRemoveItem;
	// function to remove all items from the cart
	this.removeAllItems = OBETCRemoveAllItems;
	// function to return the number of items (rows)
	this.getItemCount = OBETCGetItemCount;
	// function to return the number items array
	this.getItems = OBETCGetItems;
	// calculate the subtotal
	this.getSubtotal = OBETCGetSubtotal;
	// set the checkout step
	this.setCheckoutStep = OBETCSetCheckoutStep;
	// get the checkout step
	this.getCheckoutStep = OBETCGetCheckoutStep;
	// set the shipping address
	this.setShippingAddress = OBETCSetShippingAddress;
	// get the shipping address
	this.getShippingAddress = OBETCGetShippingAddress;
	// gets the items array and shipping data as a one-dimensional object
	this.getOneDimensionalCart = OBETCGetOneDimensionalCart;
	// updates the cart components and totals
	this.updateCart = OBETCUpdateCart;
};
// add an item
var OBETCAddItem = function( itm_id ){
	// will hold the item object
	var item_obj = new Object();
	// look for the proper product
	for( var ky in OBE_available_products ){
		if( OBE_available_products[ky]['item_id']==itm_id ){
			item_obj = OBE_available_products[ky];
			break;
		}
	}
		
	// calculate a new theoretical subtotal
	new_subtotal = this.getSubtotal() + parseInt(item_obj['item_price']);

	// check the price of the object selected and make sure it doesn't push us over
	if( item_obj['item_price']>OBEInfo.UserInfo['user_balance'] || new_subtotal>OBEInfo.UserInfo['user_balance'] ){
		OBEDisplayCartError( 'Error: you do not have enough karmas to redeem for that goodie.' );
	}
	else{
		// search the existing items, and make sure this item doesn't already exist
		var item_exists = false;
		for( var key in this.items ){
			//alert( this.items[key].item_id + '-' + item_obj.item_id );
			if( this.items[key].item_id == item_obj.item_id ){
				item_exists = true;
				// just increment the quantity
				this.items[key].item_quantity++;
				break;
			}
		}
		
		// if the item doesn't exist, we need to add it
		if( !item_exists ){
			item_obj.item_quantity = 1;
			this.items.push( item_obj );
		}	
		// now redraw the cart
		OBECartRedraw();
	}
};
// remove an item
var OBETCRemoveItem = function( num ){
	// dupe the object from the global products object
	//var item_obj = OBE_available_products[num];
	// search the existing items, and make sure this item doesn't already exist
	var item_exists = false;
	for( var key in this.items ){
		if( this.items[key].item_id == num ){
			item_exists = true;
			// just decrement the quantity
			this.items[key].item_quantity--;
			// if the quantity is zero, then remove this item entirely
			if( this.items[key].item_quantity==0 ){
				this.items.splice( key, 1 );
			}
			break;
		}
	}
	// now redraw the cart
	OBECartRedraw();
};
// remove all items
var OBETCRemoveAllItems = function(){
	this.items = new Array();
};
// get the number of items (rows...unique item types)
var OBETCGetItemCount = function(){
	return this.items.length;
};
// get the shipping address
var OBETCGetItems = function(){
	return this.items;
};
// get the subtotal
var OBETCGetSubtotal = function(){
	var sbt = 0;
	var max = 0;
	if( this.items.length>0 ){
		for( var x=0, max=this.items.length; x<max; x++ ){
			sbt = sbt + parseInt((this.items[x].item_quantity * this.items[x].item_price));
		}
	}
	return sbt;
};
// set the checkout step
var OBETCSetCheckoutStep = function( step ){
	this.checkout_step = step;
};
// get the checkout step
var OBETCGetCheckoutStep = function( ){
	return this.checkout_step;
};
// set the shipping address
var OBETCSetShippingAddress = function( ship_addr ){
	this.shipping_address = ship_addr;
};
// get the shipping address
var OBETCGetShippingAddress = function( ){
	return this.shipping_address;
};
// get the cart array as a one-dimensional object
var OBETCGetOneDimensionalCart = function(){
	var max = 0;
	var itms = this.getItems();
	var shpg = this.getShippingAddress();
	var output_obj = new Object();
	var prop = null;

	// LOOP THROUGH THE SHIPPING OBJECT AND ADD ON THE PROPS
	for( prop in shpg ){
		output_obj[prop] = shpg[prop];
	}
	// LOOP THROUGH THE ITEM LIST AND GET EACH OBJECT
	// ADD IT ONTO THE OUTPUT OBJECT as numbered variables
	for( var x=0, max=itms.length; x<max; x++ ){
		for( prop in itms[x] ){
			output_obj[prop+'_'+x] = itms[x][prop];
		}
	}
	// return it
	return output_obj;
};
// function to update totals and other stuff in cart
var OBETCUpdateCart = function(){
	
};
// INSTANTIATE THE CART
OBECart = new OBETempCart();



/*  END OBE TEMP CART  */
/*  GENERIC DOM-RELATED FUNCTIONS  */

// creates and returns a generic element
// designed for simple elements like div or p
// at a minimum, it must be passed an object with a property 'node_type'
var SSDOMCreateElement = function( obj ){
	if( obj.node_type ){
		mn = document.createElement( obj.node_type );

		// loop all properties of obj and add them as attributes
		for( var pr in obj ){
			// handle special ones
			// text node
			if( pr=='text_node' ){
				tn = SSDOMCreateTextNode( obj.text_node );
				mn.appendChild( tn );
			}
			// default, with extra little bit for class
			else{
				mn.setAttribute( pr,obj[pr] );
				if( pr=='className' ){
					mn.setAttribute( 'class',obj[pr] );
				}
			}
		}
		return mn;
	}
	else{
		return null;
	}
};

// creates and returns a text node
var SSDOMCreateTextNode = function( str ){
	tn = null;
	if( str ){
		tn = document.createTextNode( str );
	}
	return tn;
};
/*  GENERIC FUNCTION TO FORMAT NUMBER  */

var SSNumberFormat = function( num ){
	num = '' + num;
	if( num.length > 3 ){
		var mod = num.length % 3;
		var output = (mod > 0) ? num.substring(0,mod) : '';
		for( i=0; i < Math.floor(num.length/3) ; i++ ){
			if( (mod==0) && (i==0) ){
				output += num.substring(mod+3*i,mod+3*i+3);
			}
			else{
				output += ',' + num.substring(mod+3*i,mod+3*i+3);
			}
		}
		return( output );
	}
	else{
		return( num );
	}
};

/*  END GENERIC FUNCTION TO FORMAT NUMBER  */




/*  GENERIC FUNCTION TO EMPTY A NODE  */
var SSEmptyNode = function( the_node ){
	while( the_node.hasChildNodes() ){
		the_node.removeChild(the_node.firstChild);
	}
	return true;
};
/*  END GENERIC FUNCTION TO EMPTY A NODE  */



/*  GENERIC FUNCTION TO WALK XML DOM NODE AND TURN IT INTO XHTML  */
/*
	this is to work around Safari's "DOM Exception 4" complaint when I try to pass valid XHTML from XML directly into the XHTML DOM it directly into the tree
	ASSUMES THE NODE EQUATES TO VALID XHTML...DON'T PASS ARBITRARY XML TO THIS FUNCTION
*/
var SSXMLElementToXHTMLElement = function( obj ){
	var max = 0;
	// handle an element
	if( obj.nodeType==1 ){
		// create an element of that type
		var this_el = document.createElement( obj.nodeName );
		YAHOO.log('node name: '+obj.nodeName, "my_debug");
		// loop all of its attributes
		for (var i = 0, max=obj.attributes.length; i < max; i++) {
			if( obj.attributes[i].name=='class' ){
				this_el.className = obj.attributes[i].value;
			}
			else{
				this_el.setAttribute(obj.attributes[i].name,obj.attributes[i].value);
			}
			//alert(  obj.attributes[i].name + ' - ' + obj.attributes[i].value );
		}
		// now loop the children of this element
		for( i = 0; i < obj.childNodes.length; i++ ){
			this_el.appendChild( SSXMLElementToXHTMLElement( obj.childNodes[i] ) );
		}
		return( this_el );
	}
	// handle a text node
	else if( obj.nodeType==3 ){
		// create a text node
		the_txt = document.createTextNode( obj.nodeValue );
		return( the_txt );
	}
	// handle a comment
	
};

/*  END GENERIC FUNCTION TO WALK XML SELECT AND TURN IT INTO XHTML  */


/*  GENERIC FUNCTION TO SELECT A PARTICULAR OPTION IN A SELECT BASED ON THE VALUE  */
var SSFormSelectElement = function( el, val ){
	var max = 0;
	if( val ){
		for( var x=0, max=el.options.length; x<max; x++ ){
			if( el.options[x].value==val ){
				el.selectedIndex = x;
				break;
			}
		}
	}
	// if no val, select the first element
	else{
		el.selectedIndex = 0;
	}
};

/*  END GENERIC FUNCTION TO SELECT A PARTICULAR OPTION IN A SELECT BASED ON THE VALUE  */




/*  GENERIC FUNCTION TO CHECK EMAIL FORMAT  */
var SSEmailAddressCheck = function( str ){
	var at  ="@";
	var dot = ".";
	var lat = str.indexOf(at);
	var lstr = str.length;
	var ldot = str.indexOf(dot);
	if(str.indexOf(at)==-1){
		return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false;
	}
	if (str.indexOf(at,(lat+1))!=-1){
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1){
		return false;
	}
	if (str.indexOf(" ")!=-1){
		return false;
	}
	return true;				
}
/*  END GENERIC FUNCTION TO CHECK EMAIL FORMAT  */






/*  GENERIC COOKIE FUNCTIONS  */
/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}
/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0){
			return null;
		}
	}
	else{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1){
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}
/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0){
		date.setTime(date.getTime() - skew);
	}
}
/*  END GENERIC COOKIE FUNCTIONS  */


/*  ACTIONS: EDIT ACCOUNT  */
var toggleOBEBarEditAccount = function(e){
	//alert( 'edit account clicked.' );
	toggleOBEBar( e, 'edit_account', OBEBarEditAccountLoadUserData );
	return false;
};
YAHOO.util.Event.addListener("obe_action_text_links_edit_account","click",toggleOBEBarEditAccount);
// get the detailed user data
var OBEBarEditAccountLoadUserData = function(){
	// get the user's info
	var login_qs = '?c=user_info';
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + login_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEBarEditAccountLoadUserDataSuccess, failure:OBEBarEditAccountLoadUserDataFailure });
};
var OBEBarEditAccountLoadUserDataSuccess = function(o){
	var max = 0;
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	// set the username
	if( root.getElementsByTagName('user_username')[0].childNodes[0].nodeValue ){
		document.getElementById('obebar_edit_account_username_highlight').childNodes[0].nodeValue = root.getElementsByTagName('user_username')[0].childNodes[0].nodeValue;
	}
	// define the normal text fields
	var txt_fields = [
		'user_name_first'
		,'user_name_last'
		,'user_city'
		,'user_email'
		,'user_title'
	];
	
	// loop those fields and handle them
	for( var x=0, max=txt_fields.length; x<max; x++ ){
		if( root.getElementsByTagName(txt_fields[x])[0].childNodes.length>0 ){
			if( root.getElementsByTagName(txt_fields[x])[0].childNodes[0].nodeValue ){
				document.getElementById(txt_fields[x]).value = root.getElementsByTagName(txt_fields[x])[0].childNodes[0].nodeValue;
			}
		}
	}
	// set the first name
	document.getElementById('user_name_first').value = root.getElementsByTagName('user_name_first')[0].childNodes[0].nodeValue;
	// set the last name
	document.getElementById('user_name_last').value = root.getElementsByTagName('user_name_last')[0].childNodes[0].nodeValue;
	// set the email
	document.getElementById('user_email').value = root.getElementsByTagName('user_email')[0].childNodes[0].nodeValue;
	// set the city
	document.getElementById('user_city').value = root.getElementsByTagName('user_city')[0].childNodes[0].nodeValue;
	// set the title
	//document.getElementById('user_title').value = root.getElementsByTagName('user_title')[0].childNodes[0].nodeValue;
	// set the country
	// get the options
	var opts = document.getElementById('user_country').options;
	var sel_num = 0;
	var uc = root.getElementsByTagName('user_country')[0].childNodes[0].nodeValue;
	// loop them until we find what we want
	for( var x=0, max=opts.length; x<max; x++ ){
		if( uc==opts[x].value ){
			sel_num = x;
			break;
		}
	}
	// finally, select the right element
	document.getElementById('user_country').selectedIndex = sel_num;
	// handle the checkboxes for mailing list stuff
	document.getElementById('user_intemail').checked = (root.getElementsByTagName('user_intemail')[0].childNodes[0].nodeValue=='y') ? true : false;
	document.getElementById('user_extemail').checked = (root.getElementsByTagName('user_extemail')[0].childNodes[0].nodeValue=='y') ? true : false;
	// assign the keypress event
	YAHOO.util.Event.addListener("obebar_edit_account_form","keyup",OBEBarEditAccountKeypressHandler);
	YAHOO.util.Event.addListener("obebar_edit_account_submit_link","click",OBEBarEditAccountVerifyForm);
	YAHOO.util.Event.addListener("user_change_password","click",OBEBarEditAccountChangePasswordToggle);
};
var OBEBarEditAccountLoadUserDataFailure = function(o){
	//alert( 'could not get user info' );
};
var OBEBarEditAccountKeypressHandler = function(e){
	if( e.keyCode==13 ){
		OBEBarEditAccountVerifyForm();
	}
	return false;
};
// handle the change password checkbox
var OBEBarEditAccountChangePasswordToggle = function(e){
	//alert( 'Please enter your passwords.' );
	document.getElementById('user_password_1').disabled = (e.target.checked) ? false : true;
	document.getElementById('user_password_2').disabled = (e.target.checked) ? false : true;
};
// verify the password form
var OBEBarEditAccountVerifyForm = function(){
	// get ref to the pw field
	var pw_el = document.getElementById('user_password');
	
	if( pw_el.value.length>0 ){
		// create an object to hold the user data
		var user_pw_md5 = hex_md5(pw_el.value)
		// pass it off to the right function
		OBEEditAccountCheckPassword( user_pw_md5 );
	}
	else{
		pw_el.focus();
		alert( 'Please enter your password to complete the changes to your account information.' );
	}
};
// check the password
var OBEEditAccountCheckPassword = function( user_pw_md5 ){
	// build the URL to the script
	var pw_qs = '?user_password=' + user_pw_md5 + '&c=check_password';
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + pw_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerEditAccountCheckPassword, failure:OBEAjaxFailureHandlerEditAccountCheckPassword });
};
// the AJAX succes/failure handlers
var OBEAjaxSuccessHandlerEditAccountCheckPassword = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	
	if( root.getElementsByTagName('obe_status')[0].firstChild.nodeValue=='1' ){
		// continue with handling the form
		OBEBarEditAccountHandler();
	}
	else{
		OBEBarEditAccountDisplayError( root.getElementsByTagName('obe_message')[0].firstChild.nodeValue );
	}
};
var OBEAjaxFailureHandlerEditAccountCheckPassword = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.innerHTML = o.status + " " + o.statusText;
	//alert( o.status + " " + o.statusText );
};
// handle the login form
var OBEBarEditAccountHandler = function(){
	// make sure that all the required information has been entered
	if( document.getElementById('user_name_first').value 
	&& document.getElementById('user_name_last').value
	&& document.getElementById('user_email').value
	&& document.getElementById('user_city').value
	&& document.getElementById('user_country').value ){

		// look for the new passwords
		var change_pw = (document.getElementById('user_change_password').checked==true) ? 'y' : 'n'
		var ok_to_change_pw = false;
		if( change_pw=='y' ){
			if( (document.getElementById('user_password_1').value && document.getElementById('user_password_2').value)
				&& (document.getElementById('user_password_1').value==document.getElementById('user_password_2').value) ){
				ok_to_change_pw = true;
			}
			else{
				OBEBarEditAccountDisplayError('When changing your password, please ensure that you have entered it exactly the same in both fields provided.');
			}
		}
		
		// continue if the password is not involved, or if it is OK.
		if( change_pw=='n' || ok_to_change_pw ){
			var account_info = {
				user_name_first: document.getElementById('user_name_first').value
				,user_name_last: document.getElementById('user_name_last').value
				,user_email: document.getElementById('user_email').value
				,user_city: document.getElementById('user_city').value
				,user_title: document.getElementById('user_title').value
				,user_country: document.getElementById('user_country').options[ document.getElementById('user_country').selectedIndex ].value
			};
			if( ok_to_change_pw ){
				account_info['user_password'] = hex_md5( document.getElementById('user_password_1').value );
			}
			// handle the mailing list checkboxes
			account_info['user_intemail'] = (document.getElementById('user_intemail').checked) ? 'y' : 'n';
			account_info['user_extemail'] = (document.getElementById('user_extemail').checked) ? 'y' : 'n';
			OBEEditAccountSubmit( account_info );
		}
	}
	else{
		OBEBarEditAccountDisplayError( 'Please enter all required information.' );
	}	
};
// display an error
var OBEBarEditAccountDisplayError = function( str ){
	alert( str );
};
// finally edit the account
var OBEEditAccountSubmit = function( info_arr ){
	var login_qs = DP_QueryString.generate( info_arr ) + '&c=edit_account_handler';
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + login_qs;
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerEditAccountSubmit, failure:OBEAjaxFailureHandlerEditAccountSubmit });
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerEditAccountSubmit = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;

	var edit_account_status = root.getElementsByTagName('obe_status')[0].firstChild.nodeValue;

	// if the status is 1, then  go ahead with the login
	if( edit_account_status=='1' ){
		//alert( the_contents );
		OBEBarEditAccountDisplayError( 'Your account information was changed.' );
	}
	else{
		OBEBarEditAccountDisplayError( 'There was a problem editing your account information.  Please try again.' );
	}
}
var OBEAjaxFailureHandlerEditAccountSubmit = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.innerHTML = o.status + " " + o.statusText;
}
/*  END ACTIONS: EDIT ACCOUNT  */

/*  ACTIONS: LOG IN  */
var toggleOBEBarLogin = function(e){
	toggleOBEBar( e, 'log_in', OBEBarLoginAssignEvents );
	return false;
};
YAHOO.util.Event.addListener("obe_action_text_links_log_in","click",toggleOBEBarLogin);
//document.getElementById('obe_action_text_links_log_in').onclick();
var loadLoginFromSatellite = function(){
	dummy_obj = document.createElement('a');
	dummy_obj.setAttribute( 'id','obe_action_text_links_log_in' );
	toggleOBEBarLogin( dummy_obj );
};
// assign events (after content load)
var OBEBarLoginAssignEvents = function(){
	YAHOO.util.Event.addListener("obebar_log_in_box_form","keyup",OBEBarLoginKeypressHandler);
	// add the username to the field
	if( OBEInfo.AutologinInfo.user_username ){
		document.getElementById('user_username').value = OBEInfo.AutologinInfo.user_username;
		// check the checkbox to automatically re-set the cookie
		document.getElementById('user_username_remember').checked = true;
	}
};
// handle a keypress on the form
var OBEBarLoginKeypressHandler = function(e){
	//alert( e.keyCode );
	//OBEBarLoginHandler();
	if( e.keyCode==13 ){
		OBEBarLoginHandler();
	}
	return false;
};
// handle the login form
var OBEBarLoginHandler = function(){
	if( document.getElementById('user_username').value && document.getElementById('user_password').value ){
		var remember_user = (document.getElementById('user_username_remember').checked==true) ? 'y' : 'n'
		var login_info = {
			user_username: document.getElementById('user_username').value
			,user_password: hex_md5( document.getElementById('user_password').value )
			,user_remember: remember_user
		};
		//alert( login_info.user_password );
		OBEUserLogin( login_info );
	}
	else{
		OBEBarLoginDisplayError( 'Please enter both a username and password to log in.' );
	}	
};
// handles the username remember
var OBEBarLoginRememberUsername = function(){
	// CALL THIS FUNCTION ONLY AFTER A SUCCESSFUL LOGIN
	
	// SET A COOKIE WTH THE AUTOLOGIN INFO
	
	//alert( 'user wants to remember username' );
};
// load in the content
var OBEUserLogin = function( login_info ){
	var login_qs = DP_QueryString.generate( login_info ) + '&c=user_login';
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + login_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerLogin, failure:OBEAjaxFailureHandlerLogin });
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerLogin = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;

	var login_status = root.getElementsByTagName('obe_status')[0].firstChild.nodeValue;

	// if the status is 1, then  go ahead with the login
	if( login_status=='1' ){
		// proceed with login
		//alert( 'You are logged in.' );
		// handle the autologin
		if( document.getElementById('user_username_remember').checked==true ){
			OBEBarLoginRememberUsername();
		}
		// reload the page
		var this_page_url = OBEInfo.PageInfo.url;
		var the_date = new Date();
		window.location.href = this_page_url + '?d=' + the_date.valueOf();
		//alert( this_page_url );
	}
	else{
		OBEBarLoginDisplayError( 'The username and password you entered is not recognized.  Please try again.' );
	}
}
var OBEAjaxFailureHandlerLogin = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.innerHTML = o.status + " " + o.statusText;
	OBEBarLoginDisplayError( 'There seems to be a network problem.  Please try again.' );
}
// display an error
var OBEBarLoginDisplayError = function( txt ){
	// get a reference to the cart div
	var outer_div = document.getElementById('obebar_log_in_box_form');
	// get a reference to the title div
	var top_div = document.getElementById('obebar_log_in_box_label_top');
	// create a div
	var the_div = document.createElement( 'div' );
	var the_date = new Date();
	var the_id = 'obebar_product_list_cart_error' + the_date.valueOf();
	the_div.id = the_id;
	the_div.className = 'obebar_login_error';
	// create a p
	var the_p = document.createElement('p');
	the_p.className = 'obebar_login_error';
	// create a text node
	var the_txt = document.createTextNode( txt );
	// append txt to p
	the_p.appendChild( the_txt );
	// append p to div
	the_div.appendChild( the_p );
	// insert the div where we want it (after the title)
	//alert( top_div );
	outer_div.insertBefore(the_div, top_div);
	//top_div.appendChild( the_div );
	// set a timeout that removes it after a number of seconds
	setTimeout( 'OBERemoveNode("'+the_id+'")', 6000 );
};
// removes a node from the tree
var OBERemoveNode = function( the_id ){
	// try to get a ref to the error
	if( div_to_remove = document.getElementById( the_id ) ){
		div_to_remove.parentNode.removeChild( div_to_remove );
	}
}
/*  FORGOT PASSWORD STUFF  */
// shows the change password form
var OBEBarLoginShowChangePassword = function(){
	// get the login form
	OBEInfo.LoginInfo.login_form = document.getElementById( 'obebar_log_in_box_form' );
	// get the enclosing div
	var login_form_div = document.getElementById( 'obebar_log_in_box' );
	SSEmptyNode( login_form_div );
	OBEBarLoginAppendForgotPasswordForm( login_form_div );
	//alert( OBEInfo.LoginInfo.login_form );
};
// adds the forgot password form to an element
var OBEBarLoginAppendForgotPasswordForm = function( el ){
	// create a form element
	fp_form = document.createElement( 'form' );
	fp_form.setAttribute( 'class','obebar_log_in_box' );
	fp_form.setAttribute( 'id','obebar_log_in_box_form' );
	fp_form.onsubmit = function(){
		return false;
	};
	// create a p element for instructions
	fp_instr = document.createElement( 'p' );
	fp_instr.setAttribute( 'class','obebar_log_in_forgot_password_instructions' );
	fp_instr.setAttribute( 'id','obebar_log_in_box_label_top' );
	fp_instr_txt = document.createTextNode( 'If you have forgotten your login information, enter your email address below and we will reset your password and email it to you.' );
	fp_instr.appendChild( fp_instr_txt );
	fp_form.appendChild( fp_instr );
	// create an input for email address
	fp_ea_lbl = document.createElement( 'p' );
	fp_ea_lbl.setAttribute( 'class','obebar_log_in_box_label' );
	fp_ea_lbl_txt = document.createTextNode( 'Email address' );
	fp_ea_lbl.appendChild( fp_ea_lbl_txt );
	fp_form.appendChild( fp_ea_lbl );
	fp_ea_div = document.createElement( 'div' );
	fp_ea_div.setAttribute( 'class','obebar_log_in_box_field' );
	fp_ea_fld = document.createElement( 'input' );
	fp_ea_fld.setAttribute( 'type','text' );
	fp_ea_fld.setAttribute( 'class','obebar_log_in_box_field' );
	fp_ea_fld.setAttribute( 'id','user_email' );
	fp_ea_fld.setAttribute( 'name','user_email' );
	fp_ea_div.appendChild( fp_ea_fld );
	fp_form.appendChild( fp_ea_div );
	// create back to sign in form link
	fp_back_div = document.createElement( 'div' );
	fp_back_div.setAttribute( 'class','obebar_log_in_box_change_password_link' );
	fp_back_a = document.createElement( 'a' );
	fp_back_a.setAttribute( 'href','#' );
	fp_back_a.onclick = function(){
		OBEBarLoginRestoreForm();
	};
	fp_back_txt = document.createTextNode( 'Back to log in form' );
	fp_back_a.appendChild( fp_back_txt );
	fp_back_div.appendChild( fp_back_a );
	fp_form.appendChild( fp_back_div );
	// create submit arrow link
	fp_sa_div = document.createElement( 'div' );
	fp_sa_div.setAttribute( 'class','obebar_log_in_arrow_link' );
	fp_sa_div.onclick = function(){
		//alert( 'hello' );
		OBEBarLoginChangePasswordHandler();
		return false;
	};
	fp_sa_p = document.createElement( 'p' );
	fp_sa_p.setAttribute( 'class','obebar_log_in_arrow_link' );
	fp_sa_a = document.createElement( 'a' );
	fp_sa_a.setAttribute( 'class','obebar_log_in_arrow_link' );
	fp_sa_a.setAttribute( 'title','Submit' );
	fp_sa_a.setAttribute( 'href','#' );
	fp_sa_txt = document.createTextNode( 'Submit' );
	fp_sa_a.appendChild( fp_sa_txt );
	fp_sa_p.appendChild( fp_sa_a );
	var fp_sa_img = SSDOMCreateElement( { 
		node_type:'img'
		,className:'obebar_link_arrow'
		,src:'http://69.56.220.155/_gr/_obe_bar/right_arrow.png'
	} );
	fp_sa_p.appendChild( fp_sa_img );
	fp_sa_div.appendChild( fp_sa_p );
	fp_form.appendChild( fp_sa_div );
	// append form to main element
	el.appendChild( fp_form );
	// assign events so that return key submits form
	OBEBarLoginForgotPasswordAssignEvents();
};
// assign events (after content load)
var OBEBarLoginForgotPasswordAssignEvents = function(){
	YAHOO.util.Event.addListener("obebar_log_in_box","keyup",OBEBarLoginForgotPasswordKeypressHandler);
};
// handle a keypress on the form
var OBEBarLoginForgotPasswordKeypressHandler = function(e){
	//alert( e.keyCode );
	//OBEBarLoginHandler();
	if( e.keyCode==13 ){
		OBEBarLoginChangePasswordHandler();
	}
	return false;
};
// handles the change password form
var OBEBarLoginChangePasswordHandler = function(){
	//alert( 'handling form' );
	// first, make sure something resembling an email address has been entered
	if( document.getElementById('user_email').value ){
		var user_info = {
			user_email: document.getElementById('user_email').value
		};
		//alert( document.getElementById('user_email').value );
		OBEBarLoginLookupUser( user_info );
	}
	else{
		//alert( 'displaying error');
		OBEBarLoginDisplayError( 'Please enter your email address.' );
	}
};
// restores the login form
var OBEBarLoginRestoreForm = function( ){
	var login_form_div = document.getElementById( 'obebar_log_in_box' );
	//alert( 'restoring form' );
	SSEmptyNode( login_form_div );
	login_form_div.appendChild( OBEInfo.LoginInfo.login_form );
	return true;
};
// look for the user based on email address
var OBEBarLoginLookupUser = function( user_info ){
	var login_qs = DP_QueryString.generate( user_info ) + '&c=lookup_user';
	//alert( login_qs );
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + login_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBELoginLookupUserSuccessHandlerLogin, failure:OBEAjaxFailureHandlerLogin });
};
// the AJAX succes/failure handlers for the main content load
var OBELoginLookupUserSuccessHandlerLogin = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	//alert( the_contents );
	var login_status = root.getElementsByTagName('obe_status')[0].firstChild.nodeValue;

	// if the status is 1, then  go ahead with the login
	if( login_status=='1' ){
		var user_info = {
			user_id: root.getElementsByTagName('user_id')[0].firstChild.nodeValue
			,user_email: root.getElementsByTagName('user_email')[0].firstChild.nodeValue
			,user_username: root.getElementsByTagName('user_username')[0].firstChild.nodeValue
		};
		OBEBarLoginExecuteChangePassword( user_info );
	}
	else{
		OBEBarLoginDisplayError( 'The email address you entered does not match a user in our database.  Please try again.' );
	}
};
// finally, execute the user's change password request
var OBEBarLoginExecuteChangePassword = function( user_info ){
	var login_qs = DP_QueryString.generate( user_info ) + '&c=reset_password';
	//alert( login_qs );
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + login_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEBarLoginExecuteChangePasswordSuccessHandler, failure:OBEAjaxFailureHandlerLogin });
};
// the AJAX succes/failure handlers for the main content load
var OBEBarLoginExecuteChangePasswordSuccessHandler = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	//alert( the_contents );
	var login_status = root.getElementsByTagName('obe_status')[0].firstChild.nodeValue;

	// if the status is 1, then  go ahead with the login
	if( login_status=='1' ){
		if( OBEBarLoginRestoreForm() ){
			OBEBarLoginDisplayError( 'We have reset your password.  Your username and password have been emailed to the address you specified.' );
		}
	}
	else{
		OBEBarLoginDisplayError( 'There has been a problem resetting the password.  Please try again.' );
	}
};
/*  END FORGOT PASSWORD STUFF  */
/*  END ACTIONS: LOG IN  */

/*  ACTIONS: LOG OUT  */
// handle the logout request
// the heavy lifting will really be done in the proxy script
var OBEUserLogout = function( login_info ){

	var login_qs = '?c=user_logout';
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + login_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerLogout, failure:OBEAjaxFailureHandlerLogout });
};
YAHOO.util.Event.addListener("obe_action_text_links_log_out","click",OBEUserLogout);
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerLogout = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	//alert( the_contents );
	var logout_status = root.getElementsByTagName('obe_status')[0].firstChild.nodeValue;

	// if the status is 1, then  go ahead with the login
	if( logout_status=='1' ){
		// reload the page
		var this_page_url = OBEInfo.PageInfo.url;
		var the_date = new Date();
		window.location.href = this_page_url + '?d=' + the_date.valueOf();
		//alert( this_page_url );
	}
	else{
		alert( 'Logout failed.  Please try again.' );
	}
}
var OBEAjaxFailureHandlerLogout = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.innerHTML = o.status + " " + o.statusText;
}
/*  END ACTIONS: LOG OUT  */

/*  ACTIONS: OBE LOGO  */
var toggleOBEBarAbout = function(e){
	toggleOBEBar( e, 'about' );
};
var rolloverAbout = function(e){
	var e_obj = YAHOO.util.Event.getTarget(e);
	switch( e.type ){
		case 'mouseover':
			YAHOO.util.Dom.setStyle( e_obj,'cursor','pointer' );
			break;
		default:
	}
};
YAHOO.util.Event.addListener("obe_action_logo","click",toggleOBEBarAbout);
YAHOO.util.Event.addListener("obe_action_logo","mouseover",rolloverAbout);
//YAHOO.util.Event.addListener("obe_action_logo","mouseout",rolloverAbout);
/*  END ACTIONS: OBE LOGO  */

/*  DISPLAY THE CART PAGE  */

// master function
var OBECheckoutCartRedraw = function(){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_checkout_cart_holder');
	if( SSEmptyNode( cart_div ) ){
		OBECheckoutCartPopulate();
	}
};
var OBECheckoutDisplayCart = function(){
	// set the cart step
	OBECart.setCheckoutStep( 'checkout_cart' );
	// get ref to main div
	var holder_div = document.getElementById('obe_bar_content_holder');
	// empty the holder
	if( SSEmptyNode( holder_div ) ){
		OBECheckoutAddGenericElements( holder_div, OBE_checkout_settings.checkout_process_headline_step_1 );
		// add the subbheader
		var subh_div = SSDOMCreateElement( { 
			node_type:'div'
			,className:'obebar_cart_subheader'
			,text_node:OBE_checkout_settings.checkout_process_subheader_step_1 
		} );
		// add it onto the holder
		holder_div.appendChild( subh_div );
		// add on a div to hold the cart
		var cart_hldr = SSDOMCreateElement( { 
			node_type:'div'
			,className:'obebar_checkout_cart_holder'
			,id:'obebar_checkout_cart_holder' 
		} );

		holder_div.appendChild( cart_hldr );

		// add on the link for continuing
		var link_div = SSDOMCreateElement( { 
			node_type:'div'
			,className:'obebar_cart_link_continue'
			,id:'obebar_cart_link_continue' 
		} );
		// the 'continue checkout' bit
		var cont_p = SSDOMCreateElement( { 
			node_type:'p'
			,className:'obebar_cart_link_header'
			,text_node:'Continue checkout' 
		} );
		link_div.appendChild( cont_p );
		// the "enter shipping information" bit
		var ship_link_p = SSDOMCreateElement( { 
			node_type:'p'
			,className:'obebar_cart_link_link'
		} );
		ship_link_p.onclick = function(){
			OBECheckoutDisplay( 'checkout_shipping' );
		};

		var ship_link_a = SSDOMCreateElement( { 
			node_type:'a'
			,className:'obebar_cart_link_link'
			,href:'#'
			,text_node:'Enter shipping information'
		} );
		ship_link_a.onclick = function(){
			return false;
		};
		ship_link_p.appendChild( ship_link_a );

		var ship_link_arrow = SSDOMCreateElement( { 
			node_type:'img'
			,className:'obebar_link_arrow_right'
			,src:'http://69.56.220.155/_gr/_obe_bar/right_arrow.png'
		} );
		ship_link_p.appendChild( ship_link_arrow );
		link_div.appendChild( ship_link_p );
		holder_div.appendChild( link_div );
		OBECartRedraw();
	}
};
// adds the cart itself to the cart page
var OBECheckoutCartPopulate = function(){
	// set up the title text
	var ttl_txt = (OBECart.getItemCount()>0) ? 'Your cart contains:' : 'Your cart is empty';
	// get a reference to the cart holder div
	cart_hldr = document.getElementById( 'obebar_checkout_cart_holder' );
	// add the top text
	var cart_hdr = SSDOMCreateElement( { 
		node_type:'div'
		,className:'obebar_checkout_cart_title'
		,id:'obebar_checkout_cart_title'
	} );

	var cart_hdr_p = SSDOMCreateElement( { 
		node_type:'p'
		,className:'obebar_checkout_cart_title'
		,text_node:ttl_txt
	} );

	cart_hdr.appendChild( cart_hdr_p );
	cart_hldr.appendChild( cart_hdr );

	// add on the cart itself
	if( OBECart.getItemCount()>0 ){
		cart_hldr.appendChild( OBECheckoutCartPopulateData() );
	}
	else{
		// add on a link to return to the product list
		var pl_div = SSDOMCreateElement( { 
			node_type:'div'
			,className:'obebar_checkout_cart_pl_link'
		} );
		pl_div.onclick = function(){
			OBEContentLoad( 'product_list' );
			return false;
		};
		var pl_img = SSDOMCreateElement( { 
			node_type:'img'
			,className:'obebar_link_arrow_left'
			,src:'http://69.56.220.155/_gr/_obe_bar/left_arrow.png'
		} );
		pl_div.appendChild( pl_img );
		var pl_a = SSDOMCreateElement( { 
			node_type:'a'
			,className:'obebar_checkout_cart_pl_link'
			,href:'#'
			,text_node:'Return to the goodie list'
		} );
		pl_a.onclick = function(){
			return false;
		};
		pl_div.appendChild( pl_a );
		cart_hldr.appendChild( pl_div );
		// hide the link to the next step
		document.getElementById( 'obebar_cart_link_continue' ).style.visibility = 'hidden';
	}
	// return the holder
	return cart_hldr;
};
// populate a full cart
var OBECheckoutCartPopulateData = function(){
	var max = 0;
	// create a div
	var the_div = SSDOMCreateElement( { 
		node_type:'div'
		,className:'obebar_checkout_cart_data'
		,id:'obebar_checkout_cart_data'
	} );
	// create a table
	var the_table = SSDOMCreateElement( { 
		node_type:'table'
		,className:'obebar_checkout_cart_data'
		,cellpadding:'0'
		,cellspacing:'0'
	} );
	// create the tbody
	var the_tbody = SSDOMCreateElement( { 
		node_type:'tbody'
	} );
	// create the tr
	var the_tr = SSDOMCreateElement( { 
		node_type:'tr'
	} );
	// create the heading tds and add them to the tbody
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_header_item','obebar_checkout_cart_heading','Item',false) );
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_header_quantity','obebar_checkout_cart_heading','Qty.',false) );
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_header_points','obebar_checkout_cart_heading','Karmas',false) );
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_header_subtotal','obebar_checkout_cart_heading','Subtotal',false) );
	// add the tr onto the tbody
	the_tbody.appendChild( the_tr );
	// add the tbody onto the table
	the_table.appendChild( the_tbody );
	// add the table onto the div
	the_div.appendChild( the_table );
	
	// loop through the items and display them
	for( var x=0, max=OBECart.items.length; x<max; x++ ){

		// create a table
		var the_table = SSDOMCreateElement( { 
			node_type:'table'
			,className:'obebar_checkout_cart_data'
			,cellpadding:'0'
			,cellspacing:'0'
		} );
		// create the tbody
		var the_tbody = SSDOMCreateElement( { 
			node_type:'tbody'
		} );
		// create the tr
		var the_tr = SSDOMCreateElement( { 
			node_type:'tr'
		} );
		// set up the subtotal
		var this_subtotal = OBECart.items[x]['item_quantity'] * OBECart.items[x]['item_price'];
		this_subtotal = SSNumberFormat( this_subtotal );
		var this_price = SSNumberFormat( OBECart.items[x]['item_price'] );
		// create the data tds and add them to the tbody
		// the image
		var img_td = SSDOMCreateElement( { 
			node_type:'td'
			,className:'obebar_checkout_cart_image'
		} );
		var img_el = SSDOMCreateElement( { 
			node_type:'img'
			,className:'obebar_checkout_cart_image'
			,src:'http://69.56.220.155/_keepout/products/' + OBECart.items[x]['item_id'] + '/gr/prod_image_40x40.jpg'
		} );
		img_td.appendChild( img_el );
		the_tr.appendChild( img_td );
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_item','obebar_checkout_cart_data',OBECart.items[x]['item_title_text'],false) );
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_quantity','obebar_checkout_cart_data',OBECart.items[x]['item_quantity'],false) );
		// the quantity buttons
		var img_td = SSDOMCreateElement( { 
			node_type:'td'
			,className:'obebar_checkout_cart_quantity_buttons'
		} );
		var img_el = SSDOMCreateElement( { 
			node_type:'img'
			,className:'obebar_checkout_cart_quantity_buttons'
			,id:'btncartadd_' + OBECart.items[x]['item_id']
			,src:'http://69.56.220.155/_gr/_obe_bar/btn_cart_add.png'
		} );
		img_el.onclick = function( ){
			// get the value
			var itm_id = this.id.split('_')[1];
			OBECart.addItem( itm_id );
		};
		img_td.appendChild( img_el );
		var img_el = SSDOMCreateElement( { 
			node_type:'img'
			,className:'obebar_checkout_cart_quantity_buttons'
			,id:'btncartsubtract_' + OBECart.items[x]['item_id']
			,src:'http://69.56.220.155/_gr/_obe_bar/btn_cart_subtract.png'
		} );
		img_el.onclick = function( ){
			// get the value
			var itm_id = this.id.split('_')[1];
			OBECart.removeItem( itm_id );
		};
		img_td.appendChild( img_el );
		the_tr.appendChild( img_td );
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_points','obebar_checkout_cart_data',this_price,false) );
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_checkout_cart_subtotal','obebar_checkout_cart_data',this_subtotal,false) );
		// add the tr onto the tbody
		the_tbody.appendChild( the_tr );
		// add the tbody onto the table
		the_table.appendChild( the_tbody );
		// add the table onto the div
		the_div.appendChild( the_table );
	
	}
	
	// create the total points div
	var ttl_div = SSDOMCreateElement( { 
		node_type:'div'
		,className:'obebar_checkout_cart_total'
	} );
	// create a p to hold the text
	var the_p = SSDOMCreateElement( { 
		node_type:'p'
		,className:'obebar_checkout_cart_total'
		,text_node:'Total karmas: ' + SSNumberFormat( OBECart.getSubtotal() )
	} );
	// apend the p to the div
	ttl_div.appendChild( the_p );
	the_div.appendChild( ttl_div );
	
	// return the div
	return the_div;
};
// create a td for the table
var OBECheckoutCartPopulateDataTD = function( td_cls, p_cls, txt, del_img ){
	// create a td for the item
	var the_td = SSDOMCreateElement( { 
		node_type:'td'
		,className:td_cls
	} );
	// create a p
	var the_p = SSDOMCreateElement( { 
		node_type:'p'
		,className:p_cls
		,text_node:txt
	} );
	// append p to div
	the_td.appendChild( the_p );
/*
	if( del_img ){
		// create an image element
		var the_img = document.createElement( 'img' );
		the_img.src = 'http://69.56.220.155/_gr/_obe_bar/btn_cart_delete.png';
		the_img.className = 'obebar_product_list_cart_data_delete_img';
		the_img.onclick = function(){
			alert( 'delete' );
		};
		// append the img onto the p
		the_td.appendChild( the_img );
	}
*/
	// return the div
	return the_td;
};
// display an error
var OBECheckoutCartDisplayError = function( txt ){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_checkout_cart_holder');
	// get a reference to the title div
	var ttl_div = document.getElementById('obebar_checkout_cart_title');
	// set up the title text
	var ttl_txt = (OBECart.getItemCount()>0) ? 'Your cart contains:' : 'Your cart is empty';
	// create a div
	var the_date = new Date();
	var the_div = SSDOMCreateElement( { 
		node_type:'div'
		,className:'obebar_checkout_cart_error'
		,id:'obebar_checkout_cart_error' + the_date.valueOf()
	} );
	// create a p
	var the_p = SSDOMCreateElement( { 
		node_type:'p'
		,className:'obebar_checkout_cart_error'
		,text_node:txt
	} );
	// append p to div
	the_div.appendChild( the_p );
	// insert the div where we want it (after the title)
	cart_div.insertBefore(the_div, ttl_div.nextSibling);
	// set a timeout that removes it after a number of seconds
	setTimeout( 'OBECheckoutCartRemoveError("'+the_class_name+'")', 6000 );
};
// remove the error (after a small amount of time, we want the error to just disappear)
var OBECheckoutCartRemoveError = function( the_id ){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_checkout_cart_holder');
	// try to get a ref to the error
	if( error_div = document.getElementById( the_id ) ){
		cart_div.removeChild( error_div );
	}
}
/*  END DISPLAY THE CART PAGE  */

/*  DISPLAY THE CONFIRM PAGE  */

// load in the states and countries data
var OBECheckoutDisplayConfirm = function(){
	//alert( 'display confirm...' );
	//OBECheckoutDisplayConfirmStatic();
	OBEDisplayContentLoading();
	// build the URL to the script
	var shipping_qs = DP_QueryString.generate( OBE_user_shipping_data ) + '&c=address_format';
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + shipping_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerCheckoutConfirm, failure:OBEAjaxFailureHandlerCheckoutConfirm });
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerCheckoutConfirm = function(o){
	var root = o.responseXML.documentElement;
	OBEInfo.OBEFormElementStuff.address_p = SSXMLElementToXHTMLElement( root.getElementsByTagName('p')[0] );
	OBECheckoutDisplayConfirmStatic();
};
var OBEAjaxFailureHandlerCheckoutConfirm = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	the_el.innerHTML = o.status + " " + o.statusText;
};
var OBECheckoutDisplayConfirmStatic = function(){
	// set the cart step
	OBECart.setCheckoutStep( 'checkout_confirm' );
	// get ref to main div
	var holder_div = document.getElementById('obe_bar_content_holder');
	// empty the holder
	if( SSEmptyNode( holder_div ) ){
		
		OBECheckoutAddGenericElements( holder_div, OBE_checkout_settings.checkout_process_headline_step_3 );
		
		
		
		// add the left subbheader
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_shipping_subheader_left';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_subheader_left_step_3 );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );

		// add the right subbheader
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_shipping_subheader_right';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_subheader_right_1_step_3 );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );



		// add on the link for continuing
		link_div = document.createElement( 'div' );
		link_div.className = 'obebar_shipping_link_continue';
		link_div.id = 'obebar_shipping_link_continue';
		// the 'continue checkout' bit
		cont_p = document.createElement( 'p' );
		cont_p.className = 'obebar_shipping_link_header';
		cont_txt = document.createTextNode( 'Finish checkout' );
		cont_p.appendChild( cont_txt );
		link_div.appendChild( cont_p );
		
		// the "enter shipping information" bit
		ship_link_p = document.createElement( 'p' );
		ship_link_p.className = 'obebar_shipping_link_link';
		ship_link_p.onclick = function(){
			OBECheckoutConfirmHandleOrder();
		};
		ship_link_a = document.createElement( 'a' );
		ship_link_a.className = 'obebar_shipping_link_link';
		ship_link_a.href = '#';
		ship_link_a.onclick = function(){
			return false;
		};
		ship_link_txt = document.createTextNode( 'Place your order' );
		ship_link_a.appendChild( ship_link_txt );
		ship_link_p.appendChild( ship_link_a );
		ship_link_arrow = document.createElement( 'img' );
		ship_link_arrow.className = 'obebar_link_arrow_right';
		ship_link_arrow.src = 'http://69.56.220.155/_gr/_obe_bar/right_arrow.png';
		ship_link_p.appendChild( ship_link_arrow );
		link_div.appendChild( ship_link_p );
		holder_div.appendChild( link_div );

		// create a div for the cart
		var cart_div = document.createElement( 'div' );
		cart_div.id = 'obebar_checkout_confirm_cart_holder';
		cart_div.className = 'obebar_checkout_confirm_cart_holder';
		holder_div.appendChild( cart_div );
		OBECartRedraw();
		
		// add a holdeer for the right side
		right_hldr = document.createElement( 'div' );
		right_hldr.className = 'obebar_checkout_confirm_right_holder';
		
		// add on the shipping information
		ship_div = document.createElement( 'div' );
		ship_div.className = 'obebar_checkout_confirm_shipping_holder';
		
		// add on the title
		var ship_hdr = document.createElement( 'div' );
		ship_hdr.className = 'obebar_checkout_confirm_shipping_title';
		ship_hdr.id = 'obebar_checkout_confirm_cart_title';
		var ship_hdr_p = document.createElement( 'p' );
		var ship_hdr_txt = document.createTextNode( 'You entered:' );
		ship_hdr_p.appendChild( ship_hdr_txt );
		ship_hdr_p.className = 'obebar_checkout_confirm_shipping_title';
		ship_hdr.appendChild( ship_hdr_p );
		ship_div.appendChild( ship_hdr );
		
		// add the edit link
		ship_edit_div = document.createElement( 'div' );
		ship_edit_div.className = 'obebar_checkout_confirm_shipping_link';
		ship_edit_div.onclick = function(){
			OBECheckoutDisplay( 'checkout_shipping' );
		};
		ship_edit_a = document.createElement( 'a' );
		ship_edit_a.className = 'obebar_checkout_confirm_shipping_link';
		ship_edit_arrow = document.createElement( 'img' );
		ship_edit_arrow.setAttribute( 'src', 'http://69.56.220.155/_gr/_obe_bar/arrow_white_left.png' );
		ship_edit_arrow.className = 'obebar_checkout_confirm_shipping_link_arrow';
		ship_edit_div.appendChild( ship_edit_arrow );
		ship_edit_a_txt = document.createTextNode( 'Edit' );
		ship_edit_a.appendChild( ship_edit_a_txt );
		ship_edit_div.appendChild( ship_edit_a );
		ship_div.appendChild( ship_edit_div );
		
		// add the p with the shipping address
		OBEInfo.OBEFormElementStuff.address_p.className = 'obebar_checkout_confirm_shipping_address';
		ship_div.appendChild( OBEInfo.OBEFormElementStuff.address_p );

		right_hldr.appendChild( ship_div );
		
		
		// now append the next subheader
		sh2_div = document.createElement( 'div' );
		sh2_div.className = 'obebar_checkout_confirm_right_subheader_2';
		// add a text node
		sh2_txt = document.createTextNode( 'Secure checkout' );
		sh2_div.appendChild( sh2_txt );
		right_hldr.appendChild( sh2_div );
		
		
		// append the password form
		var frm_div = document.createElement( 'div' );
		frm_div.className = 'obebar_checkout_confirm_password_form';
		var frm = document.createElement( 'form' );
		frm.className = 'obebar_checkout_confirm_password_form';
		frm.id = 'obebar_checkout_confirm_password_form';
		frm.onsubmit = function(){
			return false;
		};
		// label
		var frm_lbl = document.createElement( 'p' );
		frm_lbl.className = 'obebar_checkout_confirm_password_form_label';
		frm_lbl_txt = document.createTextNode( 'Enter your password' );
		frm_lbl.appendChild( frm_lbl_txt );
		// form element
		var frm_el = document.createElement( 'input' );
		frm_el.className = 'obebar_checkout_confirm_password_form_element';
		frm_el.setAttribute( 'type','password' );
		frm_el.setAttribute( 'name','user_password' );
		frm_el.setAttribute( 'id','user_password' );
		// instructions
		var frm_inst = document.createElement( 'p' );
		frm_inst.className = 'obebar_checkout_confirm_password_form_instructions';
		frm_inst_txt = document.createTextNode( '(This is the same password that you login with.)' );
		frm_inst.appendChild( frm_inst_txt );

		frm.appendChild( frm_lbl );
		frm.appendChild( frm_el );
		frm.appendChild( frm_inst );
		frm_div.appendChild( frm );
		right_hldr.appendChild( frm_div );
		
		holder_div.appendChild( right_hldr );

		YAHOO.util.Event.addListener("obebar_checkout_confirm_password_form","keyup",OBEBarCheckoutConfirmKeypressHandler);
		
	}
};
var OBECheckoutConfirmCartRedraw = function(){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_checkout_confirm_cart_holder');
	//alert( 'trying to draw cart...' );
	if( SSEmptyNode( cart_div ) ){
		OBECheckoutConfirmCartPopulate();
	}
};
// adds the cart itself to the cart page
var OBECheckoutConfirmCartPopulate = function(){
	// set up the title text
	var ttl_txt = (OBECart.getItemCount()>0) ? 'Your cart contains:' : 'Your cart is empty';
	// get a reference to the cart holder div
	cart_hldr = document.getElementById( 'obebar_checkout_confirm_cart_holder' );
	// add the top text
	var cart_hdr = document.createElement( 'div' );
	cart_hdr.className = 'obebar_checkout_confirm_cart_title';
	cart_hdr.id = 'obebar_checkout_confirm_cart_title';
	var cart_hdr_p = document.createElement( 'p' );
	var cart_hdr_txt = document.createTextNode( ttl_txt );
	cart_hdr_p.appendChild( cart_hdr_txt );
	cart_hdr_p.className = 'obebar_checkout_confirm_cart_title';
	cart_hdr.appendChild( cart_hdr_p );
	cart_hldr.appendChild( cart_hdr );
	// add the edit link
	cart_edit_div = document.createElement( 'div' );
	cart_edit_div.className = 'obebar_checkout_confirm_cart_link';
	cart_edit_div.onclick = function(){
		OBECheckoutDisplay( 'checkout_cart' );
	};
	cart_edit_a = document.createElement( 'a' );
	cart_edit_a.className = 'obebar_checkout_confirm_cart_link';
	cart_edit_arrow = document.createElement( 'img' );
	cart_edit_arrow.setAttribute( 'src', 'http://69.56.220.155/_gr/_obe_bar/arrow_white_left.png' );
	cart_edit_arrow.className = 'obebar_checkout_confirm_cart_link_arrow';
	cart_edit_div.appendChild( cart_edit_arrow );
	cart_edit_a_txt = document.createTextNode( 'Edit' );
	cart_edit_a.appendChild( cart_edit_a_txt );
	cart_edit_div.appendChild( cart_edit_a );
	cart_hldr.appendChild( cart_edit_div );
	// add on the cart itself
	if( OBECart.getItemCount()>0 ){
		cart_hldr.appendChild( OBECheckoutConfirmCartPopulateData() );
	}
	else{
		// add on a link to return to the product list
		pl_div = document.createElement( 'div' );
		pl_div.className = 'obebar_checkout_confirm_cart_pl_link';
		pl_div.onclick = function(){
			OBEContentLoad( 'product_list' );
			return false;
		};
		pl_img = document.createElement( 'img' );
		pl_img.src = 'http://69.56.220.155/_gr/_obe_bar/left_arrow.png';
		pl_img.className = 'obebar_link_arrow_left';
		pl_div.appendChild( pl_img );
		pl_a = document.createElement( 'a' );
		pl_a.className = 'obebar_checkout_confirm_cart_pl_link';
		pl_a.href = '#';
		pl_a.onclick = function(){
			return false;
		};
		pl_txt = document.createTextNode( 'Return to the goodie list' );
		pl_a.appendChild( pl_txt );
		pl_div.appendChild( pl_a );
		cart_hldr.appendChild( pl_div );
		// hide the link to the next step
		document.getElementById( 'obebar_cart_link_continue' ).style.visibility = 'hidden';
	}
	// return the holder
	return cart_hldr;
};
// populate a full cart
var OBECheckoutConfirmCartPopulateData = function(){
	var max = 0;
	// create a div
	var the_div = document.createElement( 'div' );
	the_div.className = 'obebar_checkout_confirm_cart_data';
	the_div.id = 'obebar_checkout_confirm_cart_data';
	// create a table
	var the_table = document.createElement( 'table' );
	the_table.className = 'obebar_checkout_confirm_cart_data';
	the_table.setAttribute( 'cellpadding','0' );
	the_table.setAttribute( 'cellspacing','0' );
	// create the tbody
	var the_tbody = document.createElement( 'tbody' );
	// create the tr
	var the_tr = document.createElement( 'tr' );
	// create the heading tds and add them to the tbody
	the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_header_item','obebar_checkout_confirm_cart_heading','Item',false) );
	the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_header_quantity','obebar_checkout_confirm_cart_heading','Qty.',false) );
	the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_header_points','obebar_checkout_confirm_cart_heading','Karmas',false) );
	the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_header_subtotal','obebar_checkout_confirm_cart_heading','Subtotal',false) );
	// add the tr onto the tbody
	the_tbody.appendChild( the_tr );
	// add the tbody onto the table
	the_table.appendChild( the_tbody );
	// add the table onto the div
	the_div.appendChild( the_table );
	
	// loop through the items and display them
	for( var x=0, max=OBECart.items.length; x<max; x++ ){

		// create a table
		var the_table = document.createElement( 'table' );
		the_table.className = 'obebar_checkout_confirm_cart_data';
		the_table.setAttribute( 'cellpadding','0' );
		the_table.setAttribute( 'cellspacing','0' );
		// create the tbody
		var the_tbody = document.createElement( 'tbody' );
		// create the tr
		var the_tr = document.createElement( 'tr' );
		// set up the subtotal
		var this_subtotal = OBECart.items[x]['item_quantity'] * OBECart.items[x]['item_price'];
		this_subtotal = SSNumberFormat( this_subtotal );
		var this_price = SSNumberFormat( OBECart.items[x]['item_price'] );
		// create the data tds and add them to the tbody
		// the image
		var img_td = document.createElement( 'td' );
		img_td.className = 'obebar_checkout_confirm_cart_image';
		var img_el = document.createElement( 'img' );
		img_el.className = 'obebar_checkout_confirm_cart_image';
		img_el.src = 'http://69.56.220.155/_keepout/products/' + OBECart.items[x]['item_id'] + '/gr/prod_image_40x40.jpg';
		img_td.appendChild( img_el );
		the_tr.appendChild( img_td );
		the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_item','obebar_checkout_confirm_cart_data',OBECart.items[x]['item_title_text'],false) );
		the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_quantity','obebar_checkout_confirm_cart_data',OBECart.items[x]['item_quantity'],false) );
		// the quantity buttons
		var img_td = document.createElement( 'td' );
		img_td.className = 'obebar_checkout_confirm_cart_quantity_buttons';
		the_tr.appendChild( img_td );
		the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_points','obebar_checkout_confirm_cart_data',this_price,false) );
		the_tr.appendChild( OBECheckoutConfirmCartPopulateDataTD('obebar_checkout_confirm_cart_subtotal','obebar_checkout_confirm_cart_data',this_subtotal,false) );
		// add the tr onto the tbody
		the_tbody.appendChild( the_tr );
		// add the tbody onto the table
		the_table.appendChild( the_tbody );
		// add the table onto the div
		the_div.appendChild( the_table );
	
	}
	
	// create the total points div
	var ttl_div = document.createElement( 'div' );
	ttl_div.className = 'obebar_checkout_confirm_cart_total';
	// create a p to hold the text
	var the_p = document.createElement( 'p' );
	the_p.className = 'obebar_checkout_confirm_cart_total';
	// create a text node to hold the text
	var the_txt = document.createTextNode( 'Total karmas: ' + SSNumberFormat( OBECart.getSubtotal() ) );
	// append the text node to the p
	the_p.appendChild( the_txt );
	// apend the p to the div
	ttl_div.appendChild( the_p );
	the_div.appendChild( ttl_div );

	
	// return the div
	return the_div;
};
// create a td for the table
var OBECheckoutConfirmCartPopulateDataTD = function( td_cls, p_cls, txt, del_img ){
	// create a td for the item
	var the_td = document.createElement( 'td' );
	the_td.className = td_cls;
	// create a p
	var the_p = document.createElement('p');
	the_p.className = p_cls;
	// create a text node
	var the_txt = document.createTextNode( txt );
	// append txt to p
	the_p.appendChild( the_txt );
	// append p to div
	the_td.appendChild( the_p );
/*
	if( del_img ){
		// create an image element
		var the_img = document.createElement( 'img' );
		the_img.src = 'http://69.56.220.155/_gr/_obe_bar/btn_cart_delete.png';
		the_img.className = 'obebar_product_list_cart_data_delete_img';
		the_img.onclick = function(){
			alert( 'delete' );
		};
		// append the img onto the p
		the_td.appendChild( the_img );
	}
*/
	// return the div
	return the_td;
};
// handle a keypress on the form
var OBEBarCheckoutConfirmKeypressHandler = function(e){
	//alert( e.keyCode );
	//OBEBarLoginHandler();
	if( e.keyCode==13 ){
		OBECheckoutConfirmHandleOrder();
	}
	return false;
};
var OBECheckoutConfirmHandleOrder = function(){
	
	// verify the password form
	OBECheckoutConfirmVerifyForm();
	
	// send the password
	
	
	//alert( 'handling the order.' );
};
// verify the password form
var OBECheckoutConfirmVerifyForm = function(){
	// get ref to the pw field
	var pw_el = document.getElementById('user_password');
	
	if( pw_el.value.length>0 ){
		// create an object to hold the user data
		var user_pw_md5 = hex_md5(pw_el.value)
		// pass it off to the right function
		OBECheckoutConfirmCheckPassword( user_pw_md5 );
	}
	else{
		pw_el.focus();
		alert( 'Please enter your password to complete your order.' );
	}
};
// check the password
var OBECheckoutConfirmCheckPassword = function( user_pw_md5 ){
	// build the URL to the script
	var pw_qs = '?user_password=' + user_pw_md5 + '&c=check_password';
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + pw_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerCheckoutConfirmCheckPassword, failure:OBEAjaxFailureHandlerCheckoutConfirmCheckPassword });
};
// the AJAX succes/failure handlers
var OBEAjaxSuccessHandlerCheckoutConfirmCheckPassword = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	
	if( root.getElementsByTagName('obe_status')[0].firstChild.nodeValue=='1' ){
		// continue with the order submission
		OBECheckoutConfirmSubmitOrder();
	}
	else{
		alert( root.getElementsByTagName('obe_message')[0].firstChild.nodeValue );
	}
};
var OBEAjaxFailureHandlerCheckoutConfirmCheckPassword = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.innerHTML = o.status + " " + o.statusText;
	alert( o.status + " " + o.statusText );
};
// finally, submit the order
var OBECheckoutConfirmSubmitOrder = function(){
	// build the URL to the script
	var cart_qs = DP_QueryString.generate( OBECart.getOneDimensionalCart() ) + '&c=submit_order';
	//var cart_qs = '?user_password=' + user_pw_md5 + '&c=submit_order';
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + cart_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerCheckoutConfirmSubmitOrder, failure:OBEAjaxFailureHandlerCheckoutConfirmSubmitOrder });
};
// the AJAX succes/failure handlers
var OBEAjaxSuccessHandlerCheckoutConfirmSubmitOrder = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	//alert( the_contents );
	if( root.getElementsByTagName('obe_status')[0].firstChild.nodeValue=='1' ){
		
		//alert( 'the order was a success...' );
		// ON SUCCESS, WE NEED TO UPDATE A GLOBAL OBJECT AND THEN DISPLAY THE FINAL RECEIPT PAGE
		OBEInfo.OrderInfo.ord_id = root.getElementsByTagName('ord_id')[0].firstChild.nodeValue;
		OBEInfo.OrderInfo.ord_added_string = root.getElementsByTagName('ord_added_string')[0].firstChild.nodeValue;
		
		
		// WE ALSO NEED TO UPDATE THE USER BALANCE BY THE AMOUNT OF THE ORDER, AND BLITZ THE CART
		var the_new_balance = OBEInfo.UserInfo.user_balance - OBECart.getSubtotal();
		OBEInfo.UserInfo.user_balance = parseInt( the_new_balance );
		document.getElementById('obe_action_my_karmas_number').firstChild.nodeValue = SSNumberFormat( OBEInfo.UserInfo.user_balance );
		OBECart.removeAllItems();
		
		OBECheckoutDisplay( 'checkout_receipt' );
		
	}
	else{
		alert( root.getElementsByTagName('obe_message')[0].firstChild.nodeValue );
	}
};
var OBEAjaxFailureHandlerCheckoutConfirmSubmitOrder = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.innerHTML = o.status + " " + o.statusText;
	alert( o.status + " " + o.statusText );
};
/*  END DISPLAY THE CONFIRM PAGE  */


/*  ACTIONS: SIGNUP  */
var toggleOBEBarSignUp = function(e){
	toggleOBEBar( e, 'sign_up', OBEBarSignUpAssignEvents );
	return false;
};
YAHOO.util.Event.addListener("obe_action_text_links_sign_up","click",toggleOBEBarSignUp);
// function for loading signup form from satellite content below
var loadSignUpFromSatellite = function(){
	dummy_obj = document.createElement('a');
	dummy_obj.setAttribute( 'id','obe_action_text_links_sign_up' );
	toggleOBEBarSignUp( dummy_obj );
};
// assign events (after content load)
var OBEBarSignUpAssignEvents = function(){
	YAHOO.util.Event.addListener("obebar_sign_up_form","keyup",OBEBarSignupKeypressHandler);
	// add the username to the field
	//document.getElementById('user_username').value = OBEInfo.AutologinInfo.user_username;
};
// handle a keypress on the form
var OBEBarSignupKeypressHandler = function(e){
	//alert( e.keyCode );
	//OBEBarLoginHandler();
	if( e.keyCode==13 ){
		OBEBarSignUpHandler();
	}
	return false;
};
// handle the login form
var OBEBarSignUpHandler = function(){
	var max = 0;
	var error_msg = null;
	// note all the required fields
	var req_flds = [
		'user_username'
		,'user_password_1'
		,'user_password_2'
		,'user_name_first'
		,'user_name_last'
		,'user_email'
		,'user_city'
		,'user_country'
	];
	var ok_to_submit = true;
	// check the fields
	for( var x=0, max=req_flds.length; x<max; x++ ){
		if( !document.getElementById( req_flds[x] ).value ){
			error_msg = 'Please fill out all required fields.';
		}
	}
	// check that the passwords match
	if( document.getElementById('user_password_1').value && document.getElementById('user_password_2').value ){
		if( document.getElementById('user_password_1').value != document.getElementById('user_password_2').value ){
			error_msg = 'Please make sure the password has been entered exactly the same in both fields.';
		}
	}
	// check the email formatting
	if( !SSEmailAddressCheck( document.getElementById('user_email').value ) ){
		error_msg = 'Please ensure that your email address is in the form "user@domain.ext".';
	}
	// now verify the ok to submit flag
	ok_to_submit = (error_msg===null) ? true : false;
	if( ok_to_submit ){
		// assemble all the information into an object
		signup_info = {
			user_username: document.getElementById('user_username').value
			,user_password: hex_md5( document.getElementById('user_password_1').value )
			,user_name_first: document.getElementById('user_name_first').value
			,user_name_last: document.getElementById('user_name_last').value
			,user_email: document.getElementById('user_email').value
			,user_city: document.getElementById('user_city').value
			,user_country: document.getElementById('user_country').value
			,user_satellite: 3		};
		if( document.getElementById('user_title').value ){
			signup_info['user_title'] = document.getElementById('user_title').value;
		}
		// handle the op-ins
		if( document.getElementById('user_intemail').checked ){
			signup_info['user_intemail'] = 'y';
		}
		if( document.getElementById('user_extemail').checked ){
			signup_info['user_extemail'] = 'y';
		}
		
		OBEBarSignUpSubmitToOBE( signup_info );
	}
	else{
		OBEBarSignUpDisplayError( error_msg );
	}
/*

	if( document.getElementById('user_username').value && document.getElementById('user_password').value ){
		var remember_user = (document.getElementById('user_username_remember').checked==true) ? 'y' : 'n'
		var login_info = {
			user_username: document.getElementById('user_username').value
			,user_password: hex_md5( document.getElementById('user_password').value )
			,user_remember: remember_user
		};
		//alert( pw );
		OBEUserLogin( login_info );
	}
	else{
		OBEBarLoginDisplayError( 'Please enter both a username and password to log in.' );
	}	
*/
};
// load in the content
var OBEBarSignUpSubmitToOBE = function( login_info ){
	var login_qs = DP_QueryString.generate( login_info ) + '&c=signup_handler';
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php' + login_qs;
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerSignupSubmit, failure:OBEAjaxFailureHandlerSignupSubmit });
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerSignupSubmit = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;

	var login_status = root.getElementsByTagName('obe_status')[0].firstChild.nodeValue;

	// if the status is 1, then  go ahead with the login
	if( login_status=='1' ){
		// proceed with login
		// OBEBarSignUpDisplayError( 'Thank you for signing up. You may now log in.' );
		// load the confirmation screen
		OBEContentLoad( 'sign_up_confirmation' );
	}
	else{
		OBEBarSignUpDisplayError( root.getElementsByTagName('obe_message')[0].firstChild.nodeValue );
	}
}
var OBEAjaxFailureHandlerSignupSubmit = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	//the_el.innerHTML = o.status + " " + o.statusText;
}
// display an error
var OBEBarSignUpDisplayError = function( txt ){
	alert( txt );
/*
	// get a reference to the cart div
	var outer_div = document.getElementById('obebar_log_in_box_form');
	// get a reference to the title div
	var top_div = document.getElementById('obebar_log_in_box_label_top');
	// create a div
	var the_div = document.createElement( 'div' );
	var the_date = new Date();
	var the_id = 'obebar_product_list_cart_error' + the_date.valueOf();
	the_div.id = the_id;
	the_div.className = 'obebar_login_error';
	// create a p
	var the_p = document.createElement('p');
	the_p.className = 'obebar_login_error';
	// create a text node
	var the_txt = document.createTextNode( txt );
	// append txt to p
	the_p.appendChild( the_txt );
	// append p to div
	the_div.appendChild( the_p );
	// insert the div where we want it (after the title)
	outer_div.insertBefore(the_div, top_div);
	// set a timeout that removes it after a number of seconds
	setTimeout( 'OBERemoveNode("'+the_id+'")', 6000 );
*/
};
/*  END ACTIONS: SIGNUP  */

/*  DISPLAY THE RECEIPT PAGE  */

// load in the states and countries data
var OBECheckoutDisplayReceipt = function(){

	OBECheckoutDisplayReceiptStatic();

};
var OBECheckoutDisplayReceiptStatic = function(){
	// set the cart step
	OBECart.setCheckoutStep( 'checkout_receipt' );
	// get ref to main div
	var holder_div = document.getElementById('obe_bar_content_holder');
	// empty the holder
	if( SSEmptyNode( holder_div ) ){
		
		OBECheckoutAddGenericElements( holder_div, OBE_checkout_settings.checkout_process_headline_receipt );
		
		
		
		// add the left subbheader
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_receipt_subheader';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_subheader_receipt );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );


		// a hlder to hold the text
		txt_hldr = document.createElement( 'div' );
		txt_hldr.className = 'obebar_receipt_text_holder';
		
		// display the order number
		ord_num_div = document.createElement( 'div' );
		ord_num_div.className = 'obebar_receipt_order_number';
		ord_num_txt = document.createTextNode( 'Order number: ' + OBEInfo.OrderInfo.ord_id );
		ord_num_div.appendChild( ord_num_txt );
		txt_hldr.appendChild( ord_num_div );

		// display the order date
		ord_date_div = document.createElement( 'div' );
		ord_date_div.className = 'obebar_receipt_order_date';
		ord_date_txt = document.createTextNode( 'Order date: ' + OBEInfo.OrderInfo.ord_added_string );
		ord_date_div.appendChild( ord_date_txt );
		txt_hldr.appendChild( ord_date_div );

		// info 1
		info1_div = document.createElement( 'div' );
		info1_div.className = 'obebar_receipt_info';
		info1_txt = document.createTextNode( 'Items will be shipped 4-6 weeks from the above date.' );
		info1_div.appendChild( info1_txt );
		txt_hldr.appendChild( info1_div );

		// info 2
		info2_div = document.createElement( 'div' );
		info2_div.className = 'obebar_receipt_info';
		info2_txt = document.createTextNode( 'A detailed copy of your receipt will be emailed to you shortly.' );
		info2_div.appendChild( info2_txt );
		txt_hldr.appendChild( info2_div );


		// the "return to my account" bit
		ship_link_p = document.createElement( 'p' );
		ship_link_p.className = 'obebar_receipt_top_link';
		ship_link_p.onclick = function(){
			OBEContentLoad( 'product_list' );
		};
		ship_link_a = document.createElement( 'a' );
		ship_link_a.className = 'obebar_receipt_top_link';
		ship_link_a.href = '#';
		ship_link_a.onclick = function(){
			return false;
		};
		ship_link_txt = document.createTextNode( 'Return to my account' );
		ship_link_a.appendChild( ship_link_txt );
		ship_link_p.appendChild( ship_link_a );
		ship_link_arrow = document.createElement( 'img' );
		ship_link_arrow.className = 'obebar_link_arrow_right';
		ship_link_arrow.src = 'http://69.56.220.155/_gr/_obe_bar/right_arrow.png';
		ship_link_p.appendChild( ship_link_arrow );
		txt_hldr.appendChild( ship_link_p );

		// the "close account panel" bit
		ship_link_p = document.createElement( 'p' );
		ship_link_p.className = 'obebar_receipt_bottom_link';
		ship_link_p.onclick = function(){
			OBEBarGenericCollapse();
		};
		ship_link_a = document.createElement( 'a' );
		ship_link_a.className = 'obebar_receipt_bottom_link';
		ship_link_a.href = '#';
		ship_link_a.onclick = function(){
			return false;
		};
		ship_link_txt = document.createTextNode( 'Close account panel' );
		ship_link_a.appendChild( ship_link_txt );
		ship_link_p.appendChild( ship_link_a );
		ship_link_arrow = document.createElement( 'img' );
		ship_link_arrow.className = 'obebar_link_arrow_right';
		ship_link_arrow.src = 'http://69.56.220.155/_gr/_obe_bar/right_arrow.png';
		ship_link_p.appendChild( ship_link_arrow );
		txt_hldr.appendChild( ship_link_p );



		holder_div.appendChild( txt_hldr );
	}
};
/*  END DISPLAY THE RECEIPT PAGE  */

/*  ACTIONS: VIEW POINTS BY CAMPAIGN  */
var OBEBarStatsToggleViewByCampaign = function( obj ){
	// all these things can only be done if the user is logged in (though this function should never be called otherwise)
	if( OBEInfo.UserInfo.user_id ){
		///obj.clicked = (obj.clicked) ? false : true;
		//alert( obj.id );
		// detail div
		det_div = document.getElementById('obebar_stats_detail');
		//alert( det_div.id );
		// the atributes for the animation
		var attributes = {
		  height: { to: OBEInfo.OBEStatsBarDetail.height_closed }
		};
		// will hold animation object
		var anim = null;


		// determine which background to show
		if( OBEInfo.OBEStatsBarDetail.expanded && OBEInfo.OBEStatsBar.last_clicked==obj ){
			//YAHOO.util.Dom.setStyle( obj,'backgroundImage','url(http://69.56.220.155/_gr/_obe_bar/btn_points_by_campaign_view.png)');
		
			attributes.height.to = OBEInfo.OBEStatsBarDetail.height_closed;
			anim = new YAHOO.util.Anim(det_div, attributes, 0.5, YAHOO.util.Easing.easeOut);
			anim.onComplete.subscribe(OBEStatsViewByCampaignCollapsed);
			anim.onComplete.subscribe(OBERemoveCurrentViewByCampaignContent);
			OBERemoveCurrentViewByCampaignContent();
			
		}
		else{
			//YAHOO.util.Dom.setStyle( obj,'backgroundImage','url(http://69.56.220.155/_gr/_obe_bar/btn_points_by_campaign_hide.png)');

			attributes.height.to = OBEInfo.OBEStatsBarDetail.height_open_1;
			//alert( attributes.height.to );
			anim = new YAHOO.util.Anim(det_div, attributes, 0.5, YAHOO.util.Easing.easeOut);
			anim.onComplete.subscribe(OBEStatsViewByCampaignExpanded);
			OBELoadViewByCampaignCampaigns();
			
		}
		OBEInfo.OBEStatsBar.last_clicked = obj;

		if( anim!==null ){
			anim.animate();
		}
	}
	else{
		alert( "You must be logged in to use this feature." );
	}
};
var OBEStatsViewByCampaignExpanded = function(){
	OBEInfo.OBEStatsBarDetail.expanded = true;
};
var OBEStatsViewByCampaignCollapsed = function(){
	OBEInfo.OBEStatsBarDetail.expanded = false;
};
var OBERemoveCurrentViewByCampaignContent = function(){
	// get all the nodes in the content area
	var the_el = document.getElementById('obebar_stats_detail_holder');
	the_el.innerHTML = '<div></div>'
	return true;
};
// load in the campaign stats
var OBELoadViewByCampaignCampaigns = function(){
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php?c=stats_view_campaigns';
	//alert( the_url );
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerStatsViewByCampaignCampaigns, failure:OBEAjaxFailureHandlerStatsViewByCampaignCampaigns });
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerStatsViewByCampaignCampaigns = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	var the_el = document.getElementById('obebar_stats_detail_holder');
	//alert( the_el );
	the_el.innerHTML = the_contents;

};
var OBEAjaxFailureHandlerStatsViewByCampaignCampaigns = function(o){
	var the_el = document.getElementById('obebar_stats_detail_holder');
	the_el.innerHTML = o.status + " " + o.statusText;
};
var OBELoadCampaignTransactions = function( sat_id ){
	// detail div
	det_div = document.getElementById('obebar_stats_detail');
	if( det_div.style.height!=OBEInfo.OBEStatsBarDetail.height_open_2+'px' ){
	
		// the atributes for the animation
		var attributes = {
		  height: { to: OBEInfo.OBEStatsBarDetail.height_open_2 }
		};
		OBEInfo.OBEStatsBarDetail.current_campaign = sat_id;
		
		// build the URL to the script
		var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php?c=stats_view_campaign_transactions&s='+sat_id;
		//alert( the_url );
		// now, load the proper content
		var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerStatsViewByCampaignCampaignTransactions, failure:OBEAjaxFailureHandlerStatsViewByCampaignCampaignTransactions });
	}
	else{
		var attributes = {
		  height: { to: OBEInfo.OBEStatsBarDetail.height_open_1 }
		};
		var el_name = 'obebar_stat_campaign_transactions_holder_'+OBEInfo.OBEStatsBarDetail.current_campaign;
		var the_el = document.getElementById(el_name);
		the_el.innerHTML = '';
	}
	// will hold animation object
	var anim = null;
	anim = new YAHOO.util.Anim(det_div, attributes, 0.5, YAHOO.util.Easing.easeOut);
	anim.animate();
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerStatsViewByCampaignCampaignTransactions = function(o){
	var root = o.responseXML.documentElement;
	var the_contents = o.responseText;
	var el_name = 'obebar_stat_campaign_transactions_holder_'+OBEInfo.OBEStatsBarDetail.current_campaign;
	var the_el = document.getElementById(el_name);
	//alert( the_contents );
	the_el.innerHTML = the_contents;

};
var OBEAjaxFailureHandlerStatsViewByCampaignCampaignTransactions = function(o){
	var the_el = document.getElementById('obebar_stat_campaign_transactions_holder_'+OBEInfo.OBEStatsBarDetail.current_campaign);
	the_el.innerHTML = o.status + " " + o.statusText;
};
var OBECollapseStatsDetail = function(){
	det_div = document.getElementById('obebar_stats_detail');
	// the atributes for the animation
	var attributes = {
	  height: { to: OBEInfo.OBEStatsBarDetail.height_closed }
	};
	anim = new YAHOO.util.Anim(det_div, attributes, 0.5, YAHOO.util.Easing.easeOut);
	anim.animate();
};
/*  END ACTIONS: VIEW POINTS BY CAMPAIGN  */

/*  PRODUCT LIST FUNCTIONS  */
// product clicked
var OBEBarProductListProductClicked = function( num, total_num ){
	//alert( 'clicked product ' + num );
	//YAHOO.util.Dom.setStyle(other_divs,'visibility',0.3);
	// make an array of the other ones
	var other_divs = new Array()
	// make all the others hidden
	for( var x = 0; x<total_num; x++ ){
		if( x != num ){
			other_divs.push( 'obebar_product_list_popup_'+x );
		}
		else{
			YAHOO.util.Dom.setStyle('obebar_product_list_popup_'+x,'visibility','visible');
		}
	}
	YAHOO.util.Dom.setStyle(other_divs,'visibility','hidden');
};
// product moused over
var OBEBarProductListProductMouseOver = function( num, total_num ){
	// get the title div
	var ttl_div = document.getElementById('obebar_product_list_title_'+num);
	// get the image div
	var img_div = document.getElementById('obebar_product_list_image_'+num);
	// make an array of the other ones
	var other_image_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		if( x != num ){
			other_image_divs.push( 'obebar_product_list_image_'+x );
		}
	}
	YAHOO.util.Dom.setStyle(other_image_divs,'border-top','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_image_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_image_divs,'border-right','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(img_div,'border-top','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(img_div,'border-left','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(img_div,'border-right','1px solid #73b8cc');
	// make an array of the other ones
	var other_title_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		if( x != num ){
			other_title_divs.push( 'obebar_product_list_title_'+x );
		}
	}
	YAHOO.util.Dom.setStyle(other_title_divs,'border-bottom','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_title_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_title_divs,'border-right','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(ttl_div,'border-bottom','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(ttl_div,'border-left','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(ttl_div,'border-right','1px solid #73b8cc');
	//YAHOO.util.Dom.setStyle(other_divs,'opacity',0.3);
};
// product moused out
var OBEBarProductListProductMouseOut = function( num, total_num ){
	// get the title div
	var ttl_div = document.getElementById('obebar_product_list_title_'+num);
	// make an array of the all divs
	var all_image_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		all_image_divs.push( 'obebar_product_list_image_'+x );
	}
	YAHOO.util.Dom.setStyle(all_image_divs,'border-top','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_image_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_image_divs,'border-right','1px solid #363b3d');
	// make an array of the all divs
	var all_title_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		all_title_divs.push( 'obebar_product_list_title_'+x );
	}
	YAHOO.util.Dom.setStyle(all_title_divs,'border-bottom','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_title_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_title_divs,'border-right','1px solid #363b3d');
	//YAHOO.util.Dom.setStyle(all_divs,'opacity',1);
};
// close the popup
var OBEBarProductListPopupClose = function( num, total_num ){
	// make an array of the all divs
	var all_divs = new Array()
	// close all of them
	for( var x = 0; x<total_num; x++ ){
		all_divs.push( 'obebar_product_list_product_'+x );
	}
	YAHOO.util.Dom.setStyle(all_divs,'opacity',1);
	YAHOO.util.Dom.setStyle('obebar_product_list_popup_'+num,'visibility','hidden');
};
/*  END PRODUCT LIST FUNCTIONS  */




/*  ADD AN ITEM TO THE CART  */
var OBEBarProductListAddToCart = function( id ){
	OBECart.addItem( id );
	//alert( id );
};
/*  END ADD AN ITEM TO THE CART  */




/*  GENERIC FUNCTION FOR REDRAWING CART  */
var OBECartRedraw = function(){
	//choose the proper redrawing function based on the checkout step
	switch( OBECart.getCheckoutStep() ){
		case 'product_list':
		default:
			OBEProductListCartRedraw();
			break;
		case 'checkout_cart':
			OBECheckoutCartRedraw();
			break;
		case 'checkout_confirm':
			OBECheckoutConfirmCartRedraw();
			
			break;
	}
};
/*  END GENERIC FUNCTION FOR REDRAWING CART  */


/*  GENERIC FUNCTION FOR DISPLAYING ERROR  */
var OBEDisplayCartError = function( str ){
	//choose the proper redrawing function based on the checkout step
	switch( OBECart.getCheckoutStep() ){
		case 'product_list':
		default:
			OBEProductListCartDisplayError( str );
			break;
		case 'checkout_cart':
			OBECheckoutCartDisplayError( str );
			break;
		case 'checkout_confirm':
			OBECheckoutConfirmCartDisplayError();
			break;
	}
};
/*  END GENERIC FUNCTION FOR DISPLAYING ERROR  */



/*  CAMPAIGN LIST FUNCTIONS  */
// campaign clicked
var OBEBarCampaignListCampaignClicked = function( url ){
	//obj = document.getElementById('
	if( url ){
		window.document.location.href = url;
	}
};
// campaign moused over
var OBEBarCampaignListCampaignMouseOver = function( num, total_num ){
	// get the description div matching this div
	var desc_div = document.getElementById('obebar_view_campaigns_description_'+num);
	// get the title div
	var ttl_div = document.getElementById('obebar_view_campaigns_title_'+num);
	// get the image div
	var img_div = document.getElementById('obebar_view_campaigns_image_'+num);
	// get the sponsor div
	var spon_div = document.getElementById('obebar_view_campaigns_sponsor_'+num);
	// make an array of the other images
	var other_image_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		if( x != num ){
			other_image_divs.push( 'obebar_view_campaigns_image_'+x );
		}
	}
	YAHOO.util.Dom.setStyle(other_image_divs,'border-top','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_image_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_image_divs,'border-right','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(img_div,'border-top','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(img_div,'border-left','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(img_div,'border-right','1px solid #73b8cc');
	// make an array of the other titles
	var other_title_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		if( x != num ){
			other_title_divs.push( 'obebar_view_campaigns_title_'+x );
		}
	}
	YAHOO.util.Dom.setStyle(other_title_divs,'border-bottom','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_title_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(other_title_divs,'border-right','1px solid #363b3d');
	// make the border of the selected one blue
	YAHOO.util.Dom.setStyle(desc_div,'border-bottom','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(desc_div,'border-left','1px solid #73b8cc');
	YAHOO.util.Dom.setStyle(desc_div,'border-right','1px solid #73b8cc');
	//YAHOO.util.Dom.setStyle(other_divs,'opacity',0.3);
	// show the description and sponsor and hide the title
	YAHOO.util.Dom.setStyle( desc_div, 'visibility', 'visible' );
	YAHOO.util.Dom.setStyle( ttl_div, 'visibility', 'hidden' );
	YAHOO.util.Dom.setStyle( spon_div, 'visibility', 'visible' );
};
// campaign moused out
var OBEBarCampaignListCampaignMouseOut = function( num, total_num ){
	// get the description div matching this div
	var desc_div = document.getElementById('obebar_view_campaigns_description_'+num);
	// get the title div
	var ttl_div = document.getElementById('obebar_view_campaigns_title_'+num);
	// get the sponsor div
	var spon_div = document.getElementById('obebar_view_campaigns_sponsor_'+num);
	// make an array of the all divs
	var all_image_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		all_image_divs.push( 'obebar_view_campaigns_image_'+x );
	}
	YAHOO.util.Dom.setStyle(all_image_divs,'border-top','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_image_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_image_divs,'border-right','1px solid #363b3d');
	// make an array of the all divs
	var all_title_divs = new Array()
	// make all the others translucent
	for( var x = 0; x<total_num; x++ ){
		all_title_divs.push( 'obebar_view_campaigns_title_'+x );
	}
	YAHOO.util.Dom.setStyle(all_title_divs,'border-bottom','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_title_divs,'border-left','1px solid #363b3d');
	YAHOO.util.Dom.setStyle(all_title_divs,'border-right','1px solid #363b3d');
	//YAHOO.util.Dom.setStyle(all_divs,'opacity',1);
	// show the title and hide the description and the sponsor
	YAHOO.util.Dom.setStyle( desc_div, 'visibility', 'hidden' );
	YAHOO.util.Dom.setStyle( ttl_div, 'visibility', 'visible' );
	YAHOO.util.Dom.setStyle( spon_div, 'visibility', 'hidden' );
};
/*  END CAMPAIGN LIST FUNCTIONS  */
/*  PRODUCT LIST CART DISPLAY FUNCTIONS  */
// master function
var OBEProductListCartRedraw = function(){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_product_list_cart_holder');
	OBEProductListCartResize();
	if( SSEmptyNode( cart_div ) ){
		OBEProductListCartPopulate();
	}
};
// resize the cart
var OBEProductListCartResize = function(){
	// determine the target height
	var target_height = (OBECart.getItemCount()>0) ? OBEInfo.OBECart.height_open : OBEInfo.OBECart.height_closed;
	// the atributes for the animation
	var attributes = {
	  height: { to: target_height }
	};
	// animation object
	anim = new YAHOO.util.Anim('obebar_product_list_cart_holder', attributes, 0.5, YAHOO.util.Easing.easeOut);
	anim.animate();
};
// populate the cart
var OBEProductListCartPopulate = function(){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_product_list_cart_holder');
	// are there items or not?
	if( OBECart.getItemCount()>0 ){
		// append the cart title
		cart_div.appendChild( OBEProductListCartPopulateTitle() );
		cart_div.appendChild( OBEProductListCartPopulateData() );
		cart_div.appendChild( OBEProductListCartPopulateTotal() );
		cart_div.appendChild( OBEProductListCartPopulateCheckoutLink() );
	}
	else{
		cart_div.appendChild( OBEProductListCartPopulateTitle() );	
	}
};
// populate an empty cart
var OBEProductListCartPopulateTitle = function(){
	// set up the title text
	var ttl_txt = (OBECart.getItemCount()>0) ? 'Your cart contains:' : 'Your cart is empty';
	// create a div
	var the_div = document.createElement( 'div' );
	the_div.className = 'obebar_product_list_cart_title';
	the_div.id = 'obebar_product_list_cart_title';
	// create a p
	var the_p = document.createElement('p');
	the_p.className = 'obebar_product_list_cart_title';
	// create a text node
	var the_txt = document.createTextNode( ttl_txt );
	// append txt to p
	the_p.appendChild( the_txt );
	// append p to div
	the_div.appendChild( the_p );
	// return the div
	return the_div;
};
// populate a full cart
var OBEProductListCartPopulateData = function(){
	var max = 0;
	// create a div
	var the_div = document.createElement( 'div' );
	the_div.className = 'obebar_product_list_cart_data';
	the_div.id = 'obebar_product_list_cart_data';
	// create a table
	var the_table = document.createElement( 'table' );
	the_table.className = 'obebar_product_list_cart_data';
	the_table.setAttribute( 'cellpadding','0' );
	the_table.setAttribute( 'cellspacing','0' );
	// create the tbody
	var the_tbody = document.createElement( 'tbody' );
	// create the tr
	var the_tr = document.createElement( 'tr' );
	// create the heading tds and add them to the tbody
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_item','obebar_product_list_cart_heading','Item',false) );
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_quantity','obebar_product_list_cart_heading','Qty.',false) );
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_points','obebar_product_list_cart_heading','Karmas',false) );
	the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_subtotal','obebar_product_list_cart_heading','Subtotal',false) );
	// add the tr onto the tbody
	the_tbody.appendChild( the_tr );
	// add the tbody onto the table
	the_table.appendChild( the_tbody );
	// add the table onto the div
	the_div.appendChild( the_table );
	
	// loop through the items and display them
	for( var x=0, max=OBECart.items.length; x<max; x++ ){

		// create a table
		var the_table = document.createElement( 'table' );
		the_table.className = 'obebar_product_list_cart_data';
		the_table.setAttribute( 'cellpadding','0' );
		the_table.setAttribute( 'cellspacing','0' );
		// create the tbody
		var the_tbody = document.createElement( 'tbody' );
		// create the tr
		var the_tr = document.createElement( 'tr' );
		// set up the subtotal
		var this_subtotal = OBECart.items[x]['item_quantity'] * OBECart.items[x]['item_price'];
		this_subtotal = SSNumberFormat( this_subtotal );
		var this_price = SSNumberFormat( OBECart.items[x]['item_price'] );
		// create the heading tds and add them to the tbody
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_item','obebar_product_list_cart_data',OBECart.items[x]['item_title_text'],false) );
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_quantity','obebar_product_list_cart_data',OBECart.items[x]['item_quantity'],false) );
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_points','obebar_product_list_cart_data',this_price,false) );
		the_tr.appendChild( OBEProductListCartPopulateDataTD('obebar_product_list_cart_subtotal','obebar_product_list_cart_data',this_subtotal,false) );
		// add the tr onto the tbody
		the_tbody.appendChild( the_tr );
		// add the tbody onto the table
		the_table.appendChild( the_tbody );
		// add the table onto the div
		the_div.appendChild( the_table );
	
	}
	
	// return the div
	return the_div;
};
// create a td for the table
var OBEProductListCartPopulateDataTD = function( td_cls, p_cls, txt, del_img ){
	// create a td for the item
	var the_td = document.createElement( 'td' );
	the_td.className = td_cls;
	// create a p
	var the_p = document.createElement('p');
	the_p.className = p_cls;
	// create a text node
	var the_txt = document.createTextNode( txt );
	// append txt to p
	the_p.appendChild( the_txt );
	// append p to div
	the_td.appendChild( the_p );
/*
	if( del_img ){
		// create an image element
		var the_img = document.createElement( 'img' );
		the_img.src = 'http://69.56.220.155/_gr/_obe_bar/btn_cart_delete.png';
		the_img.className = 'obebar_product_list_cart_data_delete_img';
		the_img.onclick = function(){
			alert( 'delete' );
		};
		// append the img onto the p
		the_td.appendChild( the_img );
	}
*/
	// return the div
	return the_td;
};
// display the total
var OBEProductListCartPopulateTotal = function(){
	// create a div for this item
	var the_div = document.createElement( 'div' );
	the_div.className = 'obebar_product_list_cart_total';
	// create a p to hold the text
	var the_p = document.createElement( 'p' );
	the_p.className = 'obebar_product_list_cart_total';
	// create a text node to hold the text
	var the_txt = document.createTextNode( 'Total karmas: ' + SSNumberFormat( OBECart.getSubtotal() ) );
	// append the text node to the p
	the_p.appendChild( the_txt );
	// apend the p to the div
	the_div.appendChild( the_p );
	// return the div
	return the_div;
};
// display the checkout link
var OBEProductListCartPopulateCheckoutLink = function(){
	// create a div
	var the_div = document.createElement( 'div' );
	the_div.className = 'obebar_product_list_cart_checkout';
	the_div.onclick = function(){
		OBECheckoutDisplay( 'checkout_cart' );
	};
	// create a p
	var the_p = document.createElement( 'p' );
	the_p.className = 'obebar_product_list_cart_checkout';
	// create an a tag
	var the_a = document.createElement( 'a' );
	the_a.className = 'obebar_product_list_cart_checkout';
	// create a text node
	var the_txt = document.createTextNode( 'Checkout' );
	the_a.appendChild( the_txt );
	the_p.appendChild( the_a );
	// create an img
	var the_img = document.createElement( 'img' );
	the_img.src = 'http://69.56.220.155/_gr/_obe_bar/right_arrow.png';
	the_img.className = 'obebar_link_arrow';
	the_p.appendChild( the_img );
	// append the p to the div
	the_div.appendChild( the_p );
	// return the div
	return the_div;
};
// display an error
var OBEProductListCartDisplayError = function( txt ){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_product_list_cart_holder');
	// get a reference to the title div
	var ttl_div = document.getElementById('obebar_product_list_cart_title');
	// set up the title text
	var ttl_txt = (OBECart.getItemCount()>0) ? 'Your cart contains:' : 'Your cart is empty';
	// create a div
	var the_div = document.createElement( 'div' );
	var the_date = new Date();
	var the_class_name = 'obebar_product_list_cart_error' + the_date.valueOf();

	the_div.className = 'obebar_product_list_cart_error';
	the_div.id = the_class_name;
	// create a p
	var the_p = document.createElement('p');
	the_p.className = 'obebar_product_list_cart_error';
	// create a text node
	var the_txt = document.createTextNode( txt );
	// append txt to p
	the_p.appendChild( the_txt );
	// append p to div
	the_div.appendChild( the_p );
	// insert the div where we want it (after the title)
	cart_div.insertBefore(the_div, ttl_div.nextSibling);
	// set a timeout that removes it after a number of seconds
	setTimeout( 'OBEProductListCartRemoveError("'+the_class_name+'")', 6000 );
};
// remove the error (after a small amount of time, we want the error to just disappear)
var OBEProductListCartRemoveError = function( the_id ){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_product_list_cart_holder');
	// try to get a ref to the error
	if( error_div = document.getElementById( the_id ) ){
		cart_div.removeChild( error_div );
	}
}
/*  END PRODUCT LIST CART DISPLAY FUNCTIONS  */

/*  CART/CHECKOUT PROCESS FUNCTIONS  */

// function to handle which checkout step to display
var OBECheckoutDisplay = function( step ){
	switch( step ){
		case 'checkout_cart':
		default:
			OBECart.setCheckoutStep( step );
			OBECheckoutDisplayCart();
			break;
		case 'checkout_shipping':
			OBECart.setCheckoutStep( step );
			OBECheckoutDisplayShipping();
			break;
		case 'checkout_confirm':
			OBECart.setCheckoutStep( step );
			OBECheckoutDisplayConfirm();
			break;
		case 'checkout_receipt':
			OBECart.setCheckoutStep( step );
			OBECheckoutDisplayReceipt();
			break;
	}
};

// function to add all the generic page elements to the checkout process
var OBECheckoutAddGenericElements = function( hldr, txt ){
	// create a headline div
	headline_div = document.createElement( 'div' );
	headline_div.className = 'obebar_content_headline';
	// create a text node
	headline_txt = document.createTextNode( txt );
	headline_div.appendChild( headline_txt );
	hldr.appendChild( headline_div );
	// create the horizontal rules
	top_line_div = document.createElement( 'div' );
	top_line_div.className = 'obebar_content_rule_top';
	bottom_line_div = document.createElement( 'div' );
	bottom_line_div.className = 'obebar_content_rule_bottom';
	hldr.appendChild( top_line_div );
	hldr.appendChild( bottom_line_div );
};
/*  END CART/CHECKOUT PROCESS FUNCTIONS  */
/*  ACTIONS: VIEW CAMPAIGNS  */
var toggleOBEBarViewCampaigns = function(e){
	var e_obj = YAHOO.util.Event.getTarget(e);
	e_obj.clicked = (e_obj.clicked) ? false : true;
	toggleOBEBar( e, 'campaign_list' );
};
YAHOO.util.Event.addListener("obe_action_active_campaigns_link","click",toggleOBEBarViewCampaigns);
/*  END ACTIONS: VIEW CAMPAIGNS  */
/*  DISPLAY THE SHIPPING PAGE  */

// load in the states and countries data
var OBECheckoutDisplayShipping = function(){
	OBEDisplayContentLoading();
	// build the URL to the script
	var the_url = 'http://www.helpmarysavecoral.org/_misc/obe_bar_proxy.php?c=countries_states';
	// now, load the proper content
	var request = YAHOO.util.Connect.asyncRequest('GET', the_url, { success:OBEAjaxSuccessHandlerCheckoutShipping, failure:OBEAjaxFailureHandlerCheckoutShipping });
};
// the AJAX succes/failure handlers for the main content load
var OBEAjaxSuccessHandlerCheckoutShipping = function(o){
	var root = o.responseXML.documentElement;
	OBEInfo.OBEFormElementStuff.select_country = SSXMLElementToXHTMLElement( root.getElementsByTagName('select')[0] );
	OBEInfo.OBEFormElementStuff.select_state = SSXMLElementToXHTMLElement( root.getElementsByTagName('select')[1] );
	OBECheckoutDisplayShippingStatic();
};
var OBEAjaxFailureHandlerCheckoutShipping = function(o){
	var the_el = document.getElementById('obe_bar_content_holder');
	the_el.innerHTML = o.status + " " + o.statusText;
};
var OBECheckoutDisplayShippingStatic = function(){
	// set the cart step
	OBECart.setCheckoutStep( 'checkout_shipping' );
	// get ref to main div
	var holder_div = document.getElementById('obe_bar_content_holder');
	// empty the holder
	if( SSEmptyNode( holder_div ) ){
		
		OBECheckoutAddGenericElements( holder_div, OBE_checkout_settings.checkout_process_headline_step_2 );
		
		
		
		// add the left subbheader
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_shipping_subheader_left';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_subheader_left_step_2 );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );

		// add the middle subbheader
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_shipping_subheader_middle';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_subheader_middle_step_2 );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );

		// add the right subbheader
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_shipping_subheader_right';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_subheader_right_step_2 );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );

		// add the right help text
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_shipping_help_text';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_help_text_step_2 );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );

		// add a form to hold everything below
		form_div = document.createElement( 'form' );
		form_div.className = 'obebar_shipping_form';
		form_div.setAttribute( 'id','obebar_shipping_form' );
		form_div.onsubmit = function(){
			return false;
		};
		
		// add a hidden element
		id_el = document.createElement( 'input' );
		id_el.setAttribute( 'type','hidden' );
		id_el.setAttribute( 'name','user_id' );
		id_el.setAttribute( 'value',OBEInfo.UserInfo.user_id );
		id_el.setAttribute( 'id','user_id' );
		form_div.appendChild( id_el );
		
		// add a div to hold the left column
		left_div = document.createElement( 'div' );
		left_div.className = 'obebar_shipping_column_left';


		// put the form elements in the left column
		left_div.appendChild( OBECheckoutShippingFormElement('user_name_first','First/given name',OBE_user_shipping_data.user_name_first) );
		left_div.appendChild( OBECheckoutShippingFormElement('user_name_last','Last/family name',OBE_user_shipping_data.user_name_last) );
		left_div.appendChild( OBECheckoutShippingFormElement('user_email','Email address',OBE_user_shipping_data.user_email) );

		
		// add a div to hold the middle column
		middle_div = document.createElement( 'div' );
		middle_div.className = 'obebar_shipping_column_middle';
		// put the form elements in the left column
		middle_div.appendChild( OBECheckoutShippingFormElement('user_address_1','Address line 1',OBE_user_shipping_data.user_address_1) );
		middle_div.appendChild( OBECheckoutShippingFormElement('user_address_2','Address line 2',OBE_user_shipping_data.user_address_2) );
		middle_div.appendChild( OBECheckoutShippingFormElement('user_address_3','Address line 3',OBE_user_shipping_data.user_address_3) );
		middle_div.appendChild( OBECheckoutShippingFormElement('user_city','City',OBE_user_shipping_data.user_city) );

		// add on the special case for state and zip
		state_zip_div = document.createElement( 'div' );
		state_zip_div.className = 'obebar_shipping_element_holder';

		// create a table to hold the state and zip fields
		sz_tbl = document.createElement( 'table' );
		sz_tbl.className = 'obebar_shipping_table_state_zip';
		sz_tbl.setAttribute( 'cellspacing','0' );
		sz_tbl.setAttribute( 'cellpadding','0' );
		sz_tbl_tbody = document.createElement( 'tbody' );
		
		// create a tr to hold the label row
		sz_tbl_lbl_row = document.createElement( 'tr' );
		
		// create a cell for the labels
		sz_tbl_st_lbl = document.createElement( 'td' );
		sz_tbl_st_lbl.className = 'obebar_shipping_table_state';
		sz_tbl_z_lbl = document.createElement( 'td' );
		sz_tbl_z_lbl.className = 'obebar_shipping_table_zip';
		
		// add the labels
		sz_tbl_st_lbl_p = document.createElement( 'p' );
		sz_tbl_st_lbl_p.className = 'obebar_shipping_element_label';
		sz_tbl_st_lbl_txt = document.createTextNode( 'State/Province' );
		sz_tbl_st_lbl_p.appendChild( sz_tbl_st_lbl_txt );
		sz_tbl_st_lbl.appendChild( sz_tbl_st_lbl_p );
		sz_tbl_z_lbl_p = document.createElement( 'p' );
		sz_tbl_z_lbl_p.className = 'obebar_shipping_element_label';
		sz_tbl_z_lbl_txt = document.createTextNode( 'Postal code' );
		sz_tbl_z_lbl_p.appendChild( sz_tbl_z_lbl_txt );
		sz_tbl_z_lbl.appendChild( sz_tbl_z_lbl_p );
		
		// append the labels onto the row
		sz_tbl_lbl_row.appendChild( sz_tbl_st_lbl );
		sz_tbl_lbl_row.appendChild( sz_tbl_z_lbl );

		// create a tr to hold the elements
		sz_tbl_el_row = document.createElement( 'tr' );

		// create a cell for the labels
		sz_tbl_st_el = document.createElement( 'td' );
		sz_tbl_st_el.className = 'obebar_shipping_table_state';
		sz_tbl_z_el = document.createElement( 'td' );
		sz_tbl_z_el.className = 'obebar_shipping_table_zip';

		// set some settings on the state element
		OBEInfo.OBEFormElementStuff.select_state.setAttribute( 'name', 'user_state' );
		OBEInfo.OBEFormElementStuff.select_state.setAttribute( 'id', 'user_state' );
		OBEInfo.OBEFormElementStuff.select_state.className = 'obebar_shipping_select_state';
		// select the proper element
		SSFormSelectElement( OBEInfo.OBEFormElementStuff.select_state,OBE_user_shipping_data.user_state );
		// append the select element
		sz_tbl_st_el.appendChild( OBEInfo.OBEFormElementStuff.select_state );

		// create an input element for the postal code
		zip_el = document.createElement( 'input' );
		zip_el.className = 'obebar_shipping_element_zip';
		zip_el.setAttribute( 'name', 'user_zip' );
		zip_el.setAttribute( 'id', 'user_zip' );
		zip_el.setAttribute( 'type','text' );
		zip_el.setAttribute( 'value', OBE_user_shipping_data.user_zip );
		sz_tbl_z_el.appendChild( zip_el );

		// append the labels onto the row
		sz_tbl_el_row.appendChild( sz_tbl_st_el );
		sz_tbl_el_row.appendChild( sz_tbl_z_el );

		// append the label row onto the tbody
		sz_tbl_tbody.appendChild( sz_tbl_lbl_row );
		sz_tbl_tbody.appendChild( sz_tbl_el_row );
		
		// append the tbody onto the table
		sz_tbl.appendChild( sz_tbl_tbody );
		
		// append the table onto the div
		state_zip_div.appendChild( sz_tbl );

		// append this to the middle div
		middle_div.appendChild( state_zip_div );
		

		// add on the special case for country
		country_div = document.createElement( 'div' );
		country_div.className = 'obebar_shipping_element_holder';

		// add the label
		lbl_p = document.createElement( 'p' );
		lbl_p.className = 'obebar_shipping_element_label';
		lbl_txt = document.createTextNode( 'Country' );
		lbl_p.appendChild( lbl_txt );
		
		country_div.appendChild( lbl_p );

		// set some settings on the state element
		OBEInfo.OBEFormElementStuff.select_country.setAttribute( 'name', 'user_country' );
		OBEInfo.OBEFormElementStuff.select_country.setAttribute( 'id', 'user_country' );
		OBEInfo.OBEFormElementStuff.select_country.className = 'obebar_shipping_select_country';
		// select the proper element
		SSFormSelectElement( OBEInfo.OBEFormElementStuff.select_country,OBE_user_shipping_data.user_country );
		// append the select element
		country_div.appendChild( OBEInfo.OBEFormElementStuff.select_country );

		middle_div.appendChild( country_div );


		// add it onto the holder
		form_div.appendChild( left_div );
		// add it onto the holder
		form_div.appendChild( middle_div );
		// add the form onto the main div
		holder_div.appendChild( form_div );


		// add on the link for continuing
		link_div = document.createElement( 'div' );
		link_div.className = 'obebar_shipping_link_continue';
		link_div.id = 'obebar_shipping_link_continue';
		// the 'continue checkout' bit
		cont_p = document.createElement( 'p' );
		cont_p.className = 'obebar_shipping_link_header';
		cont_txt = document.createTextNode( 'Continue checkout' );
		cont_p.appendChild( cont_txt );
		link_div.appendChild( cont_p );
		
		// the "enter shipping information" bit
		ship_link_p = document.createElement( 'p' );
		ship_link_p.className = 'obebar_shipping_link_link';
		ship_link_p.onclick = function(){
			OBECheckoutShippingHandleForm();
		};
		ship_link_a = document.createElement( 'a' );
		ship_link_a.className = 'obebar_shipping_link_link';
		ship_link_a.href = '#';
		ship_link_a.onclick = function(){
			return false;
		};
		ship_link_txt = document.createTextNode( 'Confirm your order' );
		ship_link_a.appendChild( ship_link_txt );
		ship_link_p.appendChild( ship_link_a );
		ship_link_arrow = document.createElement( 'img' );
		ship_link_arrow.className = 'obebar_link_arrow_right';
		ship_link_arrow.src = 'http://69.56.220.155/_gr/_obe_bar/right_arrow.png';
		ship_link_p.appendChild( ship_link_arrow );
		link_div.appendChild( ship_link_p );
		holder_div.appendChild( link_div );

		YAHOO.util.Event.addListener("obebar_shipping_form","keyup",OBEBarCheckoutShippingKeypressHandler);


	}
};
// returns a div holding a form element
var OBECheckoutShippingFormElement = function( e_name,lbl,val ){
	// create the div
	e_div = document.createElement( 'div' );
	e_div.className = 'obebar_shipping_element_holder';

	// add the label
	lbl_p = document.createElement( 'p' );
	lbl_p.className = 'obebar_shipping_element_label';
	lbl_txt = document.createTextNode( lbl );
	lbl_p.appendChild( lbl_txt );
	
	e_div.appendChild( lbl_p );
	
	// add the form element
	e = document.createElement( 'input' );
	e.className = 'obebar_shipping_element';
	e.setAttribute( 'name', e_name );
	e.setAttribute( 'id',e_name );
	e.setAttribute( 'type','text' );
	e.setAttribute( 'value',val );
	e_div.appendChild( e );

	// return it
	return e_div;
};
// handle the shipping form
// basically this will simply copy the newly entered shipping infrmation into the global object
var OBECheckoutShippingHandleForm = function(){
	// get a reference to the form
	f = document.getElementById( 'obebar_shipping_form' );
	//alert( 'user_id: ' + document.getElementById('user_id').value );
	// CHECK THE FORM FOR PROPER INPUT
	if( OBECheckoutShippingCheckForm() ){
		// IF OK, COPY EACH FIELD INTO THE GLOBAL OBJECT
		OBE_user_shipping_data.user_name_first = document.getElementById('user_name_first').value;
		OBE_user_shipping_data.user_name_last = document.getElementById('user_name_last').value;
		OBE_user_shipping_data.user_email = document.getElementById('user_email').value;
		OBE_user_shipping_data.user_address_1 = document.getElementById('user_address_1').value;
		OBE_user_shipping_data.user_address_2 = document.getElementById('user_address_2').value;
		OBE_user_shipping_data.user_address_3 = document.getElementById('user_address_3').value;
		OBE_user_shipping_data.user_city = document.getElementById('user_city').value;
		OBE_user_shipping_data.user_zip = document.getElementById('user_zip').value;
		OBE_user_shipping_data.user_state = document.getElementById('user_state').options[ document.getElementById('user_state').selectedIndex ].value;
		OBE_user_shipping_data.user_country = document.getElementById('user_country').options[ document.getElementById('user_country').selectedIndex ].value;
		// COPY THE SHIPPING INFO INTO THE CART
		OBECart.setShippingAddress( OBE_user_shipping_data );
		// THEN CAN CONTINUE TO THE CONFIRM STEP
		OBECheckoutDisplayConfirm();
	}	
};
// handle a keypress on the form
var OBEBarCheckoutShippingKeypressHandler = function(e){
	//alert( e.keyCode );
	//OBEBarLoginHandler();
	if( e.keyCode==13 ){
		//alert( 'enter pressed.' );
		OBECheckoutShippingHandleForm();
	}
	return false;
};
// check the form for errors
var OBECheckoutShippingCheckForm = function(){
	// the message to be returned
	msg = '';
	// check the first name
	if( !document.getElementById('user_name_first').value ){
		msg = 'Please enter your first (given) name';
		document.getElementById('user_name_first').focus();
	}
	// check the last name
	else if( !document.getElementById('user_name_last').value ){
		msg = 'Please enter your last (family) name';
		document.getElementById('user_name_last').focus();
	}
	// check the email address
	else if( !document.getElementById('user_email').value ){
		msg = 'Please enter your email address';
		document.getElementById('user_email').focus();
	}
	// check the email address formatting
	else if( !SSEmailAddressCheck( document.getElementById('user_email').value ) ){
		msg = 'The email address you enteres appears to be invalid.  It should be in the form "user@domain.ext".';
		document.getElementById('user_email').focus();
	}
	// check the address
	else if( !document.getElementById('user_address_1').value ){
		msg = 'Please enter your address';
		document.getElementById('user_address_1').focus();
	}
	// check the city
	else if( !document.getElementById('user_city').value ){
		msg = 'Please enter your city';
		document.getElementById('user_city').focus();
	}
	// check the postal code
	else if( !document.getElementById('user_zip').value ){
		msg = 'Please enter your zip/postal code';
		document.getElementById('user_zip').focus();
	}
	// check the country
	else if( !document.getElementById('user_country').options[ document.getElementById('user_country').selectedIndex ].value ){
		msg = 'Please select your country';
		document.getElementById('user_country').focus();
	}
	// check the country
	else if( (document.getElementById('user_country').options[ document.getElementById('user_country').selectedIndex ].value=='US'
		|| document.getElementById('user_country').options[ document.getElementById('user_country').selectedIndex ].value=='CA') 
		&& !document.getElementById('user_state').options[ document.getElementById('user_state').selectedIndex ].value ){
		msg = 'Please select your state or province';
		document.getElementById('user_state').focus();
	}
	
	
	// handle the message and return
	if( msg!=='' ){
		alert( msg );
		return false;
	}
	else{
		return true;
	}
};
// display an error
var OBECheckoutShippingDisplayError = function( txt ){
	alert( txt );
/*
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_checkout_cart_holder');
	// get a reference to the title div
	var ttl_div = document.getElementById('obebar_checkout_cart_title');
	// set up the title text
	var ttl_txt = (OBECart.getItemCount()>0) ? 'Your cart contains:' : 'Your cart is empty';
	// create a div
	var the_div = document.createElement( 'div' );
	var the_date = new Date();
	var the_class_name = 'obebar_checkout_cart_error' + the_date.valueOf();

	the_div.className = 'obebar_checkout_cart_error';
	the_div.id = the_class_name;
	// create a p
	var the_p = document.createElement('p');
	the_p.className = 'obebar_checkout_cart_error';
	// create a text node
	var the_txt = document.createTextNode( txt );
	// append txt to p
	the_p.appendChild( the_txt );
	// append p to div
	the_div.appendChild( the_p );
	// insert the div where we want it (after the title)
	cart_div.insertBefore(the_div, ttl_div.nextSibling);
	// set a timeout that removes it after a number of seconds
	setTimeout( 'OBECheckoutCartRemoveError("'+the_class_name+'")', 6000 );
*/
};
// remove the error (after a small amount of time, we want the error to just disappear)
var OBECheckoutShippingRemoveError = function( the_id ){
	// get a reference to the cart div
	var cart_div = document.getElementById('obebar_checkout_cart_holder');
	// try to get a ref to the error
	if( error_div = document.getElementById( the_id ) ){
		cart_div.removeChild( error_div );
	}
}
/*  END DISPLAY THE SHIPPING PAGE  */




/*  DISPLAY THE LOGIN PAGE  */

// load in the login form
var OBEDisplayLogin = function(){

	// get ref to main div
	var holder_div = document.getElementById('obe_bar_content_holder');
	// empty the holder
	if( SSEmptyNode( holder_div ) ){
		
		OBECheckoutAddGenericElements( holder_div, OBE_checkout_settings.checkout_process_headline_receipt );
		
		
		
		// add the left subbheader
		subh_div = document.createElement( 'div' );
		subh_div.className = 'obebar_receipt_subheader';
		// add a text node
		subh_txt = document.createTextNode( OBE_checkout_settings.checkout_process_subheader_receipt );
		subh_div.appendChild( subh_txt );
		// add it onto the holder
		holder_div.appendChild( subh_div );


		// a hlder to hold the text
		txt_hldr = document.createElement( 'div' );
		txt_hldr.className = 'obebar_receipt_text_holder';
		
		// display the order number
		ord_num_div = document.createElement( 'div' );
		ord_num_div.className = 'obebar_receipt_order_number';
		ord_num_txt = document.createTextNode( 'Order number: ' + OBEInfo.OrderInfo.ord_id );
		ord_num_div.appendChild( ord_num_txt );
		txt_hldr.appendChild( ord_num_div );

		// display the order date
		ord_date_div = document.createElement( 'div' );
		ord_date_div.className = 'obebar_receipt_order_date';
		ord_date_txt = document.createTextNode( 'Order date: ' + OBEInfo.OrderInfo.ord_added_string );
		ord_date_div.appendChild( ord_date_txt );
		txt_hldr.appendChild( ord_date_div );

		// info 1
		info1_div = document.createElement( 'div' );
		info1_div.className = 'obebar_receipt_info';
		info1_txt = document.createTextNode( 'Items will be shipped 4-6 weeks from the above date.' );
		info1_div.appendChild( info1_txt );
		txt_hldr.appendChild( info1_div );

		// info 2
		info2_div = document.createElement( 'div' );
		info2_div.className = 'obebar_receipt_info';
		info2_txt = document.createTextNode( 'A detailed copy of your receipt will be emailed to you shortly.' );
		info2_div.appendChild( info2_txt );
		txt_hldr.appendChild( info2_div );


		// the "return to my account" bit
		ship_link_p = document.createElement( 'p' );
		ship_link_p.className = 'obebar_receipt_top_link';
		ship_link_p.onclick = function(){
			OBEContentLoad( 'product_list' );
		};
		ship_link_a = document.createElement( 'a' );
		ship_link_a.className = 'obebar_receipt_top_link';
		ship_link_a.href = '#';
		ship_link_a.onclick = function(){
			return false;
		};
		ship_link_txt = document.createTextNode( 'Return to my account' );
		ship_link_a.appendChild( ship_link_txt );
		ship_link_p.appendChild( ship_link_a );
		ship_link_arrow = document.createElement( 'img' );
		ship_link_arrow.className = 'obebar_link_arrow_right';
		ship_link_arrow.src = 'http://69.56.220.155/_gr/_obe_bar/right_arrow.png';
		ship_link_p.appendChild( ship_link_arrow );
		txt_hldr.appendChild( ship_link_p );

		// the "close account panel" bit
		ship_link_p = document.createElement( 'p' );
		ship_link_p.className = 'obebar_receipt_bottom_link';
		ship_link_p.onclick = function(){
			OBEBarGenericCollapse();
		};
		ship_link_a = document.createElement( 'a' );
		ship_link_a.className = 'obebar_receipt_bottom_link';
		ship_link_a.href = '#';
		ship_link_a.onclick = function(){
			return false;
		};
		ship_link_txt = document.createTextNode( 'Close account panel' );
		ship_link_a.appendChild( ship_link_txt );
		ship_link_p.appendChild( ship_link_a );
		ship_link_arrow = document.createElement( 'img' );
		ship_link_arrow.className = 'obebar_link_arrow_right';
		ship_link_arrow.src = 'http://69.56.220.155/_gr/_obe_bar/right_arrow.png';
		ship_link_p.appendChild( ship_link_arrow );
		txt_hldr.appendChild( ship_link_p );



		holder_div.appendChild( txt_hldr );
	}
};
/*  END DISPLAY THE LOGIN PAGE  */










/*  ACTIONS: VIEW MY ACCOUNT  */
var toggleOBEBarViewMyAccount = function(e){
	var e_obj = YAHOO.util.Event.getTarget(e);
	e_obj.clicked = (e_obj.clicked) ? false : true;
	toggleOBEBar( e, 'product_list' );
};
YAHOO.util.Event.addListener("obe_action_my_karmas_link","click",toggleOBEBarViewMyAccount);
/*  END ACTIONS: VIEW MY ACCOUNT  */




