
function submitForm(formname)
	{			
		getval=eval('document.' + formname + '.submit()');
	}
			
function clearForm(formname)
	{
		getval=eval('document.' + formname + '.reset()');
	}
		
function validateForm(formname)
	{
		if (formname) {
			var aElements = eval('document.' + formname + '.elements');
		}
			/*		
			for( var i=0; i < aElements.length-1; i++ )
			{
				if( !aElements[i].value )
				{
					alert( aElements[i].name +' cannot be blank' );
					aElements[i].focus();
					return false;
				}
			}*/
	}		

String.prototype.trim = function () {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function killSelect(o) {
	var f = o.innerHTML;
	o.innerHTML='';
	o.innerHTML=f;
}
function tabNavigation() 
{
	alert('tab funct');
}	
function elementRemove(elementId) {
	if (! $(elementId)) return false;
	if (! $(elementId).parentNode) return false;
	$(elementId).parentNode.removeChild($(elementId));
	return false;
}
function clearGroupSearchBox(box) {
    if(!box.alreadyCleared) {
        box.style.color = "black";
        box.value = "";
        box.alreadyCleared = true;
    }
}

function validateGroupActivityInput(inputId, unpressedText, selectId, errorDivId) {
    if($(inputId).value == unpressedText) {
        $(inputId).value = "94110";
    }
    if($F(selectId) == 0) {
        $(errorDivId).innerHTML = "Please select an activity type";
        return false;
    }
    $(groupForm).submit();
    return false;
}

function IsNumeric(strString){
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++){
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1){
         blnResult = false;
         }
      }
   return blnResult;
}

function deleteBoardPost(id,listView, pageIndex)
{
 if(!confirm('Are you sure you want to delete this comment?')){
	 return;
 }
 var rrStr = '';
 if ($('numCommentsCounter')) {
	 $('numCommentsCounter').innerHTML=parseInt($('numCommentsCounter').innerHTML)-1;
	 rrStr='&resourceFormat=true';
 }
 new Ajax.Updater('objectCommentsSection','/deleteBoardPost.s?view='+listView+'&boardPostId='+id+'&pageIndex='+pageIndex+''+rrStr);
}

function createPhone(){
	var value = document.getElementsByName('numberPrefix')[0].value + document.getElementsByName('numberBegin')[0].value + document.getElementsByName('numberEnd')[0].value;
  if(!IsNumeric(value)){
      alert("\nPhone Number value must be a numeric value")
      return false
  }
	if (value.length < 10) {
		alert("\nPlease enter full number");
		return false;
	}
//  initIndicator()
  new Ajax.Updater('phoneSection','createPhone.s?carrier='+document.getElementsByName('carrier')[0].value+'&number='+value+'&view=setGoal');
}

function verifyPhone(personId){
  new Ajax.Updater('phoneSection','confirmPhone.s?person.id='+personId+'&id='+document.getElementsByName('phoneId')[0].value+'&view=setGoal'+'&confirmationKey='+document.getElementsByName('confirmationKey')[0].value);
}
function editPhone(phoneId){
  new Ajax.Updater('phoneSection','editPhone.s?id='+phoneId);
}
function deletePhone(){
  if(confirm('Are you sure you want to delete this phone?')){
    new Ajax.Updater('phoneSection','deletePhone.s');
  }
}

function viewPhone(phoneId){
  new Ajax.Updater('phoneSection','viewPhone.s?sessionUserPhone=true');
}
function updatePhone(){
	var value = document.getElementsByName('numberPrefix')[0].value + document.getElementsByName('numberBegin')[0].value + document.getElementsByName('numberEnd')[0].value;
  if(!IsNumeric(value)){
      alert("\nPhone Number value must be a numeric value")
      return false
  }
	if (value.length < 10) {
		alert("\nPlease enter full number");
		return false;
	}
  new Ajax.Updater('phoneSection','updatePhone.s?carrier='+document.getElementsByName('carrier')[0].value+'&number='+value+'&view=setGoal'+'&id='+document.getElementsByName('phoneId')[0].value+'&person.id='+document.getElementsByName('personId')[0].value);
}

function registerIndicator(id) {
	Ajax.Responders.register({
		onCreate: function() {Element.show(id);},
		onComplete: function() {Element.hide(id); Ajax.Responders.unregister(this);}
	});
}

function openAndPositionLayer(e,layer) {
	cursor = getCursorCoordinates(e);
	$(layer).style.top = cursor.y;
	$(layer).style.left = cursor.x;
	$(layer).style.display = 'block';
	return false;
}

