
function jjContact(){
	var jjAddress = "tmccurdy@owlo.com";
	location.href = "mailto:" + jjAddress;
}

function jjContactWSubject(){
	var jjAddress = "tmccurdy@owlo.com";
	location.href = "mailto:" + jjAddress + "?subject=RSVP - Reflections Bariatric Fashion Show";
}

function jjContactMulti(w){
	var jj_eNumber = w;
	if (jj_eNumber==1){
		location.href = "mailto:tmccurdy@owlo.com";
	}
	if (jj_eNumber==2){
		location.href = "mailto:tmccurdy@owlo.com";
	}
}



function ccLiveNoPass(e){
var key = (window.Event) ? e.which : e.keyCode;
if ((key < 48 || key > 57) && (key < 0 || key > 9) && (key < 96 || key > 105) && (key != 37) && (key != 39)){
	if (key == 13) {
	self.compute();
	}
	return false;
}}

function ccEndCatch(e){
var key = (window.Event) ? e.which : e.keyCode;
	if (key == 13 || key == 9) {
	self.document.forms[0].htf.focus();
	}
}

function ccClearResults(){
var ccClearAllString = self.document.forms[0];
ccClearAllString.htf.value = "";
ccClearAllString.hti.value = "";
ccClearAllString.wt.value = "";
ccClearAllString.bmi.value = "";
changeResults(0);
ccClearAllString.htf.focus();
}

function cal_bmi(lbs, ins){
   h2 = ins * ins;
   bmi = lbs/h2 * 703
   f_bmi = Math.floor(bmi);
   diff  = bmi - f_bmi;
   diff = diff * 10;
   diff = Math.round(diff);

   if (diff == 10){
      f_bmi += 1;
      diff   = 0;
   }
   bmi = f_bmi + "." + diff;
   return bmi;
}



function compute(){
   var f = self.document.forms[0];
   w = f.wt.value;
   v = f.htf.value;
   u = f.hti.value;
   
   if (!chkw(u)){
     var ii = 0;
     f.hti.value = 0;
   }
   else{
     var it = f.hti.value*1;
     var ii = parseInt(it);
    }
   var fi = parseInt(f.htf.value * 12);
   var i =  parseInt(f.htf.value * 12) + f.hti.value*1.0;

   if (!chkw(v)){
     alert("Please enter a number for your height.");
     f.htf.focus();
     return;
   }
   if (!chkw(w)){
     alert("Please enter a number for your weight.");
     f.wt.focus();
     return;
   }
   f.bmi.value = cal_bmi(w, i);
   changeResults(cal_bmi(w, i));
   f.bmi.focus();
}



function chkw(w){
   if (isNaN(parseInt(w))){
      return false;
   } else if (w < 0){
  return false;
  }
  else{
  return true;
  }
}



function changeResults(jjFinalBMI){
var ni = document.getElementById('bmiResults');

var divIdName = "bmiResultsSub";
var newdiv = document.createElement('div');

newdiv.setAttribute("id",divIdName);
 
if (ni.hasChildNodes()) {
	removeResults('bmiResultsSub');
	newdiv.innerHTML = jjPlainTextResults(jjFinalBMI);
	ni.appendChild(newdiv);
} else {
	newdiv.innerHTML = jjPlainTextResults(jjFinalBMI);
	ni.appendChild(newdiv);
	}
}



function removeResults(divNum){
var d = document.getElementById('bmiResults');
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);
}


function jjPlainTextResults(ccBmiNumber){

jjPrintHighlightPRE = "<div style='color:#FFFFFF;font-weight: bold;background-color:#8EB25E;padding: 2px 0px 2px 0px;margin:0px;width:184px'><span style='padding:0px 0px 0px 10px;'>"
jjPrintHighlightPOST = "</span></div>"

jjPrintNormPRE = "<div style='padding : 2px 0px 2px 10px;'>"
jjPrintNormPOST = "</div>"

jjResult001 = "Underweight < 18.5"
jjResult002 = "Normal 18.5-24.9"
jjResult003 = "Overweight 25-29.9"
jjResult004 = "Obese I 30-34.9"
jjResult005 = "Obese II 35-39.9"
jjResult006 = "Morbid Obesity 40+"

jjResultsARR_001 = new Array (jjPrintNormPRE + jjResult001 + jjPrintNormPOST,jjPrintHighlightPRE + jjResult001 + jjPrintHighlightPOST)
jjResultsARR_002 = new Array (jjPrintNormPRE + jjResult002 + jjPrintNormPOST,jjPrintHighlightPRE + jjResult002 + jjPrintHighlightPOST)
jjResultsARR_003 = new Array (jjPrintNormPRE + jjResult003 + jjPrintNormPOST,jjPrintHighlightPRE + jjResult003 + jjPrintHighlightPOST)
jjResultsARR_004 = new Array (jjPrintNormPRE + jjResult004 + jjPrintNormPOST,jjPrintHighlightPRE + jjResult004 + jjPrintHighlightPOST)
jjResultsARR_005 = new Array (jjPrintNormPRE + jjResult005 + jjPrintNormPOST,jjPrintHighlightPRE + jjResult005 + jjPrintHighlightPOST)
jjResultsARR_006 = new Array (jjPrintNormPRE + jjResult006 + jjPrintNormPOST,jjPrintHighlightPRE + jjResult006 + jjPrintHighlightPOST)

	if ((ccBmiNumber > 0) && (ccBmiNumber < 18.5)) {
		jjLightswitch = new Array (1,0,0,0,0,0);
	} else if ((ccBmiNumber >= 18.5) && (ccBmiNumber <= 24.9)) {
		jjLightswitch = new Array (0,1,0,0,0,0);
	} else if ((ccBmiNumber >= 25) && (ccBmiNumber <= 29.9)) {
		jjLightswitch = new Array (0,0,1,0,0,0);
	} else if ((ccBmiNumber >= 30) && (ccBmiNumber <= 34.9)) {
		jjLightswitch = new Array (0,0,0,1,0,0);
	} else if ((ccBmiNumber >= 35) && (ccBmiNumber <= 39.9)) {
		jjLightswitch = new Array (0,0,0,0,1,0);
	} else if (ccBmiNumber >= 40) {
		jjLightswitch = new Array (0,0,0,0,0,1);
	} else {
		jjLightswitch = new Array (0,0,0,0,0,0);
	}
	 
	jjPrintResults = new Array (jjResultsARR_001[(jjLightswitch[0])],jjResultsARR_002[(jjLightswitch[1])],jjResultsARR_003[(jjLightswitch[2])],jjResultsARR_004[(jjLightswitch[3])],jjResultsARR_005[(jjLightswitch[4])],jjResultsARR_006[(jjLightswitch[5])]);
	if (ccBmiNumber > 0){
		jjPrintFinal = jjPrintResults.join("");
		jjPrintFinal = "<img src='0i/sb_div_b.gif' alt='' height='21' width='185' border='0'><br>" + jjPrintFinal;
	} else {
		jjPrintFinal = "";
	}
return jjPrintFinal;
}



