//js hacks, js libraries object prototypes, and class extensions here
String.prototype.contains = function(needle) { return this.indexOf(needle) >= 0 ? true : false }



function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

//.

// function base: oo functions

var bvAddEvent = function addEvent( obj, type, fn )
{
if (obj.addEventListener)
    obj.addEventListener( type, fn, false );
else if (obj.attachEvent)
{
    obj["e"+type+fn] = fn;
    obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
    obj.attachEvent( "on"+type, obj[type+fn] );
}
}

var bvRemoveEvent = function removeEvent( obj, type, fn )
{
if (obj.removeEventListener)
    obj.removeEventListener( type, fn, false );
else if (obj.detachEvent)
{
    obj.detachEvent( "on"+type, obj[type+fn] );
    obj[type+fn] = null;
    obj["e"+type+fn] = null;
}
}



BVCOM.FUNCTION.AddEvent = bvAddEvent;
//

function O_LC2(){var _sY,_tp;if(navigator.userAgent.indexOf("AOL")>(-1)){_sY=0;_tp=0;}else{_sY=((_sH-192)/2);_tp=((_sH-192)/2);}_w.open('https://secure.opinionlab.com/ccc01/comment_card.asp?time1='+_tm+'&time2='+(new Date()).getTime()+'&prev='+_fC(escape(_hr))+'&referer='+_fC(_ht)+'&height='+_sH+'&width='+_sW+'&custom_var='+custom_var_static,'comments','width=535,height=192,screenX='+((_sW-535)/2)+',screenY='+_sY+',top='+_tp+',left='+((_sW-535)/2)+',resizable=yes,copyhistory=yes,scrollbars=no')}

function dl_init() {
    
    if (!document.getElementById("dl2")) return;
    
    dlObj = document.getElementById("dl_container");
    
    
    
    for (i=0; i<dlObj.getElementsByTagName("div").length; i++) {
        
        dynLeads[i]  = dlObj.getElementsByTagName("div")[i];
        
        dynLeads[i].xid = i;
        
        dynLeads[i].xdirection = 0;
        
        dynLeads[i].xheight = dynLeads[i].getElementsByTagName("h2")[0].offsetHeight*i;
        
        dynLeads[i].xtop = dynLeads[i].offsetTop;
        
        dynLeads[i].getElementsByTagName("h2")[0].onclick = function() { dl_handleClick(this.parentNode.xid); }
        
    }
    
    
    
    dlObj.style.height = dlObj.offsetHeight+"px";
    
    dynLeads[0].xtop=0;
    
    dynLeads[0].xdirection = 1;
    
    
    
    for (i=0; i<dynLeads.length; i++) {
        
        dynLeads[i].style.position = "absolute";
        
        dynLeads[i].style.top = dynLeads[i].xtop+"px";
        
    }
    
    
    
    yInterval = setInterval("autoScroll()",(AUTO_INTERVAL*1000));
    
}




function sbTest() {
    
    if (document.forms['bb_topform'] && document.forms['bb_topform'].query && document.forms['bb_topform'].query.value.length <= 0) {document.forms['bb_topform'].query.value='Search for news, sports, health and entertainment gossip';}
    
}

if (typeof dojo==='object' ) {dojo.addOnLoad( sbTest );} else {
    
    window.onload = sbTest;
    
}








function submitCommentsWithSN(sn)

{
    
    var comment = document.getElementById("addCommentHere").value;
    
    if(comment == null || comment.length < 1 || comment == 'Type your own comment here')
        
    return;
    
    
    
var uri = document.getElementById("cmmt_uri").value;
    
var category = document.getElementById("cmmt_category").value;
    
var assetType = document.getElementById("cmmt_assetType").value;
    
var appID = document.getElementById("cmmt_appID").value;
    
    
    
procName = "dms.trri.addReview";
    
    
    
var del='|';
    
parameters = uri;
    
parameters += del + sn;
    
parameters += del + comment;
    
parameters += del + category;
    
parameters += del + assetType;
    
parameters += del + appID;
    
    
    
if (window.ActiveXObject) {
        
    xmlHttpAddComment = new ActiveXObject("Microsoft.XMLHTTP");
        
}
    
else if (window.XMLHttpRequest) {
        
    xmlHttpAddComment = new XMLHttpRequest();
        
}
    
    
    
xmlHttpAddComment.onreadystatechange = afterAddComments;
    
    
    
var url = "http://www.blackvoices.com/";
    
url += 'httprequest.adp';
    
    
    
data = "_pn=" + procName;
    
data += "&_pa=" + parameters;
    
data += "&_del=" + del;
    
    
    
xmlHttpAddComment.open("POST",url,true);
    
xmlHttpAddComment.setRequestHeader("Accept", "text/xml");
    
xmlHttpAddComment.send(data);
    
} 



function displayComments(start) {
    
var uri = document.getElementById("cmmt_uri").value;
    
var category = document.getElementById("cmmt_category").value;
    
var assetType = document.getElementById("cmmt_assetType").value;
    
var appID = document.getElementById("cmmt_appID").value;
    
var numCmmt = document.getElementById("cmmt_numCmmt").value;
    
var AddBtnLbl = document.getElementById("cmmt_AddBtnLbl").value;
    
var CanBtnLbl = document.getElementById("cmmt_CanBtnLbl").value;
    
var reportThis = document.getElementById("cmmt_reportThis").value;
    
var thisurl = document.getElementById("cmmt_thisurl").value;
    
    
    
var procName = "dms.trri.displayReviews"
    
var del=',';
    
var parameters = uri;
    
parameters += del + category;
    
parameters += del + assetType;
    
parameters += del + appID;
    
parameters += del + start;
    
parameters += del + numCmmt;
    
parameters += del + AddBtnLbl;
    
parameters += del + CanBtnLbl;
    
parameters += del + reportThis;
    
parameters += del + thisurl;
    
    
    
if (window.ActiveXObject) {
        
    xmlHttpComment = new ActiveXObject("Microsoft.XMLHTTP");
        
}
    
else if (window.XMLHttpRequest) {
        
    xmlHttpComment = new XMLHttpRequest();
        
}
    
    
    
xmlHttpComment.onreadystatechange = readyForComments;
    
    
    
var ourl = document.URL;
    
    
    
var ind = ourl.indexOf('aol.com/');
    
var url = "http://www.blackvoices.com/";
    
url += 'httprequest.adp';
    
    
    
url = url + "?_pn=" + procName;
    
if (parameters!="")
        
{
        
    url = url + "&_pa=" + parameters;
        
}
    
    
    
url += '&date=' + new Date().getTime();
    
    
    
//alert(url);
    
xmlHttpComment.open("GET", url, true);
    
xmlHttpComment.setRequestHeader("Accept", "text/xml");
    
xmlHttpComment.send(null);
    
}

//script for rating...........

   function sampleRateMessageFunction(webtag, tid, tsn, ratingVal,frmCounter)
    {
        /* Declare a callback function to be executed on command completion */
		var callback = function(commandResultsJSON)
		{
		    var resultsObj = commandResultsJSON["CommandResultInfo"];
		    if (resultsObj["@succeeded"] == "true")
		    {
		       // alert(resultsObj["@message"]);
                         // document.usrRtngFrm.rtgFcr.value=frmCounter;
                          document.getElementById("usrRtngFrm"+frmCounter).rtgFcr.value=frmCounter;
                          document.getElementById("usrRtngFrm"+frmCounter).rtgTsn.value=tsn;
                         document.getElementById("usrRtngFrm"+frmCounter).submit();
		    }
		    else
		    {
		        alert("Error " + resultsObj["@code"] + ": " + resultsObj["@message"]);
		    }
		    /* This code displays all of the items in the results object */
			var s = makeObjectString(resultsObj);
            //alert("CommandResults: \n" + s);
		 };
		/* Execute the command */
		TempestNS.COMMANDHANDLER.SetMessageRating(webtag, tid, tsn, ratingVal, callback);
	}
	/* Helper function for displaying the results object */
	function makeObjectString(o, indentIn)
	{
	    var s = new String();
	    var indent = indentIn ? indentIn : "";
	    for (var prop in o)
	    {
	       var val = o[prop];
	       if (typeof val == "object")
	       {
	            s = s + indent + prop + ":\n" + makeObjectString(val, indent + "   ");
	       }
	       else if (val)
	       {
	            s = s + indent + prop + ": " + val + "\n";
	       }
	    }
	    return s;
	}