function getCursorCoordinates(e) {
	e = e || window.event;
	var cursorXY = {x:0, y:0};
	cursorXY.x = ((e.pageX || e.pageY) ? (e.pageX) : (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - (document.documentElement.clientLeft || 0)))-25;
	cursorXY.y = ((e.pageY || e.pageX) ? (e.pageY) : (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - (document.documentElement.clientTop || 0)))-10;
	return cursorXY;
}

function updateUserPointsSection(personId) {
	new Ajax.Updater('userPoints', '/userPointsNewValues.s?personId=' + personId);
}

function validateLogValue(value){
  if(!IsNumeric(value)){
    alert('Log value must be numeric.')
  }
}

function shufnums(z) {
	if (z && z.length>0) {
	z = z.split('')
	if (z && z.length>0) {
		var s = 'SPAN';
		o = $('centerPageUnitLower').getElementsByTagName(s);
		if (o && o.length>0) {
			 for (var i=0; i < o.length; i++) {
				 if (o[i].className == 'scoreAtom') {
					o[i].getElementsByTagName(s)[parseInt(z.shift())].className='';
					if (z.length < 1) break;
				 }				 
			 }			
		}
	}
	}
}

function createCopyOFidx(idx,idxt) {
	var t = $(idx).cloneNode(true);
	t.id = idxt;
	document.getElementById('headerPageUnit').appendChild(t);
}

function display(idx, display) {
	idxt = idx+'_tmp';
	if (! $(idxt)) createCopyOFidx(idx,idxt);
	$(idxt).className = (display>0) ? 'def-g-style def-g-yes' : 'def-g-style def-g-no';
}

function setPosition(idx, e) {
	idxt = idx+'_tmp';
	if (! $(idxt)) createCopyOFidx(idx,idxt);
	var dx = 5, dy = 5;
	e = e || window.event;
	$(idxt).style.left = ((e.pageX || e.pageY) ? (e.pageX) : (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - (document.documentElement.clientLeft || 0)))+dx;
	$(idxt).style.top = ((e.pageY || e.pageX) ? (e.pageY) : (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - (document.documentElement.clientTop || 0)))+dy;
/*
	if (e.pageX && e.pageY) {
		$(idx).style.left = dx + e.pageX;
		$(idx).style.top = dy + e.pageY;
	} else
	if (e.clientX && e.clientY) {
		$(idx).style.left = dx + e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
		$(idx).style.top = dy + e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	}
*/
}

function closeHideLayeredPopup(o,event,zeroPosition) {
	var tmpMp = null;
	if(event.toElement) tmpMp = event.toElement;
	else if(event.relatedTarget) tmpMp = event.relatedTarget;
	if(!checkIfNested(o,tmpMp) && o!=tmpMp) {
		o.style.display = 'none';
		if (zeroPosition == true) {
		o.style.top = 0;
		o.style.left = 0;
		}
	}
}
function closeScoreRatingPopup(o,event) {
	closeHideLayeredPopup(o,event,true);
}
function checkIfNested(o,t) {
if(t!=null) {while(t.parentNode) {if((t=t.parentNode)==o) return true;}}
return false;
}
var yVideoFlipFramesL;
var yVideoFlipFramesLc;
function yVideoFlipFramesF(event,o) {
	var tmpMp = null;
	if(event.toElement) tmpMp = event.toElement;
	else if(event.relatedTarget) tmpMp = event.relatedTarget;
	if(!checkIfNested(o,tmpMp) && o!=tmpMp) {
		o = o.getElementsByTagName('IMG')[0];
		if (o.src && o.src.length>0 && o.src.indexOf('.jpg')>0) {
			yVideoFlipFramesLc=null;
			yVideoFlipFrames(false,o);
		}
	}
	else return false;
}
function yVideoFlipFramesI(i,o) {
	if (yVideoFlipFramesL && o==yVideoFlipFramesLc) return false;
	oi = o.getElementsByTagName('IMG')[0];
	if (oi.src && oi.src.length>0 && oi.src.indexOf('.jpg')>0) {
		yVideoFlipFramesLc=o;
		yVideoFlipFrames(i,oi);
	}
	else return false;
}
function yVideoFlipFrames(i,o) {
	if (o.src && o.src.length>0 && o.src.indexOf('.jpg')>0) {
		var n,z;
		z = o.src.indexOf('.jpg');
		n = parseInt(o.src.substring(z-1,z));
		n = ((i)&&(n==1||n==2)) ? n+1:1;
		o.src = o.src.substring(0,z-1)+n+'.jpg';
		if (i) yVideoFlipFramesL = setTimeout(function() {yVideoFlipFramesHlp(o);},750);
		else clearTimeout(yVideoFlipFramesL);
	}
}
function yVideoFlipFramesHlp(o) {
	yVideoFlipFrames(true,o);
}

