///////////////////////////////////////////////////////////////////////
//Force Login Form Data Fields to Lowercase
///////////////////////////////////////////////////////////////////////
function makeLoginLowercase() {
document.loginForm.username.value = document.loginForm.username.value.toLowerCase();
document.loginForm.password.value = document.loginForm.password.value.toLowerCase();
}

///////////////////////////////////////////////////////////////////////
//Force All Registration Forms and Admin Add & Edit Forms Data Fields to Lowercase
///////////////////////////////////////////////////////////////////////
function makeRegLowercase() {
document.registerForm.email.value = document.registerForm.email.value.toLowerCase();
document.registerForm.email_verify.value = document.registerForm.email_verify.value.toLowerCase();
document.registerForm.password.value = document.registerForm.password.value.toLowerCase();
document.registerForm.password_verify.value = document.registerForm.password_verify.value.toLowerCase();
}

///////////////////////////////////////////////////////////////////////
//Force Edit Profile Form Data Fields to Lowercase
///////////////////////////////////////////////////////////////////////
function makeeditProfilLowercase() {
document.editProfileForm.password.value = document.editProfileForm.password.value.toLowerCase();
document.editProfileForm.password_verify.value = document.editProfileForm.password_verify.value.toLowerCase();
}

///////////////////////////////////////////////////////////////////////
//Force Modify Participant Form Data Fields to Lowercase
///////////////////////////////////////////////////////////////////////
function makeModifyParticipantLowercase() {
document.modifyParticipantForm.email.value = document.modifyParticipantForm.email.value.toLowerCase();
document.modifyParticipantForm.email_verify.value = document.modifyParticipantForm.email_verify.value.toLowerCase();
document.modifyParticipantForm.password.value = document.modifyParticipantForm.password.value.toLowerCase();
document.modifyParticipantForm.password_verify.value = document.modifyParticipantForm.password_verify.value.toLowerCase();
}

///////////////////////////////////////////////////////////////////////
//Function To Place Focus In Form
///////////////////////////////////////////////////////////////////////
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}

///////////////////////////////////////////////////////////////////////
// Calculations For Personalize Page
///////////////////////////////////////////////////////////////////////
function round(number,X) {
// rounds number to X decimal places, defaults to 2
X = (!X ? 2 : X);
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function recalculate()  {
  goal_weight=document.personalizeForm.goal_weight.value;
  steps_fifty_feet=document.personalizeForm.steps_fifty_feet.value;
  stride_length=50/steps_fifty_feet;
  if ((goal_weight != "") && (steps_fifty_feet != "")) {

    //Number 3
    stride_length=round(stride_length);
    document.personalizeForm.stride_length.value=stride_length;
							
    //Number 4
    document.personalizeForm.calories.value=Math.round(goal_weight*.67);
						
    //Number 5
    document.personalizeForm.steps_mile.value=Math.round(5280/stride_length);
							
    //Number 6
    document.personalizeForm.steps_calorie.value=Math.round(document.personalizeForm.steps_mile.value/document.personalizeForm.calories.value);
							
    //Number 7
    document.personalizeForm.steps_goal_weight.value=Math.round(document.personalizeForm.steps_mile.value*4.5);
							
    //Number 8
    document.personalizeForm.steps_accell.value=Math.round(document.personalizeForm.steps_goal_weight.value*1.5);

    //Number 9
    document.personalizeForm.bmi.value=Math.round((document.personalizeForm.goal_weight.value * 704.4) / (document.personalizeForm.height.value * document.personalizeForm.height.value));
  }
}


///////////////////////////////////////////////////////////////////////
//Open Browser Window
///////////////////////////////////////////////////////////////////////
function openBrWindow(theURL,winName,features) {
  messageWindow=window.open(theURL,winName,features);

  //Move window to center of screen
  var screen_width=screen.availWidth;
  var screen_height=screen.availHeight;
		
  var x=((screen_width/2)-200);
  var y=((screen_height/2)-100);
	
  messageWindow.moveTo(x,y); 
}

///////////////////////////////////////////////////////////////////////
//Print It
///////////////////////////////////////////////////////////////////////
function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";  
}
}