var submited=0;
function submitRating(element, starOverURL, cntr, webtag, tsn, tid,rCntr,frmCounter) {
//alert(webtag + " " + tsn + " " + tid);
element.style.cursor = 'hand';
var baseId = element.getAttribute('baseId');
	
var starNum = element.getAttribute('starNum');
for(i=1;i<=starNum;i++) {
    var myEl = getEl(baseId + i + rCntr);
    myEl.src = starOverURL;
}
sampleRateMessageFunction(webtag, tid, tsn, cntr,frmCounter)
submited=1;

starDiv="starDiv"+rCntr;
defRate= "defRate"+rCntr;
//alert(document.getElementById(starDiv));
//document.getElementById(starDiv).style.display='none';
//document.getElementById(defRate).style.display='block';

}

/**
* Change the image on mouse over
*/
function rtngOver(element, starOverURL,cntr) {
//if(submited==0){
    
element.style.cursor = 'hand';
var baseId = element.getAttribute('baseId');
//alert(cntr);
var starNum = element.getAttribute('starNum');
//  alert(starNum);
for(i=1;i<=starNum;i++) {
    var myEl = getEl(baseId + i + cntr);
    myEl.src = starOverURL;
    //  }
}
}

/**
* Change the image on mouse out
*/
function rtngOut(element,cntr) {
//if(submited==0) {
element.style.cursor = 'auto';
var baseId = element.getAttribute('baseId');
var starNum = element.getAttribute('starNum');

for(i=1;i<=starNum;i++) {
    var myEl = getEl(baseId + i + cntr);
    myEl.src = myEl.getAttribute('oSrc');
    //   }
}
}

var aratings = {
rtngOver: function(element, starOverURL) {
    element.style.cursor = 'hand';
    var baseId = element.getAttribute('baseId');
    var starNum = element.getAttribute('starNum');
    for(i=1;i<=starNum;i++) {
        var myEl = getEl(baseId + i);
        myEl.className = starOverURL;
    }
   
},
   
rtngOut: function(element) {
    element.style.cursor = 'auto';
    var baseId = element.getAttribute('baseId');
    alert(baseId);
    var starNum = element.getAttribute('starNum');
   
    for(i=1;i<=starNum;i++) {
        var myEl = getEl(baseId + i);
        myEl.className = myEl.getAttribute('oSrc');
    }
}
};
    

function rateVis(div1,div2){
document.getElementById(div1).style.display="block";
document.getElementById(div2).style.display="none";
}

 function sampleResetRelationshipFunction(webtag, userId)
    {
       
    	var callback = function(commandResultsJSON)
	{
	  var resultsObj = commandResultsJSON["CommandResultInfo"];
	  if (resultsObj["@succeeded"] == "true")
	  {
	    alert(resultsObj["@message"]);
              document.location.reload();
	  }
	  else
	  {
	   // alert("Error " + resultsObj["@code"] + ": " + resultsObj["@message"]);
            document.location.href=document.location.href;
	  }
    /* This code displays all of the items in the results object */
	var s = makeObjectString(resultsObj);
	//alert("CommandResults: \n" + s);
       };
    	TempestNS.COMMANDHANDLER.ResetRelationship(webtag, userId, callback);
    }
    


//sns//
function ctaPopup(ctaUrl)
{ if (!ctaUrl) {ctaUrl = "";}
window.open (ctaUrl,'CTA','scrollbars=no,location=no,directories=no,height=265,width=275,menubar=no,resizable=no,titlebar=no');}

function genPopup(url, name, features)
{ if (!url) {url = "";} window.open (url,name,features);}
//
//
// fix common.js error
function hideHeaderMore(e){}
document.onclick = hideHeaderMore;

function AsnsSignInfn( obj, leftOffSet, topOffSet ) {
  
// siteState Modification -- Madan KN // Starts Here
alert("siteState "+siteState);
   var snsLoc = ""+window.location;
   var newsiteState = "";
   if(snsLoc.indexOf("?")!= -1){
      var siteState1 = snsLoc.substring(0,snsLoc.indexOf("?"));
      var siteState2 = snsLoc.substring(snsLoc.indexOf("?")+1,snsLoc.length);
      newsiteState = siteState1+"?sns=true&"+siteState2;
   }else if(snsLoc.indexOf("#")!= -1){
      var siteState1 = snsLoc.substring(0,snsLoc.indexOf("#"));
      var siteState2 = snsLoc.substring(snsLoc.indexOf("#"),snsLoc.length);
      newsiteState = siteState1+"?sns=true&"+siteState2;
   }else {
      newsiteState = snsLoc+"?sns=true";
   }
   snsLoc = newsiteState;
 
   siteState = encodeURIComponent("OrigUrl="+encodeURIComponent(snsLoc));
  var fileref=document.createElement('script');
  fileref.setAttribute("type","text/javascript");
  fileref.setAttribute("src", "http://my.screenname.aol.com/_cqr/login/jslogin.psp");
 document.getElementsByTagName("head")[0].appendChild(fileref);

   //alert('after siteState = '+siteState);
// siteState Modification -- Madan KN // End Here

var obj = obj.parentNode;
var leftOffSet = 7;
var topOffSet = -35;
if (!leftOffSet) leftOffSet = 0;
if (!topOffSet) topOffSet = 0;
var pSNS = getEl("snsMiniUI");
pSNS.innerHTML = "";
pSNS.innerHTML += _sns_var_;
if ( document.all ) {
    var pos = findPos(obj);
    pSNS.style.position = 'absolute';
    pSNS.style.left = (pos[0] + leftOffSet - 138) + 'px';
    pSNS.style.top =  (pos[1] + topOffSet + 12)  + 'px';
        
} else {
    obj.appendChild(pSNS);
    pSNS.style.left = leftOffSet + 'px';
    pSNS.style.top =  topOffSet  + 'px';
    pSNS.style.position = 'relative';
}
pSNS.onclick = closeSNS;
var close = document.createElement("span");
var a = document.createElement("a");
a.href = "javascript:AsnsClose();";
a.title = "close";
var img = document.createElement("img");
img.src = "http://my.screenname.aol.com/images/10x10_x.gif";
img.style.border = "0px";
a.appendChild(img);
close.appendChild(a);
spans = pSNS.getElementsByTagName( "span" );
spans[1].style.cssFloat = "right";
spans[1].style.styleFloat = "right";
spans[1].style.margin = "1px 0px 0px 10px";
close.style.cssFloat = "right";
close.style.styleFloat = "right";
close.style.margin = "2px 2px 0px 0px";
spanPar = spans[1].parentNode;
spanPar.insertBefore(close,spans[1]);

pSNS.style.zIndex = 10000;
pSNS.style.display = "block";
}
function closeSNS() {
getEl("snsMiniUI").innerHTML = '';
}

function AsnsClose() {
pSNS = getEl("snsMiniUI");
pSNS.style.display = "none";
}

function getSelectedValue( selObj ){
return selObj.options[selObj.selectedIndex].value;
}

var http = false;
function xmlhttpPost1(x,y,userName,url) {
  //userName="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

   document.getElementById("displaypopMainConttextdis").innerHTML=userName;
   document.getElementById("displaypopMainConttextdis1").innerHTML="Loading..." ;  
   document.getElementById("displaypopMainConttextdis2").innerHTML="Loading..." ;  
   

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

http.open("GET",url);
http.onreadystatechange=function() {
  if(http.readyState == 4) {
      
     trimmed = http.responseText.replace(/^\s+|\s+$/g, '') ;
    
     
      var profileGender=trimmed.substring(0,trimmed.indexOf('|'))
      var profileAge=trimmed.substring((trimmed.indexOf('|')+1),trimmed.length)
      var profileLocatn=trimmed.substring((trimmed.lastIndexOf('|')+1),trimmed.length)
      var profileAgenew=profileAge.substring(0,profileAge.indexOf('|'))

      if(profileGender=='M' || profileGender=='m'){
      profileGender="Male";
  } else if(profileGender=='F' || profileGender=='f'){
      profileGender="Female";
}
   
   
    document.getElementById("displaypopMainConttextdis1").innerHTML=profileGender+ " "+profileAgenew ;      
    document.getElementById("displaypopMainConttextdis2").innerHTML=profileLocatn ;
   }
}
http.send(null);
  
}