function openFlagModule(entityType, entityId) {
	new Ajax.Updater('flagModule', '/flagEntity.s?entityType=' + entityType + '&entityId=' + entityId, {method: 'get'});
}

function submitFlagForm() {
	new Ajax.Updater('flagModule', '/flagEntity.s', {parameters: document.flagForm.serialize(true)})
}

function closeFlagModule() {
	document.getElementById("flagModule").innerHTML = '';
}

function popUpBoxConstruct(part) {
	if (part=='open') return "<div class=\"v3bbGreenWhite\"><div class=\"v3bbr1\"></div><div class=\"v3bbr2\"></div><div class=\"v3bbr3\"><div></div></div><div class=\"v3bbr4\"><div></div></div><div class=\"v3bbr5\"><div></div></div><div class=\"v3bbrc1\"><div class=\"v3bbrc2\">";
	if (part=='close') return "</div></div><div class=\"v3bbr5\"><div></div></div><div class=\"v3bbr4\"><div></div></div><div class=\"v3bbr3\"><div></div></div><div class=\"v3bbr2\"></div><div class=\"v3bbr1\"></div></div>";
}
function buttonActionConstruct(aClick,aLabel,aHref,aClass) {
	return '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="button20blue"><a href="'+aHref+'" onclick="'+aClick+'" class="'+aClass+'" ><div><div><div><b>'+aLabel+'</b></div></div></div><div class="cbtnb"><div><div></div></div></div></a></td></tr></table>';
}
function universalBookmarkShowDo(title,url,eid,e) {
	if (!$(eid)) {
		var ppBox  = document.createElement('DIV');
		ppBox.id = eid;
		document.getElementsByTagName('BODY')[0].appendChild(ppBox);
	}
	var formName = 'addBookmarkForm';
	if (eid != 'bookmarkContainerUnit') formName+='_'+eid;
	var outBkm = '<table cellspacing="0" cellpadding="0" border="0"><tr><td>';
	outBkm += popUpBoxConstruct('open') +
		'<div class="bookmarkContainerPopup"><form action="/addMyBookmark.s" name="'+formName+'" id="'+formName+'" class="pm0all">' +
		'<input name="url" value="' + url + '" type="hidden" />' +
		'<input name="backUrl" value="' + url + '" type="hidden" />' +
		'<input name="title" value="' + title + '" type="hidden" />' +
		'<table cellspacing="0" cellpadding="0" border="0"><tr><td>' +
		'<tr><td class="global-mfc p5right">Tags: </td><td><input name="tags" id="tags" type="text" value="" class="color555" style="width:180px;" /></td></tr>'+
		'<tr><td></td><td class="p10top"><div class="clearff"><div class="leftAlign p10right">'+buttonActionConstruct('submitForm(\''+formName+'\'); return false','Add to Bookmarks','','button_action')+'</div>'+
		'<div class="p3top"><a href="" onclick="universalBookmarkShowKill(\''+eid+'\'); return false;">Cancel</a></div></div></td></tr></table>'+
		'</form></div>' + popUpBoxConstruct('close') + '</td></tr></table>';
	$(eid).style.display = 'block';
	$(eid).style.position = 'absolute';
	$(eid).style.zIndex = 9999999;
	e = e || window.event;
	$(eid).style.left = ((e.pageX || e.pageY) ? (e.pageX) : (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - (document.documentElement.clientLeft || 0)))-60;
	$(eid).style.top = ((e.pageY || e.pageX) ? (e.pageY) : (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - (document.documentElement.clientTop || 0)))-30;
	$(eid).innerHTML = outBkm;
	$('tags').focus();
	
}
function universalBookmarkShowKill(eid) {
	$(eid).innerHTML = '';
	$(eid).style.display = 'none';
}