function CC_VFF_SUB(){
	var theForm = document.FormNameMini;
	var sFlg_PrefD = false;
	var emailRE = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	var errMsg = "";
	var setfocus = "";
	
	for(var s1=0;s1<theForm['ff_mini_contact_pref'].length;s1++){if(theForm['ff_mini_contact_pref'].options[s1].selected){if(theForm['ff_mini_contact_pref'].options[s1].text==theForm['ff_mini_contact_pref'].options[0].text)sFlg_PrefD=true;}}

	if (sFlg_PrefD){
		errMsg = "Please select a preferred\nseminar date from the list\.";
		setfocus = "['ff_mini_contact_pref']";
	}
	if (!emailRE.test(theForm['email'].value)){
		errMsg = "A valid email address is required\.";
		setfocus = "['email']";
	}
	if (theForm['realname'].value == ""){
		errMsg = "A contact name is required\.";
		setfocus = "['realname']";
	}
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	else theForm.submit();
}



function CC_VFF(){
	var theForm = document.FormContact;
	var sFlg_PrefD = false;
	var emailRE = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	var errMsg = "";
	var setfocus = "";
	
	for(var s1=0;s1<theForm['ff_contact_pref'].length;s1++){if(theForm['ff_contact_pref'].options[s1].selected){if(theForm['ff_contact_pref'].options[s1].text==theForm['ff_contact_pref'].options[0].text)sFlg_PrefD=true;}}

	if (sFlg_PrefD){
		errMsg = "Please select a preferred\ncontact method from the list\.";
		setfocus = "['ff_contact_pref']";
	}
	if (!emailRE.test(theForm['email'].value)){
		errMsg = "A valid email address is required\.";
		setfocus = "['email']";
	}
	if (theForm['realname'].value == ""){
		errMsg = "A contact name is required\.";
		setfocus = "['realname']";
	}
	if (!theForm['message'].value == ""){
		errMsg = "Blank\.";
		setfocus = "['message']";
	}
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	else theForm.submit();
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



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

function ScrollTo(obj){
	if ((BrowserDetect.browser=="Explorer") && (BrowserDetect.version<6)){
		var objpos = ObjectPosition(document.getElementById(obj));
		try{
		scroll(0,objpos[1]);
		} catch(e) {}
		try{
		window.scrollTo(0,objpos[1]);
		} catch(e) {}
	} else {
		try{
		var objpos = ObjectPosition(document.getElementById(obj));
		} catch(e) {}
		try{
		setTimeout(function(){scroll(0,objpos[1]);},250);
		} catch(e) {}
		try{
		setTimeout(function(){window.scrollTo(0,objpos[1]);},250);
		}	catch(e) {}
	}
}

function jjClearFormA(){
	document.FormNameMini.realname.value = '';
	document.FormNameMini.email.value = '';
	document.FormNameMini.ff_mini_phone_a.value = '';
	document.FormNameMini.ff_mini_comments.value = '';
}

function jjClearFormB(){
	document.FormContact.realname.value = '';
	document.FormContact.email.value = '';
	document.FormContact.ff_phone_a.value = '';
	document.FormContact.ff_phone_b.value = '';
	document.FormContact.ff_address_a.value = '';
	document.FormContact.ff_address_b.value = '';
	document.FormContact.ff_city.value = '';
	document.FormContact.ff_state.value = '';
	document.FormContact.ff_zip.value = '';
	document.FormContact.ff_comments.value = '';
}

function jjClearFormC(){
	document.FormNameMini.realname.value = '';
	document.FormNameMini.email.value = '';
	document.FormNameMini.ff_mini_phone_a.value = '';
	document.FormNameMini.ff_insurance.value = '';
	document.FormNameMini.ff_mini_comments.value = '';
}


function ccLoadPage(){
	changeResults(0);
	if (ccCap=="1"){
		ScrollTo('jjJump');
	}
}
//function ccResized(){
//}


window.onload=ccLoadPage;

//window.onresize=ccResized;