function showmsgPopup(img,popupvalue,userName,addLeft,addTop,url){

if (popupvalue == 1) {
   
    //url = url + userName;
    if(navigator.appName.indexOf("Microsoft") != -1) {
    var cElement = img;    
    var x = cElement.offsetLeft;
    var y = cElement.offsetTop;    
    var pElement = img.offsetParent;
    while (pElement != document.body) {
       x += pElement.offsetLeft;
       y += pElement.offsetTop;
       pElement = pElement.offsetParent;
   }
  } else {
      
       x=img.offsetLeft-addLeft;
       y=img.offsetTop-addTop;
}
 document.getElementById("displaypopMainCont").style.display = "block";
     document.getElementById("displaypopMainCont").style.left = x+'px';
    document.getElementById("displaypopMainCont").style.top = y+'px';
    xmlhttpPost1(x,y,userName,url);

  } else {
     http.abort();
    document.getElementById("displaypopMainCont").style.display = "none";
}

}


function clearSearchText(textBoxvalue) {
    
var CurrenttextBoxvalue = textBoxvalue.value;
    
if (CurrenttextBoxvalue != "") {
        
    textBoxvalue.value = '';
        
}
    
}
function replaceSearchText(textBoxvalue,defValue) {
    
var CurrenttextBoxvalue = textBoxvalue.value;
    
if (CurrenttextBoxvalue == "") {
        
    textBoxvalue.value = defValue;
        
}
    
}

function showReadMore(moretext) {
document.getElementById("lastposttextalign").innerHTML=document.getElementById(moretext).innerHTML;

    
}


var divNewId="";
var divNewId1="";
var popupleft="";
var popuptop="";

/*  mouse over */




/* Email and report popup javascript */

function showDisReport(e,divid,alinkid,msgtext,printdiv)
{
 
if(msgtext){
    document.getElementById(printdiv).innerHTML= "<p class='disprintidp6'>" + document.getElementById(msgtext).innerHTML + "</p>";
} 
	
//document.getElementById("discussreportmsgsecond").innerHTML=document.getElementById("discussreportmsgsecondwrap").innerHTML;
var disdiv=p_o(divid);
var aLnk=p_o(alinkid);
posY = findMousePos(e);
disdiv.style.left=(ai_posX(aLnk)-9)+'px';
disdiv.style.top=(posY+aLnk.offsetHeight/2)+'px';
	
disdiv.style.zIndex=99999999;
disdiv.style.display='block';
popupleft=disdiv.style.left;
popuptop=disdiv.style.top;
 

}
function hideDisReport(divid)
{

var disdiv=p_o(divid);
disdiv.style.display='none';

}

function setDiv(divId,divId1){

divNewId=divId;
divNewId1=divId1;

}
var webtag = 'bvtestforum01';
/* Declare a callback function to be executed on command completion */
var callback = function(commandResultsJSON)
{
var resultsObj = commandResultsJSON["CommandResultInfo"];
if (resultsObj["@succeeded"] == "true")
{
    // alert(resultsObj["@message"]); - no success message for forwardMessage
}
else
{
    //alert("Error " + resultsObj["@code"] + ": " + resultsObj["@message"]);
}
/* This code displays all of the items in the results object */
var s = makeObjectString(resultsObj);
//alert("CommandResults: \n" + s);
//alert("Report sent successfully");
  if(divNewId=='dismsgid'){
			
			myobj = document.getElementById('disReportsent1id');
			myobjnew=document.getElementById('dismsgid');
                        document.getElementById("tos_comments").value='Enter Text';
			myobjnew.style.display='none';
                        myobj.style.left=popupleft;
                        myobj.style.top=popuptop;
	                myobj.style.zIndex=99999999;
			myobj.style.display='block';

			}
			else{
				
			myobj = document.getElementById('disMailsent1id');
                      	myobjnew=document.getElementById('dismailid');
                        document.getElementById("pre_address").value='Enter Address';
			document.getElementById("pre_comments").value='Enter Text';
                        document.getElementById("pre_fromUserId").value='';
			myobjnew.style.display='none';
                        myobj.style.left=popupleft;
                        myobj.style.top=popuptop;
	                myobj.style.zIndex=99999999;
                        myobj.style.display='block';

			}
};
 
function sampleForwardMessageFunction(webtag, fieldPrefix, form)
{
/* Execute the command */
	
TempestNS.COMMANDHANDLER.ForwardMessage(webtag, fieldPrefix, null, form, callback);
// alert(form.elements[0].id);
}
/* Helper function for displaying the results object */
function makeObjectString(o, indentIn)
{
var s = new String();
var indent = indentIn ? indentIn : "";
for (var prop in o)
{
    var val = o[prop];
    if (typeof val == "object")
    {
        s = s + indent + prop + ":\n" + makeObjectString(val, indent + "   ");
    }
    else if (val)
    {
        s = s + indent + prop + ": " + val + "\n";
    }
}
return s;
}


function sampleSendTOSViolationReport(webtag, fieldPrefix, form)
{
/* Execute the command */
TempestNS.COMMANDHANDLER.SendTOSViolationReport(webtag, fieldPrefix, form, callback);
return false;
}
/* Helper function for displaying the results object */
function makeObjectString(o, indentIn)
{
var s = new String();
var indent = indentIn ? indentIn : "";
for (var prop in o)
{
    var val = o[prop];
    if (typeof val == "object")
    {
        s = s + indent + prop + ":\n" + makeObjectString(val, indent + "   ");
    }
    else if (val)
    {
        s = s + indent + prop + ": " + val + "\n";
    }
}
return s;
}
function PrintMsg (msgtext,postedBy,datePosted) {
 
var prtContent = document.getElementById(msgtext);

var WinPrint = window.open (printUrl,"Print","location=1,status=1,scrollbars=auto,width=800,height=800"); 
WinPrint.focus();

WinPrint.document.write("<div style='margin:20px;width:750px;'>Posted By: "+postedBy+"<br/>"+"Date: "+datePosted+"<br/>"+prtContent.innerHTML + "<div><a href='javascript:window.print()'>Print</a></div></div>");
WinPrint.document.close();

//WinPrint.print();
//WinPrint.close();
   
}
function PrintDiscMsg (printUrl,type) {
  
   if (type=="poll"){

    if(document.getElementById("dscussVotNew").style.display=="none"){
    printUrl=printUrl.replace("/print/","/print-r/");
    printUrl=printUrl.replace("/printDisc/","/printDisc-r/");
}
}
    var WinPrint = window.open (printUrl,"Print","location=1,status=1,scrollbars=1,width=800,height=800"); 


//var WinPrint = window.open(printUrl,'Print');
WinPrint.focus();

    
    }


var countnew=0;
function showDisReportnew(e,divid,alinkid,msgtext,printdiv){
  var disdiv=p_o(divid);
  var aLnk=p_o(alinkid);
  posY = findMousePos(e);
  disdiv.style.left=(ai_posX(aLnk)+15)+'px';
  disdiv.style.top=(posY+aLnk.offsetHeight/2)+'px';
  disdiv.style.zIndex=99999999;
  disdiv.style.display='block';
//  countnew++;
  //if(countnew%2==0){
 //     disdiv.style.display='none';
//  }
}