function communityLandingLoadInit(eId,eClass,adjHeight) {
	o = $(eId).getElementsByClassName(eClass);
	op = $(eId).getElementsByClassName(adjHeight);
	if (!o || o.length<1) return;
	for (var i=0;i<o.length;i++) o[i].style.display='none';
	for (var i=0;i<op.length;i++) op[i].style.height='110px';
	communityLandingFixArrows(eId);
	return;
}
function communityLandingFixArrows(im) {
	o = $(im).getElementsByClassName('dabCommImg');
	for (var i=0; i<o.length; i++) {
		tmp = o[i].parentNode.innerHTML.trim();
		tmpImg = tmp.substring(tmp.indexOf("<")).trim();
		tmp = (tmp.substring(0,tmp.indexOf("<")).trim()).split(' ');
		str = '';
		for (var j=0; j<tmp.length; j++) {
			if (j>0) str+=' ';
			if (j+1 == tmp.length) str += '<span class="commLandArrowFix">';
			str += tmp[j];
			if (j+1 == tmp.length) str += tmpImg+'</span>';
		}
		o[i].parentNode.innerHTML = str;
	}
	return;
}
function communityLandingOverOnAction(o,tgti,tgtf) {
	wo = loadTargetNodeDown(loadTargetNodeUp(o,tgti),tgtf);
	if (!wo.getAttribute('openforce')) {
		loadTargetNodeUp(o,tgti).style.height = 'auto';
		wo.style.display = 'block';
	}
	return;
}
function communityLandingOverOffAction(o,tgti,tgtf) {
	wo = loadTargetNodeDown(loadTargetNodeUp(o,tgti),tgtf);
	if (!wo.getAttribute('openforce')) {
		loadTargetNodeUp(o,tgti).style.height = '110px';
		wo.style.display = 'none';
	}
	return;
}
function communityLandingClickAction(o,tgti,tgtf) {
	wo = loadTargetNodeDown(loadTargetNodeUp(o,tgti),tgtf);
//	wo.style.display = (wo.style.display.indexOf('none')<0) ? 'none' : 'block';
	var isThisOpen = wo.getAttribute('openforce');
	if(isThisOpen){
		wo.removeAttribute('openforce');
//		wo.style.display = 'none';
	} else {
		wo.setAttribute('openforce', 'true');
		wo.style.display = 'block';
	}
	return;
}
function loadTargetNodeUp(o,wtlf) {
	return ((o.nodeType==1) && (o.nodeName == 'DIV') && (o.className) && (o.className.indexOf(wtlf)>-1)) ? o : loadTargetNodeUp(o.parentNode,wtlf);
}
function loadTargetNodeDown(o,wtlf) {
	o.id = "tmpId_459fh345y6";
	tgt = $(o.id).getElementsByClassName(wtlf);
	r = (!tgt || !tgt[0]) ? false : tgt[0];
	o.removeAttribute('id');
	return r;
}

function makeOnLoadShares(te) {
	$(te).style.display = 'none';
}
function useOnLoadShares(te) {
	$(te).style.display = ($(te).style.display == 'none') ? 'block' : 'none';
}

/* START :: in page signup/login screen helper */
function rewriteSubmitIndex(ind) {
	$('submitButtonIndexed').tabIndex=ind;
}
function addOnCaptchaIndex(ind) {
	tmp = document.getElementsByClassName('qsrCaptcha');
	if (!tmp[0]) return;
	tmp = tmp[0].getElementsByTagName('INPUT')[0];
	if (!tmp) return;
	tmp.tabIndex = ind;
	tmp.removeAttribute('onkeydown');
}
/* END :: in page signup/login screen helper */

/* takess care of long char strings */

function injectTextBreaks(s,f,o) {
	mxStep = Math.floor(Math.random()*15) + 10;
	ilbr = "<b class='invisible'> </b>";
	return (s.length > o+mxStep) ? injectTextBreaks(s,f+s.substring(o,o+mxStep)+ilbr,o+mxStep) : f+s.substring(o)+ilbr;
}
function adjustForeignTxtLength(ary,cMax) {
	for (var i=0; i<ary.length; i++) {
		tmp = ary[i].nodeValue.trim().split(' ');
		str = '';
		swch = false;
		for (var j=0; j<tmp.length; j++) {
			if (tmp[j].trim().length > cMax) {str += injectTextBreaks(tmp[j].trim(),'',0)+' ';swch=true;}
			else {str += tmp[j]+' ';}
		}
		if (swch) {
			nai = document.createElement('span');
			nai.innerHTML = str;
			ary[i].parentNode.replaceChild(nai,ary[i]);
		}
	}
}
function adjustForeignImgDimensions(ary) {
//	alert('do img rescale: '+ary.length);
}
function cleanBlankNodes(ary) {
	var r = new Array();
	for (var i=0; i<ary.length; i++) if (ary[i].nodeValue.trim().length > 1) r[r.length] = ary[i];
	return r;
}
function pullUnitNodes(ret,nn,nt,obj) {
	if (obj.hasChildNodes()) {
		for(var i = 0; i < obj.childNodes.length; i++) {
			t = obj.childNodes[i];
			if ((t.nodeType==nt) && (!nn || t.nodeName.toUpperCase() == nn)) {ret[ret.length] = t;}
			if (t.hasChildNodes()) ret = pullUnitNodes(ret,nn,nt,t);
		}
		return ret;
	}
}
function cleanupUserDataMarkup(o) {
	if (o.targetId.length < 1 || !$(o.targetId)) return;
	if (o.targetClass.length > 0) {
		oo = $(o.targetId).getElementsByClassName(o.targetClass);
	} else {
		oo = new Array($(o.targetId));
	}
	if (oo.length < 1 || !oo[0]) return;
	/*
	if (o.cleanImage) {
		for (var i=0; i<oo.length; i++) {
			imgNodes = new Array();
			imgNodes = pullUnitNodes(imgNodes,'IMG',1,oo[i]);
			if (imgNodes.length > 0) adjustForeignImgDimensions(imgNodes);
		}
	}
	*/
	if (o.cleanText) {
		for (var i=0; i<oo.length; i++) {
			txtNodes = new Array();
			txtNodes = pullUnitNodes(txtNodes,null,3,oo[i]);
			if (!txtNodes) return;
			txtNodes = cleanBlankNodes(txtNodes);
			if (txtNodes.length > 0) adjustForeignTxtLength(txtNodes,o.charMax);
		}
	}
}