///////////////////////////////////////////////////////////////////////
//Alert Before Redirection
///////////////////////////////////////////////////////////////////////
function go_there(){
 var where_to= confirm("I understand that it is highly recommended to visit my physcian prior to starting any exercise program.");
 if (where_to== true)
 {
   window.location="http://www.cornerstonefitness.com/cgi-bin/acmeCompany/cart/ABCstore.cgi";
   //window.location="http://www.cornerstonefitness.com/acmeCompany/10ksteps.html";
 }
 else
 {
  window.location="http://www.cornerstonefitness.com/acmeCompany/10ksteps.html";
  }
}

///////////////////////////////////////////////////////////////////////
// Populate SelectBox With Current Date
///////////////////////////////////////////////////////////////////////
var months = new Array()
months[1] = "01"
months[2] = "02"
months[3] = "03"
months[4] = "04"
months[5] = "05"
months[6] = "06"
months[7] = "07"
months[8] = "08"
months[9] = "09"
months[10] = "10"
months[11] = "11"
months[12] = "12"

var today = new Date()
var month = today.getMonth()+1
var date = today.getDate()


function correctDate(form,menu1){

	for(i=0; i<form.elements.length; i++){
		if(form.elements[i]==menu1){
		var nextmenu=form.elements[i+1]
		break
		}
	}
var formerlength=nextmenu.options.length

	if(menu1.options[1].selected){
	thelength=28
	}
	else if(menu1.options[3].selected || menu1.options[5].selected || menu1.options[8].selected || menu1.options[10].selected){
	thelength=30
	}
	else{
	thelength=31
	}
	nextmenu.options.length=thelength
	for(i=formerlength; i<thelength; i++){
	nextmenu.options[i].value=i+1
	nextmenu.options[i].text=i+1
	}
	nextmenu.selectedIndex=thelength-1
	
}


///////////////////////////////////////////////////////////////////////
//Bookmark Function
///////////////////////////////////////////////////////////////////////
function addbookmark() {
bookmarkurl="http://www.cornerstonefitness.com/acmeCompany/index.php"
bookmarktitle="Login: 10,000 Steps-a-Day Walking Program"
alertMsg="Sorry. Your browser does not support this function.  Netscape users may bookmark this page manually by clicking <Ctrl-D>."

if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
else 
alert(alertMsg);
}

///////////////////////////////////////////////////////////////////////
//Display Current Date
///////////////////////////////////////////////////////////////////////
// Set an array for the days of the week
// We add a comma and a space to each for presentation
// get.day will return 0 through 6 as valid values 
function displayCurrentDate() {
word_day = new Array(
"Sunday, ",
"Monday, ",
"Tuesday, ",
"Wednesday, ",
"Thursday, ",
"Friday, ",
"Saturday")

// Set an array for the Months of the year
// We add a space after the month for presentation
// get.month will return 0 through 11 as valid values 
word_month = new Array(
"January ",
"February ",
"March ",
"April ",
"May ",
"June ",
"July ",
"August ",
"September ", 
"October ",
"November ",
"December ")

// Set right_now to the current date() value
right_now = new Date();

// Write the day of the week
document.write(word_day[right_now.getDay()]+ "&nbsp;");
// Write the Month of the year
document.write(word_month[right_now.getMonth()]+ "&nbsp;");

//Write the date of the month
document.write(right_now.getDate() + ",&nbsp;");

// Write out the Year
var right_year=right_now.getYear();
if (right_year < 2000) 
right_year = right_year + 1900; 
document.write( right_year );
}

///////////////////////////////////////////////////////////////////////
//Accept Medical Disclaimer" form submission
///////////////////////////////////////////////////////////////////////
var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read & accept Medical Disclaimer before proceeding.")
return false
}
}
}


///////////////////////////////////////////////////////////////////////
//Show Form Elements on Admin Report Feature
///////////////////////////////////////////////////////////////////////