function hideComboboxdis(sortshowing,cntr){
   
    if(cntr=='1'){  
    var hidbox=p_o(sortshowing);
    hidbox.style.visibility='hidden';
    }
    return false;
  }
 function showComboboxdis(sortshowing){
   
    var hidbox=p_o(sortshowing);
    hidbox.style.visibility='visible';
    return false;
   }

      
  function appendNewPost(divToAppend,wt,tid,n,wyreturn,wystyle,user) {
 	console.log("user has fired wysiwyg request: new post (original)");
     //test authentication of user
     if (BVCOM.FUNCTION.testAuthentication()) {  
     console.log('wysiwyg arguments: div='+divToAppend+' webtag='+wt);
         	if(typeof wt == null || typeof wt == 'undefined') {wt=BVCOM.CONSTANT.defaultBoard;}
        		wt='ti-'+wt;
        	//board override based on config
        	if(BVCOM.CONSTANT.WysiwygOverride == true && wt==BVCOM.CONSTANT.WysiwygOverrideBoard) {wt=BVCOM.CONSTANT.WysiwygOverrideBoardNew;}
        
        //define default wysiwyg parameters
        if(typeof n == null || typeof n == 'undefined') {n='iframepost';}
        if(typeof tid == null || typeof tid == 'undefined') {tid='1';}
        if(typeof wyreturn == null || typeof wyreturn == 'undefined') {wyreturn=document.location.toString();}
        if(typeof wystyle == null || typeof wystyle == 'undefined') {wystyle='http://www.aolcdn.com/black-voices/bv-mzingaform-post.css';}
        //alert(divToAppend);
        if (typeof divToAppend == null || typeof divToAppend ==  'undefined') {
        divToAppend = "dscussnforumconfirmnew1";
        }
        	console.log("wysiwyg command (n)= "+n);
        	console.log("wysiwyg webtag (wt)= "+wt);
        	console.log("wysiwyg webtag (tid)= "+tid);
        	console.log("wysiwyg inital return url (wyreturn)= "+wyreturn);
        	console.log("wysiwyg css (wystyle)= "+wystyle);
        	console.log("wysiwyg dom hook (divToAppend)= "+divToAppend);
        	
                    wyreturn = wyreturn.toString();
        	//create query value for return page
        	returnpath1 = wyreturn.toString().replace(/wyret=[0-9]*\.[0-9]*/g,"");
            returnpath1 = returnpath1.replace(/status=[a-z]*[\?|\&]/g,"");
            returnpath1 = returnpath1.replace(/\tsn[0-9]*/g,"");
            if(returnpath1.indexOf("#")>0) { 
                returnpath1 = returnpath1.substr(0,returnpath1.indexOf("#"));
             }
              if(returnpath1.indexOf("?")>0) { 
                returnpath1 = returnpath1.substr(0,returnpath1.indexOf("?"));
             }
            decodedReturnPath = encodeURIComponent(returnpath1);
                 console.log("wysiwyg encoded :"+decodedReturnPath);
        		decodedReturnPathCompare = decodedReturnPath.contains("%3F"); //%3F is urlencoded "?"
        	console.log(decodedReturnPathCompare+"= decoded compare ? and "+decodedReturnPath);
        	if (decodedReturnPathCompare) {
             	 qsAppendchar = "&" ;} else {
              	 qsAppendchar = "?";}
        	wyreturn = decodedReturnPath+qsAppendchar+'wyret=1.100';
        	console.log("wysiwyg final return url (wyreturn)= "+wyreturn);
        	
	var el = document.createElement("iframe");
	    thisDomId = 'ifrm-'+tid+'-newpost';
	    //handle request, if wysiwyg already open.
	    	if(BVCOM.PAGE.wysiwygopen == "true") {console.log('div existed');return false;}

	    var apel = document.getElementById(divToAppend);
	   if(document.getElementById(thisDomId)||document.getElementById(thisDomId) != null) {apel.removeChild(thisDomId);console.log('div already exist');}
		el.setAttribute('id', thisDomId);
		defaultWidth = BVCOM.CONSTANT.bvwysiwygWidth || '575px';
		el.setAttribute('width', defaultWidth);
		defaultHeight = BVCOM.CONSTANT.bvwysiwygHeight || '530px';
		el.setAttribute('height', defaultHeight);
		el.setAttribute('border', '0px');
		el.setAttribute('frameborder','0');
		el.setAttribute('class', 'dynwysiwyg wyzion'+divToAppend);
		//alert('appending div='+divToAppend+'. webtag ='+wt+'. tid='+tid);
		

    var apelchild = apel.firstChild;
             console.log(apel.id+"= parent div"); 
             console.log(apelchild+"= firstChild")
             console.log(apelchild.id+"= id of firstChild");
             console.log(apel.lastChild+"=  lastChild");
             console.log(apel.lastChild.id+"= id of lastChild");
             console.log(apel.nextSibling+"=  next sibling");
             //console.log(apel.nextSibling.id+"= id of next sibling");
           
		apel.insertBefore(el,apelchild);
		el.setAttribute('src', jDomainURL+'webtag='+wt+'&nav='+n+'&replyToTid='+tid+'&replyToTsn=1&postreturnURL='+wyreturn+'&cssUrl='+encodeURIComponent(wystyle)+' ');
        BVCOM.PAGE.wysiwygopen = "true";
} else {
	//user detected as non authenticated
	console.log('user failed authentication test for new post (original post)')
	BVCOM.FUNCTION.messageUser("You must be signed in to create a new post.","dscussntopnewDis1")
    }
}  


function appendNewDiscussion(divToAppend,wt,n,wyreturn,wystyle,user) {
        console.log("user has fired wysiwyg request: new discussion");
     //test authentication of user
     if (BVCOM.FUNCTION.testAuthentication()) { 
            console.log('wysiwyg arguments: div='+divToAppend+' webtag='+wt); 
        	//define default wysiwyg parameters
        	if(typeof wt == null || typeof wt == 'undefined') {wt=BVCOM.CONSTANT.defaultBoard;}
        		wt='ti-'+wt;
        	//board override based on config
        	if(BVCOM.CONSTANT.WysiwygOverride == true && wt==BVCOM.CONSTANT.WysiwygOverrideBoard) {wt=BVCOM.CONSTANT.WysiwygOverrideBoardNew;}
            //define default wysiwyg parameters
        	if(typeof n == null || typeof n ==  'undefined') {n='iframepost';}
        	if(typeof wyreturn == null || typeof wyreturn ==  'undefined') {var wyreturn = window.location.href.toString();}
        	if(typeof wystyle == null || typeof wystyle == 'undefined') {wystyle='http://www.aolcdn.com/black-voices/bv-mzingaform-discussion.css';}
        	//alert(divToAppend);
        	if (typeof divToAppend == null || typeof divToAppend ==  'undefined') {
        		divToAppend = "dscussnforumconfirmnew1";
        	}
        	console.log("wysiwyg command (n)= "+n);
        	console.log("wysiwyg webtag (wt)= "+wt);
        	console.log("wysiwyg inital return url (wyreturn)= "+wyreturn);
        	console.log("wysiwyg css (wystyle)= "+wystyle);
        	console.log("wysiwyg dom hook (divToAppend)= "+divToAppend);
            wyreturn = wyreturn.toString();
        	//create query value for return page
        	 //clean up old query params via regex, prevents query params repeating in url after multiple submissions
        	returnpath1 = wyreturn.toString().replace(/wyret=[0-9]*\.[0-9]*/g,"");
            returnpath1 = returnpath1.replace(/status=[a-z]*[\?|\&]/g,"");
            returnpath1 = returnpath1.replace(/tsn[0-9]*/g,"");
            //decodedReturnPath = encodeURIComponent(returnpath1);
            decodedReturnPath = returnpath1;
            //alert(decodedReturnPath+'=decodedReturnPath');
        	//decodedReturnPathCompare = decodedReturnPath.contains("%3F"); //%3F is urlencoded "?"
        	decodedReturnPathCompare = decodedReturnPath.contains("?");
        	console.log(decodedReturnPathCompare+"= decoded compare ? and "+decodedReturnPath);
        	if (decodedReturnPathCompare) {
             	 qsAppendchar = "&" ;} else {
              	 qsAppendchar = "?";}
            wyreturn = decodedReturnPath+qsAppendchar+'wyret=1.102';
        	console.log("wysiwyg final return url (wyreturn)= "+wyreturn);
	    
	    	thisDomId = 'ifrm-bv-newdisc';  
	    	//handle request, if wysiwyg already open.
	    	if(BVCOM.PAGE.wysiwygopen == "true") {console.log('div existed');return false;}

		    var apel = document.getElementById(divToAppend);
			var el = document.createElement("iframe");
			el.setAttribute('id', thisDomId);
			defaultWidth = BVCOM.CONSTANT.bvwysiwygWidth || '575px';
			el.setAttribute('width', defaultWidth);
			defaultHeight = BVCOM.CONSTANT.bvwysiwygHeight || '530px';
			el.setAttribute('height', defaultHeight);
			el.setAttribute('border', '0px');
			el.setAttribute('frameborder','0');
			el.setAttribute('class', 'dynwysiwyg wyzion-'+divToAppend);

    		var apelchild = apel.lastChild;
      		console.log(apel.id+"= parent div"); 
             console.log(apelchild+"= firstChild")
             console.log(apelchild.id+"= id of firstChild");
             console.log(apel.lastChild+"=  lastChild");
             console.log(apel.lastChild.id+"= id of lastChild");
             console.log(apel.nextSibling+"=  next sibling");
             //console.log(apel.nextSibling.id+"= id of next sibling");
             apel.insertBefore(el,apelchild);
             
			el.setAttribute('src', jDomainURL+'webtag='+wt+'&nav='+n+'&postreturnURL='+encodeURIComponent(wyreturn)+'&wy&cssUrl='+encodeURIComponent(wystyle)+' ');
			BVCOM.PAGE.wysiwygopen = "true";
	} else {
	//user detected as non authenticated
	console.log('user failed authentication test for new discussion')
	BVCOM.FUNCTION.messageUser("You must be signed in to create a discussion.","dscussntop")
    }
}  