/* -- -- -- -- -- -- -- -- -- -- -- */

/* -- -- -- Report Abuse :: START :: -- -- -- -- -- -- -- -- */
var wsFgcId= "wsFlagReportContainer";
var tmtBubble;
var centeredObject;
function showFlagReportForm(cType,cId) {
	if ((!cType)||(!cId)||(isNaN(cType))||(isNaN(cId))||(!flagReportTypes(cType))) return;
	if (flagReportContainerMake(wsFgcId)===false) return;
	new Ajax.Updater(wsFgcId, '/flagEntity.s?entityType=' + flagReportTypes(cType) + '&entityId=' + cId, {method: 'get'});
	return false;
}
function flagReportTypes(cType) {
	 if (cType===1) return 'GRP_ENTRY';
else if (cType===2) return 'PERSON_GROUP_PHOTO';
else if (cType===3) return 'VIDEO';
else return false;
}
function flagReportContainerMake(tId) {
	if ($(tId)) return;
	tmpm = document.getElementsByTagName('BODY')[0];
	if (!$(tmpm)) return false;
	tmpe = document.createElement('DIV');
	if (!$(tmpe)) return false;
	tmpe.id = tId;
	centered(tmpe);
	tmpm.appendChild(tmpe);
	return;
}
function submitFlagReportForm() {
	new Ajax.Updater(wsFgcId, '/flagEntity.s', {parameters: $('flagForm').serialize()});
	$(wsFgcId).innerHTML='';
	centered($(wsFgcId));
	return false;
}
function closeFlagReportForm() {
	if (!$(wsFgcId)) return;
	$(wsFgcId).innerHTML = '';
	if ($(wsFgcId).parentNode) $(wsFgcId).parentNode.removeChild($(wsFgcId));
	return false;
}
function centered(o) {
	o.style.left = -1000;
	o.style.top = -1000;
	centeredObject = o;
	tmtBubble=setTimeout("centeredDimensions()",20);
}
function centeredDimensions() {
	if ((!centeredObject.offsetWidth)||(!centeredObject.offsetHeight)||(parseInt(centeredObject.offsetWidth)==0&&parseInt(centeredObject.offsetHeight)==0)) {
		tmtBubble=setTimeout("centeredDimensions()",10);
	} else {
		clearTimeout(tmtBubble);
		o=centeredObject;
		centeredObject=null;
		centeredPositioner(o,{x:o.offsetWidth,y:o.offsetHeight});
	}
}
function centeredPositioner(o,dims) {
	var x = 0;
	var y = 0;
	winDim = windowDimensionsXY();
	winScr = windowScrollingsXY();
	if (winDim.x > dims.x) {
		x = (winDim.x-dims.x)/2;
		x = parseInt(x);
	}
	if (winDim.y > dims.y) {
		y = (winDim.y-dims.y)/2;
		y = parseInt(y);
	}
	o.style.left = x+winScr.x;
	o.style.top  = y+winScr.y;
}
/* -- -- -- Report Abuse :: END :: -- -- -- -- -- -- -- -- */

function windowDimensionsXY() {
	if (typeof(window.innerWidth) == 'number') return {x:window.innerWidth,y:window.innerHeight};
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) return {x:document.documentElement.clientWidth,y:document.documentElement.clientHeight};
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) return {x:document.body.clientWidth,y:document.body.clientHeight};
	else return {x:0,y:0};
}
function windowScrollingsXY() {
	if(typeof(window.pageYOffset) == 'number') return {x:window.pageXOffset,y:window.pageYOffset};
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) return {x:document.body.scrollLeft,y:document.body.scrollTop};
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) return {x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};
	else return {x:0,y:0};
}