function check_totalStepsMin() {
  if(document.adminSearchForm.select_totalStepsMin.value == '0') {
  	alert('Sorry, the Minimum Total value must be greater than zero.');
  	return false;
  }
}

function enableRadioButtons() {
  if(document.adminSearchForm.select_dateRangeAfter.value != '' && document.adminSearchForm.select_dateRangeBefore.value != '') {
   document.adminSearchForm.searchOption[0].disabled = false;
   document.adminSearchForm.searchOption[1].disabled = false;
   document.adminSearchForm.searchOption[2].disabled = false;
  } else {
   document.adminSearchForm.searchOption[0].checked = false;
   document.adminSearchForm.searchOption[0].disabled = true;
   document.adminSearchForm.searchOption[1].checked = false;
   document.adminSearchForm.searchOption[1].disabled = true;
   document.adminSearchForm.searchOption[2].checked = false;
   document.adminSearchForm.searchOption[2].disabled = true;
  }
}

function averageSteps() {
  if(document.adminSearchForm.select_dateRangeAfter.value == '' || document.adminSearchForm.select_dateRangeBefore.value == '') {
  	alert('Please enter a date range.');
  	return false;
  }
  adminSearchForm.select_totalStepsMin.value = "";
  adminSearchForm.select_totalStepsMin.disabled = true;
  adminSearchForm.select_totalStepsMax.value = "";
  adminSearchForm.select_totalStepsMax.disabled = true;
  adminSearchForm.select_dailyEntries.value = "";
  adminSearchForm.select_dailyEntries.disabled = true;
  adminSearchForm.select_stepsAveraged.disabled = false;
  adminSearchForm.select_stepsAveraged.value = "";
  adminSearchForm.select_stepsAveraged.focus();
}


function totalSteps() {
  if(document.adminSearchForm.select_dateRangeAfter.value == '' || document.adminSearchForm.select_dateRangeBefore.value == '') {
  	alert('Please enter a date range.');
  	return false;
  }
  adminSearchForm.select_stepsAveraged.value = "";
  adminSearchForm.select_stepsAveraged.disabled = true;
  adminSearchForm.select_dailyEntries.value = "";
  adminSearchForm.select_dailyEntries.disabled = true;
  adminSearchForm.select_totalStepsMin.disabled = false;
  adminSearchForm.select_totalStepsMin.value = "";
  adminSearchForm.select_totalStepsMax.disabled = false;
  adminSearchForm.select_totalStepsMax.value = "";
  adminSearchForm.select_totalStepsMin.focus();
}
function dailyEntries() {
  if(document.adminSearchForm.select_dateRangeAfter.value == '' || document.adminSearchForm.select_dateRangeBefore.value == '') {
  	alert('Please enter a date range.');
  	return false;
  }
  adminSearchForm.select_stepsAveraged.value = "";
  adminSearchForm.select_stepsAveraged.disabled = true;
  adminSearchForm.select_totalStepsMin.value = "";
  adminSearchForm.select_totalStepsMin.disabled = true;
  adminSearchForm.select_totalStepsMax.value = "";
  adminSearchForm.select_totalStepsMax.disabled = true;
  adminSearchForm.select_dailyEntries.disabled = false;
  adminSearchForm.select_dailyEntries.value = "";
  adminSearchForm.select_dailyEntries.focus();
}

///////////////////////////////////////////////////////////////////////////////
// ========== Current Date ==========
///////////////////////////////////////////////////////////////////////////////
var d = new Date()
//document.write(d.getDate())
//document.write(".")
//document.write(d.getMonth() + 1)
//document.write(".")
//document.write(d.getFullYear())



///////////////////////////////////////////////////////////////////////
//Form Validation
///////////////////////////////////////////////////////////////////////
var nbsp = 160;		// non-breaking space char
var node_text = 3;	// DOM text node-type
var emptyString = /^\s*$/ ;
var global_valfield;	// retain valfield for timer thread

// --------------------------------------------
//                  trim
// Trim leading/trailing whitespace off string
// --------------------------------------------

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}