function appendNewPoll(divToAppend,wt,tid,n,wyreturn,wystyle) {
       console.log("user has fired wysiwyg request: new poll");
     //test authentication of user
	if (BVCOM.FUNCTION.testAuthentication()) { 
/*
         console.log("user has selected to add a new poll"); 
        //define default wysiwyg parameters
        var wysiwygEls = getElementsByClass('dynwysiwyg');
       // wysiwygElsLen = wysiwygEls.length;
        console.log(wysiwygEls);
        //console.log(wysiwygElsLen);
        var thard = wyiwygEls.length > 0;
        console.log(thard);
		console.log(wysiwygEls);
		if(wyiwygEls.length > 0) {
			//alert('wyzi open');
        	console.log("WARNING: multiple wysiwyg detected");
		}
		console.log("**");
*/  
  	if(typeof wt == null || typeof wt == 'undefined') {wt=BVCOM.CONSTANT.defaultBoard;}
        		wt='ti-'+wt;
        	 
    //   if(BVCOM.CONSTANT.WysiwygOverride == true && wt==BVCOM.CONSTANT.WysiwygOverrideBoard) {wt=BVCOM.CONSTANT.WysiwygOverrideBoardNew;}
         
          //define default wysiwyg parameters
        if(typeof n == null || typeof n == 'undefined') {n='iframecreatepoll';}
        if(typeof tid == null || typeof tid == 'undefined') {tid='1';}
        if(typeof wyreturn == null || typeof wyreturn ==  'undefined') {wyreturn=document.location.toString();}
        if(typeof wystyle == null ||typeof wystyle == 'undefined') {wystyle='http://www.aolcdn.com/black-voices/bv-mzingaform-poll.css';}
       if(typeof tsn == null || typeof tsn == 'undefined') {tsn='1';}
        if (typeof divToAppend == null || typeof divToAppend == 'undefined') {
        divToAppend = "dscussnforumconfirmnew1";
        }
    //   console.log("*");
        //create query value for return page
    /* 
       decodedReturnPath=decodedReturnPath.replace(/wyret=[0-9]*\.[0-9] /g,"");
       decodedReturnPath=decodedReturnPath.replace(/status=[a-z]*[\?|\&]/g,"");
       decodedReturnPath = encodeURIComponent(wyreturn);
       console.log("decoded: "+decodedReturnPath);
        decodedReturnPathCompare = decodedReturnPath.contains("?");
        console.log(decodedReturnPathCompare+"= decoded compare");
        if (decodedReturnPathCompare) {
              qsAppendchar = "&" ;} else {
               qsAppendchar = "?";}
        wyreturn = decodedReturnPath+qsAppendchar+'wyret=1.103';
        console.log("wysiwyg final return url (wyreturn)= "+wyreturn);
      */
 wyreturn = wyreturn.toString();
        	//create query value for return page
        	returnpathRoot = String(wyreturn).split('?');
			returnpath0 = returnpathRoot[0];
			returnpath1 = '';
			qsAppendchar = "?";
			if(returnpathRoot[1]){			
        		returnpath1 = returnpathRoot[1].toString().replace(/wyret=[0-9]*\.[0-9]*/g,"");
            	returnpath1 = returnpath1.replace(/status=[a-z]*[\?|\&]/g,"");
            	returnpath1 = returnpath1.replace(/tsn[0-9]*/g,"");
            	returnpath0 = returnpath0 + "?";
            	qsAppendchar = "&"
            }
                     
            //decodedReturnPath = encodeURIComponent(returnpath1);
            decodedReturnPath = returnpath0+returnpath1;
            //alert(decodedReturnPath+'=decodedReturnPath');
        	//decodedReturnPathCompare = decodedReturnPath.contains("%3F"); //%3F is urlencoded "?"
        	//decodedReturnPathCompare = decodedReturnPath.contains("?");
        	//console.log(decodedReturnPathCompare+"= decoded compare ? and "+decodedReturnPath);
        	/*if (decodedReturnPathCompare) {
             	 qsAppendchar = "&" ;} else {
              	 qsAppendchar = "?";}
            */
            
          //   wyreturn = decodedReturnPath+qsAppendchar+'wyret=1.103'+'#tsn'+tsn;
               wyreturn = decodedReturnPath+qsAppendchar+'wyret=1.103';
        	console.log("wysiwyg final return url (wyreturn)= "+wyreturn);

      var el = document.createElement("iframe");
	    thisDomId = 'ifrm-bv-newpoll';
	   //handle request, if wysiwyg already open.
	    if(BVCOM.PAGE.wysiwygopen == "true") {console.log('div existed');return false;}
	   
	    var apel = document.getElementById(divToAppend);

	   if(document.getElementById(thisDomId)||document.getElementById(thisDomId) != null) {apel.removeChild(thisDomId)}

		el.setAttribute('id', thisDomId);
        
        defaultWidth = BVCOM.CONSTANT.bvpollWidth || '575px';
        
		el.setAttribute('width', defaultWidth);

        defaultHeight = BVCOM.CONSTANT.bvpollHeight || '400px';
         
		el.setAttribute('height', defaultHeight);

        el.setAttribute('frameborder','0');

		el.setAttribute('border', '0px');

		el.setAttribute('class', 'dynwysiwyg wyzion'+divToAppend);

		//alert('appending div='+divToAppend+'. webtag ='+wt+'. tid='+tid);

		

        var apelchild = apel.firstChild;
      //  console.log(apelchild);
		
		apel.insertBefore(el,apelchild);
		
		el.setAttribute('src', jDomainURL+'webtag='+wt+'&nav='+n+'&replyToTid='+tid+'&replyToTsn=1&postreturnURL='+encodeURIComponent(wyreturn)+'&wy&cssUrl='+encodeURIComponent(wystyle)+' ');
		BVCOM.PAGE.wysiwygopen = "true";
 } else {
	//user detected as non authenticated
	console.log('user failed authentication test for new poll')
	BVCOM.FUNCTION.messageUser("You must be signed in in to create a poll.","dscussntopnewDis1")
    }
}  