function inUnitPopupLayer_close(hm) {
	tgt = $(hm);
	if (!tgt) return;
	tgt.innerHTML = "";
	tgt.style.display = 'none';
}

/* -- -- -- Health Mavens :: START :: -- -- -- */
function aboutMavensLayer_open(hm) {
	var master_id = "hmaqu9747h6f"; // diff
	if ($(master_id)) {
		tmp = $(master_id);
		tmp.style.display = 'block';
	} else {
		tgt = $(hm);
		if (!tgt) return;
		tmpw = tgt.getElementsByTagName('DIV')[0].offsetWidth;
		tmp = document.createElement('DIV');
		if (!$(tmp)) return;
		tmp.id = master_id;
		tgt.insertBefore(tmp,tgt.childNodes[0]);
		if (tmpw) {tmpw=parseInt(tmpw);if(tmpw)tmp.style.width = tmpw+'px';}
	}
	// diff
	tmp.innerHTML = "<div class=\"hmalWrapper\"><div class=\"hmalCenter\"><div class=\"hmalPadding\"><div class=\"universalWhite\"><div class=\"m6sides p10sides text12\">Health Mavens are medical and healthy living experts, including doctors, nurses, personal trainers and nutritionists, who enjoy helping connect people with information <a href=\"/healthMaven.s\">&raquo; Learn more</a><div class=\"p7top txtCenter\"><a href=\"\" onclick=\"inUnitPopupLayer_close('"+tmp.id+"'); return false;\">Close</a></div></div></div></div></div><div class=\"hmalBottom\"><div class=\"hmalBottomL\"><div class=\"hmalBottomR\"></div></div></div></div>";
}
/* -- -- -- Health Mavens :: END :: -- -- -- */

/* -- -- -- WP What Do I Have Module :: START :: -- -- -- */
function wellPageWhatIHaveLayer_open(hm) {
	var master_id = "hkdyv4738s7f"; // diff
	if ($(master_id)) {
		tmp = $(master_id);
		tmp.style.display = 'block';
	} else {
		tgt = $(hm);
		if (!tgt) return;
		tmpw = tgt.getElementsByTagName('DIV')[0].offsetWidth;
		tmp = document.createElement('DIV');
		if (!$(tmp)) return;
		tmp.id = master_id;
		tgt.insertBefore(tmp,tgt.childNodes[0]);
		if (tmpw) {tmpw=parseInt(tmpw);if(tmpw)tmp.style.width = tmpw+'px';}
	}
	// diff
	tmp.innerHTML = "<div class=\"m25sides\"><div class=\"hmalWrapper\"><div class=\"pm1all\"><div class=\"universalWhite\"><div class=\"m13sides p10sides text12\">\"Cause Finder\" helps you quickly determine what conditions are commonly associated with the symptoms you select.<div class=\"global-mfc p10sides\">IMPORTANT: This is not a medical diagnosis. Please consult with your doctor.</div><div class=\"txtCenter\"><a href=\"\" onclick=\"inUnitPopupLayer_close('"+tmp.id+"'); return false;\">Close</a></div></div></div></div></div></div>";
}
/* -- -- -- WP What Do I Have Module :: END :: -- -- -- */

function showConfirmLayerGlobal(oo) {
	if ($(oo)) {
		o = $(oo);
		o.style.display = 'block';
		centered(o);
	}
	return false;
}

/* video stuff */
function showAlertFor(element) {element.style.display = "";}
function hideAlertFor(element){element.style.display="none";}
function validateVideoCommentForm() {
    hideAlertFor($('videoComentAlert'));
	hideAlertFor($('maxVideoComentAlert'));
	hideAlertFor($('maxVideoTitleAlert'));
    if ($('videoComentTitle').value == '' || $('videoComentBody').value == '') {
        showAlertFor($('videoComentAlert'));
        return false;
    }
    if ($('videoComentBody').value.length > 500) {
        showAlertFor($('maxVideoComentAlert'));
        return false;
    }
    if ($('videoComentTitle').value.length > 200) {
        showAlertFor($('maxVideoTitleAlert'));
        return false;
    }
    return true;
}
function submitVideoCommentForm(element) {
    if (!validateVideoCommentForm()) {return false;}
    element.submit();
    return false;
}