// --------------------------------------------
//                  setfocus
// Delayed focus setting to get around IE bug
// --------------------------------------------

function setFocusDelayed()
{
  global_valfield.focus();
}

function setfocus(valfield)
{
  // save valfield in global variable so value retained when routine exits
  global_valfield = valfield;
  setTimeout( 'setFocusDelayed()', 100 );
}


// --------------------------------------------
//                  msg
// Display warn/formError message in HTML element.
// commonCheck routine must have previously been called
// --------------------------------------------

function msg(fld,     // id of element to display message in
             msgtype, // class to give element ("warn" or "formError")
             message) // string to display
{
  // setting an empty string can give problems if later set to a 
  // non-empty string, so ensure a space present. (For Mozilla and Opera one could 
  // simply use a space, but IE demands something more, like a non-breaking space.)
  var dispmessage;
  if (emptyString.test(message)) 
    dispmessage = String.fromCharCode(nbsp);    
  else  
    dispmessage = message;

  var elem = document.getElementById(fld);
  elem.firstChild.nodeValue = dispmessage;  
  
  elem.className = msgtype;   // set the CSS class to adjust appearance of message
}

// --------------------------------------------
//            commonCheck
// Common code for all validation routines to:
// (a) check for older / less-equipped browsers
// (b) check if empty fields are required
// Returns true (validation passed), 
//         false (validation failed) or 
//         proceed (don't know yet)
// --------------------------------------------

var proceed = 2;  

function commonCheck    (valfield,   // element to be validated
                         infofield,  // id of element to receive info/formError msg
                         required)   // true if required
{
  if (!document.getElementById) 
    return true;  // not available on this browser - leave validation to the server
  var elem = document.getElementById(infofield);
  if (!elem.firstChild) return true;  // not available on this browser 
  if (elem.firstChild.nodeType != node_text) return true;  // infofield is wrong type of node  

  if (emptyString.test(valfield.value)) {
    if (required) {
      msg (infofield, "formError", "ERROR: required");  
      setfocus(valfield);
      return false;
    }
    else {
      msg (infofield, "warn", "");   // OK
      return true;  
    }
  }
  return proceed;
}

// --------------------------------------------
//            validatePresent
// Validate if something has been entered
// Returns true if so 
// --------------------------------------------

function validatePresent(valfield,   // element to be validated
                         infofield ) // id of element to receive info/formError msg
{
  var stat = commonCheck (valfield, infofield, true);
  if (stat != proceed) return stat;

  msg (infofield, "warn", "");  
  return true;
}

// --------------------------------------------
//               validateEmail
// Validate if e-mail address
// Returns true if so (and also if could not be executed because of old browser)
// --------------------------------------------

function validateEmail  (valfield,   // element to be validated
                         infofield,  // id of element to receive info/formError msg
                         required)   // true if required
{
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;

  var tfld = trim(valfield.value);  // value of field with whitespace trimmed off
  var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
  if (!email.test(tfld)) {
    msg (infofield, "formError", "ERROR: not a valid e-mail address");
    setfocus(valfield);
    return false;
  }

  var email2 = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/  ;
  if (!email2.test(tfld)) 
    msg (infofield, "warn", "Unusual e-mail address - check if correct");
  else
    msg (infofield, "warn", "");
  return true;
}


// --------------------------------------------
//            validateTelnr
// Validate telephone number
// Returns true if so (and also if could not be executed because of old browser)
// Permits spaces, hyphens, brackets and leading +
// --------------------------------------------

function validateTelnr  (valfield,   // element to be validated
                         infofield,  // id of element to receive info/formError msg
                         required)   // true if required
{
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;

  var tfld = trim(valfield.value);  // value of field with whitespace trimmed off
  var telnr = /^\+?[0-9 ()-]+[0-9]$/  ;
  if (!telnr.test(tfld)) {
    msg (infofield, "formError", "ERROR: not a valid telephone number. Characters permitted are digits, space ()- and leading +");
    setfocus(valfield);
    return false;
  }

  var numdigits = 0;
  for (var j=0; j<tfld.length; j++)
    if (tfld.charAt(j)>='0' && tfld.charAt(j)<='9') numdigits++;

  if (numdigits<6) {
    msg (infofield, "formError", "ERROR: " + numdigits + " digits - too short");
    setfocus(valfield);
    return false;
  }

  if (numdigits>14)
    msg (infofield, "warn", numdigits + " digits - check if correct");
  else { 
    if (numdigits<10)
      msg (infofield, "warn", "Only " + numdigits + " digits - check if correct");
    else
      msg (infofield, "warn", "");
  }
  return true;
}