function appendNewPostReply(divToAppend,wt,tid,tsn,n,wyreturn,wystyle,user) {

        	console.log("user has fired wysiwyg request: post reply");
        //test authentication of user	
        if (BVCOM.FUNCTION.testAuthentication()) {  
        	//define default wysiwyg parameters
        	if(typeof wt == null || typeof wt == 'undefined') {wt=BVCOM.CONSTANT.defaultBoard;}
        		wt='ti-'+wt;
        	console.log("webtag ="+wt);
        	//board override based on config
        	if(BVCOM.CONSTANT.WysiwygOverride == true && wt==BVCOM.CONSTANT.WysiwygOverrideBoard) {wt=BVCOM.CONSTANT.WysiwygOverrideBoardNew;}
            tidVarName = 'replyToTid';
            tsnVarName = 'replyToTsn';
            userVarName = '&toUserId=';
            //alert(tidVarName+'=tid');
            //alert(tsnVarName+'=tsn');
        	//define default wysiwyg parameters
        	if(typeof n == null || typeof n == 'undefined' || n == '') {n='iframepost';}
        	if(typeof tid == null ||  typeof tid == 'undefined' || tid == '') {tid='1';}
        	if(typeof wyreturn == null || typeof wyreturn == 'undefined' || wyreturn == '') {wyreturn=document.location.toString()}
        	if(typeof wystyle == null || typeof wystyle == 'undefined' || wystyle == '') {wystyle='http://www.aolcdn.com/black-voices/bv-mzingaform-reply.css'}
        	if(typeof user == 'undefined' || typeof user == null || user == '') {user = '';}
        	
        	//alert(divToAppend);
        	if (typeof divToAppend == null || typeof divToAppend == 'undefined' || divToAppend == '') {
        		divToAppend = "dscussnforumconfirmnew1yup";
       		 }
       		 //alert(n+'=nav');
       		 if (n == 'edit' || n == 'iframeedit') {tidVarName = 'Tid'; tsnVarName = 'Tsn';}
        	 if (user == '') { userVarName = '';}
        	
        	  //alert(tidVarName+'=tid');
              //alert(tsnVarName+'=tsn');
        	console.log("wysiwyg command (n)= "+n);
        	console.log("wysiwyg command (tid)= "+tid);
        	console.log("wysiwyg webtag (wt)= "+wt);
        	console.log("wysiwyg inital return url (wyreturn)= "+wyreturn);
        	console.log("wysiwyg css (wystyle)= "+wystyle);
        	console.log("wysiwyg dom hook (divToAppend)= "+divToAppend);
        
           wyreturn = wyreturn.toString();
        	//create query value for return page
        	returnpathRoot = String(wyreturn).split('?');
			returnpath0 = returnpathRoot[0];
             if(returnpath0.indexOf("#")>0) { 
                returnpath0 = returnpath0.substr(0,returnpath0.indexOf("#"));
             }
              if(returnpath0.indexOf("?")>0) { 
                returnpath0 = returnpath0.substr(0,returnpath0.indexOf("?"));
             }
                     //  alert(returnpath0);
			returnpath1 = '';
			qsAppendchar = "?";
			if(returnpathRoot[1]){			
        		returnpath1 = returnpathRoot[1].toString().replace(/wyret=[0-9]*\.[0-9]*/g,"");
            	returnpath1 = returnpath1.replace(/status=[a-z]*[\?|\&]/g,"");
            	returnpath1 = returnpath1.replace(/tsn[0-9]*/g,"");
                 
                                      
            	
            } 
            qsAppendchar = "&"
           returnpath0 = returnpath0 + "?";
      
           
           
        	//decodedReturnPathCompare = decodedReturnPath.contains("%3F"); //%3F is urlencoded "?"
        	//decodedReturnPathCompare = decodedReturnPath.contains("?");
        	//console.log(decodedReturnPathCompare+"= decoded compare ? and "+decodedReturnPath);
        	/*if (decodedReturnPathCompare) {
             	 qsAppendchar = "&" ;} else {
              	 qsAppendchar = "?";}
            */
        //    wyreturn = decodedReturnPath+qsAppendchar+'wyret=1.101'+'#tsn'+tsn;
         wyreturn = returnpath0+'wyret=1.101';
         if(n=="iframeedit"){
          wyreturn = wyreturn+"&sts=edit";
          }
    
        	
       
                 console.log("wysiwyg final return url (wyreturn)= "+wyreturn);
        	
        	thisDomId = 'ifrm-bv-newreply';  
	    	//handle request, if wysiwyg already open.
	   	if(BVCOM.PAGE.wysiwygopen == "true") {console.log('div existed');return false;}

	    	var apel = document.getElementById(divToAppend);
			var el = document.createElement("iframe");
			el.setAttribute('id', thisDomId);
			defaultWidth = BVCOM.CONSTANT.bvwysiwygWidth || '575px';
			el.setAttribute('width', defaultWidth);
			defaultHeight = BVCOM.CONSTANT.bvwysiwygHeight || '530px';
			el.setAttribute('height', defaultHeight);
			el.setAttribute('border', '0px');
			el.setAttribute('frameborder','0');
			el.setAttribute('class', 'dynwysiwyg wyzion-'+divToAppend);
			
			var apelchild = apel.firstChild;
             console.log(apel.id+"= parent div"); 
             console.log(apelchild+"= firstChild")
             console.log(apelchild.id+"= id of firstChild");
             console.log(apel.lastChild+"=  lastChild");
             console.log(apel.lastChild.id+"= id of lastChild");
             console.log(apel.nextSibling+"=  next sibling");
             //console.log(apel.nextSibling.id+"= id of next sibling");
             appendPoint = apel.lastChild || apel;
             console.log(appendPoint.id+"= id of appendPoint"); 
		     apel.parentNode.appendChild(el);
		     appendreplyUrl = jDomainURL+'webtag='+wt+'&nav='+n+'&'+tidVarName+'='+tid+'&'+tsnVarName+'='+tsn+userVarName+user+'&wy&cssUrl='+encodeURIComponent(wystyle)+'&postreturnURL='+encodeURIComponent(wyreturn)+'';
		     //alert(appendreplyUrl+' =final iframe url');
		     el.setAttribute('src',appendreplyUrl);
		 BVCOM.PAGE.wysiwygopen = "true";
		} else {
		console.log("user has failed authentication test for reply to post");
		BVCOM.FUNCTION.messageUser("You must be signed in in to respond to post.",divToAppend);
		} 
}
        
function showTogglemail(msgsn,postedby,replyto,dismailid,dismsgid,disReportsent1id,disMailsent1id)
{
   document.getElementById("pre_toUserId").value=replyto;  
    document.getElementById("pre_fromUserId").value=postedby;   
    document.getElementById("pre_tsn").value=msgsn;
    var dismsgidnew=p_o(dismsgid);
    var dismailidnew=p_o(dismailid);
    var disReportsent1idnew=p_o(disReportsent1id);
    var disMailsent1idnew=p_o(disMailsent1id);
    disMailsent1idnew.style.display='none';
    dismsgidnew.style.display='none';
    disReportsent1idnew.style.display='none';
    dismailidnew.style.display='block';
    
}
function showTogglereport(msgsn,postedby,dismailid,dismsgid,disMailsent1id,disReportsent1id)
{
    document.getElementById("tos_victim").value=postedby;  
    document.getElementById("tos_tsn").value=msgsn;
    var dismsgidnew=p_o(dismsgid);
   var dismailidnew=p_o(dismailid);
   var disMailsent1idnew=p_o(disMailsent1id);
   var disReportsent1idnew=p_o(disReportsent1id);
   disReportsent1idnew.style.display='none';
   disMailsent1idnew.style.display='none';
   dismailidnew.style.display='none';
   dismsgidnew.style.display='block';
    
}
function showToggleall(dismailid,dismsgid,disMailsent1id,disReportsent1id)
{
   var dismsgidnew=p_o(dismsgid);
   var dismailidnew=p_o(dismailid);
   var disMailsent1idnew=p_o(disMailsent1id);
   var disReportsent1idnew=p_o(disReportsent1id);
   disMailsent1idnew.style.display='none';
   dismailidnew.style.display='none';
   dismsgidnew.style.display='none';
   disReportsent1idnew.style.display='none';
}
function validateemail(inputTxtid, forwardFields,webtag){
                
                var str=document.getElementById(inputTxtid).value;
	        var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please input a valid email address!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please input a valid email address!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please input a valid email address!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please input a valid email address!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please input a valid email address!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please input a valid email address!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please input a valid email address!")
		    return false
		 }
                 else{
                     sampleForwardMessageFunction(webtag, 'pre', document.getElementById('forwardFields'));
                     return false
                 }
     return false
 }
 
var countNewvalue = "400";  
var characterLeft;
function charecterCount(pre_comments,mailTxtcount)
{
   
	var textNew = document.getElementById(pre_comments).value;
      	var lengthNew = textNew.length;
	if(lengthNew > countNewvalue)
	{
		textNew = textNew.substring(0,countNewvalue);
		document.getElementById(pre_comments).value =textNew;
		return false;
	}
        var characterLeft=countNewvalue-lengthNew;
        if(characterLeft==400)
        {
           document.getElementById(mailTxtcount).innerHTML= "<p class='discussreportmsgsecondp4' >" +characterLeft+' Characters Max'+ "</p>"; 
        }
        else{
        document.getElementById(mailTxtcount).innerHTML= "<p class='discussreportmsgsecondp4' >" +characterLeft+' Characters Left'+ "</p>";
        }
	
}
   function addOption(selectbox,text,value,optId,slcted )
{

var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
optn.id=optId;
optn.selected=slcted;
selectbox.options.add(optn);
}

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}
   
   function sortChd(){
      
    
       var selValBy=document.getElementById("sortby").selectedIndex;
         removeAllOptions(document.getElementById('sortby'));
      var selVal=document.getElementById("sortshowing").options[document.getElementById("sortshowing").selectedIndex].value;
        if(selVal=="POLL" || selVal=="ATTACHMENT"){
   		addOption(document.getElementById('sortby'),'Most Recent','MOST-RECENT','sort.MOST-RECENT','selected');

} else {   
     removeAllOptions(document.getElementById('sortby'));
     addOption(document.getElementById('sortby'),'Most Recent','MOST-RECENT','sort.MOST-RECENT','');
     addOption(document.getElementById('sortby'),'Total Posts','TOTAL-POSTS','sort.TOTAL-POSTS','');
     addOption(document.getElementById('sortby'),'Highest Rating','HIGHEST-RATING','sort.HIGHEST-RATING','');
     addOption(document.getElementById('sortby'),'Lowest Rating','LOWEST-RATING','sort.LOWEST-RATING','');
     document.getElementById("sortby").selectedIndex=selValBy;
 }
     } 
  