function sendRateCommand(videoId, personId, rateValue) {
	var button = document.getElementById("button_rateVideo");
	button.className = "complimentButton-disabled";
	var request = makeHttpRequest();
	var clientData = new Object();
	clientData.videoId = videoId;
	clientData.personId = personId;
	clientData.rateValue = rateValue;
	clientData.button = button;
	request.onreadystatechange = function() {rateResultCallback(request, clientData);}
	request.open("POST", "/rateVideo.s", true);
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	var sendText = "videoId=" + videoId + "&rateValue=" + rateValue + "&personId=" + personId;
	request.send(sendText);
}
function rateResultCallback(request, clientData) {
	if(request.readyState == 4 && request.status == 200) {
		if(request.responseText.indexOf("success") != -1) {
			videoRate_updateComplimentCountArea(clientData.postId, clientData.personId, clientData.complimentType, clientData.removeVoteFlag);
		}
		else {
			videoRate_showUnsuccessful(clientData.postId, clientData.personId, clientData.complimentType, clientData.removeVoteFlag);
		}
	} else if (request.readyState == 4 && request.status != 200) {
		videoRate_showComplimentError(clientData.postId, clientData.personId, clientData.complimentType, clientData.removeVoteFlag);
	}
}
function videoRate_enableButton(postId, complimentType) {
	var button = document.getElementById("button_complimentArea_article" + postId + "_type" + complimentType);
	button.className = "complimentButton";
}
function videoRate_showUnsuccessful(postId, personId, complimentType, removeVoteFlag) {
	alert("unsuccessful trying to " + (removeVoteFlag ? "remove" : "add" ) + " compliment on article" + postId + " by person " + personId + " with compliment type " + complimentType);
	videoRate_enableButton(postId, complimentType);
}
function videoRate_showComplimentError(postId, personId, complimentType, removeVoteFlag) {
	alert("error trying to " + (removeVoteFlag ? "remove" : "add" ) + " compliment on article" + postId + " by person " + personId + " with compliment type " + complimentType);
	videoRate_enableButton(postId, complimentType);
}
function setStarsValue(i){
	document.getElementById('rate').innerHTML.value = qqq;
	elem = document.getElementById('rate');
	alert(elem);
	//	elem.value = i;
	//	clearStars();
}
function showStars(i){
	for (j=1; j <= 5; j++){
	  	if (j <= i){document.getElementById('star' + j).src = "/images/star.gif";}
    	else{document.getElementById('star' + j).src = "/images/star-empty.gif";}
	}
}
function clearStars(i){
try {
	starsSet = getCurrentStarsSet();
	for (j=1; j <= 5; j++){
		if (j <= starsSet){document.getElementById('star' + j).src = "/images/star.gif";}
		else{document.getElementById('star' + j).src = "/images/star-empty.gif";}
	}
} catch(err) {
	return;
}
}
function getCurrentStarsSet(){
	vals = document.getElementsByName('rate');
	return vals[0].getValue();
}

function redoButtons() {
	if (navigator.userAgent.indexOf("irefox")!=-1) {
		btns = document.getElementsByTagName('td');
		if (btns.length > 0){
			for (var i=0; i<btns.length; i++) {
				if (btns[i].className && (btns[i].className=='button20blue' || btns[i].className=='button20blueV3') && btns[i].childNodes.length==5) {
					btns[i].innerHTML = btns[i].innerHTML.substring(0,btns[i].innerHTML.indexOf("</a>")) + "<div><div><div><b>"+btns[i].innerHTML.replace(/(<([^>]+)>)/ig,"")+"</b></div></div></div><div class=\"cbtnb\"><div><div></div></div></div></a>";
				}
			}
		}
	}
}