// --------------------------------------------
//             validateAge
// Validate person's age
// Returns true if OK 
// --------------------------------------------

function validateAge    (valfield,   // element to be validated
                         infofield,  // id of element to receive info/formError msg
                         required)   // true if required
{
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;

  var tfld = trim(valfield.value);
  var ageRE = /^[0-9]{1,3}$/
  if (!ageRE.test(tfld)) {
    msg (infofield, "formError", "ERROR: not a valid age");
    setfocus(valfield);
    return false;
  }

  if (tfld>=200) {
    msg (infofield, "formError", "ERROR: not a valid age");
    setfocus(valfield);
    return false;
  }

  if (tfld>110) msg (infofield, "warn", "Older than 110: check correct");
  else {
    if (tfld<7) msg (infofield, "warn", "Bit young for this, aren't you?");
    else        msg (infofield, "warn", "");
  }
  return true;
}

// --------------------------------------------
//             validateNumber
// Validate for numerics only
// Returns true if OK 
// --------------------------------------------

function validateNumber  (valfield,   // element to be validated
                         infofield,  // id of element to receive info/formError msg
                         required)   // true if required
{
  var stat = commonCheck (valfield, infofield, required);
  if (stat != proceed) return stat;

  var tfld = trim(valfield.value);
  var ageRE = /^[0-9]{1,6}$/
  if (!ageRE.test(tfld)) {
    msg (infofield, "formError", "ERROR: not a valid number");
    setfocus(valfield);
    return false;
  }

  if (tfld>999998) msg (infofield, "warn", "Warning: Number is high.");
  else {
    if (tfld<1) msg (infofield, "warn", "Warning: Number is low.");
    else        msg (infofield, "warn", "");
  }
  return true;
}