function charecterCountreset(mailTxtcount)
{
   var characterLeft='400'
    document.getElementById(mailTxtcount).innerHTML= "<p class='discussreportmsgsecondp4' >" +characterLeft+' Characters Max'+ "</p>"; 
        
}

//
//set page levels
if (typeof BVCOM.PAGE !='object') {BVCOM = {}; BVCOM.PAGE = {}}
	BVCOM.PAGE.query = location.search;
	BVCOM.PAGE.queryName = location.search.substring(1, location.search.length)
	BVCOM.PAGE.queryNameLen = location.search.substring(1, location.search.length).length;
	BVCOM.PAGE.queryLen = BVCOM.PAGE.queryName.length;
	console.log("query string preserved as "+BVCOM.PAGE.queryName+"("+BVCOM.PAGE.queryNameLen+" char length)");
	if (BVCOM.PAGE.queryLen > 0) {
	console.log("query length confirmed");
		//if query var, reply status and response code
	console.group("Page object settings:");
		BVCOM.PAGE.queryArg = BVCOM.PAGE.queryName.split('&');
        console.log("query args: "+BVCOM.PAGE.queryArg);
		BVCOM.PAGE.queryArgCount = BVCOM.PAGE.queryArg.length;
		console.log("query arg count= "+BVCOM.PAGE.queryArgCount);
		BVCOM.PAGE.queryString=[];
	console.groupEnd();	
		for (var i=0, j = BVCOM.PAGE.queryArgCount; i<j; i++) {

		//for (var i=0; i < BVCOM.PAGE.queryNamVal; i++) {

			var argToSplit = BVCOM.PAGE.queryArg[i].split('=');
			var name = decodeURIComponent(argToSplit[0]);
			var value = (argToSplit.length==2) ? decodeURIComponent(argToSplit[1]) : name;
		//array for now, json later
		console.log(i+". name="+name+" value="+value);
		BVCOM.PAGE.queryString[name] = value;
		//BVCOM.PAGE[name] = value;
	//	}
	}
	if(BVCOM.PAGE.queryString['status'])BVCOM.PAGE.status = BVCOM.PAGE.queryString['status'];
	if(BVCOM.PAGE.queryString['wyret'])BVCOM.PAGE.wyret = BVCOM.PAGE.queryString['wyret'];
	

	}



	console.log(BVCOM);
    console.trace();
    
   //poll
   
    function sampleVoteFunction(webtag, fieldPrefix, form)
    {
        
          var callback = function(commandResultsJSON){
        var resultsObj = commandResultsJSON["CommandResultInfo"];
        if (resultsObj["@succeeded"] == "true"){
              document.voteFields.submit();
        }else{
            alert("Error " + resultsObj["@code"] + ": " + resultsObj["@message"]);
        }
 
        var s = makeObjectString(resultsObj);
    };
        shouldSubmitVote=1;
      len = form.votenewrd.length

for (i = 0; i <len; i++) {
  if (form.votenewrd[i].checked) {
    selectedVal = form.votenewrd[i].value
     }
   }
   form.pre_choice.value=selectedVal;
//webtag="ti-20something";

TempestNS.COMMANDHANDLER.Vote(webtag, fieldPrefix, form, callback);


}

     function sampleEndPollFunction(webtag, fieldPrefix, form)
    {
         
           var callback = function(commandResultsJSON){
        var resultsObj = commandResultsJSON["CommandResultInfo"];
        if (resultsObj["@succeeded"] == "true"){
              document.endPollFields.submit();
        }else{
            alert("Error " + resultsObj["@code"] + ": " + resultsObj["@message"]);
        }
 
        var s = makeObjectString(resultsObj);
    };
        
		/* Execute the command */
                   if(confirm("Are you sure you want to end this poll?")){ 
		TempestNS.COMMANDHANDLER.EndPoll(webtag, fieldPrefix, form, callback);
                 }
	}


	/* Helper function for displaying the results object */
	function makeObjectString(o, indentIn)
	{
	    var s = new String();
	    var indent = indentIn ? indentIn : "";
	    for (var prop in o)
	    {
	       var val = o[prop];
	       if (typeof val == "object")
	       {
	            s = s + indent + prop + ":\n" + makeObjectString(val, indent + "   ");
	       }
	       else if (val)
	       {
	            s = s + indent + prop + ": " + val + "\n";
	       }
	    }
	    return s;
	}
	function testRegex(form, controlList)
	{
	if(controlList && form)
	  {
	    var controlsToGet = "^" + controlList.replace(",", "$|^").replace("*", ".*") + "$";
	    var controlsRE = new RegExp(controlsToGet, "i");
	    var postParams = "";
	    for(var i = 0; i < form.elements.length; i++)
	    {
	      var el = form.elements[i];
	      var elId = el.id;
		  alert("El Id: " + elId);
	      if(elId)
	      {
	        if(elId.search(controlsRE) != -1)
	        {
	        alert(elId + ' was found');
	          // this control is in our list
	          var ctlVal = TempestNS.Client.GetControlValue(el);
	          if(ctlVal != null)
	          {
	            postParams += "&" + el.name + "=" + escape(ctlVal);
	          }
	        }
	      }
	    }
	    alert("Post Params: " + postParams);
  	}
  	}
         
         function showCastvote(){
            // alert("test");
            document.getElementById("dscussVotNew").style.display='block';
            document.getElementById("dscussVotRes").style.display='none';  
             }
function openPollView(){
    // var pollwin=window.open("/boards/include/pop.html","view Result");
   //   pollwin.document.getElementById("testDiv").innerHTML= "<div class='voteResWrap'>"+document.getElementById("dscussVotRes").innerHTML+"</div>";
     document.getElementById("dscussVotNew").style.display='none';
            document.getElementById("dscussVotRes").style.display='block'; 
   
   // pollwin.document.write("<div class='voteResWrap'>"+document.getElementById("dscussVotRes").innerHTML+"</div>");
    }

function cancelDisReport(divid)
{
    var disdiv=p_o(divid);
    disdiv.style.display='none';
    
 }
    function deleteMessageAd(postNumber) {
        if(confirm("Are you sure you want to delete this message?")){ 
        thisToDelete = "frmDelete"+postNumber
        document.getElementById(thisToDelete).submit();
        }
    }
        
 //cookie handling
 //inspired by pk cookies
 var bvcookies = {	createCookie: function(name,value,days) {
						if (days) {
						var date = new Date();
						date.setTime(date.getTime()+(days*24*60*60*1000));
						var expires = "; expires="+date.toGMTString();
					    }
					 else var expires = "";
			   		 document.cookie = name+"="+value+expires+"; path=/";
					},
					readCookie: function(name) {
						var nameEQ = name + "=";
						var ca = document.cookie.split(';');
						for(var i=0;i < ca.length;i++) {
							var c = ca[i];
							while (c.charAt(0)==' ') c = c.substring(1,c.length);
							if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
						}
					return null;
					},
					eraseCookie: function(name) {
						createCookie(name,"",-1);
					}
         		}
