
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 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;
 }
 new Ajax.Updater('objectCommentsSection','deleteBoardPost.s?view='+listView+'&boardPostId='+id+'&pageIndex='+pageIndex);
}

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 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()
	{
    new Ajax.Updater('userPoints', 'userPointsNewValues.s');
	}

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);
	}
*/
}

var yVideoFlipFramesL;
var yVideoFlipFramesLc;
function closeScoreRatingPopup(o,event) {
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';
o.style.top = 0;
o.style.left = 0;
}
}
function checkIfNested(o,t) {
if(t!=null) {while(t.parentNode) {if((t=t.parentNode)==o) return true;}}
return false;
}
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(fn,fl) {
	return '<table border=0 cellspacing=0 cellpadding=0><tr><td class="button20blue"><a href="" onclick="submitForm(\''+fn+'\'); return false" class="button_action" ><div><div><div><b>'+fl+'</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(formName,'Add to Bookmarks')+'</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';
}



/* 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]);
			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};
}