///////////////////////////////////////////////////////////////////////
// REMEMBER FORM INPUT
///////////////////////////////////////////////////////////////////////
function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value, days){
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

function rememberForm(formid){ //Main remember form values object
this.formref=document.getElementById(formid)? document.getElementById(formid) : document.forms[formid]
this.cookiename=formid
this.persistdays=180 //days to persist form values
this.fields=new Array()
this.cookiestr=""
var forminstance=this
rememberForm.dotask(this.formref, function(){forminstance.savevalues()}, "submit") //save form values onsubmit
rememberForm.dotask(window, function(){forminstance.recallvalues()}, "load") //populate form with saved values onload (body)
}

rememberForm.prototype.getfield=function(attr){ //get form field based on its ID or name attribute
var fieldref=document.getElementById(attr)? document.getElementById(attr) : this.formref[attr]
return fieldref
}

rememberForm.prototype.persistfields=function(){ //get form fields to persist values for
for (var i=0; i<arguments.length; i++){
this.fields[i]=this.getfield(arguments[i])
this.fields[i].fname=arguments[i] //store name or id of field in custom property
}
}

rememberForm.prototype.savevalues=function(){ //get form values and store in cookie
for (var i=0; i<this.fields.length; i++){
if (this.fields[i].type=="text")
this.cookiestr+=this.fields[i].fname+":"+escape(this.fields[i].value)+"#"
}
if (typeof this.togglebox!="undefined"){ //if "remember values checkbox" is defined
this.persistdays=(this.togglebox.checked)? this.persistdays : -1 //decide whether to save form values
this.cookiestr=(this.togglebox.checked)? this.cookiestr+"toggleboxid:on;" : this.cookiestr
}
else //if checkbox isn't defined, just remove final "#" from cookie string
this.cookiestr=this.cookiestr.substr(0, this.cookiestr.length-1)+";"
setCookie(this.cookiename, this.cookiestr, this.persistdays)
}

rememberForm.prototype.recallvalues=function(){ //populate form with saved values
var cookievalue=getCookie(this.cookiename)
if (cookievalue!=""){ //parse cookie, where cookie looks like: field1:value1#field2:value2...
var cookievaluepair=cookievalue.split("#")
for (var i=0; i<cookievaluepair.length; i++){
if (cookievaluepair[i].split(":")[0]!="toggleboxid" && this.getfield(cookievaluepair[i].split(":")[0]).type=="text")
this.getfield(cookievaluepair[i].split(":")[0]).value=unescape(cookievaluepair[i].split(":")[1])
else //else if name in name/value pair is "toggleboxid"
this.togglebox.checked=true
}
}
}

rememberForm.prototype.addtoggle=function(attr){
this.togglebox=this.getfield(attr)
}

//Call this function if you wish to clear the user's cookie of any saved values for this form instantly
rememberForm.prototype.clearcookie=function(){
setCookie(this.cookiename, "", -1)
}

rememberForm.dotask=function(target, functionref, tasktype){
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}


///////////////////////////////////////////////////////////////////////
//Drop Down/ Overlapping Content: http://www.dynamicdrive.com
///////////////////////////////////////////////////////////////////////
var dropdowncontent={
	disableanchorlink: true, //when user clicks on anchor link, should link itself be disabled (always true if "revealbehavior" above set to "click")
	hidedivmouseout: [false, 200], //Set hiding behavior within Drop Down DIV itself: [hide_div_onmouseover?, miliseconds_before_hiding]
	ajaxloadingmsg: "Loading content. Please wait...", //HTML to show while ajax page is being feched, if applicable
	ajaxbustcache: true, //Bust cache when fetching Ajax pages?

	getposOffset:function(what, offsettype){
		return (what.offsetParent)? what[offsettype]+this.getposOffset(what.offsetParent, offsettype) : what[offsettype]
	},

	isContained:function(m, e){
		var e=window.event || e
		var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
		while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
		if (c==m)
			return true
		else
			return false
	},

	show:function(anchorobj, subobj, e){
		if (!this.isContained(anchorobj, e)){
			var e=window.event || e
			if (e.type=="click" && subobj.style.visibility=="visible"){
				subobj.style.visibility="hidden"
				return
			}
			var horizontaloffset=(subobj.dropposition[0]=="left")? -(subobj.offsetWidth-anchorobj.offsetWidth) : 0 //calculate user added horizontal offset
			var verticaloffset=(subobj.dropposition[1]=="top")? -subobj.offsetHeight : anchorobj.offsetHeight //calculate user added vertical offset
			subobj.style.left=this.getposOffset(anchorobj, "offsetLeft") + horizontaloffset + "px"
			subobj.style.top=this.getposOffset(anchorobj, "offsetTop")+verticaloffset+"px"
			subobj.style.clip=(subobj.dropposition[1]=="top")? "rect(auto auto auto 0)" : "rect(0 auto 0 0)" //hide drop down box initially via clipping
			subobj.style.visibility="visible"
			subobj.startTime=new Date().getTime()
			subobj.contentheight=parseInt(subobj.offsetHeight)
			if (typeof window["hidetimer_"+subobj.id]!="undefined") //clear timer that hides drop down box?
				clearTimeout(window["hidetimer_"+subobj.id])
			this.slideengine(subobj, (subobj.dropposition[1]=="top")? "up" : "down")
		}
	},

	curveincrement:function(percent){
		return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
	},

	slideengine:function(obj, direction){
		var elapsed=new Date().getTime()-obj.startTime //get time animation has run
		if (elapsed<obj.glidetime){ //if time run is less than specified length
			var distancepercent=(direction=="down")? this.curveincrement(elapsed/obj.glidetime) : 1-this.curveincrement(elapsed/obj.glidetime)
			var currentclip=(distancepercent*obj.contentheight)+"px"
			obj.style.clip=(direction=="down")? "rect(0 auto "+currentclip+" 0)" : "rect("+currentclip+" auto auto 0)"
			window["glidetimer_"+obj.id]=setTimeout(function(){dropdowncontent.slideengine(obj, direction)}, 10)
		}
		else{ //if animation finished
			obj.style.clip="rect(0 auto auto 0)"
		}
	},

	hide:function(activeobj, subobj, e){
		if (!dropdowncontent.isContained(activeobj, e)){
			window["hidetimer_"+subobj.id]=setTimeout(function(){
				subobj.style.visibility="hidden"
				subobj.style.left=subobj.style.top=0
				clearTimeout(window["glidetimer_"+subobj.id])
			}, dropdowncontent.hidedivmouseout[1])
		}
	},

	hidediv:function(subobjid){
		document.getElementById(subobjid).style.visibility="hidden"
	},

	ajaxconnect:function(pageurl, divId){
		var page_request = false
		var bustcacheparameter=""
		if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
			page_request = new XMLHttpRequest()
		else if (window.ActiveXObject){ // if IE6 or below
			try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
			} 
			catch (e){
				try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch (e){}
			}
		}
		else
			return false
		document.getElementById(divId).innerHTML=this.ajaxloadingmsg //Display "fetching page message"
		page_request.onreadystatechange=function(){dropdowncontent.loadpage(page_request, divId)}
		if (this.ajaxbustcache) //if bust caching of external page
			bustcacheparameter=(pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
		page_request.open('GET', pageurl+bustcacheparameter, true)
		page_request.send(null)
	},

	loadpage:function(page_request, divId){
		if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
			document.getElementById(divId).innerHTML=page_request.responseText
		}
	},

 init:function(anchorid, pos, glidetime, revealbehavior){
		var anchorobj=document.getElementById(anchorid)
		var subobj=document.getElementById(anchorobj.getAttribute("rel"))
		var subobjsource=anchorobj.getAttribute("rev")
		if (subobjsource!=null && subobjsource!="")
			this.ajaxconnect(subobjsource, anchorobj.getAttribute("rel"))
		subobj.dropposition=pos.split("-")
		subobj.glidetime=glidetime || 1000
		subobj.style.left=subobj.style.top=0
		if (typeof revealbehavior=="undefined" || revealbehavior=="mouseover"){
			anchorobj.onmouseover=function(e){dropdowncontent.show(this, subobj, e)}
			anchorobj.onmouseout=function(e){dropdowncontent.hide(subobj, subobj, e)}
			if (this.disableanchorlink) anchorobj.onclick=function(){return false}
		}
		else
			anchorobj.onclick=function(e){dropdowncontent.show(this, subobj, e); return false}
		if (this.hidedivmouseout[0]==true) //hide drop down DIV when mouse rolls out of it?
			subobj.onmouseout=function(e){dropdowncontent.hide(this, subobj, e)}
	}
}


///////////////////////////////////////////////////////////////////////
//Personalize Form Check Height
///////////////////////////////////////////////////////////////////////
	function checkHeight (){
		var h = document.personalizeForm.height.value;
		if ( h == "" ) {
			alert ( "Please enter your height expressed in inches." );
			document.personalizeForm.height.focus();
			return false;
		} else if ( h.length != 2) {
			alert ( "Please enter a valid height expressed in inches." );
			document.personalizeForm.height.focus();
			return false;
		} else if ( h < 36) {
			alert ( "This appears to be a bit short. Please enter a valid height expressed in inches." );
			document.personalizeForm.height.focus();
			return false;
		} else if ( h > 78) {
			alert ( "This appears to be a bit tall. Please enter a valid height expressed in inches." );
			document.personalizeForm.height.focus();
			return false;
		} else {
			return true;
		}
	}

        function numeralsOnly(evt) {
            evt = (evt) ? evt : event;
            var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
                ((evt.which) ? evt.which : 0));
            if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                alert("Enter numerals only in this field.");
                return false;
            }
            return true;
        }