BVCOM.FUNCTION.cookiehandling = bvcookies;
console.log(BVCOM.FUNCTION.cookiehandling);
//city to cookie
BVCOM.FUNCTION.currentCityToCookie = function currentCityToCookie(overrideOffset){
    splitOffsetTag = overrideOffset || 1;
    splitOffsetCity = splitOffsetTag +1;
	console.log(jCategory + '=jcategory: '+jBoard+'=jboard: ');
	if (jCategory == 'cities-sub') {
		//user is on cities page, split url to determine which
		docSplit = document.location.href.split('/');
		console.log(docSplit);
		docSplitLen = docSplit.length;
		console.log(docSplitLen);
		docSplitWebTag = docSplit[docSplitLen-splitOffsetTag];
		console.log(docSplitWebTag);
        docSplitCityName = docSplit[docSplitLen-splitOffsetCity];
        bvcookies.createCookie('lastVistedCityTag',jBoard,365);
        bvcookies.createCookie('lastVistedCityName',docSplitCityName,365);
        bvcookies.createCookie('lastVistedCityCode',docSplitWebTag,365);
	}
} 
// generic ajax
BVCOM.FUNCTION.Ajax = function ajax( options ) {

    // Load the options object with defaults, if no
    // values were provided by the user
    options = {
        // The type of HTTP Request
        type: options.type || "POST",

        // The URL the request will be made to
        url: options.url || "",

        // How long to wait before considering the request to be a timeout
        timeout: options.timeout || 5000,

        // Functions to call when the request fails, succeeds,
        // or completes (either fail or succeed)
        onComplete: options.onComplete || function(){},
        onError: options.onError || function(){},
        onSuccess: options.onSuccess || function(){},

        // The data type that'll be returned from the server
        // the default is simply to determine what data was returned from the
        // and act accordingly.
        data: options.data || ""
    };

    // Create the request object
    var xml = new XMLHttpRequest();

    // Open the asynchronous POST request
    xml.open("GET", options.url, true);

    // We're going to wait for a request for 5 seconds, before giving up
    var timeoutLength = 5000;

    // Keep track of when the request has been succesfully completed
    var requestDone = false;

    // Initalize a callback which will fire 5 seconds from now, cancelling
    // the request (if it has not already occurred).
    setTimeout(function(){
         requestDone = true;
    }, timeoutLength);

    // Watch for when the state of the document gets updated
    xml.onreadystatechange = function(){
        // Wait until the data is fully loaded,
        // and make sure that the request hasn't already timed out
        if ( xml.readyState == 4 && !requestDone ) {

            // Check to see if the request was successful
            if ( httpSuccess( xml ) ) {

                // Execute the success callback with the data returned from the server
                options.onSuccess( httpData( xml, options.type ) );

            // Otherwise, an error occurred, so execute the error callback
            } else {
                options.onError();
            };

            // Call the completion callback
            options.onComplete();

            // Clean up after ourselves, to avoid memory leaks
            xml = null;
        }
    };

    // Establish the connection to the server
    xml.send();

    // Determine the success of the HTTP response
    function httpSuccess(r) {
        try {
            // If no server status is provided, and we're actually 
            // requesting a local file, then it was successful
            return !r.status && location.protocol == "file:" ||

                // Any status in the 200 range is good
                ( r.status >= 200 && r.status < 300 ) ||

                // Successful if the document has not been modified
                r.status == 304 ||

                // Safari returns an empty status if the file has not been modified
                navigator.userAgent.indexOf("Safari") >= 0 && typeof r.status == "undefined";
        } catch(e){}

        // If checking the status failed, then assume that the request failed too
        return false;
    };

    // Extract the correct data from the HTTP response
    function httpData(r,type) {
        // Get the content-type header
        var ct = r.getResponseHeader("content-type");

        // If no default type was provided, determine if some
        // form of XML was returned from the server
        var data = !type && ct && ct.indexOf("xml") >= 0;

        // Get the XML Document object if XML was returned from
        // the server, otherwise return the text contents returned by the server
        data = type == "xml" || data ? r.responseXML : r.responseText;

        // If the specified type is "script", execute the returned text
        // response as if it was JavaScript
        if ( type == "script" )
            eval.call( window, data );

        // Return the response data (either an XML Document or a text string)
        return data;
        };
     }
 BVCOM.FUNCTION.getCityInfo = function(){
	BVCOM.CONSTANT.lastCityVistedName = BVCOM.FUNCTION.cookiehandling.readCookie("lastVistedCityName");
	BVCOM.CONSTANT.lastCityVistedCode = BVCOM.FUNCTION.cookiehandling.readCookie('lastVistedCityCode');
	BVCOM.CONSTANT.lastCityVistedWebTag = BVCOM.FUNCTION.cookiehandling.readCookie('lastVistedCityTag');
} 

BVCOM.FUNCTION.messageUser = function(message,parentNode,referenceNode,newID,w,h,b,c){
				    console.log("message user fired");
                    divMessage = message || "You must log in to create a discussion. Don't have an account yet? Create one now, it's quick and easy";
					parentDivId= parentNode || 'dscussntop';
					//alert('parent div='+parentDivId);
	    			parentEl = document.getElementById(parentDivId);
	    			console.log(parentEl);
	   					
					thisDomId = newID || "responseMSGtoUser";
					if(document.getElementById(thisDomId)||document.getElementById(thisDomId) != null) {thisDomId.parentNode.removeChild(thisDomId);}
				    console.log(thisDomId+"=thisDom");
				    
					thisWidth = w || "470px";
					thisHeight = h || "75px";
					thisBorder = b || "1px";
					thisClass = c || "msgresponse BVCOMmsgbox";
					
					console.log(thisWidth+"= width");
					console.log(thisHeight+"= height");
					console.log(thisBorder+"= border");
					console.log(thisClass+"= class");
					
                	responseEl = document.createElement("DIV");
                	
					responseEl.setAttribute('id', thisDomId);
					responseEl.setAttribute('width', thisWidth);
					responseEl.setAttribute('height', thisHeight);
					responseEl.setAttribute("border", thisBorder);
					responseEl.setAttribute('class', thisClass);

					
					responseTxt = document.createTextNode(divMessage);
		

		           apelchild = parentEl.firstChild;
		           refEl = document.getElementById(referenceNode) || apelchild;
		           
		           //if(apelchild && (typeof apelchild != 'null' || typeof apelchild != 'undefined') && typeof apelchild.id != 'undefined')console.log(apelchild.id+"=first child");
		          // if(parentEl && (typeof parentEl != 'null' || typeof parentEl != 'undefined') && typeof parentEl.id != 'undefined')console.log(parentEl.id+"=parent");
		           
		           var fragmentMsg=document.createDocumentFragment()
		           
                   responseEl.appendChild(responseTxt);
                   fragmentMsg.appendChild(responseEl);
                   
                   parentEl.insertBefore( ( fragmentMsg.cloneNode(true) ),refEl);
				      			
					//console.log(apelchild.appendChild(responseEl));
					//if((typeof responseEl != 'null' || typeof responseEl != 'undefined') && typeof responseEl.id != 'undefined')console.log(responseEl.id+"=new element");
 }
                 
 
				BVCOM.FUNCTION.testAuthentication = function tellauth(){
				//BVCOM.USER.user_status = "true";
                //BVCOM.USER.vl6 = "true";
					if(BVCOM.USER.user_status == "true" && BVCOM.USER.vl6 == "true"){
						return true;
    
					} else {return false;
					
					}
				}
				
 BVCOM.FUNCTION.pageResponder = function respondToStatus(message) {	
 // x.y.x
	if(typeof BVCOM.PAGE.status != "undefined" && typeof BVCOM.PAGE.status != "null" ) {
		console.log("user has returned from someplace");
		if(typeof BVCOM.PAGE.status != 'undefined' && BVCOM.PAGE.status == 'posted') {
			console.log("user successful post detected");
				//determine what kind of post was made
				switch(BVCOM.PAGE.wyret) {
				    case '1.101':
				    	BVCOM.FUNCTION.messageUser("Thank you for your reply!",'dscussnforum');
				    break;
				 	case '1.102':
				 		BVCOM.FUNCTION.messageUser("Thank you for your discussion!",'dscussnforumconfirmnew1');
				    break;
				    case '1.100':
				 		BVCOM.FUNCTION.messageUser("Thank you for your post!",'dscussnforum');
				    break;
				    case '1.103':
				 		BVCOM.FUNCTION.messageUser("Thank you for your poll!",'dscussnforum');
				    break;
				    default:
				        console.log('no wyret code found');	
		        }
	     }
     }
 }
 //ke-cleanup :rm upon ke fix
if (typeof flashTagParams == "undefined") {flashTagParams = undefined;}

BVCOM.FUNCTION.AddEvent(window, 'load', BVCOM.FUNCTION.pageResponder);


    function sampleIgnoreUserFunction(webtag, userId)
    {
	var callback = function(commandResultsJSON)
	{
	  var resultsObj = commandResultsJSON["CommandResultInfo"];
	  if (resultsObj["@succeeded"] == "true")
	  {
	    alert(resultsObj["@message"]);
             document.location.reload();
	  }
	  else
	  {
	    alert("Error " + resultsObj["@code"] + ": " + resultsObj["@message"]);
	  }
    /* This code displays all of the items in the results object */
	var s = makeObjectString(resultsObj);
	//alert("CommandResults: \n" + s);
       };
	/* Execute the command */
    	TempestNS.COMMANDHANDLER.IgnoreUser(webtag, userId, callback);
    }