//
//Helpers to deal with secondary window height - lightwindow stuff
//
function fetchCurrentWindowHeight(lookmax) {
var windowScroll=0;
var windowHeight;
if (lookmax===true) {
	if (window.innerHeight && window.scrollMaxY) {	
		windowScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ 
		windowScroll = document.body.scrollHeight;
	} else { 
		windowScroll = document.body.offsetHeight;
	}
}
if (window.innerHeight) {	
	windowHeight = window.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { 
	windowHeight = document.documentElement.clientHeight;
} else if (document.body) { 
	windowHeight = document.body.clientHeight;
}
return (!lookmax || windowScroll < windowHeight) ? windowHeight : windowScroll;  
}
function dymanicLightWindowHeightFixer() {
var curWinHeight = fetchCurrentWindowHeight(true);
if (curWinHeight && curWinHeight>0) parent.myLightWindow.adjustWindow({h:curWinHeight});
}

//
// add or remove friend dialog
//
function friendshipCreate(e,aLink,aName) {
	friendshipAddRemove(e||window.event,aLink,aName,1);
	return false;
}
function friendshipRemove(e,aLink,aName) {
	friendshipAddRemove(e||window.event,aLink,aName,0);
	return false;
}
function friendshipAddRemove(e,aLink,aName,aCmd) {
	var dialogId = "friendAddRemoveModuleUnitId";
	var out = friendshipAddRemoveModule(aLink,aName,aCmd,dialogId);
	if ($(dialogId)) elementRemove(dialogId);
	oDialogBox = document.createElement("DIV");
	oDialogBox.setAttribute("id",dialogId);
	oDialogBox.setAttribute("class","text12"); 
	if (! oDialogBox.className) oDialogBox.className = "text12";
	oDialogBox.setAttribute("style","display:none;");
	document.body.appendChild(oDialogBox);
	$(dialogId).style.width = '240px';
	$(dialogId).style.position = 'absolute';
	$(dialogId).style.zIndex = 9999999;
	$(dialogId).style.left = ((e.pageX || e.pageY) ? (e.pageX) : (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - (document.documentElement.clientLeft || 0)))-60;
	$(dialogId).style.top = ((e.pageY || e.pageX) ? (e.pageY) : (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - (document.documentElement.clientTop || 0)))-20;
	$(dialogId).innerHTML = out;
	$(dialogId).style.display = 'block';
}
function friendshipAddRemoveModule(aLink,aName,aCmd,elementId) {
	var out = "";
	out += '<table border="0" cellpadding="0" cellspacing="0"><tr><td>' + popUpBoxConstruct('open') + '<div class="p12sides m20sides text12 txtCenter">';
	if (aCmd>0) {
		out +=  "<div>Add "+aName+" as a friend.</div>" +
				"<div class=\"clearff p12top\">" +
				"<div style=\"width:35%;\" class=\"leftAlign txtRight textLine25\"><a href=\"\" onclick=\"return elementRemove('"+elementId+"');\">Cancel</a></div>" +
				"<div style=\"width:50%;\" class=\"rightAlign\">"+buttonActionConstruct('','Add',aLink,'button_action2')+"</div>" + 
				"</div>";
	} else {
		out +=  "<div>Are you sure you want to remove "+aName+" from your friends?</div>" +
				"<div class=\"clearff p12top\">" + 
				"<div style=\"width:50%;\" class=\"leftAlign clearff\"><div class=\"rightAlign\">"+buttonActionConstruct("return elementRemove('"+elementId+"');",'Cancel','','button_action2')+"</div></div>" +
				"<div style=\"width:35%;\" class=\"rightAlign txtLeft textLine25\"><a href=\""+aLink+"\">Remove</a></div>" + 
				"</div>";
	}
	out += "</div>" + popUpBoxConstruct('close') + "</td></tr></table>";
	return out;
}

// 
// Twitter updater stuff 
// 
updateNewTwitterFeedCount = function(newFeedCounter) {
	if (!$('twitterUpdaterBubbleModule')) {
		var tmpdiv = document.createElement('DIV');
		tmpdiv.id = 'twitterUpdaterBubbleModule';
		tmpdiv.className = 'orangishBgOver';
		$('twitterFeedContentHeader').appendChild(tmpdiv);
	}
	$('twitterUpdaterBubbleModule').innerHTML = "<div class=\"m20sides rightAlign\">"+newFeedCounter+" new update"+ (newFeedCounter>1?'s':'') +" &rsaquo; <a href=\""+refreshTwitterFeedUrl+"\">Refresh to see</a></div>";
};

//
//LightWindow, LightView
//
function showLightDialog(params){
	invokeLightWindow(params);
}


//
// Dynamic resizer of user content images
//
function imgXYadjuster() {
	var uDatacBlocks = document.getElementsByClassName('commentBodyBlock');
	if (!uDatacBlocks || uDatacBlocks.length < 1) return false;
	for (var i=maxImgW=0,im=uDatacBlocks.length;i<im;++i) {
		imgNodes = pullUnitNodes([],'IMG',1,uDatacBlocks[i]);
		if (imgNodes.length > 0) {
			maxImgW = (uDatacBlocks[i].style.width) ? parseInt(uDatacBlocks[i].style.width) : -1;
			if (maxImgW<0) continue;
			for (var j=0,jm=imgNodes.length;j<jm;++j) {
				if (imgNodes[j]) imgXYadjusterHelper(0,maxImgW,imgNodes[j]);
			}
		}
	}
	return;
}
function imgXYadjusterHelper(cnt,mxw,imo) {
if (cnt<3 && !imo.complete) {
	setTimeout(function() {imgXYadjusterHelper(cnt+1,mxw,imo);}, 1000);
} else {
	var tmpw = (imo.width) ? parseInt(imo.width) : -1;
	if (tmpw<1) return false;
	if (tmpw>mxw) {
		imo.style.width=mxw+"px";
		imo.style.height='auto';
	}
	return true;
}
}
